This is the mail archive of the
mailing list for the GCC project.
Re: Request for discussion: Rewrite of inline assembler docs
- From: dw <limegreensocks at yahoo dot com>
- To: gcc at gcc dot gnu dot org, rdsandiford at googlemail dot com
- Date: Mon, 24 Mar 2014 00:37:47 -0700
- Subject: Re: Request for discussion: Rewrite of inline assembler docs
- Authentication-results: sourceware.org; auth=none
- References: <530F1C69 dot 5050305 at redhat dot com> <87eh2oah7l dot fsf at sandifor-thinkpad dot stglab dot manchester dot uk dot ibm dot com> <530FE6CE dot 1000001 at yahoo dot com> <87ha7jd75c dot fsf at talisman dot default> <53144EC6 dot 2080600 at yahoo dot com> <87fvmzy0n9 dot fsf at sandifor-thinkpad dot stglab dot manchester dot uk dot ibm dot com> <53181FBE dot 1010306 at yahoo dot com> <87y5024i3m dot fsf at talisman dot default>
Sorry for the slow response.
Thanks for getting back to me. I was pretty sure I didn't have this all
quite right yet.
asm ("" : "=m" (*x), "=r" (y));
you have to assume that the address in %0 might use the same register as %1
Ok, now I'm getting there. It helps that I've compiled some examples
and can see what is happening. This one is subtle. I'm going to have
to go back and review my code to see if I've ever done this.
So, the existing text (which only talks about overlaps with input
"Unless an output operand has the '&' constraint modifier (see
Modifiers), GCC may allocate it in the same register as an unrelated
input operand, on the assumption that the assembler code will consume
its inputs before producing outputs. This assumption may be false if the
assembler code actually consists of more than one instruction. In this
case, use '&' for each output operand that must not overlap an input."
I'm thinking about adding something like this after it:
"The same problem can occur if one of the output parameters allows a
register constraint and contains an address. In this case, GCC may use
the same register for this parameter as it does for other output
parameters that allow a memory constraint. This can produce
inconsistent results if the register address is updated before updating
the memory address. Combining the '&' constraint with the register
constraint prevents this overlap and resolves the inconsistency."
That's as clear as I can come up with. Better?