From 0991131fa8095e66dcddee45c0ac3cae9acc0710 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 21 Mar 2021 19:55:21 +0100 Subject: [PATCH] don't stript unused asmsub definitions --- compiler/src/prog8/optimizer/StatementOptimizer.kt | 5 +++-- compiler/src/prog8/optimizer/UnusedCodeRemover.kt | 1 + docs/source/todo.rst | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/src/prog8/optimizer/StatementOptimizer.kt b/compiler/src/prog8/optimizer/StatementOptimizer.kt index c4b49e3df..029f2f713 100644 --- a/compiler/src/prog8/optimizer/StatementOptimizer.kt +++ b/compiler/src/prog8/optimizer/StatementOptimizer.kt @@ -56,9 +56,10 @@ internal class StatementOptimizer(private val program: Program, } if(subroutine !in callgraph.usedSymbols && !forceOutput) { - if(!subroutine.isAsmSubroutine) + if(!subroutine.isAsmSubroutine) { errors.warn("removing unused subroutine '${subroutine.name}'", subroutine.position) - return listOf(IAstModification.Remove(subroutine, subroutine.definingScope())) + return listOf(IAstModification.Remove(subroutine, subroutine.definingScope())) + } } return noModifications diff --git a/compiler/src/prog8/optimizer/UnusedCodeRemover.kt b/compiler/src/prog8/optimizer/UnusedCodeRemover.kt index d20137184..cd539391a 100644 --- a/compiler/src/prog8/optimizer/UnusedCodeRemover.kt +++ b/compiler/src/prog8/optimizer/UnusedCodeRemover.kt @@ -25,6 +25,7 @@ internal class UnusedCodeRemover(private val program: Program, val removals = mutableListOf() // remove all subroutines that aren't called, or are empty + // NOTE: part of this is also done already in the StatementOptimizer val entrypoint = program.entrypoint() program.modules.forEach { callgraph.forAllSubroutines(it) { sub -> diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 63c2fc269..93dd5395a 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,8 +2,6 @@ TODO ==== -- add cx16.vsave() to be able to make screenshots? (there's no kernal routine for this) - - optimize several inner loops in gfx2 - hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine) - optimize swap of two memread values with index, using the same pointer expression/variable, like swap(@(ptr+1), @(ptr+2)) @@ -13,7 +11,7 @@ TODO - refactor the asmgen into their own submodule? - refactor the compiler optimizers into their own submodule? - optimizer: detect variables that are written but never read - mark those as unused too and remove them, such as uword unused = memory("unused222", 20) - also remove the memory slab allocation -- add a compiler option to not remove unused subroutines. this allows for building library programs +- add a compiler option to not remove unused subroutines. this allows for building library programs. But this won't work with 64tass's .proc ... - make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as ``v_`` - option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging) - c64: make the graphics.BITMAP_ADDRESS configurable (VIC banking)