This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: inline asm clobbers
- From: <Paul_Koning at Dell dot com>
- To: <dw at LimeGreenSocks dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Thu, 12 Mar 2015 14:24:55 +0000
- 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>
> 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