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 7:19 PM, Ian Lance Taylor <iant@google.com> wrote:
> 
> On Wed, Mar 11, 2015 at 3:58 PM, David Wohlferd <dw@limegreensocks.com> wrote:
>> 
>> Why does gcc allow you to specify clobbers using numbers:
>> 
>>   asm ("" : : "r" (var) : "0"); // i386: clobbers eax
>> 
>> How is this better than using register names?
>> 
>> This makes even less sense when you realize that (apparently) the indices of
>> registers aren't fixed.  Which means there is no way to know which register
>> you have clobbered in order to use it in the template.
>> 
>> Having just seen someone trying (unsuccessfully) to use this, it seems like
>> there is no practical way you can.
>> 
>> Which makes me wonder why it's there.  And whether it still should be.
> 
> I don't know why it works.  It should be consistent, though.  It's
> simply GCC's internal hard register number, which doesn't normally
> change.
> 
> 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.

Register names would be nice as an additional capability.

	paul


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