public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: cgen@sources.redhat.com, binutils@sources.redhat.com
Subject: Re: Fix cgen warnings in opcodes/
Date: Mon, 02 Dec 2002 04:57:00 -0000	[thread overview]
Message-ID: <20021202125720.GG27956@bubble.sa.bigpond.net.au> (raw)
In-Reply-To: <20021202065854.GE27956@bubble.sa.bigpond.net.au>

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

  reply	other threads:[~2002-12-02 12:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-01 22:59 Alan Modra
2002-12-02  4:57 ` Alan Modra [this message]
2002-12-02 10:53 ` Frank Ch. Eigler
2002-12-02 14:06   ` Alan Modra
2002-12-02 14:27     ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021202125720.GG27956@bubble.sa.bigpond.net.au \
    --to=amodra@bigpond.net.au \
    --cc=binutils@sources.redhat.com \
    --cc=cgen@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).