From ca791df458272a3f90e56c22c4942860afab3b49 Mon Sep 17 00:00:00 2001 From: Flight_Control Date: Thu, 20 Apr 2023 10:47:41 +0200 Subject: [PATCH] - Coalesce optimization option implemented: - nocoalesce: disables coalesce completely. - Removed the coalesce testing if both classes were equal, as this does not make any sense ... --- .../java/dk/camelot64/kickc/Compiler.java | 24 +++++++++++++------ src/main/java/dk/camelot64/kickc/KickC.java | 8 +++++++ .../kickc/passes/Pass4MemoryCoalesce.java | 3 --- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index cc8b197cd..edb7f84f2 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -31,7 +31,10 @@ public class Compiler { private int upliftCombinations = 100; /** Enable the zero-page coalesce pass. It takes a lot of time, but limits the zero page usage significantly. */ - private boolean enableZeroPageCoalasce = false; + private boolean enableZeroPageCoalesce = false; + + /** Disables coalesce completely, which reduces compile time significantly. */ + private boolean disableCoalesce = false; /** Disable the entire register uplift. This will create significantly less optimized ASM since registers are not utilized. */ private boolean disableUplift = false; @@ -81,7 +84,11 @@ public class Compiler { } public void enableZeroPageCoalesce() { - this.enableZeroPageCoalasce = true; + this.enableZeroPageCoalesce = true; + } + + public void disableCoalesce() { + this.disableCoalesce = true; } void enableLoopHeadConstant() { @@ -712,12 +719,15 @@ public class Compiler { // Register coalesce on assignment (saving bytes & cycles) new Pass4MemoryCoalesceAssignment(program).coalesce(); - // Register coalesce on call graph (saving ZP) - new Pass4MemoryCoalesceCallGraph(program).coalesce(); + // Coalesce can be completely disabled for compilation speed reasons during programming and testing. + if(!disableCoalesce) { + // Register coalesce on call graph (saving ZP) + new Pass4MemoryCoalesceCallGraph(program).coalesce(); - if(enableZeroPageCoalasce) { - // Register coalesce using exhaustive search (saving even more ZP - but slow) - new Pass4MemoryCoalesceExhaustive(program).coalesce(); + if (enableZeroPageCoalesce) { + // Register coalesce using exhaustive search (saving even more ZP - but slow) + new Pass4MemoryCoalesceExhaustive(program).coalesce(); + } } new Pass4RegistersFinalize(program).allocate(true, true); new Pass4AssertZeropageAllocation(program).check(); diff --git a/src/main/java/dk/camelot64/kickc/KickC.java b/src/main/java/dk/camelot64/kickc/KickC.java index e79bf722c..5202df9de 100644 --- a/src/main/java/dk/camelot64/kickc/KickC.java +++ b/src/main/java/dk/camelot64/kickc/KickC.java @@ -96,6 +96,12 @@ public class KickC implements Callable { @CommandLine.Option(names = {"-Ocoalesce"}, description = "Optimization Option. Enables zero-page coalesce pass which limits zero-page usage significantly, but takes a lot of compile time.") private boolean optimizeZeroPageCoalesce = false; + @CommandLine.Option(names = {"-Ofastcoalesce"}, description = "Optimization Option. Enables zero-page only coalesce, which reduces compile time significantly, but with less coalesce optimimzation.") + private boolean optimizeFastCoalesce = false; + + @CommandLine.Option(names = {"-Onocoalesce"}, description = "Optimization Option. Disables coalesce completely, which reduces compile time significantly.") + private boolean optimizeNoCoalesce = false; + @CommandLine.Option(names = {"-Oloophead"}, description = "Optimization Option. Enabled experimental loop-head constant pass which identifies loops where the condition is constant on the first iteration.") private boolean optimizeLoopHeadConstant = false; @@ -319,6 +325,8 @@ public class KickC implements Callable { if(optimizeZeroPageCoalesce) compiler.enableZeroPageCoalesce(); + if(optimizeNoCoalesce) + compiler.disableCoalesce(); if(optimizeLoopHeadConstant) compiler.enableLoopHeadConstant(); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java b/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java index 29163d077..65974bb6f 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java @@ -140,9 +140,6 @@ public abstract class Pass4MemoryCoalesce extends Pass2Base { // Check the both registers are in memory if(!register1.isMem() || !register2.isMem()) return false; - // Check the both registers have the same type - if(!register1.getType().equals(register2.getType())) - return false; if(register1.getType() == Registers.RegisterType.MAIN_MEM) return false; // Check the both registers have the same size