Patch for specifier bug fixes in calls to asm_fprintf
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Thu May 22 18:15:00 GMT 2003
This patch fixes a bunch of bugs uncovered with my asm_fprintf
checking patch. It also fixes a couple of specifiers in regular
*printf calls that I noticed while testing.
Tested by cross-compiling cc1 to the following targets using a host
compiler with my asm_fprintf patch applied: arm-unknown-linux-gnu
m68k-unknown-linux-gnu and vax-unknown-elf.
Notes:
1. The first hunk was needed to apply the cast correctly when NBYTES
expands to "foo ? bar : baz". As originally written, it would
apply the cast to "foo", whereas it should apply it to the result
of the ?: expr. Hence the parens are necessary.
2. The m68k.c hunk removes a HOST_WIDE_INT_PRINT_DEC in favor of
%wd. Looking at asm_fprintf, I don't think it handles long long
specifiers (%ll). In any case, %wd is more readable without the
string concatenation. (I'll be upgrading asm_fprintf to handle
%ll and other stuff, but that's for later.)
The rest of the bits should be self-evident.
Ok for mainline?
Thanks,
--Kaveh
2003-05-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* arm/aout.h (ASM_OUTPUT_SKIP): Fix cast for format specifier warning.
* arm.c (arm_output_function_prologue): Fix format specifiers.
* arm.h (ARM_PRINT_OPERAND_ADDRESS): Likewise.
* m68k.c (m68k_output_mi_thunk): Use more readable %wd instead of
HOST_WIDE_INT_PRINT_DEC.
* vax.c (vax_output_function_prologue): Fix format specifiers.
* vax.h (ASM_GENERATE_INTERNAL_LABEL): Likewise.
diff -rup orig/egcc-CVS20030519/gcc/config/arm/aout.h egcc-CVS20030519/gcc/config/arm/aout.h
--- orig/egcc-CVS20030519/gcc/config/arm/aout.h 2003-05-12 20:01:47.000000000 -0400
+++ egcc-CVS20030519/gcc/config/arm/aout.h 2003-05-22 10:05:22.466481000 -0400
@@ -240,7 +240,7 @@
/* Output a gap. In fact we fill it with nulls. */
#undef ASM_OUTPUT_SKIP
#define ASM_OUTPUT_SKIP(STREAM, NBYTES) \
- fprintf (STREAM, "\t.space\t%d\n", (int)NBYTES)
+ fprintf (STREAM, "\t.space\t%d\n", (int)(NBYTES))
/* Align output to a power of two. Horrible /bin/as. */
#ifndef ASM_OUTPUT_ALIGN
diff -rup orig/egcc-CVS20030519/gcc/config/arm/arm.c egcc-CVS20030519/gcc/config/arm/arm.c
--- orig/egcc-CVS20030519/gcc/config/arm/arm.c 2003-05-16 14:53:58.000000000 -0400
+++ egcc-CVS20030519/gcc/config/arm/arm.c 2003-05-22 10:03:13.948271000 -0400
@@ -8412,7 +8412,7 @@ arm_output_function_prologue (f, frame_s
if (IS_NESTED (func_type))
asm_fprintf (f, "\t%@ Nested: function declared inside another function.\n");
- asm_fprintf (f, "\t%@ args = %d, pretend = %d, frame = %d\n",
+ asm_fprintf (f, "\t%@ args = %d, pretend = %d, frame = %wd\n",
current_function_args_size,
current_function_pretend_args_size, frame_size);
diff -rup orig/egcc-CVS20030519/gcc/config/arm/arm.h egcc-CVS20030519/gcc/config/arm/arm.h
--- orig/egcc-CVS20030519/gcc/config/arm/arm.h 2003-05-15 20:01:23.000000000 -0400
+++ egcc-CVS20030519/gcc/config/arm/arm.h 2003-05-22 10:01:37.927163000 -0400
@@ -2377,7 +2377,7 @@ extern int making_const_table;
offset = INTVAL (index); \
if (is_minus) \
offset = -offset; \
- asm_fprintf (STREAM, "[%r, #%d]", \
+ asm_fprintf (STREAM, "[%r, #%wd]", \
REGNO (base), offset); \
break; \
\
@@ -2428,7 +2428,7 @@ extern int making_const_table;
{ \
asm_fprintf (STREAM, "[%r, ", REGNO (XEXP (X, 0))); \
if (GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT) \
- asm_fprintf (STREAM, "#%d]!", \
+ asm_fprintf (STREAM, "#%wd]!", \
INTVAL (XEXP (XEXP (X, 1), 1))); \
else \
asm_fprintf (STREAM, "%r]!", \
@@ -2438,7 +2438,7 @@ extern int making_const_table;
{ \
asm_fprintf (STREAM, "[%r], ", REGNO (XEXP (X, 0))); \
if (GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT) \
- asm_fprintf (STREAM, "#%d", \
+ asm_fprintf (STREAM, "#%wd", \
INTVAL (XEXP (XEXP (X, 1), 1))); \
else \
asm_fprintf (STREAM, "%r", \
diff -rup orig/egcc-CVS20030519/gcc/config/m68k/m68k.c egcc-CVS20030519/gcc/config/m68k/m68k.c
--- orig/egcc-CVS20030519/gcc/config/m68k/m68k.c 2003-05-17 18:09:09.000000000 -0400
+++ egcc-CVS20030519/gcc/config/m68k/m68k.c 2003-05-22 10:26:18.552557000 -0400
@@ -3689,8 +3689,7 @@ m68k_output_mi_thunk (file, thunk, delta
else if (delta < 0 && delta >= -8)
asm_fprintf (file, "\tsubq.l %I%d,4(%Rsp)\n", (int) -delta);
else
- asm_fprintf (file, "\tadd.l %I" HOST_WIDE_INT_PRINT_DEC ",4(%Rsp)\n",
- delta);
+ asm_fprintf (file, "\tadd.l %I%wd,4(%Rsp)\n", delta);
xops[0] = DECL_RTL (function);
diff -rup orig/egcc-CVS20030519/gcc/config/vax/vax.c egcc-CVS20030519/gcc/config/vax/vax.c
--- orig/egcc-CVS20030519/gcc/config/vax/vax.c 2003-05-16 14:54:00.000000000 -0400
+++ egcc-CVS20030519/gcc/config/vax/vax.c 2003-05-22 10:46:05.971329000 -0400
@@ -121,9 +121,9 @@ vax_output_function_prologue (file, size
size -= STARTING_FRAME_OFFSET;
if (size >= 64)
- asm_fprintf (file, "\tmovab %d(%Rsp),%Rsp\n", -size);
+ asm_fprintf (file, "\tmovab %wd(%Rsp),%Rsp\n", -size);
else if (size)
- asm_fprintf (file, "\tsubl2 $%d,%Rsp\n", size);
+ asm_fprintf (file, "\tsubl2 $%wd,%Rsp\n", size);
}
/* This is like nonimmediate_operand with a restriction on the type of MEM. */
diff -rup orig/egcc-CVS20030519/gcc/config/vax/vax.h egcc-CVS20030519/gcc/config/vax/vax.h
--- orig/egcc-CVS20030519/gcc/config/vax/vax.h 2003-05-12 20:02:33.000000000 -0400
+++ egcc-CVS20030519/gcc/config/vax/vax.h 2003-05-22 10:45:01.097202000 -0400
@@ -1019,7 +1019,7 @@ enum reg_class { NO_REGS, ALL_REGS, LIM_
This is suitable for output with `assemble_name'. */
#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf (LABEL, "*%s%d", PREFIX, NUM)
+ sprintf (LABEL, "*%s%lu", PREFIX, (long)(NUM))
/* This is how to output an insn to push a register on the stack.
It need not be very fast code. */
More information about the Gcc-patches
mailing list