This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 18/20] MIPS/GAS: Simplify sign-extension tests


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]