RFA: xscale-elf -mstrict-prototypes
James Lemke
jim@wasabisystems.com
Thu Feb 19 16:47:00 GMT 2004
Given this source (gcc/testsuite/arm-g4-1.c):
short int addhi3 (short int a, short int b) __attribute__ ((naked));
short int addhi3 (short int a, short int b)
{
return a + b + (short int)32;
}
The assembler generated (xscale-elf-gcc -O2 -S) is rather poor:
.file "arm-g4-1.c"
.text
.align 2
.global addhi3
.type addhi3, %function
addhi3:
@ Naked Function: prologue and epilogue provided by programmer.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
mov r1, r1, asl #16
mov r0, r0, asl #16
mov r1, r1, asr #16
add r1, r1, r0, asr #16
add r1, r1, #32
mov r1, r1, asl #16
mov r0, r1, asr #16
.size addhi3, .-addhi3
.ident "GCC: (GNU) 3.5.0 20040216 (experimental)"
This is because of argument widening even in the presence of a
prototype. The attached patch adds the option -mstrict-prototypes (off
by default) which suppresses the widening. So we get (xscale-elf-gcc
-O2 -mstrict-prototypes -S):
.file "arm-g4-1.c"
.text
.align 2
.global addhi3
.type addhi3, %function
addhi3:
@ Naked Function: prologue and epilogue provided by programmer.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
add r1, r0, r1
add r1, r1, #32
mov r1, r1, asl #16
mov r0, r1, asr #16
.size addhi3, .-addhi3
.ident "GCC: (GNU) 3.5.0 20040216 (experimental)"
make check-gcc shows no regressions.
Patch is attached.
OK to commit?
Jim.
--
James Lemke jim@wasabisystems.com Orillia, Ontario
http://www.wasabisystems.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: g4-20040218.patch
Type: text/x-patch
Size: 9515 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040219/8d9a02c9/attachment.bin>
More information about the Gcc-patches
mailing list