about summary refs log tree commit diff
path: root/ports/sysdeps/arm
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2013-02-14 09:46:56 -0800
committerRichard Henderson <rth@twiddle.net>2013-03-06 07:44:25 -0800
commit3ae44082ab30918a6f5aa135620dda08e62593d5 (patch)
tree659127296546c56218bfe4dd8ede95a389dd3b62 /ports/sysdeps/arm
parentcd24e113c38e81c15a72536a99062373d5701389 (diff)
downloadglibc-3ae44082ab30918a6f5aa135620dda08e62593d5.tar.gz
glibc-3ae44082ab30918a6f5aa135620dda08e62593d5.tar.xz
glibc-3ae44082ab30918a6f5aa135620dda08e62593d5.zip
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.
Diffstat (limited to 'ports/sysdeps/arm')
-rw-r--r--ports/sysdeps/arm/sysdep.h16
1 files changed, 16 insertions, 0 deletions
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.  */