Rework floating point conversion. Bash enough of the table into workingness
that the libraries build now.
This commit is contained in:
parent
d2c14ca44f
commit
379c1a4a3c
|
@ -6,8 +6,8 @@
|
|||
|
||||
.data
|
||||
|
||||
.define .fromud
|
||||
.fromud:
|
||||
.define .c_ud_i
|
||||
.c_ud_i:
|
||||
/* Input: f0
|
||||
* Output: r2
|
||||
* Only at and f31 may be used.
|
||||
|
@ -30,8 +30,3 @@ toobig:
|
|||
addiu r2, r2, 0x8000
|
||||
jr ra
|
||||
nop
|
||||
|
||||
sect .rom
|
||||
.fd_80000000:
|
||||
!float 2.147483648e+9 sz 8
|
||||
.data4 0x41e00000, 0
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
.data
|
||||
|
||||
.define .fromuf
|
||||
.fromuf:
|
||||
.define .c_uf_i
|
||||
.c_uf_i:
|
||||
/* Input: f0
|
||||
* Output: r2
|
||||
* Only at and f31 may be used.
|
||||
|
@ -31,7 +31,3 @@ toobig:
|
|||
jr ra
|
||||
nop
|
||||
|
||||
sect .rom
|
||||
.fd_80000000:
|
||||
!float 2.147483648e+9 sz 4
|
||||
.data4 0x4f000000, 0
|
11
mach/mips/libem/fd_80000000.s
Normal file
11
mach/mips/libem/fd_80000000.s
Normal file
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
.sect .text; .sect .rom; .sect .data; .sect .bss
|
||||
|
||||
.sect .rom
|
||||
|
||||
/* 2147483648 as a double; used as a pivot for double->unsigned and unsigned->double. */
|
||||
|
||||
.define .fd_80000000
|
||||
.fd_80000000:
|
||||
.data4 0x41e00000, 0
|
||||
|
11
mach/mips/libem/ff_80000000.s
Normal file
11
mach/mips/libem/ff_80000000.s
Normal file
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
.sect .text; .sect .rom; .sect .data; .sect .bss
|
||||
|
||||
.sect .rom
|
||||
|
||||
/* 2147483648 as a float; used as a pivot for double->float and unsigned->float. */
|
||||
|
||||
.define .ff_80000000
|
||||
.ff_80000000:
|
||||
.data4 0x4f000000
|
||||
|
|
@ -269,7 +269,7 @@ struct hop* platform_move(struct basicblock* bb, struct vreg* vreg, struct hreg*
|
|||
break;
|
||||
|
||||
case burm_float_ATTR:
|
||||
hop_add_insel(hop, "mov.f %H, %H", dest, src);
|
||||
hop_add_insel(hop, "mov.s %H, %H", dest, src);
|
||||
break;
|
||||
|
||||
case burm_double_ATTR:
|
||||
|
@ -320,9 +320,9 @@ struct hop* platform_swap(struct basicblock* bb, struct hreg* src, struct hreg*
|
|||
break;
|
||||
|
||||
case burm_float_ATTR:
|
||||
hop_add_insel(hop, "mov.f f31, %H", src);
|
||||
hop_add_insel(hop, "mov.f %H, %H", src, dest);
|
||||
hop_add_insel(hop, "mov.f %H, f31", dest);
|
||||
hop_add_insel(hop, "mov.s f31, %H", src);
|
||||
hop_add_insel(hop, "mov.s %H, %H", src, dest);
|
||||
hop_add_insel(hop, "mov.s %H, f31", dest);
|
||||
break;
|
||||
|
||||
case burm_double_ATTR:
|
||||
|
|
|
@ -504,13 +504,26 @@ PATTERNS
|
|||
emit "1:"
|
||||
cost 20;
|
||||
|
||||
out:(int)reg = COMPAREF.I(left:(float)reg, right:(float)reg)
|
||||
emit "c.lt.s 0, %left, %right"
|
||||
emit "li %out, -1"
|
||||
emit "bc1t 0, 1f"
|
||||
emit "nop"
|
||||
emit "c.lt.s 0, %right, %left"
|
||||
emit "li %out, 1"
|
||||
emit "movf %out, zero, 0"
|
||||
emit "1:"
|
||||
cost 28;
|
||||
|
||||
out:(int)reg = COMPARED.I(left:(double)reg, right:(double)reg)
|
||||
emit "c.lt.d 0, %left, %right"
|
||||
emit "li %out, -1"
|
||||
emit "bc1t 0, 1f"
|
||||
emit "li %out, -1" /* delay slot */
|
||||
emit "nop"
|
||||
emit "c.lt.d 0, %right, %left"
|
||||
emit "li %out, 1"
|
||||
emit "movf %out, zero, 0"
|
||||
emit "1:"
|
||||
cost 28;
|
||||
|
||||
/* Booleans */
|
||||
|
@ -527,7 +540,7 @@ PATTERNS
|
|||
|
||||
/* If 1 or 0 then 1, else 0 */
|
||||
out:(int)reg = IFLE.I(in:(int)reg)
|
||||
emit "slt %out, %in, 1"
|
||||
emit "slti %out, %in, 1"
|
||||
cost 4;
|
||||
|
||||
|
||||
|
@ -676,14 +689,24 @@ PATTERNS
|
|||
emit "cvt.d.w %out, %out"
|
||||
cost 4;
|
||||
|
||||
out:(dret)reg = FROMUI.D(in:(iret)reg)
|
||||
emit "jal .c_ui_d"
|
||||
emit "nop"
|
||||
cost 30;
|
||||
|
||||
out:(int)reg = FROMSD.I(in:(double)reg)
|
||||
emit "trunc.w.d f31, %in"
|
||||
emit "mfc1 %out, f31"
|
||||
cost 8;
|
||||
|
||||
out:(lret)reg = FROMSD.L(in:(dret)reg)
|
||||
emit "jal .c_sd_l"
|
||||
emit "nop"
|
||||
cost 30;
|
||||
|
||||
out:(iret)reg = FROMUD.I(in:(dret)reg)
|
||||
with corrupted(dret)
|
||||
emit "jal .fromud"
|
||||
emit "jal .c_ud_i"
|
||||
emit "nop"
|
||||
cost 30;
|
||||
|
||||
|
@ -716,7 +739,7 @@ PATTERNS
|
|||
cost 4;
|
||||
|
||||
out:(float)reg = NEGF.F(left:(float)reg)
|
||||
emit "neg.f %out, %left"
|
||||
emit "neg.s %out, %left"
|
||||
cost 4;
|
||||
|
||||
out:(float)reg = FROMSI.F(in:(int)reg)
|
||||
|
@ -729,19 +752,34 @@ PATTERNS
|
|||
emit "mfc1 %out, f31"
|
||||
cost 8;
|
||||
|
||||
out:(iret)reg = FROMUD.I(in:(fret)reg)
|
||||
out:(lret)reg = FROMSF.L(in:(fret)reg)
|
||||
emit "jal .c_sf_l"
|
||||
emit "nop"
|
||||
cost 30;
|
||||
|
||||
out:(fret)reg = FROMUI.F(in:(iret)reg)
|
||||
emit "jal .c_ui_f"
|
||||
emit "nop"
|
||||
cost 30;
|
||||
|
||||
out:(iret)reg = FROMUF.I(in:(fret)reg)
|
||||
with corrupted(fret)
|
||||
emit "jal .fromuf"
|
||||
emit "jal .c_uf_i"
|
||||
emit "nop"
|
||||
cost 30;
|
||||
|
||||
out:(float)reg = COPYI.F(in:(int)reg)
|
||||
emit "mtc1 %in, %out" /* mtc1 has reversed parameters */
|
||||
cost 8;
|
||||
cost 4;
|
||||
|
||||
out:(int)reg = COPYF.I(in:(float)reg)
|
||||
emit "mfc1 %out, %in"
|
||||
cost 8;
|
||||
cost 4;
|
||||
|
||||
out:(float)reg = value:CONST.F
|
||||
when specific_constant(%value, 0)
|
||||
emit "mtc1 zero, %out" /* mtc1 has reversed parameters */
|
||||
cost 4;
|
||||
|
||||
/* vim: set sw=4 ts=4 expandtab : */
|
||||
|
||||
|
|
Loading…
Reference in a new issue