Add hacky 64-bit comparisons (used by M2).

This commit is contained in:
David Given 2018-09-17 12:16:17 +01:00
parent 15ae171aef
commit 0b65591972
2 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,39 @@
#
.sect .text; .sect .rom; .sect .data; .sect .bss
/*
* 64-big unsigned tristate comparison.
* Inputs:
* r2r3: left
* r4r5: right
* Outputs;
* r2: result
*/
.sect .text
.define .compareul
.compareul:
/* Compare high words. */
sltu at, r3, r5 ! if r3<r5, then 1
subu at, zero, at ! if r3<r5, then -1
bne at, zero, exit
nop
sltu at, r5, r3 ! if r3>r5, then 1
bne at, zero, exit
nop
/* High words are equal --- compare low words. */
sltu at, r2, r4 ! if r2<r4, then 1
subu at, zero, at ! if r2<r4, then -1
bne at, zero, exit
nop
sltu at, r4, r2 ! if r2>r4, then 1
exit:
mov r2, at
jr ra
nop

View file

@ -35,7 +35,7 @@ REGISTERS
r22 named("r22") int; r22 named("r22") int;
r23 named("r23") int; r23 named("r23") int;
r4r5 named("r4", "r5") aliases(r4, r5) long volatile; r4r5 named("r4", "r5") aliases(r4, r5) long volatilei lret1;
r6r7 named("r6", "r7") aliases(r6, r7) long volatile; r6r7 named("r6", "r7") aliases(r6, r7) long volatile;
r8r9 named("r8", "r9") aliases(r8, r9) long volatile; r8r9 named("r8", "r9") aliases(r8, r9) long volatile;
r10r11 named("r10", "r11") aliases(r10, r11) long volatile; r10r11 named("r10", "r11") aliases(r10, r11) long volatile;
@ -490,6 +490,11 @@ PATTERNS
emit "1:" emit "1:"
cost 20; cost 20;
out:(iret)reg = COMPAREUL.I(left:(lret)reg, right:(lret1)reg)
emit "jal .compareul"
emit "nop"
cost 30;
out:(int)reg = COMPAREF.I(left:(float)reg, right:(float)reg) out:(int)reg = COMPAREF.I(left:(float)reg, right:(float)reg)
with preserved(%left), preserved(%right) with preserved(%left), preserved(%right)
emit "c.lt.s 0, %left, %right" emit "c.lt.s 0, %left, %right"