AW: basic asm and memory clobbers - Proposed solution

David Wohlferd dw@LimeGreenSocks.com
Sat Nov 28 07:25:00 GMT 2015


On 11/27/2015 11:02 PM, Bernd Edlinger wrote:
> Hi,
>
>
> I just found this in the docs:
>
> The compiler copies the assembler instructions in a basic @code{asm}
> verbatim to the assembly language output file, without
> processing dialects or any of the @samp{%} operators that are available with
> extended @code{asm}. This results in minor differences between basic
> @code{asm} strings and extended @code{asm} templates. For example, to refer to
> registers you might use @samp{%eax} in basic @code{asm} and
> @samp{%%eax} in extended @code{asm}.
>
>
> So it might be good to warn about % in asm statements too, because changing
> anything on the asm syntax can be is quite dangerous.

There are a few differences to be aware of between basic and extended, 
and yes that is one of them.

I'm putting together a "How to convert basic asm to extended asm" 
guide.  Not quite sure where to put it yet.  Doesn't really belong in 
the User Guide, but I worry no one would ever see it in the wiki.

> And I wonder what the exact equivalence of asm("") is
> in extended asm ("":::) or asm volatile ("":::) ?

 From the docs: "asm statements that have no output operands, including 
asm goto statements, are implicitly volatile."  In other words, those 2 
are the same.

> Well, I start to think that Jeff is right, and we should treat a asm ("") as if it
> were asm volatile ("" ::: )

I believe Segher is already looking at this: 
https://gcc.gnu.org/ml/gcc/2015-11/msg00196.html

> but if the asm ("nonempty with optional %") we should
> treat it as asm volatile ("nonempty with optional %%" ::: "memory").
> Our docs should say that explicitly, and the implementation should follow that
> direction.
>
>
> Bernd.



More information about the Gcc mailing list