andy@CSVAX.CALTECH.EDU (Andy Fyfe) (01/27/89)
I saw someone posted diffs earlier but a later message from rms suggested
that they not be applied. To get a working compiler the following diffs
are at least required. In the case of the tm-3b1.h file, the diffs add in
two missing ';' and a '\' for continuation of the if statement in the macro.
Anyway, with those applied, the compiler gets switch statements wrong.
First the diffs I've applied:
diff -c save/m68k.md ./m68k.md
*** save/m68k.md Sat Dec 31 08:55:11 1988
--- ./m68k.md Sat Dec 31 14:58:04 1988
***************
*** 679,685 ****
--- 679,689 ----
"*
{
if (operands[1] == const0_rtx)
+ #ifdef MOTOROLA
+ return \"clr.l %0\";
+ #else
return \"clrl %0\";
+ #endif
return \"pea %a1\";
}")
diff -c save/tm-3b1.h ./tm-3b1.h
*** save/tm-3b1.h Sat Dec 31 08:56:25 1988
--- ./tm-3b1.h Sat Dec 31 15:16:43 1988
***************
*** 27,33 ****
#include "tm-hp9k320.h"
! /* See tm-m68k.h. 7 means 680[01]0 with no 68881. */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT 0
--- 27,33 ----
#include "tm-hp9k320.h"
! /* See tm-m68k.h. 0 means 680[01]0 with no 68881. */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT 0
***************
*** 347,357 ****
#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
if (RTX_INTEGRATED_P (TABLE)) \
fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n", \
! XVECLEN (PATTERN (TABLE), 1), (PREFIX), (NUM))
! else
fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n\tshort %s%%%d-%s%%%d\n", \
XVECLEN (PATTERN (TABLE), 1) + 1, (PREFIX), (NUM), \
! (PREFIX), (NUM), (PREFIX), (NUM))
/* At end of a switch table, define LD%n iff the symbol LI%n was defined. */
#define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
--- 347,357 ----
#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
if (RTX_INTEGRATED_P (TABLE)) \
fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n", \
! XVECLEN (PATTERN (TABLE), 1), (PREFIX), (NUM)); \
! else \
fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n\tshort %s%%%d-%s%%%d\n", \
XVECLEN (PATTERN (TABLE), 1) + 1, (PREFIX), (NUM), \
! (PREFIX), (NUM), (PREFIX), (NUM));
/* At end of a switch table, define LD%n iff the symbol LI%n was defined. */
#define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
And a typescript showing the problem:
$ cat test.c
foo(int x)
{
switch(x)
{
case 0:
return 5;
break;
case 1:
return 6;
break;
case 2:
return 4;
break;
case 3:
return 8;
break;
}
}
main()
{
printf("%d\n", foo(2));
}
$ gcc -S test.s
$ mv test.s test-31.s
$ gcc -o test-31 test-31.s
$ ./test-31
4
$ /usr/local/src/gcc/stage1/gcc -B/usr/local/src/gcc/stage1/ -S test.c
$ mv test.s test-32.s
$ gcc -o test-32 test-32.s
$ ./test-32
8
$ diff -c test-31.s test-32.s
*** test-31.s Thu Jan 26 23:44:56 1989
--- test-32.s Thu Jan 26 23:46:33 1989
***************
*** 13,21 ****
LI%7:
mov.w LD%7(%pc,%d0.w),%d0
jmp 6(%pc,%d0.w)
! swbeg &5
L%7:
- short L%7-L%7
short L%3-L%7
short L%4-L%7
short L%5-L%7
--- 13,20 ----
LI%7:
mov.w LD%7(%pc,%d0.w),%d0
jmp 6(%pc,%d0.w)
! swbeg &4
L%7:
short L%3-L%7
short L%4-L%7
short L%5-L%7
$ exit