From 4741a2d22e42e3fe23e372dba615ab083da52a87 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 13 Aug 2017 00:30:51 +0200 Subject: [PATCH] Improve pass structure --- .../java/dk/camelot64/kickc/Compiler.java | 336 +++++++++--------- src/main/java/dk/camelot64/kickc/TODO.txt | 3 +- .../kickc/passes/Pass3RegisterUpliftTest.java | 4 +- ...bber.java => Pass4AssertNoCpuClobber.java} | 6 +- ...neration.java => Pass4CodeGeneration.java} | 4 +- ...a => Pass4RegisterUpliftCombinations.java} | 10 +- ...s4RegisterUpliftPotentialAluAnalysis.java} | 4 +- ...isterUpliftPotentialRegisterAnalysis.java} | 12 +- ...s.java => Pass4RegisterUpliftRemains.java} | 14 +- ... => Pass4RegisterUpliftScopeAnalysis.java} | 4 +- ...alize.java => Pass4RegistersFinalize.java} | 4 +- ...tion.java => Pass4ZeroPageAllocation.java} | 4 +- ...alesce.java => Pass4ZeroPageCoalesce.java} | 4 +- ...ization.java => Pass5AsmOptimization.java} | 4 +- ...ion.java => Pass5NextJumpElimination.java} | 4 +- ...va => Pass5RedundantLabelElimination.java} | 4 +- ...va => Pass5UnnecesaryLoadElimination.java} | 4 +- ....java => Pass5UnusedLabelElimination.java} | 5 +- .../dk/camelot64/kickc/test/ref/bresenham.log | 8 +- .../dk/camelot64/kickc/test/ref/fibmem.log | 8 +- .../camelot64/kickc/test/ref/flipper-rex2.log | 12 +- .../dk/camelot64/kickc/test/ref/loopmin.log | 8 +- .../dk/camelot64/kickc/test/ref/loopnest.log | 8 +- .../dk/camelot64/kickc/test/ref/loopnest2.log | 8 +- .../dk/camelot64/kickc/test/ref/loopsplit.log | 4 +- .../dk/camelot64/kickc/test/ref/minus.log | 8 +- .../dk/camelot64/kickc/test/ref/modglobal.log | 4 +- .../camelot64/kickc/test/ref/modglobalmin.log | 4 +- .../dk/camelot64/kickc/test/ref/ptrtest.log | 4 +- .../camelot64/kickc/test/ref/ptrtestmin.log | 4 +- .../dk/camelot64/kickc/test/ref/summin.log | 6 +- .../dk/camelot64/kickc/test/ref/useglobal.log | 4 +- .../dk/camelot64/kickc/test/ref/voronoi.log | 8 +- 33 files changed, 263 insertions(+), 265 deletions(-) rename src/main/java/dk/camelot64/kickc/passes/{Pass3AssertNoCpuClobber.java => Pass4AssertNoCpuClobber.java} (96%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3CodeGeneration.java => Pass4CodeGeneration.java} (99%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3RegisterUpliftCombinations.java => Pass4RegisterUpliftCombinations.java} (94%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3RegisterUpliftPotentialAluAnalysis.java => Pass4RegisterUpliftPotentialAluAnalysis.java} (97%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3RegisterUpliftPotentialRegisterAnalysis.java => Pass4RegisterUpliftPotentialRegisterAnalysis.java} (96%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3RegisterUpliftRemains.java => Pass4RegisterUpliftRemains.java} (90%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3RegisterUpliftScopeAnalysis.java => Pass4RegisterUpliftScopeAnalysis.java} (94%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3RegistersFinalize.java => Pass4RegistersFinalize.java} (96%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3ZeroPageAllocation.java => Pass4ZeroPageAllocation.java} (98%) rename src/main/java/dk/camelot64/kickc/passes/{Pass3ZeroPageCoalesce.java => Pass4ZeroPageCoalesce.java} (96%) rename src/main/java/dk/camelot64/kickc/passes/{Pass6AsmOptimization.java => Pass5AsmOptimization.java} (93%) rename src/main/java/dk/camelot64/kickc/passes/{Pass6NextJumpElimination.java => Pass5NextJumpElimination.java} (91%) rename src/main/java/dk/camelot64/kickc/passes/{Pass6RedundantLabelElimination.java => Pass5RedundantLabelElimination.java} (97%) rename src/main/java/dk/camelot64/kickc/passes/{Pass6UnnecesaryLoadElimination.java => Pass5UnnecesaryLoadElimination.java} (96%) rename src/main/java/dk/camelot64/kickc/passes/{Pass6UnusedLabelElimination.java => Pass5UnusedLabelElimination.java} (92%) diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 60238e4cc..3ebce0ad5 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -6,7 +6,8 @@ import dk.camelot64.kickc.parser.KickCParser; import dk.camelot64.kickc.passes.*; import org.antlr.v4.runtime.*; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** * Perform KickC compilation and optimizations @@ -22,8 +23,7 @@ public class Compiler { pass2OptimizeSSA(program); pass3Analysis(program); pass4RegisterAllocation(program); - pass5GenerateAsm(program); - pass6OptimizeAsm(program); + pass5GenerateAndOptimizeAsm(program); log.append("FINAL SYMBOL TABLE"); log.append(program.getScope().getSymbolTableContents(program)); @@ -37,155 +37,24 @@ public class Compiler { } } - public void pass6OptimizeAsm(Program program) { - List pass6Optimizations = new ArrayList<>(); - pass6Optimizations.add(new Pass6NextJumpElimination(program)); - pass6Optimizations.add(new Pass6UnnecesaryLoadElimination(program)); - pass6Optimizations.add(new Pass6RedundantLabelElimination(program)); - pass6Optimizations.add(new Pass6UnusedLabelElimination(program)); - boolean asmOptimized = true; - CompileLog log = program.getLog(); - while (asmOptimized) { - asmOptimized = false; - for (Pass6AsmOptimization optimization : pass6Optimizations) { - boolean stepOptimized = optimization.optimize(); - if (stepOptimized) { - log.append("Succesful ASM optimization " + optimization.getClass().getSimpleName()); - asmOptimized = true; - log.append("ASSEMBLER"); - log.append(program.getAsm().toString()); - } + public KickCParser.FileContext pass0ParseInput(final CharStream input, CompileLog log) { + log.append(input.toString()); + KickCLexer lexer = new KickCLexer(input); + KickCParser parser = new KickCParser(new CommonTokenStream(lexer)); + parser.setBuildParseTree(true); + parser.addErrorListener(new BaseErrorListener() { + @Override + public void syntaxError( + Recognizer recognizer, + Object offendingSymbol, + int line, + int charPositionInLine, + String msg, + RecognitionException e) { + throw new RuntimeException("Error parsing file " + input.getSourceName() + "\n - Line: " + line + "\n - Message: " + msg); } - } - } - - private void pass5GenerateAsm(Program program) { - new Pass3CodeGeneration(program).generate(); - new Pass3AssertNoCpuClobber(program).check(); - } - - private void pass4RegisterAllocation(Program program) { - - // Find potential registers for each live range equivalence class - based on clobbering of fragments - boolean change; - do { - change = new Pass3RegisterUpliftPotentialRegisterAnalysis(program).findPotentialRegisters(); - } while (change); - new Pass3RegisterUpliftPotentialAluAnalysis(program).findPotentialAlu(); - program.getLog().append("REGISTER UPLIFT POTENTIAL REGISTERS"); - program.getLog().append(program.getRegisterPotentials().toString()); - - // Find register uplift scopes - new Pass3RegisterUpliftScopeAnalysis(program).findScopes(); - program.getLog().append("REGISTER UPLIFT SCOPES"); - program.getLog().append(program.getRegisterUpliftProgram().toString((program.getVariableRegisterWeights()))); - - // Attempt uplifting registers through a lot of combinations - new Pass3RegisterUpliftCombinations(program).performUplift(10_000); - - // Attempt uplifting registers one at a time to catch remaining potential not realized by combination search - new Pass3RegisterUpliftRemains(program).performUplift(); - - // Final register coalesce and code generation - new Pass3ZeroPageCoalesce(program).allocate(); - new Pass3RegistersFinalize(program).allocate(true); - - } - - private void pass3Analysis(Program program) { - - new Pass3BlockSequencePlanner(program).plan(); - - // Phi lifting ensures that all variables in phi-blocks are in different live range equivalence classes - new Pass3PhiLifting(program).perform(); - new Pass3BlockSequencePlanner(program).plan(); - program.getLog().append("CONTROL FLOW GRAPH - PHI LIFTED"); - program.getLog().append(program.getGraph().toString(program)); - pass2AssertSSA(program); - - new Pass3LiveRangesAnalysis(program).findLiveRanges(); - program.getLog().append("CONTROL FLOW GRAPH - LIVE RANGES"); - program.getLog().append(program.getGraph().toString(program)); - pass2AssertSSA(program); - - // Phi mem coalesce removes as many variables introduced by phi lifting as possible - as long as their live ranges do not overlap - new Pass3PhiMemCoalesce(program).optimize(); - new Pass2CullEmptyBlocks(program).optimize(); - new Pass3BlockSequencePlanner(program).plan(); - new Pass3LiveRangesAnalysis(program).findLiveRanges(); - program.getLog().append("CONTROL FLOW GRAPH - PHI MEM COALESCED"); - program.getLog().append(program.getGraph().toString(program)); - pass2AssertSSA(program); - - new Pass3CallGraphAnalysis(program).findCallGraph(); - program.getLog().append("CALL GRAPH"); - program.getLog().append(program.getCallGraph().toString()); - - new Pass3DominatorsAnalysis(program).findDominators(); - program.getLog().append("DOMINATORS"); - program.getLog().append(program.getDominators().toString()); - - new Pass3LoopAnalysis(program).findLoops(); - program.getLog().append("NATURAL LOOPS"); - program.getLog().append(program.getLoopSet().toString()); - - new Pass3LoopDepthAnalysis(program).findLoopDepths(); - program.getLog().append("NATURAL LOOPS WITH DEPTH"); - program.getLog().append(program.getLoopSet().toString()); - - new Pass3VariableRegisterWeightAnalysis(program).findWeights(); - program.getLog().append("\nVARIABLE REGISTER WEIGHTS"); - program.getLog().append(program.getScope().getSymbolTableContents(program, Variable.class)); - - new Pass3ZeroPageAllocation(program).allocate(); - new Pass3RegistersFinalize(program).allocate(false); - - // Initial Code generation - new Pass3CodeGeneration(program).generate(); - new Pass3AssertNoCpuClobber(program).check(); - program.getLog().append("INITIAL ASM"); - program.getLog().append(program.getAsm().toString()); - - } - - public void pass2OptimizeSSA(Program program) { - List optimizations = new ArrayList<>(); - optimizations.add(new Pass2CullEmptyBlocks(program)); - optimizations.add(new Pass2ConstantPropagation(program)); - optimizations.add(new Pass2ConstantAdditionElimination(program)); - optimizations.add(new Pass2AliasElimination(program)); - optimizations.add(new Pass2RedundantPhiElimination(program)); - optimizations.add(new Pass2SelfPhiElimination(program)); - optimizations.add(new Pass2ConditionalJumpSimplification(program)); - - boolean ssaOptimized = true; - while (ssaOptimized) { - pass2AssertSSA(program); - ssaOptimized = false; - for (Pass2SsaOptimization optimization : optimizations) { - boolean stepOptimized = optimization.optimize(); - if (stepOptimized) { - program.getLog().append("Succesful SSA optimization " + optimization.getClass().getSimpleName() + ""); - ssaOptimized = true; - program.getLog().append("CONTROL FLOW GRAPH"); - program.getLog().append(program.getGraph().toString(program)); - } - } - } - } - - public void pass2AssertSSA(Program program) { - List assertions = new ArrayList<>(); - assertions.add(new Pass2AssertSymbols(program)); - assertions.add(new Pass2AssertBlocks(program)); - assertions.add(new Pass2AssertNoCallParameters(program)); - assertions.add(new Pass2AssertNoCallLvalues(program)); - assertions.add(new Pass2AssertNoReturnValues(program)); - assertions.add(new Pass2AssertNoProcs(program)); - assertions.add(new Pass2AssertNoLabels(program)); - for (Pass2SsaAssertion assertion : assertions) { - assertion.check(); - } + }); + return parser.file(); } public Program pass1GenerateSSA(KickCParser.FileContext file, CompileLog log) { @@ -244,24 +113,155 @@ public class Compiler { return program; } - public KickCParser.FileContext pass0ParseInput(final CharStream input, CompileLog log) { - log.append(input.toString()); - KickCLexer lexer = new KickCLexer(input); - KickCParser parser = new KickCParser(new CommonTokenStream(lexer)); - parser.setBuildParseTree(true); - parser.addErrorListener(new BaseErrorListener() { - @Override - public void syntaxError( - Recognizer recognizer, - Object offendingSymbol, - int line, - int charPositionInLine, - String msg, - RecognitionException e) { - throw new RuntimeException("Error parsing file " + input.getSourceName() + "\n - Line: " + line + "\n - Message: " + msg); + public void pass2AssertSSA(Program program) { + List assertions = new ArrayList<>(); + assertions.add(new Pass2AssertSymbols(program)); + assertions.add(new Pass2AssertBlocks(program)); + assertions.add(new Pass2AssertNoCallParameters(program)); + assertions.add(new Pass2AssertNoCallLvalues(program)); + assertions.add(new Pass2AssertNoReturnValues(program)); + assertions.add(new Pass2AssertNoProcs(program)); + assertions.add(new Pass2AssertNoLabels(program)); + for (Pass2SsaAssertion assertion : assertions) { + assertion.check(); + } + } + + public void pass2OptimizeSSA(Program program) { + List optimizations = new ArrayList<>(); + optimizations.add(new Pass2CullEmptyBlocks(program)); + optimizations.add(new Pass2ConstantPropagation(program)); + optimizations.add(new Pass2ConstantAdditionElimination(program)); + optimizations.add(new Pass2AliasElimination(program)); + optimizations.add(new Pass2RedundantPhiElimination(program)); + optimizations.add(new Pass2SelfPhiElimination(program)); + optimizations.add(new Pass2ConditionalJumpSimplification(program)); + + boolean ssaOptimized = true; + while (ssaOptimized) { + pass2AssertSSA(program); + ssaOptimized = false; + for (Pass2SsaOptimization optimization : optimizations) { + boolean stepOptimized = optimization.optimize(); + if (stepOptimized) { + program.getLog().append("Succesful SSA optimization " + optimization.getClass().getSimpleName() + ""); + ssaOptimized = true; + program.getLog().append("CONTROL FLOW GRAPH"); + program.getLog().append(program.getGraph().toString(program)); + } } - }); - return parser.file(); + } + } + + private void pass3Analysis(Program program) { + + new Pass3BlockSequencePlanner(program).plan(); + + // Phi lifting ensures that all variables in phi-blocks are in different live range equivalence classes + new Pass3PhiLifting(program).perform(); + new Pass3BlockSequencePlanner(program).plan(); + program.getLog().append("CONTROL FLOW GRAPH - PHI LIFTED"); + program.getLog().append(program.getGraph().toString(program)); + pass2AssertSSA(program); + + new Pass3LiveRangesAnalysis(program).findLiveRanges(); + program.getLog().append("CONTROL FLOW GRAPH - LIVE RANGES"); + program.getLog().append(program.getGraph().toString(program)); + pass2AssertSSA(program); + + // Phi mem coalesce removes as many variables introduced by phi lifting as possible - as long as their live ranges do not overlap + new Pass3PhiMemCoalesce(program).optimize(); + new Pass2CullEmptyBlocks(program).optimize(); + new Pass3BlockSequencePlanner(program).plan(); + new Pass3LiveRangesAnalysis(program).findLiveRanges(); + program.getLog().append("CONTROL FLOW GRAPH - PHI MEM COALESCED"); + program.getLog().append(program.getGraph().toString(program)); + pass2AssertSSA(program); + + new Pass3CallGraphAnalysis(program).findCallGraph(); + program.getLog().append("CALL GRAPH"); + program.getLog().append(program.getCallGraph().toString()); + + new Pass3DominatorsAnalysis(program).findDominators(); + program.getLog().append("DOMINATORS"); + program.getLog().append(program.getDominators().toString()); + + new Pass3LoopAnalysis(program).findLoops(); + program.getLog().append("NATURAL LOOPS"); + program.getLog().append(program.getLoopSet().toString()); + + new Pass3LoopDepthAnalysis(program).findLoopDepths(); + program.getLog().append("NATURAL LOOPS WITH DEPTH"); + program.getLog().append(program.getLoopSet().toString()); + + new Pass3VariableRegisterWeightAnalysis(program).findWeights(); + program.getLog().append("\nVARIABLE REGISTER WEIGHTS"); + program.getLog().append(program.getScope().getSymbolTableContents(program, Variable.class)); + + } + + private void pass4RegisterAllocation(Program program) { + + new Pass4ZeroPageAllocation(program).allocate(); + new Pass4RegistersFinalize(program).allocate(false); + + // Initial Code generation + new Pass4CodeGeneration(program).generate(); + new Pass4AssertNoCpuClobber(program).check(); + program.getLog().append("INITIAL ASM"); + program.getLog().append(program.getAsm().toString()); + + // Find potential registers for each live range equivalence class - based on clobbering of fragments + boolean change; + do { + change = new Pass4RegisterUpliftPotentialRegisterAnalysis(program).findPotentialRegisters(); + } while (change); + new Pass4RegisterUpliftPotentialAluAnalysis(program).findPotentialAlu(); + program.getLog().append("REGISTER UPLIFT POTENTIAL REGISTERS"); + program.getLog().append(program.getRegisterPotentials().toString()); + + // Find register uplift scopes + new Pass4RegisterUpliftScopeAnalysis(program).findScopes(); + program.getLog().append("REGISTER UPLIFT SCOPES"); + program.getLog().append(program.getRegisterUpliftProgram().toString((program.getVariableRegisterWeights()))); + + // Attempt uplifting registers through a lot of combinations + new Pass4RegisterUpliftCombinations(program).performUplift(10_000); + + // Attempt uplifting registers one at a time to catch remaining potential not realized by combination search + new Pass4RegisterUpliftRemains(program).performUplift(); + + // Final register coalesce and finalization + new Pass4ZeroPageCoalesce(program).allocate(); + new Pass4RegistersFinalize(program).allocate(true); + + } + + public void pass5GenerateAndOptimizeAsm(Program program) { + + // Final ASM code generation before optimization + new Pass4CodeGeneration(program).generate(); + new Pass4AssertNoCpuClobber(program).check(); + + List pass5Optimizations = new ArrayList<>(); + pass5Optimizations.add(new Pass5NextJumpElimination(program)); + pass5Optimizations.add(new Pass5UnnecesaryLoadElimination(program)); + pass5Optimizations.add(new Pass5RedundantLabelElimination(program)); + pass5Optimizations.add(new Pass5UnusedLabelElimination(program)); + boolean asmOptimized = true; + CompileLog log = program.getLog(); + while (asmOptimized) { + asmOptimized = false; + for (Pass5AsmOptimization optimization : pass5Optimizations) { + boolean stepOptimized = optimization.optimize(); + if (stepOptimized) { + log.append("Succesful ASM optimization " + optimization.getClass().getSimpleName()); + asmOptimized = true; + log.append("ASSEMBLER"); + log.append(program.getAsm().toString()); + } + } + } } } diff --git a/src/main/java/dk/camelot64/kickc/TODO.txt b/src/main/java/dk/camelot64/kickc/TODO.txt index d223358d6..f074fdb05 100644 --- a/src/main/java/dk/camelot64/kickc/TODO.txt +++ b/src/main/java/dk/camelot64/kickc/TODO.txt @@ -2,6 +2,7 @@ Features - Move the main code into a main() function, and disallow code outside functions. The main function per default has no parameters and exits with RTS. - Add a for loop for(init;condition;increment) {stmt} -> { init; do { stmt; increment } while (condition) } - Add for loop for(byte i: 1..100) { } and for(byte i : 100..0) {} (plus maybe .+. and .-. to make the inc/dec unambiguous) +- Optimize if's without else if(expr) { stmt; } -> $1=!expr; if($1) goto @1; stmt; @1: - Add signed bytes - Add signed words - Add Fixed Point number types fixed[8.8], fixed[16.8] - maybe even fixed[24.4] @@ -26,7 +27,7 @@ Assembler Improvements - Make generated ASM human readable. + Use hex-numbers - add labels for constants and zp-variables. -- Eliminate unnecessary labels in ASM ++ Eliminate unnecessary labels in ASM - Eliminate CPX from DEX, CPX #0, BNE la1 - Eliminate LDA from DEC $2, LDA $2, BNE la1 - Eliminate LDA from STA $11, LDA $11 diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftTest.java b/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftTest.java index afab63f3c..e58d7cfb5 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftTest.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftTest.java @@ -58,8 +58,8 @@ public class Pass3RegisterUpliftTest extends Pass2Base { allocation.setRegister(var, register); } getProgram().setAllocation(allocation); - new Pass3CodeGeneration(getProgram()).generate(); - Pass3AssertNoCpuClobber clobber = new Pass3AssertNoCpuClobber(getProgram()); + new Pass4CodeGeneration(getProgram()).generate(); + Pass4AssertNoCpuClobber clobber = new Pass4AssertNoCpuClobber(getProgram()); if (clobber.hasClobberProblem(false)) { getLog().append("Uplift to " + register + " resulted in clobber."); } else { diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3AssertNoCpuClobber.java b/src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/Pass3AssertNoCpuClobber.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java index 38c2995ad..4a84f9542 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3AssertNoCpuClobber.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java @@ -10,9 +10,9 @@ import java.util.Collection; import java.util.List; /*** Ensures that no statement clobbers a CPU register used by an alive variable - and that assigning statements clobber the CPU registers they assign to */ -public class Pass3AssertNoCpuClobber extends Pass2Base { +public class Pass4AssertNoCpuClobber extends Pass2Base { - public Pass3AssertNoCpuClobber(Program program) { + public Pass4AssertNoCpuClobber(Program program) { super(program); } @@ -44,7 +44,7 @@ public class Pass3AssertNoCpuClobber extends Pass2Base { AsmClobber asmSegmentClobber = asmSegment.getClobber(); Collection clobberRegisters = getClobberRegisters(asmSegmentClobber); // Find vars assigned to in the statement - Collection assignedVars = Pass3RegisterUpliftPotentialRegisterAnalysis.getAssignedVars(statement); + Collection assignedVars = Pass4RegisterUpliftPotentialRegisterAnalysis.getAssignedVars(statement); // Two assigned vars cannot use same register if(assignedVars.size()>1) { for (VariableRef assignedVar1 : assignedVars) { diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java similarity index 99% rename from src/main/java/dk/camelot64/kickc/passes/Pass3CodeGeneration.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index bf09d546d..cab2f79ad 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -8,12 +8,12 @@ import java.util.*; /** * Code Generation of 6502 Assembler from ICL/SSA Control Flow Graph */ -public class Pass3CodeGeneration { +public class Pass4CodeGeneration { private Program program; - public Pass3CodeGeneration(Program program) { + public Pass4CodeGeneration(Program program) { this.program = program; } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftCombinations.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java similarity index 94% rename from src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftCombinations.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java index 29d0486fc..b9a8c7306 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftCombinations.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java @@ -10,9 +10,9 @@ import java.util.List; import java.util.Set; /*** Find the variable equivalence classes to attempt to uplift in each scope */ -public class Pass3RegisterUpliftCombinations extends Pass2Base { +public class Pass4RegisterUpliftCombinations extends Pass2Base { - public Pass3RegisterUpliftCombinations(Program program) { + public Pass4RegisterUpliftCombinations(Program program) { super(program); } @@ -33,12 +33,12 @@ public class Pass3RegisterUpliftCombinations extends Pass2Base { } RegisterCombination combination = combinationIterator.next(); // Reset register allocation to original zero page allocation - new Pass3RegistersFinalize(getProgram()).allocate(false); + new Pass4RegistersFinalize(getProgram()).allocate(false); // Apply the uplift combination combination.allocate(getProgram().getAllocation()); // Generate ASM try { - new Pass3CodeGeneration(getProgram()).generate(); + new Pass4CodeGeneration(getProgram()).generate(); } catch (AsmFragment.UnknownFragmentException e) { unknownFragments.add(e.getFragmentSignature()); //StringBuilder msg = new StringBuilder(); @@ -56,7 +56,7 @@ public class Pass3RegisterUpliftCombinations extends Pass2Base { continue; } // If no clobber - Find value of the resulting allocation - boolean hasClobberProblem = new Pass3AssertNoCpuClobber(getProgram()).hasClobberProblem(false); + boolean hasClobberProblem = new Pass4AssertNoCpuClobber(getProgram()).hasClobberProblem(false); int combinationScore = getAsmScore(getProgram()); StringBuilder msg = new StringBuilder(); //msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] "); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftPotentialAluAnalysis.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialAluAnalysis.java similarity index 97% rename from src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftPotentialAluAnalysis.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialAluAnalysis.java index a22730d7d..0f597026f 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftPotentialAluAnalysis.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialAluAnalysis.java @@ -5,11 +5,11 @@ import dk.camelot64.kickc.icl.*; /*** * Find equivalence classes that could be assigned to the special ALU register. */ -public class Pass3RegisterUpliftPotentialAluAnalysis extends Pass2Base { +public class Pass4RegisterUpliftPotentialAluAnalysis extends Pass2Base { private LiveRangeEquivalenceClassSet liveRangeEquivalenceClassSet; - public Pass3RegisterUpliftPotentialAluAnalysis(Program program) { + public Pass4RegisterUpliftPotentialAluAnalysis(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftPotentialRegisterAnalysis.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftPotentialRegisterAnalysis.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java index c36abc781..f6e11e1e2 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftPotentialRegisterAnalysis.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java @@ -13,9 +13,9 @@ import java.util.*; * in the statement - except the variable assigned by the statement. * * */ -public class Pass3RegisterUpliftPotentialRegisterAnalysis extends Pass2Base { +public class Pass4RegisterUpliftPotentialRegisterAnalysis extends Pass2Base { - public Pass3RegisterUpliftPotentialRegisterAnalysis(Program program) { + public Pass4RegisterUpliftPotentialRegisterAnalysis(Program program) { super(program); } @@ -138,15 +138,15 @@ public class Pass3RegisterUpliftPotentialRegisterAnalysis extends Pass2Base { while (combinations.hasNext()) { RegisterCombination combination = combinations.next(); // Reset register allocation to original zero page allocation - new Pass3RegistersFinalize(getProgram()).allocate(false); + new Pass4RegistersFinalize(getProgram()).allocate(false); // Apply the combination combination.allocate(getProgram().getAllocation()); // Generate ASM AsmProgram asm = new AsmProgram(); asm.startSegment(statement.getIndex(), statement.toString(getProgram())); - Pass3CodeGeneration.AsmCodegenAluState aluState = new Pass3CodeGeneration.AsmCodegenAluState(); + Pass4CodeGeneration.AsmCodegenAluState aluState = new Pass4CodeGeneration.AsmCodegenAluState(); try { - (new Pass3CodeGeneration(getProgram())).generateStatementAsm(asm, block, statement, aluState, false); + (new Pass4CodeGeneration(getProgram())).generateStatementAsm(asm, block, statement, aluState, false); } catch (AsmFragment.UnknownFragmentException e) { unknownFragments.add(e.getFragmentSignature()); StringBuilder msg = new StringBuilder(); @@ -157,7 +157,7 @@ public class Pass3RegisterUpliftPotentialRegisterAnalysis extends Pass2Base { continue; } AsmClobber clobber = asm.getClobber(); - Collection clobberRegisters = Pass3AssertNoCpuClobber.getClobberRegisters(clobber); + Collection clobberRegisters = Pass4AssertNoCpuClobber.getClobberRegisters(clobber); Iterator alwaysClobberIt = alwaysClobbered.iterator(); while (alwaysClobberIt.hasNext()) { RegisterAllocation.Register alwaysClobberRegister = alwaysClobberIt.next(); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftRemains.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftRemains.java similarity index 90% rename from src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftRemains.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftRemains.java index 218c59c6e..75efe611a 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftRemains.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftRemains.java @@ -1,16 +1,14 @@ package dk.camelot64.kickc.passes; import dk.camelot64.kickc.asm.AsmFragment; -import dk.camelot64.kickc.asm.AsmProgram; -import dk.camelot64.kickc.asm.AsmSegment; import dk.camelot64.kickc.icl.*; import java.util.*; /*** For eac non-uplifted equivalence class attempt to put it in a register */ -public class Pass3RegisterUpliftRemains extends Pass2Base { +public class Pass4RegisterUpliftRemains extends Pass2Base { - public Pass3RegisterUpliftRemains(Program program) { + public Pass4RegisterUpliftRemains(Program program) { super(program); } @@ -37,12 +35,12 @@ public class Pass3RegisterUpliftRemains extends Pass2Base { while (combinationIterator.hasNext()) { RegisterCombination combination = combinationIterator.next(); // Reset register allocation to original zero page allocation - new Pass3RegistersFinalize(getProgram()).allocate(false); + new Pass4RegistersFinalize(getProgram()).allocate(false); // Apply the uplift combination combination.allocate(getProgram().getAllocation()); // Generate ASM try { - new Pass3CodeGeneration(getProgram()).generate(); + new Pass4CodeGeneration(getProgram()).generate(); } catch (AsmFragment.UnknownFragmentException e) { unknownFragments.add(e.getFragmentSignature()); //StringBuilder msg = new StringBuilder(); @@ -60,8 +58,8 @@ public class Pass3RegisterUpliftRemains extends Pass2Base { continue; } // If no clobber - Find value of the resulting allocation - boolean hasClobberProblem = new Pass3AssertNoCpuClobber(getProgram()).hasClobberProblem(false); - int combinationScore = Pass3RegisterUpliftCombinations.getAsmScore(getProgram()); + boolean hasClobberProblem = new Pass4AssertNoCpuClobber(getProgram()).hasClobberProblem(false); + int combinationScore = Pass4RegisterUpliftCombinations.getAsmScore(getProgram()); //StringBuilder msg = new StringBuilder(); //msg.append("Uplift remains attempt [" + equivalenceClass + "] "); //if (hasClobberProblem) { diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftScopeAnalysis.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftScopeAnalysis.java similarity index 94% rename from src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftScopeAnalysis.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftScopeAnalysis.java index 05704d1ea..1969565d4 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegisterUpliftScopeAnalysis.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftScopeAnalysis.java @@ -5,9 +5,9 @@ import dk.camelot64.kickc.icl.*; import java.util.*; /*** Find the variable equivalence classes to attempt to uplift in each scope */ -public class Pass3RegisterUpliftScopeAnalysis extends Pass2Base { +public class Pass4RegisterUpliftScopeAnalysis extends Pass2Base { - public Pass3RegisterUpliftScopeAnalysis(Program program) { + public Pass4RegisterUpliftScopeAnalysis(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3RegistersFinalize.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/Pass3RegistersFinalize.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java index f0484040c..0a2201b6a 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3RegistersFinalize.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java @@ -6,9 +6,9 @@ import dk.camelot64.kickc.icl.*; * Move register allocation from equivalence classes to RegisterAllocation. * Also rebase zero page registers. */ -public class Pass3RegistersFinalize extends Pass2Base { +public class Pass4RegistersFinalize extends Pass2Base { - public Pass3RegistersFinalize(Program program) { + public Pass4RegistersFinalize(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3ZeroPageAllocation.java b/src/main/java/dk/camelot64/kickc/passes/Pass4ZeroPageAllocation.java similarity index 98% rename from src/main/java/dk/camelot64/kickc/passes/Pass3ZeroPageAllocation.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4ZeroPageAllocation.java index 48dd37e15..fb001b5c7 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3ZeroPageAllocation.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4ZeroPageAllocation.java @@ -8,9 +8,9 @@ import java.util.List; /** * Zero Page Register Allocation for variables based on live ranges and phi equivalence classes. */ -public class Pass3ZeroPageAllocation extends Pass2Base { +public class Pass4ZeroPageAllocation extends Pass2Base { - public Pass3ZeroPageAllocation(Program program) { + public Pass4ZeroPageAllocation(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass3ZeroPageCoalesce.java b/src/main/java/dk/camelot64/kickc/passes/Pass4ZeroPageCoalesce.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/Pass3ZeroPageCoalesce.java rename to src/main/java/dk/camelot64/kickc/passes/Pass4ZeroPageCoalesce.java index 9000b9cbd..80edfd5d2 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass3ZeroPageCoalesce.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4ZeroPageCoalesce.java @@ -6,10 +6,10 @@ import dk.camelot64.kickc.icl.*; * Coalesces zero page registers where their live ranges do not overlap. * A final step done after all other register optimizations and before ASM generation. */ -public class Pass3ZeroPageCoalesce extends Pass2Base { +public class Pass4ZeroPageCoalesce extends Pass2Base { - public Pass3ZeroPageCoalesce(Program program) { + public Pass4ZeroPageCoalesce(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass6AsmOptimization.java b/src/main/java/dk/camelot64/kickc/passes/Pass5AsmOptimization.java similarity index 93% rename from src/main/java/dk/camelot64/kickc/passes/Pass6AsmOptimization.java rename to src/main/java/dk/camelot64/kickc/passes/Pass5AsmOptimization.java index 4fcd8b0f0..812d76b1e 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass6AsmOptimization.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5AsmOptimization.java @@ -14,11 +14,11 @@ import java.util.List; * Optimization performed on Assembler Code (Asm Code). * Optimizations are performed repeatedly until none of them yield any result **/ -public abstract class Pass6AsmOptimization { +public abstract class Pass5AsmOptimization { private Program program; - public Pass6AsmOptimization(Program program) { + public Pass5AsmOptimization(Program program) { this.program = program; } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass6NextJumpElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass5NextJumpElimination.java similarity index 91% rename from src/main/java/dk/camelot64/kickc/passes/Pass6NextJumpElimination.java rename to src/main/java/dk/camelot64/kickc/passes/Pass5NextJumpElimination.java index c3d25367c..46db2a842 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass6NextJumpElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5NextJumpElimination.java @@ -9,9 +9,9 @@ import java.util.List; /** * Optimize assembler code by removing jumps to labels immediately following the jump */ -public class Pass6NextJumpElimination extends Pass6AsmOptimization { +public class Pass5NextJumpElimination extends Pass5AsmOptimization { - public Pass6NextJumpElimination(Program program) { + public Pass5NextJumpElimination(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass6RedundantLabelElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass5RedundantLabelElimination.java similarity index 97% rename from src/main/java/dk/camelot64/kickc/passes/Pass6RedundantLabelElimination.java rename to src/main/java/dk/camelot64/kickc/passes/Pass5RedundantLabelElimination.java index 629cb0632..458205862 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass6RedundantLabelElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5RedundantLabelElimination.java @@ -11,9 +11,9 @@ import java.util.Set; /** * Optimize assembler code by removing all unused labels */ -public class Pass6RedundantLabelElimination extends Pass6AsmOptimization { +public class Pass5RedundantLabelElimination extends Pass5AsmOptimization { - public Pass6RedundantLabelElimination(Program program) { + public Pass5RedundantLabelElimination(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass6UnnecesaryLoadElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/Pass6UnnecesaryLoadElimination.java rename to src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java index 908fc13a6..a18e93d67 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass6UnnecesaryLoadElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java @@ -9,9 +9,9 @@ import java.util.List; /** * Maps out register values entering all instructions. Removes unnecessary loads / clears / sets */ -public class Pass6UnnecesaryLoadElimination extends Pass6AsmOptimization { +public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization { - public Pass6UnnecesaryLoadElimination(Program program) { + public Pass5UnnecesaryLoadElimination(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass6UnusedLabelElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass5UnusedLabelElimination.java similarity index 92% rename from src/main/java/dk/camelot64/kickc/passes/Pass6UnusedLabelElimination.java rename to src/main/java/dk/camelot64/kickc/passes/Pass5UnusedLabelElimination.java index 475130f2f..e52a2c65d 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass6UnusedLabelElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5UnusedLabelElimination.java @@ -1,6 +1,5 @@ package dk.camelot64.kickc.passes; -import dk.camelot64.kickc.CompileLog; import dk.camelot64.kickc.asm.*; import dk.camelot64.kickc.icl.Program; @@ -12,9 +11,9 @@ import java.util.Set; /** * Optimize assembler code by removing all unused labels */ -public class Pass6UnusedLabelElimination extends Pass6AsmOptimization { +public class Pass5UnusedLabelElimination extends Pass5AsmOptimization { - public Pass6UnusedLabelElimination(Program program) { + public Pass5UnusedLabelElimination(Program program) { super(program); } diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log index 33a55c049..856e2ee21 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log @@ -1201,7 +1201,7 @@ Re-allocated ZP register from zp byte:6 to zp byte:5 Removing instruction jmp b1 Removing instruction jmp b3 Removing instruction jmp bend -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -1290,7 +1290,7 @@ Removing instruction b1_from_bbegin: Removing instruction b1_from_b3: Removing instruction b3_from_b1: Removing instruction bend: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -1372,7 +1372,7 @@ b3_from_b2: Removing instruction bbegin: Removing instruction b3_from_b2: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] phi from @begin to @1 @@ -1451,7 +1451,7 @@ b2: jmp b3 Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] phi from @begin to @1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log index be47fd22b..5915b99ef 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log @@ -693,7 +693,7 @@ MISSING FRAGMENTS Removing instruction jmp bend Removing instruction jmp b1 Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -741,7 +741,7 @@ main: { Replacing label b1_from_b1 with b1 Removing instruction b1_from_b1: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -790,7 +790,7 @@ Removing instruction bbegin: Removing instruction bend: Removing instruction b1_from_main: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -832,7 +832,7 @@ main: { } Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log index 700498432..d130920b2 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log @@ -4467,7 +4467,7 @@ Removing instruction jmp b3 Removing instruction jmp breturn Removing instruction jmp b1 Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -4723,7 +4723,7 @@ Removing instruction b2_from_b1: Removing instruction b2_from_b2: Removing instruction b3_from_b3: Removing instruction b1_from_b1: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -4971,7 +4971,7 @@ Removing instruction b3_from_b4: Removing instruction breturn: Removing instruction b1_from_prepare: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -5192,7 +5192,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b3 Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -5401,7 +5401,7 @@ prepare: { Replacing label b3_from_b3 with b3 Removing instruction b3_from_b3: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -5608,7 +5608,7 @@ prepare: { } Removing instruction jmp b3 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log index 8aa462366..336189d29 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log @@ -442,7 +442,7 @@ Uplifting [] best 405 combination reg byte a [ s#2 s#4 s#1 ] reg byte x [ i#2 i# Removing instruction jmp b1 Removing instruction jmp b3 Removing instruction jmp bend -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -492,7 +492,7 @@ Removing instruction b1_from_bbegin: Removing instruction b1_from_b3: Removing instruction b3_from_b1: Removing instruction bend: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -535,7 +535,7 @@ b3_from_b2: Removing instruction bbegin: Removing instruction b3_from_b2: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] phi from @begin to @1 @@ -575,7 +575,7 @@ b2: jmp b3 Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] phi from @begin to @1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log index 244fa35a4..ef849ae8d 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log @@ -820,7 +820,7 @@ Removing instruction jmp b3 Removing instruction jmp breturn Removing instruction jmp b1 Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -883,7 +883,7 @@ Replacing label b1_from_b3 with b1 Replacing label b1_from_b1 with b1 Removing instruction b1_from_b3: Removing instruction b1_from_b1: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -947,7 +947,7 @@ Removing instruction b3: Removing instruction breturn: Removing instruction b1_from_nest: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -999,7 +999,7 @@ nest: { Removing instruction jmp b1 Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log index 56f52fa59..9eda4511d 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log @@ -2118,7 +2118,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b3 Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -2273,7 +2273,7 @@ Removing instruction b2_from_b5: Removing instruction b1_from_b3: Removing instruction b2_from_b1: Removing instruction b2_from_b2: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -2417,7 +2417,7 @@ Removing instruction breturn: Removing instruction b1_from_nest2: Removing instruction b3: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -2541,7 +2541,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b1 Removing instruction jmp b2 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log index def53ba56..6367100cf 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log @@ -608,7 +608,7 @@ Removing instruction jmp bend Removing instruction jmp b1 Removing instruction jmp breturn Removing instruction jmp b5 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -669,7 +669,7 @@ Removing instruction breturn: Removing instruction b5: Removing instruction b1_from_b5: Removing instruction b1_from_b4: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/minus.log b/src/main/java/dk/camelot64/kickc/test/ref/minus.log index 84faf807b..041710afc 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/minus.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/minus.log @@ -355,7 +355,7 @@ Uplift Scope [] 31.17: zp byte:2 [ i#2 i#1 ] 22: zp byte:3 [ $1 ] Uplifting [] best 285 combination reg byte x [ i#2 i#1 ] reg byte a [ $1 ] Removing instruction jmp b1 Removing instruction jmp bend -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -386,7 +386,7 @@ bend: Replacing label b1_from_b1 with b1 Removing instruction b1_from_bbegin: Removing instruction b1_from_b1: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -414,7 +414,7 @@ bend: Removing instruction bbegin: Removing instruction bend: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] phi from @begin to @1 @@ -439,7 +439,7 @@ b1: //SEG10 @end Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] phi from @begin to @1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log b/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log index d66451813..d5eef85d5 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log @@ -810,7 +810,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp breturn Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -875,7 +875,7 @@ Removing instruction inccnt_from_b1: Removing instruction b2: Removing instruction breturn: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/modglobalmin.log b/src/main/java/dk/camelot64/kickc/test/ref/modglobalmin.log index dfe258cbc..5623b3492 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/modglobalmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/modglobalmin.log @@ -636,7 +636,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp breturn Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -692,7 +692,7 @@ Removing instruction inccnt_from_b1: Removing instruction b2: Removing instruction breturn: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log index 8f3ceb921..331d47d78 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log @@ -2129,7 +2129,7 @@ Removing instruction jmp b1 Removing instruction jmp breturn Removing instruction jmp b1 Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -2317,7 +2317,7 @@ Removing instruction b1_from_b2: Removing instruction b1_from_lvalue: Removing instruction breturn: Removing instruction b1_from_b2: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.log b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.log index 465a989e9..783575c63 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.log @@ -504,7 +504,7 @@ Uplifting [] best 235 combination Removing instruction jmp bend Removing instruction jmp b1 Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -544,7 +544,7 @@ Removing instruction bend: Removing instruction b1_from_main: Removing instruction breturn: Removing instruction b1_from_b2: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.log b/src/main/java/dk/camelot64/kickc/test/ref/summin.log index e20faf477..4fbeccdd8 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.log @@ -597,7 +597,7 @@ Removing instruction jmp b3 Removing instruction jmp b4 Removing instruction jmp bend Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -659,7 +659,7 @@ sum: { } Removing instruction sum_from_bbegin: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -727,7 +727,7 @@ Removing instruction sum_from_b3: Removing instruction b4: Removing instruction bend: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call sum param-assignment [ sum::return#0 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log index d26a2099b..41de9a46b 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log @@ -240,7 +240,7 @@ Uplifting [main] best 24 combination Uplifting [] best 24 combination Removing instruction jmp bend Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -262,7 +262,7 @@ main: { Removing instruction bbegin: Removing instruction bend: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/voronoi.log b/src/main/java/dk/camelot64/kickc/test/ref/voronoi.log index ba7140c26..732053603 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/voronoi.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/voronoi.log @@ -7523,7 +7523,7 @@ Removing instruction jmp breturn Removing instruction jmp b1 Removing instruction jmp breturn Removing instruction jmp breturn -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: @@ -8046,7 +8046,7 @@ Removing instruction b8_from_b7: Removing instruction b11_from_b10: Removing instruction b13_from_b11: Removing instruction b1_from_b1: -Succesful ASM optimization Pass6RedundantLabelElimination +Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: @@ -8564,7 +8564,7 @@ Removing instruction b8_from_b6: Removing instruction b1_from_initscreen: Removing instruction breturn: Removing instruction breturn: -Succesful ASM optimization Pass6UnusedLabelElimination +Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ] @@ -9034,7 +9034,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b1 Removing instruction jmp b1 -Succesful ASM optimization Pass6NextJumpElimination +Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin //SEG1 [0] call main param-assignment [ ]