This is the mail archive of the
mailing list for the GCC project.
Re: inline asm clobbers
- From: David Wohlferd <dw at LimeGreenSocks dot com>
- To: gcc at gcc dot gnu dot org, Paul_Koning at Dell dot com
- Date: Wed, 11 Mar 2015 17:53:06 -0700
- 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>
On 3/11/2015 4:41 PM, Paul_Koning@Dell.com wrote:
On Mar 11, 2015, at 7:19 PM, Ian Lance Taylor <firstname.lastname@example.org> wrote:
On Wed, Mar 11, 2015 at 3:58 PM, David Wohlferd <email@example.com> wrote:
Why does gcc allow you to specify clobbers using numbers:
asm ("" : : "r" (var) : "0"); // i386: clobbers eax
How is this better than using register names?
This makes even less sense when you realize that (apparently) the indices of
registers aren't fixed. Which means there is no way to know which register
you have clobbered in order to use it in the template.
Having just seen someone trying (unsuccessfully) to use this, it seems like
there is no practical way you can.
Which makes me wonder why it's there. And whether it still should be.
I don't know why it works. It should be consistent, though. It's
simply GCC's internal hard register number, which doesn't normally
I would agree that one should avoid it. I'd be wary of removing it
from GCC at this point since it might break working code.
It certainly would. Itâs not all that common, but I have seen this done in production code. Come to think of it, this certainly makes sense in machines where some instructions act on fixed registers.
Really? While I've seen much code that uses clobbers, I have never
(until this week) see anyone attempt to clobber by index. Since I'm
basically an i386 guy, maybe this is a platform thing? Do you have some
Register names would be nice as an additional capability.
Every example I've ever seen uses register names. Perhaps that what
you've seen before?