This is the mail archive of the binutils@sources.redhat.com 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]

ia64 warning fixes


Fixes a number of warnings about integer constant is too large for
"long" type, when compiling on a host with 32 bit longs.

I'm not sure what the test against 2**32 in cpu-ia64-opc.c was hoping to
accomplish, as it's clear that sign extending from a 32 bit value would
result in zero anyway.  Perhaps one of the ia64 maintainers could take a
look..

Oh, and the reason for not doing the sign extension by shifts is that
it relies on BFD_HOST_64_BIT being exactly 64 bits, and that right
shifts of signed values are in fact sign extending.  From what I recall,
right shifts of negative signed values are implementation defined.

bfd/ChangeLog
	* cpu-ia64-opc.c (ext_imms_scaled): Don't sign extend using shifts.
	(ins_imms, ins_immsm1u4): Likewise.  Warning fix.

gas/ChangeLog
	* config/tc-ia64.c (note_register_values): Warning fix.
	* config/tc-mips.c (append_insn): Likewise.

Index: bfd/cpu-ia64-opc.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-ia64-opc.c,v
retrieving revision 1.8
diff -u -p -r1.8 cpu-ia64-opc.c
--- bfd/cpu-ia64-opc.c	5 Dec 2002 02:08:00 -0000	1.8
+++ bfd/cpu-ia64-opc.c	30 Jun 2003 01:40:17 -0000
@@ -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_opera
       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 *sel
 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);
Index: gas/config/tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.90
diff -u -p -r1.90 tc-ia64.c
--- gas/config/tc-ia64.c	23 Jun 2003 19:35:52 -0000	1.90
+++ gas/config/tc-ia64.c	30 Jun 2003 01:40:22 -0000
@@ -8940,7 +8940,7 @@ note_register_values (idesc)
       else if (idesc->operands[i] == IA64_OPND_PR_ROT)
 	{
 	  if (idesc->operands[1] & ((valueT) 1 << 43))
-	    qp_changemask = ~(valueT) 0xFFFFFFFFFFF | idesc->operands[1];
+	    qp_changemask = -((valueT) 1 << 44) | idesc->operands[1];
 	  else
 	    qp_changemask = idesc->operands[1];
 	  qp_changemask &= ~(valueT) 0xFFFF;
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.221
diff -u -p -r1.221 tc-mips.c
--- gas/config/tc-mips.c	29 Jun 2003 19:41:33 -0000	1.221
+++ gas/config/tc-mips.c	30 Jun 2003 01:40:29 -0000
@@ -2116,7 +2116,8 @@ append_insn (place, ip, address_expr, re
 	      break;
 
 	    case BFD_RELOC_MIPS_HIGHEST:
-	      tmp = (address_expr->X_add_number + 0x800080008000) >> 16;
+	      tmp = (address_expr->X_add_number
+		     + ((valueT) 0x8000 << 32) + 0x80008000) >> 16;
 	      tmp >>= 16;
 	      ip->insn_opcode |= (tmp >> 16) & 0xffff;
 	      break;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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