fix IR codegen error for b=float>value

This commit is contained in:
Irmen de Jong 2024-02-24 22:01:20 +01:00
parent b941d6f1e4
commit 004048e5a7
3 changed files with 16 additions and 32 deletions

View File

@ -595,7 +595,7 @@ internal class ExpressionGen(private val codeGen: IRCodeGen) {
} else {
if (greaterEquals) Opcode.SGE else Opcode.SGT
}
addInstr(result, IRInstruction(ins, vmDt, reg1=cmpResultReg, reg2 = resultRegister, reg3 = zeroRegister), null)
addInstr(result, IRInstruction(ins, IRDataType.BYTE, reg1=cmpResultReg, reg2 = resultRegister, reg3 = zeroRegister), null)
return ExpressionCodeResult(result, IRDataType.BYTE, cmpResultReg, -1)
} else {
if(binExpr.left.type==DataType.STR || binExpr.right.type==DataType.STR) {

View File

@ -1,8 +1,6 @@
TODO
====
fix IR codegen error: type FLOAT invalid for SGTS
add tests for comparison that do an assignment rather than an if.
fix ifelse codegens:

View File

@ -6,41 +6,27 @@
main {
sub start() {
cx16.r0 = $2200
float @shared fl = 1123.56
bool @shared bb
if fl as bool
bb=fl<12345.6
cx16.r0L++
bb=fl<=12345.6
cx16.r0L++
bb=fl>12345.6
cx16.r0L++
bb=fl>=12345.6
cx16.r0L++
if bb
txt.print("yep ")
else
txt.print("nope ")
bb=fl>12345.6
if bb
txt.print("yep ")
else
txt.print("nope ")
bool @shared qq = fl as bool
if qq
txt.print("yep ")
else
txt.print("nope ")
if cx16.r0 as bool
txt.print("yep ")
else
txt.print("nope ")
qq = cx16.r0 as bool
if qq
txt.print("yep ")
else
txt.print("nope ")
if cx16.r0s as bool
txt.print("yep ")
else
txt.print("nope ")
qq = cx16.r0s as bool
if qq
txt.print("yep ")
else
txt.print("nope ")
; test_stack.test()
; broken_word_gt()