aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2003-06-30 04:09:27 +0000
committerAlan Modra <amodra@gmail.com>2003-06-30 04:09:27 +0000
commit113202d6bca060bd1480c42eb373879309041094 (patch)
treee906b82ee8940d525ae0ae11e1e3db27dc7f7ad6
parent3c6cb4a1a4a4876ff5794818e09bc9187d8b1a16 (diff)
downloadgdb-113202d6bca060bd1480c42eb373879309041094.zip
gdb-113202d6bca060bd1480c42eb373879309041094.tar.gz
gdb-113202d6bca060bd1480c42eb373879309041094.tar.bz2
* cpu-ia64-opc.c (ext_imms_scaled): Don't sign extend using shifts.
(ins_imms, ins_immsm1u4): Likewise. Warning fix.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/cpu-ia64-opc.c18
2 files changed, 11 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f2e5665..47e0038 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2003-06-30 Alan Modra <amodra@bigpond.net.au>
+
+ * cpu-ia64-opc.c (ext_imms_scaled): Don't sign extend using shifts.
+ (ins_imms, ins_immsm1u4): Likewise. Warning fix.
+
2003-06-29 Alan Modra <amodra@bigpond.net.au>
* archive.c: Convert to C90, remove unnecessary prototypes and casts.
diff --git a/bfd/cpu-ia64-opc.c b/bfd/cpu-ia64-opc.c
index 1025256..3cafb9f 100644
--- a/bfd/cpu-ia64-opc.c
+++ b/bfd/cpu-ia64-opc.c
@@ -161,8 +161,8 @@ static const char*
ext_imms_scaled (const struct ia64_operand *self, ia64_insn code,
ia64_insn *valuep, int scale)
{
- int i, bits = 0, total = 0, shift;
- BFD_HOST_64_BIT val = 0;
+ int i, bits = 0, total = 0;
+ BFD_HOST_64_BIT val = 0, sign;
for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i)
{
@@ -172,8 +172,8 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code,
total += bits;
}
/* sign extend: */
- shift = 8*sizeof (val) - total;
- val = (val << shift) >> shift;
+ sign = (BFD_HOST_64_BIT) 1 << (total - 1);
+ val = (val ^ sign) - sign;
*valuep = (val << scale);
return 0;
@@ -188,10 +188,7 @@ ins_imms (const struct ia64_operand *self, ia64_insn value, ia64_insn *code)
static const char*
ins_immsu4 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code)
{
- if (value == (BFD_HOST_U_64_BIT) 0x100000000)
- value = 0;
- else
- value = (((BFD_HOST_64_BIT)value << 32) >> 32);
+ value = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
return ins_imms_scaled (self, value, code, 0);
}
@@ -213,10 +210,7 @@ static const char*
ins_immsm1u4 (const struct ia64_operand *self, ia64_insn value,
ia64_insn *code)
{
- if (value == (BFD_HOST_U_64_BIT) 0x100000000)
- value = 0;
- else
- value = (((BFD_HOST_64_BIT)value << 32) >> 32);
+ value = ((value & 0xffffffff) ^ 0x80000000) - 0x80000000;
--value;
return ins_imms_scaled (self, value, code, 0);