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]

Re: Fix cgen warnings in opcodes/


On Mon, Dec 02, 2002 at 05:28:55PM +1030, Alan Modra wrote:
> This patch
> banishes most of the warnings in cgen files, leaving only a few about
> unused functions/vars.

Well, that was a rash claim.  There were some type punned pointer
warnings to fix in cgen/cpu/openrisc.opc, and lots of missing
initializer warnings for opcodes/m32r-opinst.c, fixed by the
opc-opinst.scm change.

cgen/ChangeLog
	* opc-opinst.scm (-gen-operand-instance-table): Init all fields
	of structure when using END.
	* cpu/openrisc.opc (openrisc_sign_extend_16bit): Don't rely on
	"short" being 16 bit.
	(parse_hi16): Likewise.  Fix type-punned pointer warnings too, and
	internationalize error message.
	(parse_lo16): Likewise.  Remove useless code.

Index: cgen/opc-opinst.scm
===================================================================
RCS file: /cvs/src/src/cgen/opc-opinst.scm,v
retrieving revision 1.2
diff -u -p -r1.2 opc-opinst.scm
--- cgen/opc-opinst.scm	20 Nov 2000 19:03:33 -0000	1.2
+++ cgen/opc-opinst.scm	2 Dec 2002 12:40:46 -0000
@@ -54,7 +54,7 @@
 		  ins)
       (string-map (lambda (op)  (-gen-operand-instance op "OUTPUT"))
 		  outs)
-      "  { END }\n};\n\n")))
+      "  { END, 0, 0, 0, 0, 0, 0 }\n};\n\n")))
 )
 
 (define (-gen-operand-instance-tables)
Index: cgen/cpu/openrisc.opc
===================================================================
RCS file: /cvs/src/src/cgen/cpu/openrisc.opc,v
retrieving revision 1.2
diff -u -p -r1.2 openrisc.opc
--- cgen/cpu/openrisc.opc	9 Oct 2001 08:24:22 -0000	1.2
+++ cgen/cpu/openrisc.opc	2 Dec 2002 12:53:26 -0000
@@ -44,7 +44,7 @@ long
 openrisc_sign_extend_16bit (value)
      long value;
 {
-  return (long) (short) value;
+  return ((value & 0xffff) ^ 0x8000) - 0x8000;
 }
 
 /* Handle hi().  */
@@ -58,15 +58,16 @@ parse_hi16 (cd, strp, opindex, valuep)
 {
   const char *errmsg;
   enum cgen_parse_operand_result result_type;
-  bfd_vma value;
+  unsigned long ret;
 
   if (**strp == '#')
     ++*strp;
 
   if (strncasecmp (*strp, "hi(", 3) == 0)
     {
-      *strp += 3;
+      bfd_vma value;
 
+      *strp += 3;
 #if 0
       errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep);
       if (errmsg != NULL)
@@ -76,23 +77,31 @@ parse_hi16 (cd, strp, opindex, valuep)
         errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
                                      &result_type, &value);
       if (**strp != ')')
-        return "missing `)'";
+        return _("missing `)'");
+
       ++*strp;
       if (errmsg == NULL
           && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
         value >>= 16;
-      *valuep = (long) (short) value;
-
-      return errmsg;
+      ret = value;
     }
   else
     {
       if (**strp == '-')
-        errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value);
+	{
+	  long value;
+	  errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
+	  ret = value;
+	}
       else
-        errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value);
+	{
+	  unsigned long value;
+	  errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
+	  ret = value;
+	}
     }
-  *valuep = (long) (short) (value & 0xffff);
+
+  *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
   return errmsg;
 }
 
@@ -107,15 +116,16 @@ parse_lo16 (cd, strp, opindex, valuep)
 {
   const char *errmsg;
   enum cgen_parse_operand_result result_type;
-  bfd_vma value;
+  unsigned long ret;
 
   if (**strp == '#')
     ++*strp;
 
   if (strncasecmp (*strp, "lo(", 3) == 0)
     {
-      *strp += 3;
+      bfd_vma value;
 
+      *strp += 3;
 #if 0 
       errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep);
       if (errmsg != NULL)
@@ -126,21 +136,28 @@ parse_lo16 (cd, strp, opindex, valuep)
         errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
                                      &result_type, &value);
       if (**strp != ')')
-        return "missing `)'";
-      ++*strp;
-      if (errmsg == NULL
-          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
-        value &= 0xffff;
-      *valuep = (long) (short) value;
+        return _("missing `)'");
 
-      return errmsg;
+      ++*strp;
+      ret = value;
     }
-
-  if (**strp == '-')
-    errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value);
   else
-    errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value);
-  *valuep = (long) (short) (value & 0xffff);
+    {
+      if (**strp == '-')
+	{
+	  long value;
+	  errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
+	  ret = value;
+	}
+      else
+	{
+	  unsigned long value;
+	  errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
+	  ret = value;
+	}
+    }
+
+  *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
   return errmsg;
 }
 

-- 
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]