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]

Re: Assigning registers to variables in inlines



  In message <200101100115.RAA06777@scyther.omnigroup.com>you write:
  > 
  >    So, I'd like some way to say "don't put offset in r0".  Any other 
  > register is OK.  The following fails, though:
  > 
  > static inline unsigned int __lwbrx(register void *addr, register int 
  > offset) {
  >      register unsigned int word;
  >      register unsigned int asm("r9") _offset = offset;
  > 
  >      asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "r" (_offset));
  >      return word;
  > }

Try:

static inline unsigned int __lwbrx(register void *addr, register int 
offset) {
     register unsigned int word;

     asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset));
     return word;
}

[ Note the different constraint in the asm for the offset variable. ]


jef



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