Request for discussion: Rewrite of inline assembler docs

dw limegreensocks@yahoo.com
Fri Mar 28 06:21:00 GMT 2014


> Looks great to me.  Just noticed one small nit: in the extended asm
> section, "=irm" isn't valid, since you can't assign to an immediate.

Doh!  I probably copied this from the Input section.  Good catch.

> Also, in the section about clobbers:
>
>    It causes the compiler to flush all registers to memory before
>    executing the asm statement.
>
> At first I read this as meaning "all registers are saved somewhere in
> memory before the asm".  Maybe something like "flush all pending stores"?
> Not sure whether that's better or not though.

You are right, and this is an important point.  I have re-worked this 
whole paragraph.  Old:

It causes the compiler to flush all registers to memory before executing 
the |asm| statement. Further, the compiler will not assume that any 
values read before the |asm| will remain unchanged after the |asm|; it 
will reload them as needed. This effectively forms a read/write barrier 
for the compiler.

New:

Using this clobber causes the compiler to flush all (modified) registers 
being used to store memory-based values to memory before executing the 
@code{asm} statement.  Further, the compiler will not assume that any 
memory-based values read before the @code{asm} will remain unchanged 
after the @code{asm}; it will reload them as needed.  This effectively 
forms a read/write memory barrier for the compiler.  For performance 
reasons, some variables only exist in registers and never get written to 
memory.  The "memory" clobber does not force these values to get written 
to memory.

> Thanks again for all the work on this.

Anything else?

> Richard



More information about the Gcc mailing list