This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH 18/20] MIPS/GAS: Simplify sign-extension tests
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: Catherine Moore <clm at codesourcery dot com>, binutils at sourceware dot org
- Date: Tue, 07 Dec 2010 11:16:10 +0000
- Subject: Re: [PATCH 18/20] MIPS/GAS: Simplify sign-extension tests
- References: <alpine.DEB.1.10.1012021610410.14129@tp.orcam.me.uk>
Patches 14-17 are OK.
"Maciej W. Rozycki" <macro@codesourcery.com> writes:
> /* 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))
Although I realise some ports have transgressed (ia64 for one), we shouldn't
use LL.
Richard