This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Request for discussion: Rewrite of inline assembler docs
- From: Richard Sandiford <rsandifo at linux dot vnet dot ibm dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: "gcc\ at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 27 Feb 2014 12:11:10 +0000
- Subject: Re: Request for discussion: Rewrite of inline assembler docs
- Authentication-results: sourceware.org; auth=none
- References: <530F1C69 dot 5050305 at redhat dot com>
Andrew Haley <aph@redhat.com> writes:
> Over the years there has been a great deal of traffic on these lists
> caused by misunderstandings of GCC's inline assembler. That's partly
> because it's inherently tricky, but the existing documentation needs
> to be improved.
>
> dw <limegreensocks@yahoo.com> has done a fairly thorough reworking of
> the documentation. I've helped a bit.
>
> Section 6.41 of the GCC manual has been rewritten. It has become:
>
> 6.41 How to Use Inline Assembly Language in C Code
> 6.41.1 Basic Asm - Assembler Instructions with No Operands
> 6.41.2 Extended Asm - Assembler Instructions with C Expression Operands
>
> We could simply post the patch to GCC-patches and have at it, but I
> think it's better to discuss the document here first. You can read it
> at
>
> http://www.LimeGreenSocks.com/gcc/Basic-Asm.html
> http://www.LimeGreenSocks.com/gcc/Extended-Asm.html
> http://www.LimeGreenSocks.com/gcc/extend04.zip (contains .texi, .patch,
> and affected html pages)
>
> All comments are very welcome.
Thanks for doing this, looks like a big improvement. A couple of comments:
The section on basic asms says:
Do not expect a sequence of asm statements to remain perfectly
consecutive after compilation. To ensure that assembler instructions
maintain their order, use a single asm statement containing multiple
instructions. Note that GCC's optimizer can move asm statements
relative to other code, including across jumps.
The "maintain their order" might be a bit misleading, since volatile asms
(including basic asms) must always be executed in the original order.
Maybe this was meaning placement/address order instead? It might also be
worth mentioning that the number of instances of an asm in the output
may be different from the input. (Can it increase as well as decrease?
I'm not sure off-hand, but probably yes.)
In the extended section:
Unless an output operand has the '&' constraint modifier (see
Modifiers), GCC may allocate it in the same register as an unrelated
input operand, [...]
It could also use it for addresses in other (memory) outputs.
For:
When using asmSymbolicNames for the output operands, you may use these
names instead of digits.
it might be worth mentioning that you need the enclosing [...].
Thanks,
Richard