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


> On Mar 11, 2015, at 8:53 PM, David Wohlferd <dw@LimeGreenSocks.com> wrote:
> 
>>> ...
>>> 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 examples/links?

The example I remember was not in open code.  It may have been cleaned up by now, but as supplied to us by the vendor, there were some bits of assembly code that needed a scratch register and used a fixed register (t0 == %8) for that purpose rather than having GCC deal with temporaries.  So there was a clobber with â8â in it.  Obviously thereâs a better way in that instance, but if GCC had removed the feature before we found and cleaned up that code, we would have had a failure on our hands.

An example of hardwired registers I remember is some VAX instructions (string instructions).  You could write those by name, of course, but if you didnât know that GCC supports names, you might just use numbers.  On machines like VAX where the register names are really just numbers (R0, R1, etc.) that isnât such a strange thing to do.

>> 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?

No; I didnât know that gcc supports register names.  The examples I had seen all use numbers.  Or more often, preprocessor symbols.  It may be thatâs because the most common asm code I run into is MIPS coprocessor references, and while general registers may be known by name, coprocessor registers may not be.  Or it may just be a case of lack of awareness.

	paul

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