This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inline asm clobbers


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 <dw@limegreensocks.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
happening.
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.

dw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]