mirror of
https://github.com/irmen/prog8.git
synced 2024-11-20 03:32:05 +00:00
todos
This commit is contained in:
parent
b3b380964c
commit
fd269453a4
@ -240,11 +240,10 @@ internal class ExpressionsAsmGen(private val program: PtProgram,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun translateExpression(expr: PtBinaryExpression) {
|
private fun translateExpression(expr: PtBinaryExpression) {
|
||||||
// Uses evalstack to evaluate the given expression.
|
// Uses evalstack to evaluate the given expression. THIS IS SLOW AND SHOULD BE AVOIDED!
|
||||||
// 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).
|
|
||||||
val leftDt = expr.left.type
|
val leftDt = expr.left.type
|
||||||
val rightDt = expr.right.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) {
|
when(expr.operator) {
|
||||||
"+" -> {
|
"+" -> {
|
||||||
if(leftDt in IntegerDatatypes && rightDt in IntegerDatatypes) {
|
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)
|
translateCompareStrings(expr.left, expr.operator, expr.right)
|
||||||
}
|
}
|
||||||
else {
|
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.left)
|
||||||
translateExpressionInternal(expr.right)
|
translateExpressionInternal(expr.right)
|
||||||
when (leftDt) {
|
when (leftDt) {
|
||||||
|
@ -388,9 +388,9 @@ class ConstantFoldingOptimizer(private val program: Program) : AstWalker() {
|
|||||||
subleftIsConst: Boolean,
|
subleftIsConst: Boolean,
|
||||||
subrightIsConst: Boolean): IAstModification?
|
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) {
|
if(expr.operator==subExpr.operator) {
|
||||||
// both operators are the same.
|
// both operators are the same.
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import kotlin.math.abs
|
|||||||
import kotlin.math.log2
|
import kotlin.math.log2
|
||||||
import kotlin.math.pow
|
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,
|
class ExpressionSimplifier(private val program: Program,
|
||||||
private val errors: IErrorReporter,
|
private val errors: IErrorReporter,
|
||||||
|
@ -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
|
// 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.
|
// into account the case where the index value is a word type.
|
||||||
// The replacement here is to fix missing cases in the 6502 codegen.
|
// 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)
|
val arrayVar = arrayIndexedExpression.arrayvar.targetVarDecl(program)
|
||||||
if(arrayVar!=null && arrayVar.datatype == DataType.UWORD) {
|
if(arrayVar!=null && arrayVar.datatype == DataType.UWORD) {
|
||||||
if(parent is AssignTarget) {
|
if(parent is AssignTarget) {
|
||||||
|
@ -3,6 +3,16 @@ TODO
|
|||||||
|
|
||||||
For next minor release
|
For next minor release
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
- fix compiler crash on Virtual Textelite example
|
||||||
|
- add optimizations for integer X <= Y-1 ---> X<Y , 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
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,8 +166,7 @@ fun parseIRCodeLine(line: String, location: Pair<IRCodeChunk, Int>?, placeholder
|
|||||||
operands.clear()
|
operands.clear()
|
||||||
}
|
}
|
||||||
if(operands.isNotEmpty()) {
|
if(operands.isNotEmpty()) {
|
||||||
TODO("huh even more operands? $operands rest=$rest'")
|
throw IRParseException("unexpected even more operands? $operands rest=$rest'")
|
||||||
// operands.clear()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class VirtualMachine(irProgram: IRProgram) {
|
|||||||
pcChunk = target
|
pcChunk = target
|
||||||
pcIndex = 0
|
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")
|
else -> throw IllegalArgumentException("VM can't execute code in a non-codechunk: $target")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user