1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-21 14:30:21 +00:00

Merge branch 'fix-compiilation-performance-only-coalesce-zeropage' into 'master'

#786 ZP Coalesce optimization

See merge request camelot/kickc!34
This commit is contained in:
Jesper Balman Gravgaard 2023-04-24 05:53:04 +00:00
commit 373b3cab35
2 changed files with 22 additions and 7 deletions

View File

@ -31,7 +31,10 @@ public class Compiler {
private int upliftCombinations = 100; private int upliftCombinations = 100;
/** Enable the zero-page coalesce pass. It takes a lot of time, but limits the zero page usage significantly. */ /** 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. */ /** Disable the entire register uplift. This will create significantly less optimized ASM since registers are not utilized. */
private boolean disableUplift = false; private boolean disableUplift = false;
@ -81,7 +84,11 @@ public class Compiler {
} }
public void enableZeroPageCoalesce() { public void enableZeroPageCoalesce() {
this.enableZeroPageCoalasce = true; this.enableZeroPageCoalesce = true;
}
public void disableCoalesce() {
this.disableCoalesce = true;
} }
void enableLoopHeadConstant() { void enableLoopHeadConstant() {
@ -713,12 +720,15 @@ public class Compiler {
// Register coalesce on assignment (saving bytes & cycles) // Register coalesce on assignment (saving bytes & cycles)
new Pass4MemoryCoalesceAssignment(program).coalesce(); new Pass4MemoryCoalesceAssignment(program).coalesce();
// Register coalesce on call graph (saving ZP) // Coalesce can be completely disabled for compilation speed reasons during programming and testing.
new Pass4MemoryCoalesceCallGraph(program).coalesce(); if(!disableCoalesce) {
// Register coalesce on call graph (saving ZP)
new Pass4MemoryCoalesceCallGraph(program).coalesce();
if(enableZeroPageCoalasce) { if (enableZeroPageCoalesce) {
// Register coalesce using exhaustive search (saving even more ZP - but slow) // Register coalesce using exhaustive search (saving even more ZP - but slow)
new Pass4MemoryCoalesceExhaustive(program).coalesce(); new Pass4MemoryCoalesceExhaustive(program).coalesce();
}
} }
new Pass4RegistersFinalize(program).allocate(true, true); new Pass4RegistersFinalize(program).allocate(true, true);
new Pass4AssertZeropageAllocation(program).check(); new Pass4AssertZeropageAllocation(program).check();

View File

@ -96,6 +96,9 @@ public class KickC implements Callable<Integer> {
@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.") @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; private boolean optimizeZeroPageCoalesce = 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.") @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; private boolean optimizeLoopHeadConstant = false;
@ -319,6 +322,8 @@ public class KickC implements Callable<Integer> {
if(optimizeZeroPageCoalesce) if(optimizeZeroPageCoalesce)
compiler.enableZeroPageCoalesce(); compiler.enableZeroPageCoalesce();
if(optimizeNoCoalesce)
compiler.disableCoalesce();
if(optimizeLoopHeadConstant) if(optimizeLoopHeadConstant)
compiler.enableLoopHeadConstant(); compiler.enableLoopHeadConstant();