This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] m68k/ColdFire, fix invalid code generation (BUG 8309)


Dear gcc gurus,

there is a bug that existed in gcc for target m68k/ColdFire since 2002:

http://gcc.gnu.org/ml/gcc/2004-05/msg01263.html
http://gcc.gnu.org/ml/gcc/2002-10/msg01441.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8309

In reload.c (find_reloads) for big endian systems a reload needs IMHO
to be forced not only for memory operands, but also for pseudo registers,
which reside in memory as well.

Can someone with deeper understanding of gcc verify that this
assumption is correct and does not break any other code?

The second patch solves another issue with invalid code being generated
for ColdFire. (ColdFire does not support add.l #<immediate>,<mem>)

Best regards,

Peter Jakubek
LaserAnimation Sollinger GmbH
peter@lasergraph-dsp.de


------------------------------------------------------------------------------- 2004-05-28 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-28  08:43:17.000000000 +0200
@@ -2963,7 +2963,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))

-------------------------------------------------------------------------------
2004-05-28  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-28 08:47:01.000000000 +0200
@@ -3371,7 +3371,17 @@
              "\tsubq.l %I%d,4(%Rsp)\n" :
              "\tsubql %I%d,%Rsp@(4)\n",
          (int) -delta);
-  else
+  else if (TARGET_COLDFIRE) {
+    /* ColdFire can't handle add.l #<no>,4(sp) */
+    /* d0 is 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",






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]