]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc: xtensa: fix fprintf format specifiers
authorMax Filippov <jcmvbkbc@gmail.com>
Tue, 30 May 2017 23:42:48 +0000 (23:42 +0000)
committerMax Filippov <jcmvbkbc@gcc.gnu.org>
Tue, 30 May 2017 23:42:48 +0000 (23:42 +0000)
HOST_WIDE_INT may not be long as assumed in print_operand and
xtensa_emit_call. Use HOST_WIDE_INT_PRINT_DEC/HOST_WIDE_INT_PRINT_HEX
format strings instead of %ld/0x%lx. This fixes incorrect assembly code
generation by the compiler running on armhf host.

2017-05-30  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
Backport from mainline
2017-05-29  Max Filippov  <jcmvbkbc@gmail.com>

* config/xtensa/xtensa.c (xtensa_emit_call): Use
HOST_WIDE_INT_PRINT_HEX instead of 0x%lx format string.
(print_operand): Use HOST_WIDE_INT_PRINT_DEC instead of %ld
format string.

From-SVN: r248709

gcc/ChangeLog
gcc/config/xtensa/xtensa.c

index 4278b371b2ce2120172a3a771fb426258b5df035..b5c21904e0a594c40fa24d7617a0d81e5ff5bf0c 100644 (file)
@@ -1,3 +1,13 @@
+2017-05-30  Max Filippov  <jcmvbkbc@gmail.com>
+
+       Backport from mainline
+       2017-05-29  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * config/xtensa/xtensa.c (xtensa_emit_call): Use
+       HOST_WIDE_INT_PRINT_HEX instead of 0x%lx format string.
+       (print_operand): Use HOST_WIDE_INT_PRINT_DEC instead of %ld
+       format string.
+
 2017-05-30  Max Filippov  <jcmvbkbc@gmail.com>
 
        Backport from mainline
index 1e9ab05fca1fa59aaf2707c6ee0e0de524c8565b..1c15a7664d9b3c8ec919e04b593e99e1b4fcc05a 100644 (file)
@@ -1808,7 +1808,8 @@ xtensa_emit_call (int callop, rtx *operands)
   rtx tgt = operands[callop];
 
   if (GET_CODE (tgt) == CONST_INT)
-    sprintf (result, "call%d\t0x%lx", WINDOW_SIZE, INTVAL (tgt));
+    sprintf (result, "call%d\t" HOST_WIDE_INT_PRINT_HEX,
+            WINDOW_SIZE, INTVAL (tgt));
   else if (register_operand (tgt, VOIDmode))
     sprintf (result, "callx%d\t%%%d", WINDOW_SIZE, callop);
   else
@@ -2379,14 +2380,14 @@ print_operand (FILE *file, rtx x, int letter)
 
     case 'L':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "%ld", (32 - INTVAL (x)) & 0x1f);
+       fprintf (file, HOST_WIDE_INT_PRINT_DEC, (32 - INTVAL (x)) & 0x1f);
       else
        output_operand_lossage ("invalid %%L value");
       break;
 
     case 'R':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "%ld", INTVAL (x) & 0x1f);
+       fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) & 0x1f);
       else
        output_operand_lossage ("invalid %%R value");
       break;
@@ -2400,7 +2401,7 @@ print_operand (FILE *file, rtx x, int letter)
 
     case 'd':
       if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "%ld", INTVAL (x));
+       fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
       else
        output_operand_lossage ("invalid %%d value");
       break;
@@ -2455,7 +2456,7 @@ print_operand (FILE *file, rtx x, int letter)
       else if (GET_CODE (x) == MEM)
        output_address (XEXP (x, 0));
       else if (GET_CODE (x) == CONST_INT)
-       fprintf (file, "%ld", INTVAL (x));
+       fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
       else
        output_addr_const (file, x);
     }