ARM setjmp and r12

Richard Earnshaw rearnsha@arm.com
Tue May 2 13:47:00 GMT 2006


On Wed, 2006-04-26 at 23:32, Shaun Jackman wrote:
> On the ARM, why does setjmp preserve r12 (ip)?  I believe r12 is
> caller-preserved, not callee-preserved.
> 
> arm/setjmp.S:122
> 	/* Save all the callee-preserved registers into the jump buffer.  */
> 	stmea		a1!, { v1-v7, fp, ip, sp, lr }
> 
> Cheers,
> Shaun

I don't really think there is any need to save ip here.  It certainly
can't be for the reason Nick cited (since IP can only be used
transitively for that purpose).  Another problem is that that means we
push an odd number of registers, which means that any subsequent stores
would be unaligned.

I'm not that thrilled with the way that statement is written, why is it
using the old APCS names, and why stmea (this isn't a stack).

	@ Push all call-saved registers, plus the return address.
	@ Keep buffer address aligned so we don't have to re-align
	@ before any co-processor registers.
	stmia	r0!, {r4-r11, r13, r14}

would be a much more sensible definition.

R.



More information about the Newlib mailing list