This is the mail archive of the
mailing list for the GCC project.
Re: inline asm clobbers
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: David Wohlferd <dw at LimeGreenSocks dot com>
- Cc: Paul_Koning at Dell dot com, Ian Lance Taylor <iant at google dot com>, gcc at gcc dot gnu dot org, Sandra Loosemore <sandra at codesourcery dot com>, jakub at redhat dot com, Jeff Law <law at redhat dot com>
- Date: Thu, 12 Mar 2015 18:13:54 -0500
- Subject: Re: inline asm clobbers
- Authentication-results: sourceware.org; auth=none
- References: <5500C898 dot 3000601 at LimeGreenSocks dot com> <CAKOQZ8yG4fPx8Ce3JiZMtW8MwXAMFk5W3_JAJ=b2WMQ4mXDDdA at mail dot gmail dot com> <7DD652D7-C369-4E2D-AEA0-9C75ABAB8636 at dell dot com> <5500E372 dot 3010207 at LimeGreenSocks dot com> <64361D38-32E1-4DEF-81B3-158CC45103BC at dell dot com> <55020EB0 dot 8030003 at LimeGreenSocks dot com>
On Thu, Mar 12, 2015 at 03:09:52PM -0700, David Wohlferd wrote:
> Ahh. So perhaps as I suspected: this is more commonly used on non-i386
> platforms. So clearly removing this is out of the question.
glibc uses it for PowerPC and s390 at least (I only grepped for "3",
quotes included -- there may be more archs that use it).
This feature was added to GCC very long ago, in 1992, SVN commit r334.
The code comment (varasm.c:decode_reg_name_and_count nowadays) makes
clear it is very much deliberate (not an implementation accident).
> This brings us to the question of documentation. Right now the docs
> only refer to register names. I expect it would be helpful for people
> to understand what it means when they come across code that uses
> indices. A few words in the 'clobbers' section and the two Reg Vars
> sections would probably cover it.
I wouldn't. Numbers *are* the register names for all platforms where
you are likely to see this used. Expecting numbers in a clobber to
work as a backref to an output constraint is a) strange, and b) fatal,
as so many errors with asm are. I think the only way to teach people
to not hurt themselves so much with asm is to let them hurt themselves
a lot, so they'll be much more careful in the future :-/
> I realize this may seem a bit redundant for people who are used to
> registers named R0,R1,R2..., but on the i386, the order is:
And that isn't even the same as the hardware numbering. No one will
or should use this on x86, and if they do, well, hurt ;-)