From 004048e5a7e365b2f6d9bb3640f4491c578d825f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 24 Feb 2024 22:01:20 +0100 Subject: [PATCH] fix IR codegen error for b=float>value --- .../codegen/intermediate/ExpressionGen.kt | 2 +- docs/source/todo.rst | 2 - examples/test.p8 | 44 +++++++------------ 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/codeGenIntermediate/src/prog8/codegen/intermediate/ExpressionGen.kt b/codeGenIntermediate/src/prog8/codegen/intermediate/ExpressionGen.kt index fd8c46456..9936d8bf9 100644 --- a/codeGenIntermediate/src/prog8/codegen/intermediate/ExpressionGen.kt +++ b/codeGenIntermediate/src/prog8/codegen/intermediate/ExpressionGen.kt @@ -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) { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 2b206cf91..971e6e46f 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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: diff --git a/examples/test.p8 b/examples/test.p8 index ac75470ac..24187108e 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -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()