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" <gcc at gcc dot gnu dot org>
- Date: Thu, 12 Mar 2015 14:02:37 -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> <5500E31C dot 4080707 at LimeGreenSocks dot com> <CAKOQZ8zbcYCSKOVfxcrVyb=R6T8dNnfi3e3Erv9s1SZTtu0UhQ at mail dot gmail dot com>
Resending due to bounced email.
On 3/11/2015 6:19 PM, Ian Lance Taylor wrote:
On Wed, Mar 11, 2015 at 5:51 PM, David Wohlferd <email@example.com> wrote:
The reason I believe the order can change is this comment from i386.h:
/* Order in which to allocate registers. Each register must be
listed once, even those in FIXED_REGISTERS. List frame pointer
late and fixed registers last. Note that, in general, we prefer
registers listed in CALL_USED_REGISTERS, keeping the others
available for storage of persistent values.
The ADJUST_REG_ALLOC_ORDER actually overwrite the order,
so this is just empty initializer for array. */
That is REG_ALLOC_ORDER. The index that appears in an asm statement
is the hard register number. REG_ALLOC_ORDER is an array holding hard
register numbers. The hard register numbers can change in principle,
by changing the source code, but I actually can't recall that ever
To wrap this up:
Like Ian said, the order of registers here apparently never changes. I
read more into that comment than I should have. For good luck, I
experimented with -fomit-frame-pointer, -ffixed-, etc, and nothing has
any impact here. The list is the list.
In fact, it turns out you can use this same format with register variables:
register int x asm("3"); // i386: ebx
So while I find it ugly, unnecessarily complex, and lacking in
self-documenting-ness, it is not inherently buggy the way I feared it
was, so I can't think of any good arguments for pulling it out.
Thanks to Ian and Paul for straightening me out.