This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 18/20] MIPS/GAS: Simplify sign-extension tests
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: Catherine Moore <clm at codesourcery dot com>, binutils at sourceware dot org
- Date: Thu, 2 Dec 2010 19:23:42 +0000 (GMT)
- Subject: [PATCH 18/20] MIPS/GAS: Simplify sign-extension tests
Hi,
This change simplifies sign-extension tests to use fewer operations as
already done elsewhere. Note that IS_ZEXT_32BIT_NUM(), despite its name
(I was unfortunate enough to come up with once ;) ), merely checks whether
its argument is a signed 33-bit number. I have refrained from renaming it
to IS_SEXT_33BIT_NUM() though, but I can do this if you think it would be
less confusing than the current name.
2010-12-02 Maciej W. Rozycki <macro@codesourcery.com>
gas/
* config/tc-mips.c (IS_SEXT_32BIT_NUM): Simplify.
(IS_SEXT_16BIT_NUM, IS_ZEXT_32BIT_NUM): Likewise.
OK to apply?
Maciej
binutils-gas-mips-ext.diff
Index: binutils-fsf-trunk-quilt/gas/config/tc-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/config/tc-mips.c 2010-12-01 21:05:58.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/config/tc-mips.c 2010-12-01 21:05:58.000000000 +0000
@@ -974,18 +974,15 @@ static int mips_relax_branch;
/* Is the given value a sign-extended 32-bit value? */
#define IS_SEXT_32BIT_NUM(x) \
- (((x) &~ (offsetT) 0x7fffffff) == 0 \
- || (((x) &~ (offsetT) 0x7fffffff) == ~ (offsetT) 0x7fffffff))
+ (((((x) & 0xffffffffLL) ^ 0x80000000LL) - 0x80000000LL) == (x))
/* Is the given value a sign-extended 16-bit value? */
#define IS_SEXT_16BIT_NUM(x) \
- (((x) &~ (offsetT) 0x7fff) == 0 \
- || (((x) &~ (offsetT) 0x7fff) == ~ (offsetT) 0x7fff))
+ (((((x) & 0xffffLL) ^ 0x8000LL) - 0x8000LL) == (x))
/* Is the given value a zero-extended 32-bit value? Or a negated one? */
#define IS_ZEXT_32BIT_NUM(x) \
- (((x) &~ (offsetT) 0xffffffff) == 0 \
- || (((x) &~ (offsetT) 0xffffffff) == ~ (offsetT) 0xffffffff))
+ (((((x) & 0x1ffffffffLL) ^ 0x100000000LL) - 0x100000000LL) == (x))
/* Replace bits MASK << SHIFT of STRUCT with the equivalent bits in
VALUE << SHIFT. VALUE is evaluated exactly once. */