bug-report: egcs-1.1.1 m68k-coff-gcc (coldfire)
Rolf Fiedler
Rolf.Fiedler@ferrari.de
Thu Jan 21 01:58:00 GMT 1999
Hi there,
this is probably the wrong list to send this bug report to, but I
thought
somebody on this list will know what to do with it.
----------------------------------------------------------
the following piece of code causes egcs gcc to emit illegal coldfire
instructions:
#define IO_BASE 0x10000000
typedef unsigned char BYTE;
/* page 1, read */
#define RTL_PAR0 (*(volatile unsigned char *)(IO_BASE + 0x00002301))
#define RTL_PAR1 (*(volatile unsigned char *)(IO_BASE + 0x00002302))
#define RTL_PAR2 (*(volatile unsigned char *)(IO_BASE + 0x00002303))
#define RTL_PAR3 (*(volatile unsigned char *)(IO_BASE + 0x00002304))
#define RTL_PAR4 (*(volatile unsigned char *)(IO_BASE + 0x00002305))
#define RTL_PAR5 (*(volatile unsigned char *)(IO_BASE + 0x00002306))
/* Get the actual MAC address out of the Ethernet chip */
long long EthGetMAC(void) {
long long temp;
EthSetPage(1);
temp = RTL_PAR0;
temp |= (long long)RTL_PAR1 << 8;
temp |= (long long)RTL_PAR2 << 16;
temp |= (long long)RTL_PAR3 << 24;
temp |= (long long)RTL_PAR4 << 32;
temp |= (long long)RTL_PAR5 << 40;
return temp;
}
the compilation shows the following results:
rfie@pontifex:/home/rfie > m68k-coff-gcc --version
egcs-2.91.60
rfie@pontifex:/home/rfie > m68k-coff-gcc -m5200 -c -o short.o short.c
/tmp/ccMS4tFx.s: Assembler messages:
/tmp/ccMS4tFx.s:26: Error: invalid instruction for this architecture;
needs 68000 or higher -- statement `rol.l #8,%d3' ignored
/tmp/ccMS4tFx.s:27: Error: invalid instruction for this architecture;
needs 68000 or higher -- statement `rol.l #8,%d2' ignored
rotate is indeed not a valid instruction for coldfires, which is sad.
the assembly output (generated by gcc -S):
.file "short.c"
gcc2_compiled.:
__gnu_compiled_c:
.text
.even
.globl EthGetMAC
EthGetMAC:
link.w %a6,#-8
lea (-24,%sp),%sp
movm.l #0xfc,(%sp)
pea 1.w
jsr EthSetPage
addq.l #4,%sp
move.b 268444417,%d0
moveq #0,%d6
moveq #0,%d7
move.b %d0,%d7
move.l %d6,-8(%a6)
move.l %d7,-4(%a6)
move.b 268444418,%d0
moveq #0,%d4
moveq #0,%d5
move.b %d0,%d5
move.l %d4,%d2
move.l %d5,%d3
rol.l #8,%d3 <- this is ok for 68000, but not for
coldfire
rol.l #8,%d2
move.b %d3,%d2
clr.b %d3
move.l -8(%a6),%d0
or.l %d2,%d0
move.l -4(%a6),%d1
or.l %d3,%d1
move.l %d0,-8(%a6)
move.l %d1,-4(%a6)
move.b 268444419,%d0
moveq #0,%d4
moveq #0,%d5
move.b %d0,%d5
move.l %d4,%d2
move.l %d5,%d3
swap %d3
swap %d2
move.w %d3,%d2
clr.w %d3
move.l -8(%a6),%d0
or.l %d2,%d0
move.l -4(%a6),%d1
or.l %d3,%d1
move.l %d0,-8(%a6)
move.l %d1,-4(%a6)
move.b 268444420,%d0
moveq #0,%d2
moveq #0,%d3
move.b %d0,%d3
move.l %d3,%d4
lsr.l #8,%d4
move.l %d2,%d5
moveq.l #24,%d7
lsl.l %d7,%d5
move.l %d4,%d0
or.l %d5,%d0
move.l %d3,%d1
moveq.l #24,%d6
lsl.l %d6,%d1
move.l -8(%a6),%d2
or.l %d0,%d2
move.l -4(%a6),%d3
or.l %d1,%d3
move.l %d2,-8(%a6)
move.l %d3,-4(%a6)
move.b 268444421,%d0
moveq #0,%d4
moveq #0,%d5
move.b %d0,%d5
move.l %d5,%d2
clr.l %d3
move.l -8(%a6),%d0
or.l %d2,%d0
move.l -4(%a6),%d1
or.l %d3,%d1
move.l %d0,-8(%a6)
move.l %d1,-4(%a6)
move.b 268444422,%d0
moveq #0,%d4
moveq #0,%d5
move.b %d0,%d5
move.l %d4,%d2
move.l %d5,%d3
asl.l #8,%d3
mov.l %d3,%d2
moveq #0,%d3
move.l -8(%a6),%d0
or.l %d2,%d0
move.l -4(%a6),%d1
or.l %d3,%d1
move.l %d0,-8(%a6)
move.l %d1,-4(%a6)
move.l -8(%a6),%d2
move.l -4(%a6),%d3
move.l %d2,%d0
move.l %d3,%d1
jbra .L1
.even
.L1:
move.l -32(%a6),%d2
move.l -28(%a6),%d3
move.l -24(%a6),%d4
move.l -20(%a6),%d5
move.l -16(%a6),%d6
move.l -12(%a6),%d7
unlk %a6
rts
changing the C source fixed that for now, but a compiler bug is a
compiler bug...
I hope anyone with compiler back-end experience can have a look at this.
I would
be happy to test any patches.
PS: egcs is better than gcc-2.8.1 for coldfire but still not perfect.
PPS: why not use:
.L1:
movml (%sp),%d2-%d7
unlk %a6
rts
for popping registers off the stack? Should be faster...
Kind regards,
Rolf
+-----------------+--------------------------------------------------+
| _____ | Rolf Fiedler |
| / ___/ | Electronic Design Engineer |
| / _/ | Ferrari electronic AG |
| /_/e/r/r/a/r/i/ | phone: +49 3328 4559 0 fax: +49 3328 4559 60 |
| electronic | E-Mail: Rolf.Fiedler@Ferrari.DE |
+-----------------+--------------------------------------------------+
"Where do you want to go tomorrow?"
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.
More information about the crossgcc
mailing list