This is the mail archive of the
mailing list for the GCC project.
Re: Using the asm suffix
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: David Wohlferd <dw at LimeGreenSocks dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Sandra Loosemore <sandra at codesourcery dot com>
- Date: Fri, 21 Aug 2015 06:42:57 -0500
- 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> <55D56D66 dot 6060704 at LimeGreenSocks dot com>
On Wed, Aug 19, 2015 at 11:02:14PM -0700, David Wohlferd wrote:
> >>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:
I think "cannot" is the correct word; this is not about what assemblers
do at all, but about what the *compiler* does. It would have to jump
through hoops to be able to give stack vars a name; or not use stack
vars, even worse :-)
> "gcc does not support using this feature with a non-static local
> variable since typically such variables do not have assembler names."
[spelling "GCC" correctly, of course...]
Get rid of "typically" and this looks fine.
> 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.
Huh, strange. Please file a PR.
> >>>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.
It already says what is supported: a valid name. "(%gs:4)" is not, "r0"
is, with most assemblers. This is one reason why some systems prefix
all C symbols with an underscore.