[patch] A minor improvement for ARM setjmp and longjmp
Jeff Johnston
jjohnstn@redhat.com
Wed May 13 19:40:00 GMT 2009
Patch applied.
-- Jeff J.
Kazu Hirata wrote:
> Hi,
>
> Attached is a patch to make a minor improvement for ARM setjmp and
> longjmp.
>
> A while ago, Nick fixed the problem of trying to save SP with STMEA in
>
> http://sourceware.org/ml/newlib/2008/msg00222.html
>
> Meanwhile, Paul independently came up with an alternative fix.
>
> Note that IP is a call-clobbered register. As such, we do not have to
> save or restore it. We can take advantage of this fact and ask STMEA
> to save IP after copying SP to IP. This way, we are effectively
> saving SP without violating the constraints on STMEA. We also get to
> reduce the number of loads by one.
>
> OK to apply?
>
> Kazu Hirata
>
> 2009-05-06 Paul Brook <paul@codesourcery.com>
>
> * libc/machine/arm/setjmp.S: Don't bother saving IP. Copy SP to
> IP before saving. Likewise when restoring.
>
> Index: newlib/libc/machine/arm/setjmp.S
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/machine/arm/setjmp.S,v
> retrieving revision 1.3
> diff -u -d -p -r1.3 setjmp.S
> --- newlib/libc/machine/arm/setjmp.S 25 Apr 2008 09:02:40 -0000 1.3
> +++ newlib/libc/machine/arm/setjmp.S 5 May 2009 16:13:46 -0000
> @@ -121,8 +121,8 @@ SYM (\name):
>
> /* Save all the callee-preserved registers into the jump buffer. */
> #ifdef __thumb2__
> + mov ip, sp
> stmea a1!, { v1-v7, fp, ip, lr }
> - str sp, [a1],#+4
> #else
> stmea a1!, { v1-v7, fp, ip, sp, lr }
> #endif
> @@ -149,7 +149,7 @@ SYM (\name):
> /* Restore the registers, retrieving the state when setjmp() was called. */
> #ifdef __thumb2__
> ldmfd a1!, { v1-v7, fp, ip, lr }
> - ldr sp, [a1],#+4
> + mov sp, ip
> #else
> ldmfd a1!, { v1-v7, fp, ip, sp, lr }
> #endif
>
More information about the Newlib
mailing list