delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/05/06/13:57:43

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
References: <BLU119-W440E3023DD8E9AB6464CF6DDD60 AT phx DOT gbl> <045401c8afa0$2e51f390$2708a8c0 AT CAM DOT ARTIMI DOT COM>
Subject: RE: '%=' invalid? (inline assembly)
Date: Tue, 6 May 2008 18:57:12 +0100
Message-ID: <045701c8afa2$9c9ff2f0$2708a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <045401c8afa0$2e51f390$2708a8c0@CAM.ARTIMI.COM>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Dave Korn wrote on 06 May 2008 18:40:

>> Why does '%=' not work in code directly copied from the gcc sources?
> 
>   The stuff in .md files is not inline assembly and cannot be [ ... ]

  Having said all that, we still have your original problem to deal with:

> Cristiano Di Buduo wrote on 06 May 2008 18:16:
> 
>> Hi, i'm porting a project to gcc, and it heavily relies on inline
>> assembly. 
>> 
>> I have some inline functions that, when optimized, generate duplicate
>> labels. So i read through the docs, and stumbled upon the %=
>> functionality.

  So, if all you need is a unique label each place the function is inlined for
a short loop or branch, you have a couple of options, that let you get unique
symbols at the assembler level, not at the compiler.

  Assuming you're using GAS, it allows you to define "local symbols" (not to
be confused with local labels, that begin with 'L'; a local symbol uses an
integer as a label, and then in your code you can refer to the nearest local
symbol with that number.  See the "Symbol names" chapter of the GAS docs.

  A second option might be to try and make use of the "\@" feature of macros,
although I'm not sure how easy that would be; you might have to do some
trickery to avoid emitting the macro definition repeatedly every time the asm
got inlined.

  So the local symbol option is probably your best and simplest bet.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019