mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
remove unused interned strings in the resulting code (for example from removed if/else blocks)
This commit is contained in:
parent
405926e811
commit
d73709653d
@ -627,7 +627,7 @@ gfx2 {
|
||||
; Non-recursive scanline flood fill.
|
||||
; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm
|
||||
; with the fixes applied to the seedfill_4 routine as mentioned in the comments.
|
||||
const ubyte MAXDEPTH = 48
|
||||
const ubyte MAXDEPTH = 64
|
||||
word @zp xx = x as word
|
||||
word @zp yy = y as word
|
||||
word[MAXDEPTH] @split @shared stack_xl
|
||||
|
@ -638,7 +638,7 @@ _done
|
||||
; Non-recursive scanline flood fill.
|
||||
; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm
|
||||
; with the fixes applied to the seedfill_4 routine as mentioned in the comments.
|
||||
const ubyte MAXDEPTH = 48
|
||||
const ubyte MAXDEPTH = 64
|
||||
word @zp xx = x as word
|
||||
word @zp yy = y as word
|
||||
word[MAXDEPTH] @split @shared stack_xl
|
||||
|
@ -373,7 +373,7 @@ monogfx {
|
||||
; Non-recursive scanline flood fill.
|
||||
; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm
|
||||
; with the fixes applied to the seedfill_4 routine as mentioned in the comments.
|
||||
const ubyte MAXDEPTH = 48
|
||||
const ubyte MAXDEPTH = 64
|
||||
word @zp xx = x as word
|
||||
word @zp yy = y as word
|
||||
word[MAXDEPTH] @split @shared stack_xl
|
||||
|
@ -19,8 +19,24 @@ internal class VerifyFunctionArgTypes(val program: Program, val errors: IErrorRe
|
||||
errors.err("memory block '${slab.name}' already exists with a different size and/or alignment at ${other.position}", slab.position)
|
||||
}
|
||||
}
|
||||
|
||||
// remove unused strings from interned strings block
|
||||
val internedBlock = program.allBlocks.singleOrNull { it.name== internedStringsModuleName }
|
||||
internedBlock?.statements?.withIndex()?.reversed()?.forEach { (index, st) ->
|
||||
if(st is VarDecl && st.scopedName !in allStringRefs) {
|
||||
internedBlock.statements.removeAt(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun visit(identifier: IdentifierReference) {
|
||||
if(identifier.wasStringLiteral(program)) {
|
||||
allStringRefs.add(identifier.nameInSource)
|
||||
}
|
||||
}
|
||||
|
||||
private val allStringRefs = mutableListOf<List<String>>()
|
||||
|
||||
private class Slab(val name: String, val size: Int, val align: Int, val position: Position)
|
||||
private val memorySlabs = mutableListOf<Slab>()
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
TODO
|
||||
====
|
||||
|
||||
- remove unused interned strings in the resulting code (for example from removed if/else blocks)
|
||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||
- [on branch: ir-less-branch-opcodes] IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
||||
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? Bitwise operations, etc), but only after setting the status bits is verified!
|
||||
|
@ -1,21 +1,12 @@
|
||||
%import textio
|
||||
%import string
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
str name = "irmen????????????"
|
||||
name[5] = 0
|
||||
|
||||
txt.print(name)
|
||||
txt.nl()
|
||||
ubyte length = string.append(name, ".prg")
|
||||
|
||||
txt.print_ub(length)
|
||||
txt.chrout('[')
|
||||
for cx16.r0L in 0 to length-1 {
|
||||
txt.chrout(name[cx16.r0L])
|
||||
if true {
|
||||
txt.print("true")
|
||||
} else {
|
||||
txt.print("false")
|
||||
}
|
||||
txt.chrout(']')
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,4 @@ org.gradle.daemon=true
|
||||
kotlin.code.style=official
|
||||
javaVersion=11
|
||||
kotlinVersion=1.9.20
|
||||
version=9.6-SNAPSHOT
|
||||
version=9.6
|
||||
|
@ -188,8 +188,7 @@ expression :
|
||||
|
||||
arrayindexed:
|
||||
scoped_identifier arrayindex
|
||||
// TODO to allow chained array indexing: | arrayindexed arrayindex
|
||||
// TODO or even to allow array indexing on any uword address value: | expression arrayindex
|
||||
// TODO to allow chained/multidimensional array indexing: | arrayindexed arrayindex
|
||||
;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user