[cfe-commits] r122643 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGStmt.cpp test/CodeGen/asm-variable.c
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Dec 30 20:34:58 PST 2010
On Dec 30, 2010, at 4:08 PM, Benjamin Kramer wrote:
>
> On 30.12.2010, at 23:59, Rafael Espindola wrote:
>
>> Author: rafael
>> Date: Thu Dec 30 16:59:32 2010
>> New Revision: 122643
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=122643&view=rev
>> Log:
>> Add support for declaring register contraints in variables. They are only used
>> in asm statements:
>>
>> register int foo asm("rdi");
>>
>> asm("..." : ... "r" (foo) ...
>>
>> We also only accept these variables if the constraint in the asm statement is "r".
>>
>> This fixes most of PR3933.
>
> I'm not very happy with this fix. Using such a pinned variable with inline asm looks like an edge case.
It is all that is required for local variables, see http://gcc.gnu.org/onlinedocs/gcc/Local-Reg-Vars.html
> Most code (e.g. ruby 1.9) uses this as a (premature) optimization so it shouldn't hurt there but on the other hand
> the linux kernel uses this extension to access the stack pointer like a variable.
>
> register unsigned long current_stack_pointer asm("esp");
> foo = current_stack_pointer;
Presumably this is a global variable, otherwise it could legally be compiled to:
foo = undef
I think we can support global variables like this one by replacing all reads and writes with empty inline assembly statements.
That will work for reserved registers like %esp. As for using allocatable registers for global variables, I really hope we can avoid that.
/jakob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101230/81d117c9/attachment.bin>
More information about the cfe-commits
mailing list