MIPS floating point problem
Ken Faiczak
kfaiczak@pixstream.com
Mon Apr 19 08:17:00 GMT 1999
We are compiling our code for MIPS R5K -mips3
using -mfp32 (since the exception handling code for
some instructions that can't be handled in hardware
assumes fp32) - but otherwise its mips64 calling convention
Target is mips-vxworks-elf
Using builtin specs.
gcc version egcs-2.93.08 19990219 (gcc2 ss-980929 experimental)
-EL -mips3 -mcpu=r4000 -non_shared -G 0 -mfp32 -ansi -nostdinc -O2
-funroll-loops -fno-for-scope -fno-builtin -DMIPSEL -fsjlj-exceptions
The calling convention gets completely messed up
it looks like it is using the mips64 flag to generate the floating
point calls but fp32 in other places.
0000000000007f40 <testf1__Fv>:
7f40: 27bdffd0 addiu $sp,$sp,-48
7f44: f7b40028 sdc1 $f20,40($sp)
7f48: 3c010000 lui $at,0x0
7f4c: d4340f30 ldc1 $f20,3888($at)
7f50: ffbf0020 sd $ra,32($sp)
7f54: 4620a306 mov.d $f12,$f20
7f58: 0c001fe0 jal 7f80 <testf2__Fdd>
7f5c: 4620a346 mov.d $f13,$f20 -->
should be moved to $f14 (overwrites f12/f13)
(and with fp32 the SR_FR bit is clear and this
is illegal)
7f60: 4404a000 mfc1 $a0,$f20
7f64: 4405a800 mfc1 $a1,$f21
7f68: 0c001ff2 jal 7fc8 <testf3__Fde>
7f6c: 0080282d move $a1,$a0 --> should
fill in a2/a3 with other arg
this is overwriting part of the first arg
7f70: dfbf0020 ld $ra,32($sp)
7f74: d7b40028 ldc1 $f20,40($sp)
7f78: 03e00008 jr $ra
7f7c: 27bd0030 addiu $sp,$sp,48
0000000000007f80 <testf2__Fdd>:
7f80: 27bdffd0 addiu $sp,$sp,-48
7f84: 44056000 mfc1 $a1,$f12 -> first arg
pulled off ok (f12/f13)
7f88: 44066800 mfc1 $a2,$f13
7f8c: 3c040000 lui $a0,0x0
7f90: 64840f38 daddiu $a0,$a0,3896
7f94: f7b40028 sdc1 $f20,40($sp)
7f98: ffbf0020 sd $ra,32($sp)
7f9c: 0c000000 jal 0
<_pdbPCIEncInstanceAddNodes__FUiPCcN21>
7fa0: 46206d06 mov.d $f20,$f13 -> second
arg pulled off wrong (should be in f14/f15)
7fa4: 4405a000 mfc1 $a1,$f20
7fa8: 4406a800 mfc1 $a2,$f21
7fac: 3c040000 lui $a0,0x0
7fb0: 0c000000 jal 0
<_pdbPCIEncInstanceAddNodes__FUiPCcN21>
7fb4: 64840f48 daddiu $a0,$a0,3912
7fb8: dfbf0020 ld $ra,32($sp)
7fbc: d7b40028 ldc1 $f20,40($sp)
7fc0: 03e00008 jr $ra
7fc4: 27bd0030 addiu $sp,$sp,48
0000000000007fc8 <testf3__Fde>: --> other errors are
in this as well
7fc8: ffa50008 sd $a1,8($sp)
7fcc: ffa60010 sd $a2,16($sp)
7fd0: ffa70018 sd $a3,24($sp)
7fd4: 27bdffd0 addiu $sp,$sp,-48
7fd8: 27a2003f addiu $v0,$sp,63
7fdc: 2403fff8 li $v1,-8
7fe0: 00431024 and $v0,$v0,$v1
7fe4: ffbf0020 sd $ra,32($sp)
7fe8: f7b40028 sdc1 $f20,40($sp)
7fec: ffa40030 sd $a0,48($sp)
7ff0: d4540000 ldc1 $f20,0($v0)
7ff4: 44840000 mtc1 $a0,$f0
7ff8: 44850800 mtc1 $a1,$f1
7ffc: 00000000 nop
8000: 44050000 mfc1 $a1,$f0
8004: 44060800 mfc1 $a2,$f1
8008: 3c040000 lui $a0,0x0
800c: 0c000000 jal 0
<_pdbPCIEncInstanceAddNodes__FUiPCcN21>
8010: 64840f38 daddiu $a0,$a0,3896
8014: 4405a000 mfc1 $a1,$f20
8018: 4406a800 mfc1 $a2,$f21
801c: 3c040000 lui $a0,0x0
8020: 0c000000 jal 0
<_pdbPCIEncInstanceAddNodes__FUiPCcN21>
8024: 64840f48 daddiu $a0,$a0,3912
8028: dfbf0020 ld $ra,32($sp)
802c: d7b40028 ldc1 $f20,40($sp)
8030: 03e00008 jr $ra
8034: 27bd0030 addiu $sp,$sp,48
------------------------------------
void testf2(double d, double e);
void testf3(double d,...);
int testf1(void)
{
double d;
d = 99.88;
testf2(d,d);
testf3(d,d);
}
void testf2(double d, double e)
{
printf("testf2 d = %e\n", d);
printf("testf2 e = %e\n", e);
}
void testf3(double d,...)
{
va_list p;
double e;
va_start(p, d);
e = va_arg(p, double);
printf("testf2 d = %e\n", d);
printf("testf2 e = %e\n", e);
va_end(p);
}
_______________________________________________________________
Ken Faiczak PixStream Incorporated
ken@pixstream.com 180 Columbia St. West
(519) 884-4196 x2234 Waterloo Ontario, Canada
fax:(519) 884-5949 N2L 3L3
More information about the Gcc-bugs
mailing list