2010-03-13 Segher Boessenkool <segher@kernel.crashing.org>
[deliverable/binutils-gdb.git] / gas / config / tc-v850.c
index c6c343940af4665a60eff8cc60cf8d9cd7b7e6b3..e0ac162279a1068d1ff279f982484a7431d34894 100644 (file)
@@ -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];
 
This page took 0.02325 seconds and 4 git commands to generate.