merge from gcc
[external/binutils.git] / gas / config / tc-v850.c
index a99bad9..e0ac162 100644 (file)
@@ -1,6 +1,6 @@
 /* tc-v850.c -- Assembler code for the NEC V850
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007  Free Software Foundation, Inc.
+   2006, 2007, 2009  Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -477,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;
@@ -1505,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);
            }
        }
     }
@@ -1536,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];