From 6ddcb9e358f796cd1e0e8610803be9763c45ec28 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 2 Jan 2022 11:51:16 +0100 Subject: [PATCH] Added commandline option to disable long branch fixing. Closes #744 --- src/main/java/dk/camelot64/kickc/Compiler.java | 13 ++++++++++++- src/main/java/dk/camelot64/kickc/KickC.java | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 61c807de8..5ffff9415 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -36,6 +36,9 @@ public class Compiler { /** Disable the entire register uplift. This will create significantly less optimized ASM since registers are not utilized. */ private boolean disableUplift = false; + /** Disable the long branch fix pass. */ + private boolean disableLongBranchFix = false; + /** * Enable loop head constant optimization. It identified whenever a while()/for() has a constant condition on the first iteration and rewrites it. * Currently the optimization is flaky and results in NPE's and wrong values in some programs. @@ -57,6 +60,10 @@ public class Compiler { this.disableUplift = disableUplift; } + public void setDisableLongBranchFix(boolean disableLongBranchFix) { + this.disableLongBranchFix = disableLongBranchFix; + } + public void setWarnFragmentMissing(boolean warnFragmentMissing) { program.setWarnFragmentMissing(warnFragmentMissing); } @@ -759,7 +766,11 @@ public class Compiler { } new Pass5ReindexAsmLines(program).optimize(); - new Pass5FixLongBranches(program).optimize(); + if(disableLongBranchFix) { + getLog().append("LONG BRANCH FIX DISABLED."); + } else { + new Pass5FixLongBranches(program).optimize(); + } getLog().append("\nFINAL SYMBOL TABLE"); getLog().append(program.getScope().toStringVars(program, false)); diff --git a/src/main/java/dk/camelot64/kickc/KickC.java b/src/main/java/dk/camelot64/kickc/KickC.java index 9dddab518..31dbf95c7 100644 --- a/src/main/java/dk/camelot64/kickc/KickC.java +++ b/src/main/java/dk/camelot64/kickc/KickC.java @@ -89,6 +89,9 @@ public class KickC implements Callable { @CommandLine.Option(names = {"-Onouplift"}, description = "Optimization Option. Disable the register uplift allocation phase. This will be much faster but produce significantly slower ASM.") private boolean optimizeNoUplift = false; + @CommandLine.Option(names = {"-Onolongbranchfix"}, description = "Optimization Option. Disable the pass that fixes long branches. This is relevant when using the PCEAS assembler.") + private boolean optimizeDisableLongBranchFix = false; + @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; @@ -306,6 +309,9 @@ public class KickC implements Callable { if(optimizeNoUplift) compiler.setDisableUplift(true); + if(optimizeDisableLongBranchFix) + compiler.setDisableLongBranchFix(true); + if(optimizeUpliftCombinations != null) compiler.setUpliftCombinations(optimizeUpliftCombinations);