From 8f2e166a229c94cfc58595a58a44c8f7709726b7 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 17 Oct 2020 22:57:54 +0200 Subject: [PATCH] annotated some high prio todos --- .../codegen/assignment/AssignmentAsmGen.kt | 28 +++++-------------- .../assignment/AugmentableAssignmentAsmGen.kt | 8 +++--- examples/test.p8 | 2 -- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt index 34ed054c3..2450a6294 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt @@ -50,7 +50,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen DataType.FLOAT -> assignVariableFloat(assign.target, variable) DataType.STR -> assignVariableString(assign.target, variable) in PassByReferenceDatatypes -> { - // TODO what about when the name is a struct? name.firstStructVarName(program.namespace) + // TODO what about when the name is a struct? name.firstStructVarName(program.namespace) **************************************** assignAddressOf(assign.target, variable) } else -> throw AssemblyError("unsupported assignment target type ${assign.target.datatype}") @@ -533,16 +533,14 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen """) } TargetStorageKind.ARRAY -> { - // TODO optimize this, but the situation doesn't occur very often + // TODO optimize this (array indexer is just a simple number or variable), but the situation doesn't occur very often **************************************** // if(target.constArrayIndexValue!=null) { // TODO("const index ${target.constArrayIndexValue}") // } else if(target.array!!.arrayspec.index is IdentifierReference) { // TODO("array[var] ${target.constArrayIndexValue}") // } asmgen.out(" lda #<$sourceName | ldy #>$sourceName | jsr floats.push_float") - target.array!! - target.array.indexer.indexNum?.let { asmgen.translateExpression(it) } - target.array.indexer.indexVar?.let { asmgen.translateExpression(it) } + asmgen.translateExpression(target.array!!) asmgen.out(" lda #<${target.asmVarname} | ldy #>${target.asmVarname} | jsr floats.pop_float_to_indexed_var") } TargetStorageKind.MEMORY -> throw AssemblyError("can't assign float to mem byte") @@ -830,15 +828,13 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen throw AssemblyError("no asm gen for assign word $word to memory ${target.memory}") } TargetStorageKind.ARRAY -> { - // TODO optimize this, but the situation doesn't occur very often + // TODO optimize this (array indexer is just a simple number or variable), but the situation doesn't occur very often **************************************** // if(target.constArrayIndexValue!=null) { // TODO("const index ${target.constArrayIndexValue}") // } else if(target.array!!.arrayspec.index is IdentifierReference) { // TODO("array[var] ${target.constArrayIndexValue}") // } - target.array!! - target.array.indexer.indexNum?.let { asmgen.translateExpression(it) } - target.array.indexer.indexVar?.let { asmgen.translateExpression(it) } + asmgen.translateExpression(target.array!!) asmgen.out(""" inx lda P8ESTACK_LO,x @@ -928,12 +924,6 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen """) } TargetStorageKind.ARRAY -> { - // TODO optimize this, but the situation doesn't occur very often -// if(target.constArrayIndexValue!=null) { -// TODO("const index ${target.constArrayIndexValue}") -// } else if(target.array!!.arrayspec.index is IdentifierReference) { -// TODO("array[var] ${target.constArrayIndexValue}") -// } if (target.array!!.indexer.indexNum!=null) { val indexValue = target.array.indexer.constIndex()!! * DataType.FLOAT.memorySize() asmgen.out(""" @@ -945,6 +935,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen sta ${target.asmVarname}+$indexValue+4 """) } else { + // TODO optimize this (don't use stack eval) as the indexer is only a simple variable **************************************** asmgen.translateExpression(target.array.indexer.indexVar!!) asmgen.out(""" lda #<${target.asmVarname} @@ -981,12 +972,6 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen """) } TargetStorageKind.ARRAY -> { - // TODO optimize this, but the situation doesn't occur very often -// if(target.constArrayIndexValue!=null) { -// TODO("const index ${target.constArrayIndexValue}") -// } else if(target.array!!.arrayspec.index is IdentifierReference) { -// TODO("array[var] ${target.constArrayIndexValue}") -// } val arrayVarName = target.asmVarname if (target.array!!.indexer.indexNum!=null) { val indexValue = target.array.indexer.constIndex()!! * DataType.FLOAT.memorySize() @@ -1003,6 +988,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen sta $arrayVarName+$indexValue+4 """) } else { + // TODO optimize this (don't use stack eval) as the indexer is only a simple variable **************************************** asmgen.translateExpression(target.array.indexer.indexVar!!) asmgen.out(""" lda #<${constFloat} diff --git a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt index 2a23a483f..6cd784fc3 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt @@ -647,7 +647,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, private fun inplaceModification_word_litval_to_variable(name: String, dt: DataType, operator: String, value: Int) { when (operator) { // note: ** (power) operator requires floats. - // TODO use these + and - optimizations in the expressionAsmGenerator as well. + // TODO use these + and - optimizations in the expressionAsmGenerator as well. **************************************** "+" -> { when { value==0 -> {} @@ -720,7 +720,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, if(value.absoluteValue in asmgen.optimizedWordMultiplications) { asmgen.out(" lda $name | ldy $name+1 | jsr math.mul_word_$value | sta $name | sty $name+1") } else { - // TODO does this work for signed words? if so the uword/word distinction can be removed altogether + // TODO does this work for signed words? if so the uword/word distinction can be removed altogether **************************************** asmgen.out(""" lda $name sta P8ZP_SCRATCH_W1 @@ -1168,7 +1168,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, remainderWord() } "<<" -> { - asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already? + asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already? **************************************** asmgen.out(""" inx ldy P8ESTACK_LO,x @@ -1180,7 +1180,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, +""") } ">>" -> { - asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already? + asmgen.translateExpression(value) // TODO huh is this okay? wasn't this done above already? ******************************************* if(dt==DataType.UWORD) { asmgen.out(""" inx diff --git a/examples/test.p8 b/examples/test.p8 index 4698f4dd4..f00304a6f 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -24,8 +24,6 @@ main { ib = array[3*ib] ib = array[ib*4] ib = array[4*ib] -; ib = array[lsb(ib)] -; ib = array[msb(ib)] testX() }