On Nov 14, 2005, at 1:31 AM, Florian Weimer wrote:
The documentation of the asm keyword does not explicitly say that a
volatile asm statement may be duplicated by the compiler, but of
course it is to be expected in some cases (inlining, for example).
However, for consistency, it might be better to document that the
compiler may introduce duplicates in general (making my example
invalid).
What do you think?
We should enhance the documentation that currently says (extend.texi):
------
If you want to test the condition code produced by an assembler
instruction, you must include a branch and a label in the @code{asm}
construct, as follows:
@smallexample
asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
: "g" (result)
: "g" (input));
@end smallexample
@noindent
This assumes your assembler supports local labels, as the GNU assembler
and most Unix assemblers do.
Speaking of labels, jumps from one @code{asm} to another are not
supported. The compiler's optimizers do not know about these jumps, and
therefore they cannot take account of them when deciding how to
optimize.
------
to state that normal labels don't work in asms, as they can be
duplicated for any reason by the compiler, for example, inlining and
that local labels (0: 0f in assembly) should be used instead. In
addition, there is a unique number generated by the compiler that can
be used to form unique labels (md.texi):
@samp{%=} outputs a number which is unique to each instruction in the
entire compilation. This is useful for making local labels to be
referred to more than once in a single template that generates multiple
assembler instructions.
that should be referenced from the other part of the documentation.