On Dec 30, 2010, at 8:34 PM, Jakob Stoklund Olesen wrote: > > 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.
Yes, this should work for global register variables. llvm-gcc does this IIRC. -Chris > > That will work for reserved registers like %esp. As for using allocatable > registers for global variables, I really hope we can avoid that. > > /jakob > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
