public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* gcc: '%=' invalid? (inline assembly)
@ 2008-05-06 17:32 Cristiano Di Buduo
  2008-05-06 17:57 ` Dave Korn
  0 siblings, 1 reply; 4+ messages in thread
From: Cristiano Di Buduo @ 2008-05-06 17:32 UTC (permalink / raw)
  To: cygwin


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.
I couldn't find more in-depth info, so i fgrepped the gcc source tree.

But to no avail...
I already tried the gcc mailing list, no response:

Why does '%=' not work in code directly copied from the gcc sources?

Any help 'd be greatly appreciated!

_________________________________________________________________
Gratis chat, gratis blog, gratis fototool, gratis....dankzij Windows Live
http://get.live.com

--
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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: '%=' invalid? (inline assembly)
  2008-05-06 17:32 gcc: '%=' invalid? (inline assembly) Cristiano Di Buduo
@ 2008-05-06 17:57 ` Dave Korn
  2008-05-06 18:10   ` Dave Korn
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Korn @ 2008-05-06 17:57 UTC (permalink / raw)
  To: cygwin

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. 

  You must have been reading the gcc internals manual.

> I couldn't find more in-depth info, so i fgrepped the gcc source tree.
> 
> But to no avail...
> I already tried the gcc mailing list, no response:
> 
> Why does '%=' not work in code directly copied from the gcc sources?

  The stuff in .md files is not inline assembly and cannot be understood by
GCC (or any other C compiler) directly.  It is a plain text format that is
parsed by various utility programs that are built as part of the gcc build
process and that emit autogenerated C files that handle the cpu-dependent
parts of the assembly generation process.  The "output templates" that are in
the .md files contain many kinds of syntax that cannot be used in inline
assembly, and "%=" is one of those. 


    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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: '%=' invalid? (inline assembly)
  2008-05-06 17:57 ` Dave Korn
@ 2008-05-06 18:10   ` Dave Korn
  2008-05-06 19:23     ` Dave Korn
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Korn @ 2008-05-06 18:10 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: '%=' invalid? (inline assembly)
  2008-05-06 18:10   ` Dave Korn
@ 2008-05-06 19:23     ` Dave Korn
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Korn @ 2008-05-06 19:23 UTC (permalink / raw)
  To: cygwin

Dave Korn wrote on 06 May 2008 18:57:

  Replying to myself for the last time in this thread, I promise!

>   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.

... or you might not, depending how GAS feels about repeatedly redefining a
macro; I don't actually know if it's allowed or not, and haven't tested it.

    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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-06 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-06 17:32 gcc: '%=' invalid? (inline assembly) Cristiano Di Buduo
2008-05-06 17:57 ` Dave Korn
2008-05-06 18:10   ` Dave Korn
2008-05-06 19:23     ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).