This commit is contained in:
Irmen de Jong 2023-07-03 21:57:32 +02:00
parent ee3e3a3a40
commit 204f5591a9
6 changed files with 18 additions and 19 deletions

View File

@ -95,7 +95,7 @@ class SymbolTableMaker(private val program: PtProgram, private val options: Comp
numElements = node.arraySize?.toInt()
}
// if(node.type in SplitWordArrayTypes) {
// TODO("split array also add _lsb and _msb to symboltable")
// ... split array also add _lsb and _msb to symboltable?
// }
StStaticVariable(node.name, node.type, initialNumeric, initialString, initialArray, numElements, node.zeropage, node)
}

View File

@ -37,8 +37,6 @@ class IRPeepholeOptimizer(private val irprog: IRProgram) {
removeEmptyChunks(sub)
joinChunks(sub)
// TODO also do register optimization step here?
sub.chunks.withIndex().forEach { (index, chunk1) ->
// we don't optimize Inline Asm chunks here.
val chunk2 = if(index<sub.chunks.size-1) sub.chunks[index+1] else null
@ -52,14 +50,15 @@ class IRPeepholeOptimizer(private val irprog: IRProgram) {
|| removeWeirdBranches(chunk1, chunk2, indexedInstructions)
|| removeDoubleSecClc(chunk1, indexedInstructions)
|| cleanupPushPop(chunk1, indexedInstructions)
// TODO other optimizations:
// more complex optimizations such as unused registers
// TODO other optimizations
} while (changed)
}
}
removeEmptyChunks(sub)
}
// TODO also do register optimization step here at the end?
irprog.linkChunks() // re-link
}

View File

@ -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
// TODO add more peephole expression optimizations? Investigate what optimizations binaryen has?
class ExpressionSimplifier(private val program: Program,
private val errors: IErrorReporter,

View File

@ -6,10 +6,10 @@ package prog8.buildversion
const val MAVEN_GROUP = "prog8"
const val MAVEN_NAME = "compiler"
const val VERSION = "9.1-SNAPSHOT"
const val GIT_REVISION = 3915
const val GIT_SHA = "bdf8aa9168e16baa29543de041c90ad8f47bba3b"
const val GIT_DATE = "2023-07-02T13:26:04Z"
const val GIT_BRANCH = "prefixing"
const val BUILD_DATE = "2023-07-02T17:14:33Z"
const val BUILD_UNIX_TIME = 1688318073184L
const val GIT_REVISION = 3922
const val GIT_SHA = "UNKNOWN"
const val GIT_DATE = "2023-07-02T21:41:15Z"
const val GIT_BRANCH = "master"
const val BUILD_DATE = "2023-07-02T21:41:41Z"
const val BUILD_UNIX_TIME = 1688334101117L
const val DIRTY = 1

View File

@ -150,8 +150,8 @@ class VirtualMachine(irProgram: IRProgram) {
else
throw IllegalArgumentException("no branchtarget in $i")
}
is IRInlineAsmChunk -> TODO()
is IRInlineBinaryChunk -> TODO()
is IRInlineAsmChunk -> TODO("branch to inline asm chunk")
is IRInlineBinaryChunk -> throw IllegalArgumentException("can't branch to inline binary chunk")
else -> {
throw IllegalArgumentException("VM can't execute code in a non-codechunk: $target")
}

View File

@ -163,7 +163,7 @@ class VmProgramLoader {
else if(opcode in OpcodesThatBranch)
chunk.instructions[line] = chunk.instructions[line].copy(branchTarget = target, address = null)
else
throw IRParseException("vm cannot yet load a label address as a value: ${chunk.instructions[line]}") // TODO
throw IRParseException("vm cannot yet load a label address as a value: ${chunk.instructions[line]}")
}
} else {
chunk.instructions[line] = chunk.instructions[line].copy(address = replacement)
@ -299,10 +299,10 @@ class VmProgramLoader {
val name = elt.addressOfSymbol!!
val symbolAddress = if(name.startsWith('<')) {
symbolAddresses[name.drop(1)]?.and(255)
?: throw IRParseException("vm cannot yet load a label address as a value: $name") // TODO
?: throw IRParseException("vm cannot yet load a label address as a value: $name")
} else if(name.startsWith('>')) {
symbolAddresses[name.drop(1)]?.shr(8)
?: throw IRParseException("vm cannot yet load a label address as a value: $name") // TODO
?: throw IRParseException("vm cannot yet load a label address as a value: $name")
} else
throw IRParseException("for byte-array address-of, expected < or > (lsb/msb)")
memory.setUB(addr, symbolAddress.toUByte())
@ -323,7 +323,7 @@ class VmProgramLoader {
if(elt.addressOfSymbol!=null) {
val name = elt.addressOfSymbol!!
val symbolAddress = symbolAddresses[name]
?: throw IRParseException("vm cannot yet load a label address as a value: $name") // TODO
?: throw IRParseException("vm cannot yet load a label address as a value: $name")
memory.setUW(addr, symbolAddress.toUShort())
} else {
memory.setUW(addr, elt.number!!.toInt().toUShort())
@ -342,7 +342,7 @@ class VmProgramLoader {
val number = if(elt.addressOfSymbol!=null) {
val name = elt.addressOfSymbol!!
val symbolAddress = symbolAddresses[name]
?: throw IRParseException("vm cannot yet load a label address as a value: $name") // TODO
?: throw IRParseException("vm cannot yet load a label address as a value: $name")
symbolAddress.toUInt()
} else {
elt.number!!.toInt().toUInt()