Error: Code generation for cpu32 (m68k)
Volker Bosch
bosch@iema.uni-stuttgart.de
Mon Jul 19 23:36:00 GMT 1999
Hello,
there seems to be an error in code generation for CPU32 (m68k) Targets in
the last recend snappshot of egcs (egcs-19990718). The error occures when
splitting the addition or substraction of an integer constant, greater then
8 nad equal or less then 16, into two addq or subq instructions.
The error occures not very often -- I first recognized it compiling
RTEMS 3.6.0 for a cpu32 target (the whole newlib compiles without
that error). I've located the error in the file
egcs-19990718/gcc/config/m68k/m68k.c
Here is the invalid assembler output (-mcpu32):
[...]
rtems_monitor_command_usage:
.stabn 68,0,145,.LM1-rtems_monitor_command_usage
.LM1:
subq.w #8,%sp
subq.w #12,%sp
movm.l #0x3c30,-(%sp)
move.l 40(%sp),%a3
move.l 44(%sp),%d0
[...]
.stabn 68,0,164,.LM34-rtems_monitor_command_usage
.LM34:
.LBE2:
movm.l (%sp)+,#0xc3c
addq.w #8,%sp
addq.w #12,%sp
rts
The same c file compiled for a plain 68000 (-m68000) produces:
[...]
rtems_monitor_command_usage:
.stabn 68,0,145,.LM1-rtems_monitor_command_usage
.LM1:
lea (-12,%sp),%sp
movm.l #0x3c30,-(%sp)
move.l 40(%sp),%a3
move.l 44(%sp),%d0
[...]
.stabn 68,0,164,.LM34-rtems_monitor_command_usage
.LM34:
.LBE2:
movm.l (%sp)+,#0xc3c
lea (12,%sp),%sp
rts
Here is the diff file (generated by: diff -cp gcc/config/m68k/m68k.c
gcc/config/m68k/m68k.c.original). Please notice that I've applied a patch
for generating interrupt service routines to m68k.c, so the line
numbers are different from the original m68k.c file but the context diff
should allow you to locate the correct code position.
------------------8<----------------------------->8--------------------------
*** gcc/config/m68k/m68k.c Mon Jul 19 20:50:47 1999
--- gcc/config/m68k/m68k.c.original Mon Jul 19 20:49:57 1999
*************** output_function_prologue (stream, size)
*** 243,252 ****
/* asm_fprintf() cannot handle %. */
#ifdef MOTOROLA
asm_fprintf (stream, "\tsubq.w %0I8,%Rsp\n\tsubq.w %0I%d,%Rsp\n",
! fsize - 4);
#else
asm_fprintf (stream, "\tsubqw %0I8,%Rsp\n\tsubqw %0I%d,%Rsp\n",
! fsize - 4);
#endif
}
else
--- 243,252 ----
/* asm_fprintf() cannot handle %. */
#ifdef MOTOROLA
asm_fprintf (stream, "\tsubq.w %0I8,%Rsp\n\tsubq.w %0I%d,%Rsp\n",
! fsize + 4);
#else
asm_fprintf (stream, "\tsubqw %0I8,%Rsp\n\tsubqw %0I%d,%Rsp\n",
! fsize + 4);
#endif
}
else
*************** output_function_epilogue (stream, size)
*** 793,802 ****
/* asm_fprintf() cannot handle %. */
#ifdef MOTOROLA
asm_fprintf (stream, "\taddq.w %0I8,%Rsp\n\taddq.w %0I%d,%Rsp\n",
! fsize - 4);
#else
asm_fprintf (stream, "\taddqw %0I8,%Rsp\n\taddqw %0I%d,%Rsp\n",
! fsize - 4);
#endif
}
else
--- 793,802 ----
/* asm_fprintf() cannot handle %. */
#ifdef MOTOROLA
asm_fprintf (stream, "\taddq.w %0I8,%Rsp\n\taddq.w %0I%d,%Rsp\n",
! fsize + 4);
#else
asm_fprintf (stream, "\taddqw %0I8,%Rsp\n\taddqw %0I%d,%Rsp\n",
! fsize + 4);
#endif
}
else
---------------------8<---------------------------->8------------------------
* * * * * * * * * *
Gruss == bosch@iema.uni-stuttgart.de
& tschuess == V. Bosch, IEMA, Pfaffenwaldring 47, D-70569 Stuttgart
Volker == +49 (0)711 685-7817, (Fax: +49 (0)711 685-7837)
More information about the Gcc-bugs
mailing list