Commit 3904010d by Max Filippov Committed by Max Filippov

gcc: xtensa: fix fprintf format specifiers

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-29  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* 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: r248586
parent 4dbe373c
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-29 Eric Botcazou <ebotcazou@adacore.com> 2017-05-29 Eric Botcazou <ebotcazou@adacore.com>
* doc/install.texi (Options specification): Restore entry of * doc/install.texi (Options specification): Restore entry of
......
...@@ -1780,7 +1780,8 @@ xtensa_emit_call (int callop, rtx *operands) ...@@ -1780,7 +1780,8 @@ xtensa_emit_call (int callop, rtx *operands)
rtx tgt = operands[callop]; rtx tgt = operands[callop];
if (GET_CODE (tgt) == CONST_INT) 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)) else if (register_operand (tgt, VOIDmode))
sprintf (result, "callx%d\t%%%d", WINDOW_SIZE, callop); sprintf (result, "callx%d\t%%%d", WINDOW_SIZE, callop);
else else
...@@ -2351,14 +2352,14 @@ print_operand (FILE *file, rtx x, int letter) ...@@ -2351,14 +2352,14 @@ print_operand (FILE *file, rtx x, int letter)
case 'L': case 'L':
if (GET_CODE (x) == CONST_INT) 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 else
output_operand_lossage ("invalid %%L value"); output_operand_lossage ("invalid %%L value");
break; break;
case 'R': case 'R':
if (GET_CODE (x) == CONST_INT) if (GET_CODE (x) == CONST_INT)
fprintf (file, "%ld", INTVAL (x) & 0x1f); fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) & 0x1f);
else else
output_operand_lossage ("invalid %%R value"); output_operand_lossage ("invalid %%R value");
break; break;
...@@ -2372,7 +2373,7 @@ print_operand (FILE *file, rtx x, int letter) ...@@ -2372,7 +2373,7 @@ print_operand (FILE *file, rtx x, int letter)
case 'd': case 'd':
if (GET_CODE (x) == CONST_INT) if (GET_CODE (x) == CONST_INT)
fprintf (file, "%ld", INTVAL (x)); fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
else else
output_operand_lossage ("invalid %%d value"); output_operand_lossage ("invalid %%d value");
break; break;
...@@ -2437,7 +2438,7 @@ print_operand (FILE *file, rtx x, int letter) ...@@ -2437,7 +2438,7 @@ print_operand (FILE *file, rtx x, int letter)
else if (GET_CODE (x) == MEM) else if (GET_CODE (x) == MEM)
output_address (GET_MODE (x), XEXP (x, 0)); output_address (GET_MODE (x), XEXP (x, 0));
else if (GET_CODE (x) == CONST_INT) else if (GET_CODE (x) == CONST_INT)
fprintf (file, "%ld", INTVAL (x)); fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
else else
output_addr_const (file, x); output_addr_const (file, x);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment