On 3/12/2015 7:24 AM, paul_kon...@dell.com wrote:
On Mar 11, 2015, at 8:53 PM, David Wohlferd <d...@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

Ahh. So perhaps as I suspected: this is more commonly used on non-i386 platforms. So clearly removing this is out of the question.

This brings us to the question of documentation. Right now the docs only refer to register names. I expect it would be helpful for people to understand what it means when they come across code that uses indices. A few words in the 'clobbers' section and the two Reg Vars sections would probably cover it.

Perhaps some variation of:

------------
In addition to specifying registers by name, it is also possible to use a register index (ie "3" to refer to the 3rd register). The list of registers and their order is platform specific. See the REGISTER_NAMES defined for your platform in the gcc source.
------------

I'm not excited about pointing people vaguely toward the source, but that's the only place I know to find this info.

I realize this may seem a bit redundant for people who are used to registers named R0,R1,R2..., but on the i386, the order is: ax,dx,cx,bx,si...

dw

Reply via email to