From 3ae44082ab30918a6f5aa135620dda08e62593d5 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 14 Feb 2013 09:46:56 -0800 Subject: arm: Introduce and use NEGOFF series of macros There are several places in which we access negative offsets from the thread-pointer, but thumb2 only supports positive offsets in memory references. Avoid duplicating the rather large macros in which these references are embedded by abstracting out the operation. --- ports/sysdeps/arm/sysdep.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ports/sysdeps/arm') diff --git a/ports/sysdeps/arm/sysdep.h b/ports/sysdeps/arm/sysdep.h index 29a78f043d..9230131c78 100644 --- a/ports/sysdeps/arm/sysdep.h +++ b/ports/sysdeps/arm/sysdep.h @@ -134,6 +134,22 @@ .previous; \ 99: OP R, [pc, T] # endif + +/* Cope with negative memory offsets, which thumb can't encode. + Use NEGOFF_ADJ_BASE to (conditionally) alter the base register, + and then NEGOFF_OFF1 to use 0 for thumb and the offset for arm, + or NEGOFF_OFF2 to use A-B for thumb and A for arm. */ +# ifdef __thumb2__ +# define NEGOFF_ADJ_BASE(R, OFF) add R, R, $OFF +# define NEGOFF_ADJ_BASE2(D, S, OFF) add D, S, $OFF +# define NEGOFF_OFF1(R, OFF) [R] +# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $((OFFA) - (OFFB))] +# else +# define NEGOFF_ADJ_BASE(R, OFF) +# define NEGOFF_ADJ_BASE2(D, S, OFF) mov D, S +# define NEGOFF_OFF1(R, OFF) [R, $OFF] +# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $OFFA] +# endif #endif /* __ASSEMBLER__ */ /* This number is the offset from the pc at the current location. */ -- cgit 1.4.1