From 2e4524f4572d4c9198692c8d1e5d43a6f9264ca5 Mon Sep 17 00:00:00 2001 From: Chris Demetriou Date: Fri, 8 Feb 2002 22:25:36 +0000 Subject: [PATCH] 2002-02-08 Chris Demetriou * config/tc-mips.c (IS_SEXT_32BIT_NUM): New macro to determine if a number is a sign-extended 32-bit number. (load_register): Use IS_SEXT_32BIT_NUM. (macro): Check if load/store macro handling is using a constant 32-bit address on 64-bit address systems, and if so optimize the generation of that address. --- gas/ChangeLog | 9 +++++++++ gas/config/tc-mips.c | 20 ++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 2daf90f5f3..c2ea1d9fae 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2002-02-08 Chris Demetriou + + * config/tc-mips.c (IS_SEXT_32BIT_NUM): New macro to + determine if a number is a sign-extended 32-bit number. + (load_register): Use IS_SEXT_32BIT_NUM. + (macro): Check if load/store macro handling is using a + constant 32-bit address on 64-bit address systems, and if + so optimize the generation of that address. + 2002-02-08 Richard Henderson * config/tc-alpha.c (alpha_force_relocation): Don't assert that diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 0da9b8b101..d64d4eb3e5 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -3353,6 +3353,11 @@ check_absolute_expr (ip, ex) ? 1 \ : 0) +/* 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)) + /* load_register() * This routine generates the least number of instructions neccessary to load * an absolute expression value into a register. @@ -3392,9 +3397,7 @@ load_register (counter, reg, ep, dbl) (int) BFD_RELOC_LO16); return; } - else if ((((ep->X_add_number &~ (offsetT) 0x7fffffff) == 0 - || ((ep->X_add_number &~ (offsetT) 0x7fffffff) - == ~ (offsetT) 0x7fffffff)) + else if ((IS_SEXT_32BIT_NUM (ep->X_add_number) && (! dbl || ! ep->X_unsigned || sizeof (ep->X_add_number) > 4 @@ -5544,8 +5547,17 @@ macro (ip) dsll $tempreg,16 daddu $tempreg,$tempreg,$breg $treg,($tempreg) (BFD_RELOC_LO16) + + If we have 64-bit addresses, as an optimization, for + addresses which are 32-bit constants (e.g. kseg0/kseg1 + addresses) we fall back to the 32-bit address generation + mechanism since it is more efficient. This code should + probably attempt to generate 64-bit constants more + efficiently in general. */ - if (HAVE_64BIT_ADDRESSES) + if (HAVE_64BIT_ADDRESSES + && !(offset_expr.X_op == O_constant + && IS_SEXT_32BIT_NUM (offset_expr.X_add_number))) { p = NULL; -- 2.11.0