* [PATCH] gcc: xtensa: fix fprintf format specifiers
@ 2017-05-29 11:12 Max Filippov
2017-05-29 16:15 ` augustine.sterling
0 siblings, 1 reply; 3+ messages in thread
From: Max Filippov @ 2017-05-29 11:12 UTC (permalink / raw)
To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov
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-28 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.
---
gcc/config/xtensa/xtensa.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 015dd10..df80ad9 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -1780,7 +1780,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
@@ -2351,14 +2352,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;
@@ -2372,7 +2373,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;
@@ -2437,7 +2438,7 @@ print_operand (FILE *file, rtx x, int letter)
else if (GET_CODE (x) == MEM)
output_address (GET_MODE (x), 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);
}
--
2.1.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gcc: xtensa: fix fprintf format specifiers
2017-05-29 11:12 [PATCH] gcc: xtensa: fix fprintf format specifiers Max Filippov
@ 2017-05-29 16:15 ` augustine.sterling
2017-05-30 0:09 ` Max Filippov
0 siblings, 1 reply; 3+ messages in thread
From: augustine.sterling @ 2017-05-29 16:15 UTC (permalink / raw)
To: Max Filippov; +Cc: gcc-patches, linux-xtensa
On Mon, May 29, 2017 at 4:11 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> 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.
This is ok.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gcc: xtensa: fix fprintf format specifiers
2017-05-29 16:15 ` augustine.sterling
@ 2017-05-30 0:09 ` Max Filippov
0 siblings, 0 replies; 3+ messages in thread
From: Max Filippov @ 2017-05-30 0:09 UTC (permalink / raw)
To: augustine.sterling; +Cc: gcc-patches, linux-xtensa
On Mon, May 29, 2017 at 9:08 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Mon, May 29, 2017 at 4:11 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> 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.
>
> This is ok.
Applied to trunk. Thank you!
-- Max
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-29 23:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-29 11:12 [PATCH] gcc: xtensa: fix fprintf format specifiers Max Filippov
2017-05-29 16:15 ` augustine.sterling
2017-05-30 0:09 ` Max Filippov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).