aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-07-09 09:09:23 +0930
committerAlan Modra <amodra@gmail.com>2025-07-09 09:35:07 +0930
commit4df44a4aead61b5d46c35c5ddf2b96ac07948794 (patch)
tree66bd50e8e7de1da4022e5960c7ed32ae84ab4ef7
parentb413e254325678474b5d363102cf6488912d0258 (diff)
downloadbinutils-4df44a4aead61b5d46c35c5ddf2b96ac07948794.zip
binutils-4df44a4aead61b5d46c35c5ddf2b96ac07948794.tar.gz
binutils-4df44a4aead61b5d46c35c5ddf2b96ac07948794.tar.bz2
gas alpha sign extension macros
Use standard sign extend and range checking using unsigned expressions that don't rely on implementation defined right shifts or size of short and int.
-rw-r--r--gas/config/tc-alpha.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c
index 99f4bc6..a91db14 100644
--- a/gas/config/tc-alpha.c
+++ b/gas/config/tc-alpha.c
@@ -170,33 +170,13 @@ struct alpha_macro
#define note_fpreg(R) (alpha_fprmask |= (1 << (R)))
/* Predicates for 16- and 32-bit ranges */
-/* XXX: The non-shift version appears to trigger a compiler bug when
- cross-assembling from x86 w/ gcc 2.7.2. */
-
-#if 1
-#define range_signed_16(x) \
- (((offsetT) (x) >> 15) == 0 || ((offsetT) (x) >> 15) == -1)
-#define range_signed_32(x) \
- (((offsetT) (x) >> 31) == 0 || ((offsetT) (x) >> 31) == -1)
-#else
-#define range_signed_16(x) ((offsetT) (x) >= -(offsetT) 0x8000 && \
- (offsetT) (x) <= (offsetT) 0x7FFF)
-#define range_signed_32(x) ((offsetT) (x) >= -(offsetT) 0x80000000 && \
- (offsetT) (x) <= (offsetT) 0x7FFFFFFF)
-#endif
+#define range_signed_16(x) ((valueT) (x) + 0x8000 <= 0xFFFF)
+#define range_signed_32(x) ((valueT) (x) + 0x80000000 <= 0xFFFFFFFF)
/* Macros for sign extending from 16- and 32-bits. */
-/* XXX: The cast macros will work on all the systems that I care about,
- but really a predicate should be found to use the non-cast forms. */
-
-#if 1
-#define sign_extend_16(x) ((short) (x))
-#define sign_extend_32(x) ((int) (x))
-#else
-#define sign_extend_16(x) ((offsetT) (((x) & 0xFFFF) ^ 0x8000) - 0x8000)
-#define sign_extend_32(x) ((offsetT) (((x) & 0xFFFFFFFF) \
- ^ 0x80000000) - 0x80000000)
-#endif
+#define sign_extend_16(x) ((((valueT) (x) & 0xFFFF) ^ 0x8000) - 0x8000)
+#define sign_extend_32(x) ((((valueT) (x) & 0xFFFFFFFF) ^ 0x80000000) \
+ - 0x80000000)
/* Macros to build tokens. */