merge from gcc
[external/binutils.git] / gas / config / tc-v850.c
index 7984956..e0ac162 100644 (file)
@@ -1,12 +1,12 @@
 /* tc-v850.c -- Assembler code for the NEC V850
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006  Free Software Foundation, Inc.
+   2006, 2007, 2009  Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
@@ -19,7 +19,6 @@
    the Free Software Foundation, 51 Franklin Street - Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 
-#include <stdio.h>
 #include "as.h"
 #include "safe-ctype.h"
 #include "subsegs.h"
@@ -478,16 +477,16 @@ v850_longcode (int type)
   if (! v850_relax)
     {
       if (type == 1)
-       as_warn (".longcall pseudo-op seen when not relaxing");
+       as_warn (_(".longcall pseudo-op seen when not relaxing"));
       else
-       as_warn (".longjump pseudo-op seen when not relaxing");
+       as_warn (_(".longjump pseudo-op seen when not relaxing"));
     }
 
   expression (&ex);
 
   if (ex.X_op != O_symbol || ex.X_add_number != 0)
     {
-      as_bad ("bad .longcall format");
+      as_bad (_("bad .longcall format"));
       ignore_rest_of_line ();
 
       return;
@@ -1179,39 +1178,7 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
 char *
 md_atof (int type, char *litp, int *sizep)
 {
-  int prec;
-  LITTLENUM_TYPE words[4];
-  char *t;
-  int i;
-
-  switch (type)
-    {
-    case 'f':
-      prec = 2;
-      break;
-
-    case 'd':
-      prec = 4;
-      break;
-
-    default:
-      *sizep = 0;
-      return _("bad call to md_atof");
-    }
-
-  t = atof_ieee (input_line_pointer, type, words);
-  if (t)
-    input_line_pointer = t;
-
-  *sizep = prec * 2;
-
-  for (i = prec - 1; i >= 0; i--)
-    {
-      md_number_to_chars (litp, (valueT) words[i], 2);
-      litp += 2;
-    }
-
-  return NULL;
+  return ieee_md_atof (type, litp, sizep, FALSE);
 }
 
 /* Very gross.  */
@@ -1538,9 +1505,9 @@ v850_insert_operand (unsigned long insn,
          else
            {
              if (file == (char *) NULL)
-               as_warn (message);
+               as_warn ("%s", message);
              else
-               as_warn_where (file, line, message);
+               as_warn_where (file, line, "%s", message);
            }
        }
     }
@@ -1569,7 +1536,24 @@ v850_insert_operand (unsigned long insn,
                min = 0;
            }
 
-         if (val < (offsetT) min || val > (offsetT) max)
+         /* Some people write constants with the sign extension done by
+            hand but only up to 32 bits.  This shouldn't really be valid,
+            but, to permit this code to assemble on a 64-bit host, we
+            sign extend the 32-bit value to 64 bits if so doing makes the
+            value valid.  */
+         if (val > max
+             && (offsetT) (val - 0x80000000 - 0x80000000) >= min
+             && (offsetT) (val - 0x80000000 - 0x80000000) <= max)
+           val = val - 0x80000000 - 0x80000000;
+
+         /* Similarly, people write expressions like ~(1<<15), and expect
+            this to be OK for a 32-bit unsigned value.  */
+         else if (val < min
+                  && (offsetT) (val + 0x80000000 + 0x80000000) >= min
+                  && (offsetT) (val + 0x80000000 + 0x80000000) <= max)
+           val = val + 0x80000000 + 0x80000000;
+
+         else if (val < (offsetT) min || val > (offsetT) max)
            {
              char buf [128];