From: Peter Barada To: peter@the-baradas.com Cc: gcc@gcc.gnu.org Subject: Re: [m68k]: patch to fix m68k_output_mi_thunk() for ColdFire Date: Thu, 27 May 2004 09:57:03 -0400 (EDT) I've: 1) removed the cast to int for the %wd params in asm_printf. 2) Fixed the spelling in the comment. 3) Fixed the !MOTOROLA syntax for addl. GCC curently assumes in m68k_output_mi_thunk() that it can add a constant outside of the rang that addq/subq can handle to memory. This is legal for m68k, but not for ColdFire. This patch converts: add.l #-404,4(%sp) into: move.l #-404,%d0 add.l %d0,4(%sp) and: add.l #-16,4(%sp) into: moveq.l #-16,%d0 add.l %d0,4(%sp) -- Peter Barada peter@the-baradas.com gcc/ 2004-05-27 Peter Barada * config/m68k/m68k.c(m68k_output_mi_thunk): For ColdFire, use %d0 as a scratch to perform an add to memory. Index: gcc/config/m68k/m68k.c =================================================================== RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v retrieving revision 1.129 diff -c -3 -p -r1.129 m68k.c *** gcc-3.4/gcc/config/m68k/m68k.c 10 Mar 2004 05:07:45 -0000 1.129 --- gcc-3.4/gcc/config/m68k/m68k.c 27 May 2004 13:48:38 -0000 *************** m68k_output_mi_thunk (FILE *file, tree t *** 3371,3376 **** --- 3371,3393 ---- "\tsubq.l %I%d,4(%Rsp)\n" : "\tsubql %I%d,%Rsp@(4)\n", (int) -delta); + else if (TARGET_COLDFIRE) + { + /* ColdFire can't add/sub a constant to memory unless it is in + the range of addq/subq. So load the value into %d0 and + then add it to 4(%sp). */ + if (delta >= -128 && delta <= 127) + asm_fprintf (file, MOTOROLA ? + "\tmoveq.l %I%wd,%Rd0\n" : + "\tmoveql %I%wd,%Rd0\n", delta); + else + 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" :