This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Assigning registers to variables in inlines
- To: gcc at gcc dot gnu dot org
- Subject: Assigning registers to variables in inlines
- From: "Timothy J. Wood" <tjw at omnigroup dot com>
- Date: Tue, 9 Jan 2001 17:15:54 -0800
I'm trying to emulate the Metrowerks __lwbrx PPC intrinsic (load word
byte reversed indexed), but not having any luck. The problem I run into
is that gcc decides to put the 'offset' into r0 and gas gives an error
on this saying that you should write '0' instead (presumably this is an
error designed to catch problems in human generated code since r0 means
'0' in this instruction instead of the actual value of r0).
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;
}
...: parse error before `asm'
...: `_offset' undeclared (first use in this function)
Is it possible to get this to work or should I look for a different
route? I could add addr and offset and always pass 0, but that would
introduce another instruction.
-tim