mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
remove redundant asm optimizer
This commit is contained in:
parent
3841cef497
commit
ab8173637a
@ -22,13 +22,6 @@ internal fun optimizeAssembly(lines: MutableList<String>, machine: IMachineDefin
|
|||||||
numberOfOptimizations++
|
numberOfOptimizations++
|
||||||
}
|
}
|
||||||
|
|
||||||
mods = optimizeCmpSequence(linesByFour)
|
|
||||||
if(mods.isNotEmpty()) {
|
|
||||||
apply(mods, lines)
|
|
||||||
linesByFour = getLinesBy(lines, 4)
|
|
||||||
numberOfOptimizations++
|
|
||||||
}
|
|
||||||
|
|
||||||
mods = optimizeStoreLoadSame(linesByFour, machine, symbolTable)
|
mods = optimizeStoreLoadSame(linesByFour, machine, symbolTable)
|
||||||
if(mods.isNotEmpty()) {
|
if(mods.isNotEmpty()) {
|
||||||
apply(mods, lines)
|
apply(mods, lines)
|
||||||
@ -90,27 +83,6 @@ private fun getLinesBy(lines: MutableList<String>, windowSize: Int) =
|
|||||||
// all lines (that aren't empty or comments) in sliding windows of certain size
|
// all lines (that aren't empty or comments) in sliding windows of certain size
|
||||||
lines.withIndex().filter { it.value.isNotBlank() && !it.value.trimStart().startsWith(';') }.windowed(windowSize, partialWindows = false)
|
lines.withIndex().filter { it.value.isNotBlank() && !it.value.trimStart().startsWith(';') }.windowed(windowSize, partialWindows = false)
|
||||||
|
|
||||||
private fun optimizeCmpSequence(linesByFour: List<List<IndexedValue<String>>>): List<Modification> {
|
|
||||||
// when statement (on bytes) generates a sequence of:
|
|
||||||
// lda $ce01,x
|
|
||||||
// cmp #$20
|
|
||||||
// beq check_prog8_s72choice_32
|
|
||||||
// lda $ce01,x
|
|
||||||
// cmp #$21
|
|
||||||
// beq check_prog8_s73choice_33
|
|
||||||
// the repeated lda can be removed
|
|
||||||
val mods = mutableListOf<Modification>()
|
|
||||||
// for(lines in linesByFour) {
|
|
||||||
// if(lines[0].value.trim()=="lda P8ESTACK_LO+1,x" &&
|
|
||||||
// lines[1].value.trim().startsWith("cmp ") &&
|
|
||||||
// lines[2].value.trim().startsWith("beq ") &&
|
|
||||||
// lines[3].value.trim()=="lda P8ESTACK_LO+1,x") {
|
|
||||||
// mods.add(Modification(lines[3].index, true, null)) // remove the second lda
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return mods
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun optimizeSameAssignments(
|
private fun optimizeSameAssignments(
|
||||||
linesByFourteen: List<List<IndexedValue<String>>>,
|
linesByFourteen: List<List<IndexedValue<String>>>,
|
||||||
machine: IMachineDefinition,
|
machine: IMachineDefinition,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
- (branch): fix optimizeCmpSequence in AsmOptimizer
|
|
||||||
- (branch): fix up cx16/keyboardhandler.p8 X register shenanigans
|
- (branch): fix up cx16/keyboardhandler.p8 X register shenanigans
|
||||||
|
|
||||||
- IR: instructions that do type conversion (SZ etc, CONCAT, SGN) should put the result in a DIFFERENT register.
|
- IR: instructions that do type conversion (SZ etc, CONCAT, SGN) should put the result in a DIFFERENT register.
|
||||||
|
@ -5,27 +5,15 @@ main
|
|||||||
{
|
{
|
||||||
sub start()
|
sub start()
|
||||||
{
|
{
|
||||||
word zc = -5583
|
byte zc = -55
|
||||||
txt.print_w(zc)
|
|
||||||
txt.spc()
|
|
||||||
txt.print_w(zc>>10) ; -6
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
txt.print_w(zc)
|
when zc*3 {
|
||||||
txt.spc()
|
123 -> zc++
|
||||||
txt.print_w(zc>>4) ; -349
|
124 -> zc++
|
||||||
txt.nl()
|
125 -> zc++
|
||||||
|
121 -> zc++
|
||||||
txt.print_w(zc)
|
120 -> zc++
|
||||||
txt.spc()
|
else -> zc++
|
||||||
txt.print_w(zc>>10) ; -6
|
}
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
cx16.r1L = (zc>>10) as ubyte
|
|
||||||
txt.print_ub(cx16.r1L) ; 250
|
|
||||||
txt.nl()
|
|
||||||
cx16.r1L = (zc>>4) as ubyte
|
|
||||||
txt.print_ub(cx16.r1L) ; 163
|
|
||||||
txt.nl()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user