diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt index 6062618f1..fd8d97893 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt @@ -240,11 +240,10 @@ internal class ExpressionsAsmGen(private val program: PtProgram, } private fun translateExpression(expr: PtBinaryExpression) { - // Uses evalstack to evaluate the given expression. - // TODO we're slowly reducing the number of places where this is called and instead replace that by more efficient assignment-form code (using temp var or register for instance). + // Uses evalstack to evaluate the given expression. THIS IS SLOW AND SHOULD BE AVOIDED! val leftDt = expr.left.type val rightDt = expr.right.type - // see if we can apply some optimized routines + // see if we can apply some optimized routines still when(expr.operator) { "+" -> { if(leftDt in IntegerDatatypes && rightDt in IntegerDatatypes) { @@ -567,7 +566,8 @@ internal class ExpressionsAsmGen(private val program: PtProgram, translateCompareStrings(expr.left, expr.operator, expr.right) } else { - // the general, non-optimized cases TODO optimize more cases.... (or one day just don't use the evalstack at all anymore) + // the general, non-optimized cases + // TODO optimize more cases.... (or one day just don't use the evalstack at all anymore) translateExpressionInternal(expr.left) translateExpressionInternal(expr.right) when (leftDt) { diff --git a/codeOptimizers/src/prog8/optimizer/ConstantFoldingOptimizer.kt b/codeOptimizers/src/prog8/optimizer/ConstantFoldingOptimizer.kt index e900d871a..3257697e9 100644 --- a/codeOptimizers/src/prog8/optimizer/ConstantFoldingOptimizer.kt +++ b/codeOptimizers/src/prog8/optimizer/ConstantFoldingOptimizer.kt @@ -388,9 +388,9 @@ class ConstantFoldingOptimizer(private val program: Program) : AstWalker() { subleftIsConst: Boolean, subrightIsConst: Boolean): IAstModification? { - // NOTE: THIS IS ONLY VALID ON FLOATING POINT CONSTANTS + // NOTE: THESE REORDERINGS ARE ONLY VALID FOR FLOATING POINT CONSTANTS + // TODO: this implements only a small set of possible reorderings at this time, we could perhaps add more - // TODO: this implements only a small set of possible reorderings at this time, we could think of more if(expr.operator==subExpr.operator) { // both operators are the same. diff --git a/codeOptimizers/src/prog8/optimizer/ExpressionSimplifier.kt b/codeOptimizers/src/prog8/optimizer/ExpressionSimplifier.kt index 674a94ff4..8430b9542 100644 --- a/codeOptimizers/src/prog8/optimizer/ExpressionSimplifier.kt +++ b/codeOptimizers/src/prog8/optimizer/ExpressionSimplifier.kt @@ -18,7 +18,7 @@ import kotlin.math.abs import kotlin.math.log2 import kotlin.math.pow -// TODO add more peephole expression optimizations? Investigate what optimizations binaryen has, also see https://egorbo.com/peephole-optimizations.html +// TODO add more peephole expression optimizations? Investigate what optimizations binaryen has class ExpressionSimplifier(private val program: Program, private val errors: IErrorReporter, diff --git a/compiler/src/prog8/compiler/astprocessing/AstOnetimeTransforms.kt b/compiler/src/prog8/compiler/astprocessing/AstOnetimeTransforms.kt index 75fb8256b..ae6f8d96f 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstOnetimeTransforms.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstOnetimeTransforms.kt @@ -31,7 +31,7 @@ internal class AstOnetimeTransforms(private val program: Program, private val op // note: The CodeDesugarer already does something similar, but that is meant ONLY to take // into account the case where the index value is a word type. // The replacement here is to fix missing cases in the 6502 codegen. - // TODO make the 6502 codegen better so this work around can be removed + // TODO make the 6502 codegen better so this workaround can be removed val arrayVar = arrayIndexedExpression.arrayvar.targetVarDecl(program) if(arrayVar!=null && arrayVar.datatype == DataType.UWORD) { if(parent is AssignTarget) { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 8e0499d74..55e940952 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,6 +3,16 @@ TODO For next minor release ^^^^^^^^^^^^^^^^^^^^^^ +- fix compiler crash on Virtual Textelite example +- add optimizations for integer X <= Y-1 ---> X= Y+1 ---> X>Y +- add optimizations for integer: + X >= 1 => X > 0 (signed and unsigned) + X < 1 => X <= 0 (signed) or X==0 (unsigned) + X <= -1 => X >= 0 (signed only) + X > -1 => X >= 0 (signed only) + +- TestSymbolTable: add some more tests + ... diff --git a/intermediate/src/prog8/intermediate/Utils.kt b/intermediate/src/prog8/intermediate/Utils.kt index fa572c694..e492845ee 100644 --- a/intermediate/src/prog8/intermediate/Utils.kt +++ b/intermediate/src/prog8/intermediate/Utils.kt @@ -166,8 +166,7 @@ fun parseIRCodeLine(line: String, location: Pair?, placeholder operands.clear() } if(operands.isNotEmpty()) { - TODO("huh even more operands? $operands rest=$rest'") - // operands.clear() + throw IRParseException("unexpected even more operands? $operands rest=$rest'") } } } diff --git a/virtualmachine/src/prog8/vm/VirtualMachine.kt b/virtualmachine/src/prog8/vm/VirtualMachine.kt index 17bf4e273..832b085dc 100644 --- a/virtualmachine/src/prog8/vm/VirtualMachine.kt +++ b/virtualmachine/src/prog8/vm/VirtualMachine.kt @@ -146,7 +146,7 @@ class VirtualMachine(irProgram: IRProgram) { pcChunk = target pcIndex = 0 } - null -> TODO("no branchtarget in $i (remove this check)") + null -> throw IllegalArgumentException("no branchtarget in $i") else -> throw IllegalArgumentException("VM can't execute code in a non-codechunk: $target") } }