gcc 3.4.0 m68k-elf generates illegal code for ColdFire (maybe a fix)
peter@lasergraph-dsp.de
peter@lasergraph-dsp.de
Thu May 27 14:18:00 GMT 2004
Dear gcc gurus,
since no one wants to handle the old illegal code generation issue (it
seems
it existed since 2002), I tried to find it myself. I might have found it:
In reload.c (find_reloads) a force reload needs IMHO to be forced not
only
for memory operands, but also for pseudo registers, which also reside in
memory.
Can someone with deeper understanding of gcc verify that this assumption
is
correct and does not break any other code?
Here is a patch:
-------------------------------------------------------------------------------
2004-05-27 Peter Jakubek <peter@laseranimation.com>
* reload.c (find_reloads): force reload for pseudo registers on big
endian machines.
diff -ru gcc.orig/gcc/reload.c gcc/gcc/reload.c
--- gcc.orig/gcc/reload.c 2004-03-10 02:51:01.000000000 +0100
+++ gcc/gcc/reload.c 2004-05-27 13:07:32.828125000 +0200
@@ -2947,7 +2947,7 @@
< BIGGEST_ALIGNMENT)
&& (GET_MODE_SIZE (operand_mode[i])
> GET_MODE_SIZE (GET_MODE (operand))))
- || (GET_CODE (operand) == MEM && BYTES_BIG_ENDIAN)
+ || (BYTES_BIG_ENDIAN)
#ifdef LOAD_EXTEND_OP
|| (GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
&& (GET_MODE_SIZE (GET_MODE (operand))
-------------------------------------------------------------------------------
I also added my original patch for m68k_output_mi_thunk to fix the invalid
code
that was genrated on ColdFire for thunks:
2004-05-27 Peter Jakubek <peter@laseranimation.com>
* config/m68k/m68k.c (m68k_output_mi_thunk): correct code generated
for
ColdFire.
diff -ru gcc.orig/gcc/config/m68k/m68k.c gcc/gcc/config/m68k/m68k.c
--- gcc.orig/gcc/config/m68k/m68k.c 2004-03-10 06:07:14.000000000
+0100
+++ gcc/gcc/config/m68k/m68k.c 2004-05-23 10:14:05.885235200 +0200
@@ -3462,7 +3464,17 @@
"\tsubq.l %I%d,4(%Rsp)\n" :
"\tsubql %I%d,%Rsp@(4)\n",
(int) -delta);
- else
+ else if (TARGET_COLDFIRE) {
+ /* PETERPATCH: ColdFire can't handle add.l #<no>,4(sp) */
+ /* d0 should be scratch, so we use this */
+ asm_fprintf (file, MOTOROLA ?
+ "\tmove.l %I%wd,%Rd0\n" :
+ "\tmovel %I%wd,%Rd0\n",
+ delta);
+ asm_fprintf (file, MOTOROLA ?
+ "\tadd.l %Rd0,4(%Rsp)\n" :
+ "\taddl %Rd0,%Rsp@(4)\n");
+ } else
asm_fprintf (file, MOTOROLA ?
"\tadd.l %I%wd,4(%Rsp)\n" :
"\taddl %I%wd,%Rsp@(4)\n",
Best regards,
Peter Jakubek
LaserAnimation Sollinger GmbH
peter@lasergraph-dsp.de
More information about the Gcc
mailing list