This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
AW: basic asm and memory clobbers - Proposed solution
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: David Wohlferd <dw at LimeGreenSocks dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: Joseph Myers <joseph at codesourcery dot com>, "Paul_Koning at Dell dot com" <Paul_Koning at Dell dot com>, "jakub at redhat dot com" <jakub at redhat dot com>, "rth at gcc dot gnu dot org" <rth at gcc dot gnu dot org>, "rth at redhat dot com" <rth at redhat dot com>, "pinskia at gcc dot gnu dot org" <pinskia at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>, Segher Boessenkool <segher at kernel dot crashing dot org>, "aph at redhat dot com" <aph at redhat dot com>, Ian Lance Taylor <iant at google dot com>, Sandra Loosemore <sandra at codesourcery dot com>, Hans-Peter Nilsson <hp at bitrange dot com>
- Date: Sat, 28 Nov 2015 07:02:03 +0000
- Subject: AW: basic asm and memory clobbers - Proposed solution
- Authentication-results: sourceware.org; auth=none
- Authentication-results: codesourcery.com; dkim=none (message not signed) header.d=none;codesourcery.com; dmarc=none action=none header.from=hotmail.de;
- References: <56552209 dot 1020306 at LimeGreenSocks dot com>,<56592801 dot 9010606 at LimeGreenSocks dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
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.
And I wonder what the exact equivalence of asm("") is
in extended asm ("":::) or asm volatile ("":::) ?
Well, I start to think that Jeff is right, and we should treat a asm ("") as if it
were asm volatile ("" ::: ) 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.