This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: inline labels


> > When compiling using the -O3, gcc will decide that some functions
> > can be inlined and expands them.  This is all well and good, but
> > when there's an asm() statement in the function with a label in
> > it, it causes the label to be defined more than once.  Is there
> > any way around this without reworking the assembly?
> 
> The GCC manual talks about local labels in assembly statements.  You
> may also look for `%='; it's described in the section about output
> templates; I'm not sure it can be used in asm statements, though.

Just thought I'd post the answer to my own question, there are a lot
of other '%' things then I thought.  I checked the gnu docs at gnu.org
(http://gcc.gnu.org/onlinedocs/gcc_16.html#SEC179) and found out 
everything that I ever wanted to know about templates.  I checked the
docs before asking the question, but I guess I just didn't check
well enough.  The '%=' does give you a unique number that you can
use in the inline assembly labels.  For example

asm("movl foo,%eax
.Lfoo%=:
     incl %eax
     jc .Lfoo%="
);

works just fine, and things don't get clobbered when you let gcc
optimize.  Gcc rocks, that all I gotta say.

-dave

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]