This is the mail archive of the
mailing list for the GCC project.
Re: Using the asm suffix
- From: David Wohlferd <dw at LimeGreenSocks dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Sandra Loosemore <sandra at codesourcery dot com>
- Date: Wed, 19 Aug 2015 23:02:14 -0700
- Subject: Re: Using the asm suffix
- Authentication-results: sourceware.org; auth=none
- References: <55D139F4 dot 7060109 at LimeGreenSocks dot com> <20150817104114 dot GB22219 at gate dot crashing dot org> <55D2BAD4 dot 7090905 at LimeGreenSocks dot com> <20150818092356 dot GA30482 at gate dot crashing dot org> <55D4F040 dot 30105 at LimeGreenSocks dot com> <20150819214759 dot GA20144 at gate dot crashing dot org>
how about replacing the existing
text ("It does not make sense to use this feature with a non-static
local variable since such variables do not have assembler names.") with
"Do not use this feature with a non-static local variable." or maybe "It
is not supported to use this feature with a non-static local variable
since such variables do not have assembler names."
"You cannot use this feature ..." etc.? Keep the part about not having
assembler names, it is useful.
Due to the quirks of the English language, I'm not sure 'cannot' is the
right word here. More correct would be 'cannot reliably' but I don't
want to be that wishy-washy.
And I'm a little iffy about the 'since such variables do not have
assembler names,' as it seemed a bit bold to make assertions about the
implementation details for all assemblers (past, present and future) for
all platforms. But you are right, it does convey a bit of the 'why' for
this limitation, so keeping it is a good idea. How about:
"gcc does not support using this feature with a non-static local
variable since typically such variables do not have assembler names."
BTW, the trick for getting the "ignoring asm-specifier for non-static
local variable" message was renaming my file from sta5.cpp to sta5.c.
Seems like this should apply to both, but whatever.
The first part ("must not use a register name") is an important warning.
Clarifying this is a good idea. Although limiting it to only saying
"don't use register names" seems a little, well, limiting. Who knows
what kind of offsets or asm qualifiers they might try to cram in here?
Register names is the common case to hurt you... "r0" etc. ;-)
But as we have seen (%gs:4), people are willing to try other things.
And rather than try to list all the things that don't work (register,
registers with offsets, etc), I'm hoping we can find a way to specify
the one thing that is supported.
"Only label names valid for your assembler are permitted within the asm."
The assembler calls it "symbol names" (labels end in a colon). But it
won't help: e.g. "r0" is a perfectly fine name for the assembler, too!
It should say something like "if the string you put here is seen as
something else than a symbol name by the assembler, anywhere the compiler
puts it, you're on your own", but that is pretty vague as well.
Ok, how about "Only symbol names that define labels are permitted within
A bit awkward, but I believe it conveys the intent.
You forgot to make it "register", so it is not a register variable.
Ahh, true. I suppose we could say something about don't use 'register'
with 'asm labels', but it doesn't seem worth the effort.