RFC: ARM: __attribute__ ((reg_return))

Paul Brook paul@codesourcery.com
Tue Sep 4 01:24:00 GMT 2007


> > The v4t interworked return needs a scratch reg, so has to jump through
> > hoops to avoid clobbering r0-r3.
>
> I'm getting the rather unexciting
> foo:
>          ldr     r3, .L3
>          ldr     r0, [r3]
>          ldr     r1, [r3, #4]
>          ldr     r2, [r3, #8]
>          ldr     r3, [r3, #12]
>          @ sp needed for prologue
>          bx      lr
>
> with that combination of options.  

Oh, you need to also push/clobber lr to get the interesting case. e.g.:
{
  S v = {0,0};
  asm volatile("":::"lr");
  return v;
}


> (.L3 is the address of sixteen bytes 
> of zeroes.  Isn't there a load-zero instruction?)

Yes, "mov r0, #0". I guess for whatever reason gcc is deciding to put the 
initializer in memory. IIRC 16 bytes is too big for SRA to kick in.

Paul



More information about the Gcc-patches mailing list