1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-14 23:04:57 +00:00

Fixed cross-scope aliasing. Improved assignment ASM for register copies.

This commit is contained in:
jespergravgaard 2017-07-29 13:41:47 +02:00
parent d159163f21
commit c12c45b5bd
21 changed files with 567 additions and 311 deletions

View File

@ -10,7 +10,9 @@ import org.antlr.v4.runtime.*;
import java.util.ArrayList;
import java.util.List;
/** Perform KickC compilation and optimizations*/
/**
* Perform KickC compilation and optimizations
*/
public class Compiler {
public static class CompilationResult {
@ -84,7 +86,7 @@ public class Compiler {
}
}
public AsmProgram pass4GenerateAsm(Program program, CompileLog log) {
public AsmProgram pass4GenerateAsm(Program program, CompileLog log) {
Pass4CodeGeneration pass4CodeGeneration = new Pass4CodeGeneration(program);
AsmProgram asmProgram = pass4CodeGeneration.generate();
@ -97,11 +99,11 @@ public class Compiler {
private void pass3RegisterAllocation(Program program, CompileLog log) {
Pass3BlockSequencePlanner pass3BlockSequencePlanner = new Pass3BlockSequencePlanner(program, log);
pass3BlockSequencePlanner.plan();
new Pass3BlockSequencePlanner(program, log).plan();
// Phi lifting ensures that all variables in phi-blocks are in different live range equivalence classes
new Pass3PhiLifting(program, log).perform();
pass3BlockSequencePlanner.plan();
new Pass3BlockSequencePlanner(program, log).plan();
log.append("CONTROL FLOW GRAPH - PHI LIFTED");
log.append(program.getGraph().toString(program.getScope()));
pass2AssertSSA(program, log);
@ -111,9 +113,10 @@ public class Compiler {
log.append(program.getGraph().toString(program.getScope()));
pass2AssertSSA(program, log);
// 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, log).optimize();
new Pass2CullEmptyBlocks(program, log).optimize();
pass3BlockSequencePlanner.plan();
new Pass3BlockSequencePlanner(program, log).plan();
new Pass3LiveRangesAnalysis(program, log).findLiveRanges();
log.append("CONTROL FLOW GRAPH - PHI MEM COALESCED");
log.append(program.getGraph().toString(program.getScope()));
@ -136,15 +139,17 @@ public class Compiler {
log.append(program.getGraph().getLoopSet().toString());
new Pass3ZeroPageAllocation(program, log).allocate();
new Pass3VariableRegisterWeightAnalysis(program, log).findWeights();
new Pass3ZeroPageCoalesce(program, log).allocate();
new Pass3RegistersFinalize(program, log).allocate();
}
public void pass2OptimizeSSA(Program program, CompileLog log) {
public void pass2OptimizeSSA(Program program, CompileLog log) {
List<Pass2SsaOptimization> optimizations = new ArrayList<>();
optimizations.add(new Pass2CullEmptyBlocks(program, log));
optimizations.add(new Pass2ConstantPropagation(program, log));
@ -176,6 +181,7 @@ public class Compiler {
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) {
@ -183,57 +189,57 @@ public class Compiler {
}
}
public Program pass1GenerateSSA(KickCParser.FileContext file, CompileLog log) {
public Program pass1GenerateSSA(KickCParser.FileContext file, CompileLog log) {
Pass1GenerateStatementSequence pass1GenerateStatementSequence1 = new Pass1GenerateStatementSequence(log);
pass1GenerateStatementSequence1.generate(file);
Pass1GenerateStatementSequence pass1GenerateStatementSequence = pass1GenerateStatementSequence1;
StatementSequence statementSequence = pass1GenerateStatementSequence.getSequence();
ProgramScope programScope = pass1GenerateStatementSequence.getProgramScope();
StatementSequence statementSequence = pass1GenerateStatementSequence.getSequence();
ProgramScope programScope = pass1GenerateStatementSequence.getProgramScope();
Pass1TypeInference pass1TypeInference = new Pass1TypeInference(programScope);
pass1TypeInference.inferTypes(statementSequence);
log.append("PROGRAM");
log.append(statementSequence.toString(programScope));
log.append("SYMBOLS");
log.append(programScope.getSymbolTableContents());
log.append(statementSequence.toString(programScope));
log.append("SYMBOLS");
log.append(programScope.getSymbolTableContents());
Pass1GenerateControlFlowGraph pass1GenerateControlFlowGraph = new Pass1GenerateControlFlowGraph(programScope);
ControlFlowGraph controlFlowGraph = pass1GenerateControlFlowGraph.generate(statementSequence);
Pass1GenerateControlFlowGraph pass1GenerateControlFlowGraph = new Pass1GenerateControlFlowGraph(programScope);
ControlFlowGraph controlFlowGraph = pass1GenerateControlFlowGraph.generate(statementSequence);
Program program = new Program(programScope, controlFlowGraph);
Program program = new Program(programScope, controlFlowGraph);
log.append("INITIAL CONTROL FLOW GRAPH");
log.append("INITIAL CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program.getScope()));
Pass1EliminateEmptyBlocks pass1EliminateEmptyBlocks = new Pass1EliminateEmptyBlocks(program, log);
boolean blockEliminated = pass1EliminateEmptyBlocks.eliminate();
if (blockEliminated) {
log.append("CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program.getScope()));
Pass1EliminateEmptyBlocks pass1EliminateEmptyBlocks = new Pass1EliminateEmptyBlocks(program, log);
boolean blockEliminated = pass1EliminateEmptyBlocks.eliminate();
if(blockEliminated) {
log.append("CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program.getScope()));
}
}
Pass1ProcedureCallParameters pass1ProcedureCallParameters =
new Pass1ProcedureCallParameters(program);
program.setGraph(pass1ProcedureCallParameters.generate());
log.append("CONTROL FLOW GRAPH WITH ASSIGNMENT CALL");
log.append(program.getGraph().toString(program.getScope()));
new Pass1ProcedureCallParameters(program);
program.setGraph(pass1ProcedureCallParameters.generate());
log.append("CONTROL FLOW GRAPH WITH ASSIGNMENT CALL");
log.append(program.getGraph().toString(program.getScope()));
Pass1GenerateSingleStaticAssignmentForm pass1GenerateSingleStaticAssignmentForm =
new Pass1GenerateSingleStaticAssignmentForm(log, program);
pass1GenerateSingleStaticAssignmentForm.generate();
Pass1GenerateSingleStaticAssignmentForm pass1GenerateSingleStaticAssignmentForm =
new Pass1GenerateSingleStaticAssignmentForm(log, program);
pass1GenerateSingleStaticAssignmentForm.generate();
log.append("CONTROL FLOW GRAPH SSA");
log.append(program.getGraph().toString(program.getScope()));
log.append("CONTROL FLOW GRAPH SSA");
log.append(program.getGraph().toString(program.getScope()));
Pass1ProcedureCallsReturnValue pass1ProcedureCallsReturnValue =
new Pass1ProcedureCallsReturnValue(program);
program.setGraph(pass1ProcedureCallsReturnValue.generate());
log.append("CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN");
log.append(program.getGraph().toString(program.getScope()));
Pass1ProcedureCallsReturnValue pass1ProcedureCallsReturnValue =
new Pass1ProcedureCallsReturnValue(program);
program.setGraph(pass1ProcedureCallsReturnValue.generate());
log.append("CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN");
log.append(program.getGraph().toString(program.getScope()));
return program;
}
public KickCParser.FileContext pass0ParseInput(final CharStream input, CompileLog log) {
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));

View File

@ -30,6 +30,18 @@ public class LiveRangeVariables {
return liveRange.add(statement);
}
/**
* Add an empty alive range for a variable
* @param variable The variable
*/
public void addEmptyAlive(VariableRef variable) {
LiveRange liveRange = liveRanges.get(variable);
if (liveRange == null) {
liveRange = new LiveRange();
liveRanges.put(variable, liveRange);
}
}
/**
* Get all variables alive at a specific statement
* @param statement The statement

View File

@ -53,5 +53,10 @@ public class Pass1ProcedureCallsReturnValue extends ControlFlowGraphCopyVisitor
return null;
}
@Override
public StatementReturn visitReturn(StatementReturn origReturn) {
addStatementToCurrentBlock(new StatementReturn(null));
return null;
}
}

View File

@ -269,7 +269,11 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
if (assignment.getrValue1() == null && assignment.getOperator() == null && assignment.getrValue2() instanceof VariableRef) {
// Alias assignment
VariableRef alias = (VariableRef) assignment.getrValue2();
aliases.add(variable, alias);
if(variable.getScopeNames().equals(alias.getScopeNames())){
aliases.add(variable, alias);
} else {
log.append("Not aliassing across scopes: "+variable+" "+alias);
}
}
}
return null;
@ -283,7 +287,11 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
if (phiRValue.getrValue() instanceof VariableRef) {
VariableRef variable = phiVariable.getVariable();
VariableRef alias = (VariableRef) phiRValue.getrValue();
aliases.add(variable, alias);
if(variable.getScopeNames().equals(alias.getScopeNames())){
aliases.add(variable, alias);
} else {
log.append("Not aliassing across scopes: "+variable+" "+alias);
}
}
}
}

View File

@ -0,0 +1,31 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.icl.ControlFlowGraphBaseVisitor;
import dk.camelot64.kickc.icl.Program;
import dk.camelot64.kickc.icl.StatementReturn;
/** Asserts that the program does not contain returns with values (as they have been replaced with assignments) */
public class Pass2AssertNoReturnValues extends Pass2SsaAssertion {
public Pass2AssertNoReturnValues(Program program) {
super(program);
}
@Override
public void check() throws AssertionFailed {
ControlFlowGraphBaseVisitor<Void> checkCalls = new ControlFlowGraphBaseVisitor<Void>() {
@Override
public Void visitReturn(StatementReturn aReturn) {
if(aReturn.getValue()!=null) {
throw new AssertionFailed("No return values allowed! "+ aReturn);
}
return null;
}
};
checkCalls.visitGraph(getGraph());
}
}

View File

@ -22,11 +22,14 @@ public class Pass3LiveRangesAnalysis {
}
public void findLiveRanges() {
generateStatementIndexes();
LiveRangeVariables liveRanges = initializeLiveRanges();
program.getScope().setLiveRangeVariables(liveRanges);
//log.append("CONTROL FLOW GRAPH - LIVE RANGES");
//log.append(program.getGraph().toString(program.getScope()));
boolean propagating;
do {
propagating = propagateLiveRanges(liveRanges);
@ -35,6 +38,7 @@ public class Pass3LiveRangesAnalysis {
//log.append("CONTROL FLOW GRAPH - LIVE RANGES");
//log.append(program.getGraph().toString(program.getScope()));
} while (propagating);
program.getScope().setLiveRangeVariables(liveRanges);
}
@ -164,7 +168,9 @@ public class Pass3LiveRangesAnalysis {
@Override
public Void visitReturn(StatementReturn aReturn) {
addInitialLiveRange(aReturn.getValue());
if (aReturn.getValue() != null) {
addInitialLiveRange(aReturn.getValue());
}
return null;
}
@ -196,7 +202,7 @@ public class Pass3LiveRangesAnalysis {
* @return true if any propagation was done. (and more propagation is necessary to complete the live ranges)
*/
private boolean propagateLiveRanges(LiveRangeVariables liveRanges) {
LiveRangePropagator liveRangePropagator = new LiveRangePropagator(program, liveRanges);
LiveRangePropagator liveRangePropagator = new LiveRangePropagator(program, liveRanges, log);
return liveRangePropagator.propagate();
}
@ -211,6 +217,7 @@ public class Pass3LiveRangesAnalysis {
* The variable live ranges being propagated.
*/
private LiveRangeVariables liveRanges;
private CompileLog log;
/**
* Has anything been modified.
@ -227,9 +234,10 @@ public class Pass3LiveRangesAnalysis {
*/
private ControlFlowBlock currentBlock;
public LiveRangePropagator(Program program, LiveRangeVariables liveRanges) {
public LiveRangePropagator(Program program, LiveRangeVariables liveRanges, CompileLog log) {
this.program = program;
this.liveRanges = liveRanges;
this.log = log;
this.modified = false;
}
@ -275,6 +283,22 @@ public class Pass3LiveRangesAnalysis {
modified |= liveRanges.addAlive(var, prev);
}
}
// If any lValues do not have a live range (they are never used) - create an empty live range for them
if (defined != null) {
for (LValue lValue : defined) {
if(lValue instanceof VariableRef) {
LiveRange lValLiveRange = liveRanges.getLiveRange((VariableRef) lValue);
if(lValLiveRange==null) {
liveRanges.addEmptyAlive((VariableRef)lValue);
log.append("Adding empty live range for unused variable "+lValue);
}
}
}
}
}
private List<Statement> getPreviousStatements() {
@ -309,6 +333,7 @@ public class Pass3LiveRangesAnalysis {
/**
* Get the last statement executed in a specific block.
* If the block is empty the last statement of the previous block is returned.
*
* @param block The block to examine
* @return The last statement of the block (or the last statement of previous blocks if the block is empty)
*/

View File

@ -10,6 +10,9 @@ import java.util.Map;
/**
* Perform PhiLifting to greatly reduce overlapping of alive intervals for variables.
*
* After phi lifting it is guaranteed that variables in different phi blocks are in different live range equivalence classes.
* <p>
* PhiLifting introduces a large number of new virtual variables (one for each rvalue in phi-functions).
* Most of these are eliminated again by the PhiMemCoalesce pass.
* <p>

View File

@ -0,0 +1,50 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.CompileLog;
import dk.camelot64.kickc.icl.ControlFlowBlock;
import dk.camelot64.kickc.icl.Program;
import dk.camelot64.kickc.icl.Statement;
/**
* Finds register weights for all variables.
*
* The register weight signifies how beneficial it would be for the variable to assigned to a register (instead of zero page).
*
* Uses Loop Depth and Live Ranges plus the statements of the control flow graph.
* <p>
* Based on ComputeWeight from http://compilers.cs.ucla.edu/fernando/projects/soc/reports/short_tech.pdf
*/
public class Pass3VariableRegisterWeightAnalysis {
private Program program;
private CompileLog log;
public Pass3VariableRegisterWeightAnalysis(Program program, CompileLog log) {
this.program = program;
this.log = log;
}
public Program getProgram() {
return program;
}
public CompileLog getLog() {
return log;
}
/** Find register weights for all variables */
public void findWeights() {
for (ControlFlowBlock block : program.getGraph().getAllBlocks()) {
for (Statement statement : block.getStatements()) {
}
}
}
}

View File

@ -68,9 +68,13 @@ public class Pass4CodeGeneration {
}
}
if (!isAlu) {
AsmFragment asmFragment = new AsmFragment(assignment, symbols);
asm.addComment(statement.toString(symbols) + " // " + asmFragment.getSignature());
asmFragment.generate(asm);
if(assignment.getOperator()==null && assignment.getrValue1()==null && isRegisterCopy(lValue, assignment.getrValue2())) {
asm.addComment(lValue.toString(symbols) + " = " + assignment.getrValue2().toString(symbols) + " // register copy "+getRegister(lValue));
} else {
AsmFragment asmFragment = new AsmFragment(assignment, symbols);
asm.addComment(statement.toString(symbols) + " // " + asmFragment.getSignature());
asmFragment.generate(asm);
}
}
} else if (statement instanceof StatementConditionalJump) {
AsmFragment asmFragment = new AsmFragment((StatementConditionalJump) statement, block, symbols, graph);
@ -145,14 +149,20 @@ public class Pass4CodeGeneration {
}
private void genAsmMove(AsmProgram asm, LValue lValue, RValue rValue) {
if (getRegister(lValue).equals(getRegister(rValue))) {
// Do not move from register to itself
asm.addComment(lValue.toString(symbols) + " = " + rValue.toString(symbols) + " // register copy ");
return;
if (isRegisterCopy(lValue, rValue)) {
asm.addComment(lValue.toString(symbols) + " = " + rValue.toString(symbols) + " // register copy "+getRegister(lValue));
} else {
AsmFragment asmFragment = new AsmFragment(lValue, rValue, symbols);
asm.addComment(lValue.toString(symbols) + " = " + rValue.toString(symbols) + " // " + asmFragment.getSignature());
asmFragment.generate(asm);
}
AsmFragment asmFragment = new AsmFragment(lValue, rValue, symbols);
asm.addComment(lValue.toString(symbols) + " = " + rValue.toString(symbols) + " // " + asmFragment.getSignature());
asmFragment.generate(asm);
}
private boolean isRegisterCopy(LValue lValue, RValue rValue) {
return
getRegister(lValue) != null &&
getRegister(rValue) != null &&
getRegister(lValue).equals(getRegister(rValue));
}

View File

@ -1046,10 +1046,10 @@ B1_from_BBEGIN:
sta 2+1
jmp B1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy
// (byte) e#3 = (byte) e#5 // register copy
// (byte) x#2 = (byte) x#1 // register copy
// (byte*) cursor#3 = (byte*) cursor#5 // register copy
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
jmp B1
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // zpiby1=coby1
@ -1073,9 +1073,9 @@ B1:
cmp 5
bcc B2
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy
// (byte) e#5 = (byte) e#1 // register copy
// (byte*) cursor#5 = (byte*) cursor#1 // register copy
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
jmp B3
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
@ -1101,9 +1101,9 @@ B2:
sbc #39
sta 5
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy
// (byte) e#5 = (byte) e#2 // register copy
// (byte*) cursor#5 = (byte*) cursor#2 // register copy
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
jmp B3
Removing instruction jmp B1
@ -1129,10 +1129,10 @@ B1_from_BBEGIN:
sta 2+1
jmp B1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy
// (byte) e#3 = (byte) e#5 // register copy
// (byte) x#2 = (byte) x#1 // register copy
// (byte*) cursor#3 = (byte*) cursor#5 // register copy
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // zpiby1=coby1
ldy #0
@ -1155,9 +1155,9 @@ B1:
cmp 5
bcc B2
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy
// (byte) e#5 = (byte) e#1 // register copy
// (byte*) cursor#5 = (byte*) cursor#1 // register copy
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
lda 4
@ -1181,9 +1181,9 @@ B2:
sbc #39
sta 5
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy
// (byte) e#5 = (byte) e#2 // register copy
// (byte*) cursor#5 = (byte*) cursor#2 // register copy
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
jmp B3
Removing instruction jmp B1
@ -1206,10 +1206,10 @@ B1_from_BBEGIN:
lda #>1024
sta 2+1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy
// (byte) e#3 = (byte) e#5 // register copy
// (byte) x#2 = (byte) x#1 // register copy
// (byte*) cursor#3 = (byte*) cursor#5 // register copy
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // zpiby1=coby1
ldy #0
@ -1232,9 +1232,9 @@ B1:
cmp 5
bcc B2
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy
// (byte) e#5 = (byte) e#1 // register copy
// (byte*) cursor#5 = (byte*) cursor#1 // register copy
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
lda 4
@ -1258,9 +1258,9 @@ B2:
sbc #39
sta 5
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy
// (byte) e#5 = (byte) e#2 // register copy
// (byte*) cursor#5 = (byte*) cursor#2 // register copy
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
jmp B3
FINAL SYMBOL TABLE
@ -1318,10 +1318,10 @@ B1_from_BBEGIN:
lda #>1024
sta 2+1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy
// (byte) e#3 = (byte) e#5 // register copy
// (byte) x#2 = (byte) x#1 // register copy
// (byte*) cursor#3 = (byte*) cursor#5 // register copy
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // zpiby1=coby1
ldy #0
@ -1344,9 +1344,9 @@ B1:
cmp 5
bcc B2
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy
// (byte) e#5 = (byte) e#1 // register copy
// (byte*) cursor#5 = (byte*) cursor#1 // register copy
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
lda 4
@ -1370,8 +1370,8 @@ B2:
sbc #39
sta 5
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy
// (byte) e#5 = (byte) e#2 // register copy
// (byte*) cursor#5 = (byte*) cursor#2 // register copy
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
jmp B3

View File

@ -3920,7 +3920,7 @@ main__B3_from_B11:
main__B3_from_B3:
jmp main__B3
main__B3_from_B6:
// (byte) main::c#2 = (byte) main::c#1 // register copy
// (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2
jmp main__B3
main__B3:
// [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1
@ -3974,20 +3974,20 @@ plot__B1_from_plot:
sta 5
jmp plot__B1
plot__B1_from_B3:
// (byte) plot::y#2 = (byte) plot::y#1 // register copy
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy
// (byte) plot::i#3 = (byte) plot::i#1 // register copy
// (byte) plot::y#2 = (byte) plot::y#1 // register copy zp byte:2
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy zp ptr byte:3
// (byte) plot::i#3 = (byte) plot::i#1 // register copy zp byte:5
jmp plot__B1
plot__B1:
plot__B2_from_B1:
// (byte) plot::x#2 = (byte) 0 // zpby1=coby1
lda #0
sta 6
// (byte) plot::i#2 = (byte) plot::i#3 // register copy
// (byte) plot::i#2 = (byte) plot::i#3 // register copy zp byte:5
jmp plot__B2
plot__B2_from_B2:
// (byte) plot::x#2 = (byte) plot::x#1 // register copy
// (byte) plot::i#2 = (byte) plot::i#1 // register copy
// (byte) plot::x#2 = (byte) plot::x#1 // register copy zp byte:6
// (byte) plot::i#2 = (byte) plot::i#1 // register copy zp byte:5
jmp plot__B2
plot__B2:
// [15] (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 [ plot::i#2 plot::line#2 plot::x#2 plot::$3 plot::y#2 ] // zpby1=cowo1_staridx_zpby2
@ -4037,22 +4037,22 @@ flip__B1_from_flip:
sta 5
jmp flip__B1
flip__B1_from_B4:
// (byte) flip::r#2 = (byte) flip::r#1 // register copy
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::r#2 = (byte) flip::r#1 // register copy zp byte:2
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy zp byte:6
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy zp byte:5
jmp flip__B1
flip__B1:
flip__B2_from_B1:
// (byte) flip::c#2 = (byte) 16 // zpby1=coby1
lda #16
sta 7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy zp byte:5
jmp flip__B2
flip__B2_from_B2:
// (byte) flip::c#2 = (byte) flip::c#1 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::c#2 = (byte) flip::c#1 // register copy zp byte:7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy zp byte:5
jmp flip__B2
flip__B2:
// [26] (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 [ flip::srcIdx#2 flip::dstIdx#3 flip::$0 flip::c#2 flip::r#2 ] // zpby1=cowo1_staridx_zpby2
@ -4090,7 +4090,7 @@ flip__B3_from_B4:
sta 2
jmp flip__B3
flip__B3_from_B3:
// (byte) flip::i#2 = (byte) flip::i#1 // register copy
// (byte) flip::i#2 = (byte) flip::i#1 // register copy zp byte:2
jmp flip__B3
flip__B3:
// [36] (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] // zpby1=cowo1_staridx_zpby2
@ -4116,7 +4116,7 @@ prepare__B1_from_prepare:
sta 2
jmp prepare__B1
prepare__B1_from_B1:
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy zp byte:2
jmp prepare__B1
prepare__B1:
// [42] *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] // ptr_cowo1_zpby1=zpby1
@ -4171,7 +4171,7 @@ main__B3_from_B11:
main__B3_from_B3:
jmp main__B3
main__B3_from_B6:
// (byte) main::c#2 = (byte) main::c#1 // register copy
// (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2
main__B3:
// [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1
lda 53266
@ -4218,19 +4218,19 @@ plot__B1_from_plot:
sta 5
jmp plot__B1
plot__B1_from_B3:
// (byte) plot::y#2 = (byte) plot::y#1 // register copy
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy
// (byte) plot::i#3 = (byte) plot::i#1 // register copy
// (byte) plot::y#2 = (byte) plot::y#1 // register copy zp byte:2
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy zp ptr byte:3
// (byte) plot::i#3 = (byte) plot::i#1 // register copy zp byte:5
plot__B1:
plot__B2_from_B1:
// (byte) plot::x#2 = (byte) 0 // zpby1=coby1
lda #0
sta 6
// (byte) plot::i#2 = (byte) plot::i#3 // register copy
// (byte) plot::i#2 = (byte) plot::i#3 // register copy zp byte:5
jmp plot__B2
plot__B2_from_B2:
// (byte) plot::x#2 = (byte) plot::x#1 // register copy
// (byte) plot::i#2 = (byte) plot::i#1 // register copy
// (byte) plot::x#2 = (byte) plot::x#1 // register copy zp byte:6
// (byte) plot::i#2 = (byte) plot::i#1 // register copy zp byte:5
plot__B2:
// [15] (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 [ plot::i#2 plot::line#2 plot::x#2 plot::$3 plot::y#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4277,21 +4277,21 @@ flip__B1_from_flip:
sta 5
jmp flip__B1
flip__B1_from_B4:
// (byte) flip::r#2 = (byte) flip::r#1 // register copy
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::r#2 = (byte) flip::r#1 // register copy zp byte:2
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy zp byte:6
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B1:
flip__B2_from_B1:
// (byte) flip::c#2 = (byte) 16 // zpby1=coby1
lda #16
sta 7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy zp byte:5
jmp flip__B2
flip__B2_from_B2:
// (byte) flip::c#2 = (byte) flip::c#1 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::c#2 = (byte) flip::c#1 // register copy zp byte:7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B2:
// [26] (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 [ flip::srcIdx#2 flip::dstIdx#3 flip::$0 flip::c#2 flip::r#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4327,7 +4327,7 @@ flip__B3_from_B4:
sta 2
jmp flip__B3
flip__B3_from_B3:
// (byte) flip::i#2 = (byte) flip::i#1 // register copy
// (byte) flip::i#2 = (byte) flip::i#1 // register copy zp byte:2
flip__B3:
// [36] (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] // zpby1=cowo1_staridx_zpby2
ldy 2
@ -4351,7 +4351,7 @@ prepare__B1_from_prepare:
sta 2
jmp prepare__B1
prepare__B1_from_B1:
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy zp byte:2
prepare__B1:
// [42] *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] // ptr_cowo1_zpby1=zpby1
ldy 2
@ -4391,7 +4391,7 @@ main__B3_from_B11:
jmp main__B3
main__B3_from_B3:
main__B3_from_B6:
// (byte) main::c#2 = (byte) main::c#1 // register copy
// (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2
main__B3:
// [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1
lda 53266
@ -4437,18 +4437,18 @@ plot__B1_from_plot:
lda #0
sta 5
plot__B1_from_B3:
// (byte) plot::y#2 = (byte) plot::y#1 // register copy
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy
// (byte) plot::i#3 = (byte) plot::i#1 // register copy
// (byte) plot::y#2 = (byte) plot::y#1 // register copy zp byte:2
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy zp ptr byte:3
// (byte) plot::i#3 = (byte) plot::i#1 // register copy zp byte:5
plot__B1:
plot__B2_from_B1:
// (byte) plot::x#2 = (byte) 0 // zpby1=coby1
lda #0
sta 6
// (byte) plot::i#2 = (byte) plot::i#3 // register copy
// (byte) plot::i#2 = (byte) plot::i#3 // register copy zp byte:5
plot__B2_from_B2:
// (byte) plot::x#2 = (byte) plot::x#1 // register copy
// (byte) plot::i#2 = (byte) plot::i#1 // register copy
// (byte) plot::x#2 = (byte) plot::x#1 // register copy zp byte:6
// (byte) plot::i#2 = (byte) plot::i#1 // register copy zp byte:5
plot__B2:
// [15] (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 [ plot::i#2 plot::line#2 plot::x#2 plot::$3 plot::y#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4494,20 +4494,20 @@ flip__B1_from_flip:
lda #0
sta 5
flip__B1_from_B4:
// (byte) flip::r#2 = (byte) flip::r#1 // register copy
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::r#2 = (byte) flip::r#1 // register copy zp byte:2
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy zp byte:6
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B1:
flip__B2_from_B1:
// (byte) flip::c#2 = (byte) 16 // zpby1=coby1
lda #16
sta 7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy zp byte:5
flip__B2_from_B2:
// (byte) flip::c#2 = (byte) flip::c#1 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::c#2 = (byte) flip::c#1 // register copy zp byte:7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B2:
// [26] (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 [ flip::srcIdx#2 flip::dstIdx#3 flip::$0 flip::c#2 flip::r#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4542,7 +4542,7 @@ flip__B3_from_B4:
lda #0
sta 2
flip__B3_from_B3:
// (byte) flip::i#2 = (byte) flip::i#1 // register copy
// (byte) flip::i#2 = (byte) flip::i#1 // register copy zp byte:2
flip__B3:
// [36] (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] // zpby1=cowo1_staridx_zpby2
ldy 2
@ -4565,7 +4565,7 @@ prepare__B1_from_prepare:
lda #0
sta 2
prepare__B1_from_B1:
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy zp byte:2
prepare__B1:
// [42] *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] // ptr_cowo1_zpby1=zpby1
ldy 2
@ -4598,7 +4598,7 @@ main__B3_from_B11:
sta 2
main__B3_from_B3:
main__B3_from_B6:
// (byte) main::c#2 = (byte) main::c#1 // register copy
// (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2
main__B3:
// [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1
lda 53266
@ -4644,18 +4644,18 @@ plot__B1_from_plot:
lda #0
sta 5
plot__B1_from_B3:
// (byte) plot::y#2 = (byte) plot::y#1 // register copy
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy
// (byte) plot::i#3 = (byte) plot::i#1 // register copy
// (byte) plot::y#2 = (byte) plot::y#1 // register copy zp byte:2
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy zp ptr byte:3
// (byte) plot::i#3 = (byte) plot::i#1 // register copy zp byte:5
plot__B1:
plot__B2_from_B1:
// (byte) plot::x#2 = (byte) 0 // zpby1=coby1
lda #0
sta 6
// (byte) plot::i#2 = (byte) plot::i#3 // register copy
// (byte) plot::i#2 = (byte) plot::i#3 // register copy zp byte:5
plot__B2_from_B2:
// (byte) plot::x#2 = (byte) plot::x#1 // register copy
// (byte) plot::i#2 = (byte) plot::i#1 // register copy
// (byte) plot::x#2 = (byte) plot::x#1 // register copy zp byte:6
// (byte) plot::i#2 = (byte) plot::i#1 // register copy zp byte:5
plot__B2:
// [15] (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 [ plot::i#2 plot::line#2 plot::x#2 plot::$3 plot::y#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4701,20 +4701,20 @@ flip__B1_from_flip:
lda #0
sta 5
flip__B1_from_B4:
// (byte) flip::r#2 = (byte) flip::r#1 // register copy
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::r#2 = (byte) flip::r#1 // register copy zp byte:2
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy zp byte:6
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B1:
flip__B2_from_B1:
// (byte) flip::c#2 = (byte) 16 // zpby1=coby1
lda #16
sta 7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy zp byte:5
flip__B2_from_B2:
// (byte) flip::c#2 = (byte) flip::c#1 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::c#2 = (byte) flip::c#1 // register copy zp byte:7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B2:
// [26] (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 [ flip::srcIdx#2 flip::dstIdx#3 flip::$0 flip::c#2 flip::r#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4749,7 +4749,7 @@ flip__B3_from_B4:
lda #0
sta 2
flip__B3_from_B3:
// (byte) flip::i#2 = (byte) flip::i#1 // register copy
// (byte) flip::i#2 = (byte) flip::i#1 // register copy zp byte:2
flip__B3:
// [36] (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] // zpby1=cowo1_staridx_zpby2
ldy 2
@ -4772,7 +4772,7 @@ prepare__B1_from_prepare:
lda #0
sta 2
prepare__B1_from_B1:
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy zp byte:2
prepare__B1:
// [42] *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] // ptr_cowo1_zpby1=zpby1
ldy 2
@ -4886,7 +4886,7 @@ main__B3_from_B11:
sta 2
main__B3_from_B3:
main__B3_from_B6:
// (byte) main::c#2 = (byte) main::c#1 // register copy
// (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2
main__B3:
// [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1
lda 53266
@ -4932,18 +4932,18 @@ plot__B1_from_plot:
lda #0
sta 5
plot__B1_from_B3:
// (byte) plot::y#2 = (byte) plot::y#1 // register copy
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy
// (byte) plot::i#3 = (byte) plot::i#1 // register copy
// (byte) plot::y#2 = (byte) plot::y#1 // register copy zp byte:2
// (byte*) plot::line#2 = (byte*) plot::line#1 // register copy zp ptr byte:3
// (byte) plot::i#3 = (byte) plot::i#1 // register copy zp byte:5
plot__B1:
plot__B2_from_B1:
// (byte) plot::x#2 = (byte) 0 // zpby1=coby1
lda #0
sta 6
// (byte) plot::i#2 = (byte) plot::i#3 // register copy
// (byte) plot::i#2 = (byte) plot::i#3 // register copy zp byte:5
plot__B2_from_B2:
// (byte) plot::x#2 = (byte) plot::x#1 // register copy
// (byte) plot::i#2 = (byte) plot::i#1 // register copy
// (byte) plot::x#2 = (byte) plot::x#1 // register copy zp byte:6
// (byte) plot::i#2 = (byte) plot::i#1 // register copy zp byte:5
plot__B2:
// [15] (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 [ plot::i#2 plot::line#2 plot::x#2 plot::$3 plot::y#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -4989,20 +4989,20 @@ flip__B1_from_flip:
lda #0
sta 5
flip__B1_from_B4:
// (byte) flip::r#2 = (byte) flip::r#1 // register copy
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::r#2 = (byte) flip::r#1 // register copy zp byte:2
// (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy zp byte:6
// (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B1:
flip__B2_from_B1:
// (byte) flip::c#2 = (byte) 16 // zpby1=coby1
lda #16
sta 7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy zp byte:5
flip__B2_from_B2:
// (byte) flip::c#2 = (byte) flip::c#1 // register copy
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy
// (byte) flip::c#2 = (byte) flip::c#1 // register copy zp byte:7
// (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy zp byte:6
// (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy zp byte:5
flip__B2:
// [26] (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 [ flip::srcIdx#2 flip::dstIdx#3 flip::$0 flip::c#2 flip::r#2 ] // zpby1=cowo1_staridx_zpby2
ldy 5
@ -5037,7 +5037,7 @@ flip__B3_from_B4:
lda #0
sta 2
flip__B3_from_B3:
// (byte) flip::i#2 = (byte) flip::i#1 // register copy
// (byte) flip::i#2 = (byte) flip::i#1 // register copy zp byte:2
flip__B3:
// [36] (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] // zpby1=cowo1_staridx_zpby2
ldy 2
@ -5060,7 +5060,7 @@ prepare__B1_from_prepare:
lda #0
sta 2
prepare__B1_from_B1:
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy
// (byte) prepare::i#2 = (byte) prepare::i#1 // register copy zp byte:2
prepare__B1:
// [42] *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] // ptr_cowo1_zpby1=zpby1
ldy 2

View File

@ -384,8 +384,8 @@ B1_from_BBEGIN:
sta 2
jmp B1
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
@ -395,7 +395,7 @@ B1:
bcs B2
!:
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
jmp B3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
@ -412,7 +412,7 @@ B2:
adc 2
sta 3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
jmp B3
Removing instruction jmp B1
@ -430,8 +430,8 @@ B1_from_BBEGIN:
sta 2
jmp B1
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
lda 2
@ -440,7 +440,7 @@ B1:
bcs B2
!:
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
dec 2
@ -455,7 +455,7 @@ B2:
adc 2
sta 3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
jmp B3
Removing instruction jmp B1
@ -470,8 +470,8 @@ B1_from_BBEGIN:
lda #10
sta 2
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
lda 2
@ -480,7 +480,7 @@ B1:
bcs B2
!:
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
dec 2
@ -495,7 +495,7 @@ B2:
adc 2
sta 3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
jmp B3
FINAL SYMBOL TABLE
@ -525,8 +525,8 @@ B1_from_BBEGIN:
lda #10
sta 2
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
lda 2
@ -535,7 +535,7 @@ B1:
bcs B2
!:
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
dec 2
@ -550,6 +550,6 @@ B2:
adc 2
sta 3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
jmp B3

View File

@ -735,7 +735,7 @@ main__B1_from_main:
sta 2
jmp main__B1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
jmp main__B1
main__B1:
jsr nest
@ -756,7 +756,7 @@ nest__B1_from_nest:
sta 3
jmp nest__B1
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
jmp nest__B1
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // coptr1=zpby1
@ -789,7 +789,7 @@ main__B1_from_main:
sta 2
jmp main__B1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
main__B1:
jsr nest
main__B3:
@ -807,7 +807,7 @@ nest__B1_from_nest:
sta 3
jmp nest__B1
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // coptr1=zpby1
lda 3
@ -833,7 +833,7 @@ main__B1_from_main:
lda #100
sta 2
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
main__B1:
jsr nest
main__B3:
@ -850,7 +850,7 @@ nest__B1_from_nest:
lda #100
sta 3
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // coptr1=zpby1
lda 3
@ -896,7 +896,7 @@ main__B1_from_main:
lda #100
sta 2
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
main__B1:
jsr nest
main__B3:
@ -913,7 +913,7 @@ nest__B1_from_nest:
lda #100
sta 3
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // coptr1=zpby1
lda 3

View File

@ -1838,7 +1838,7 @@ main__B1_from_main:
sta 2
jmp main__B1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
jmp main__B1
main__B1:
main__B2_from_B1:
@ -1847,7 +1847,7 @@ main__B2_from_B1:
sta 3
jmp main__B2
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
jmp main__B2
main__B2:
jsr nest1
@ -1875,7 +1875,7 @@ nest1__B1_from_nest1:
sta 4
jmp nest1__B1
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
jmp nest1__B1
nest1__B1:
nest1__B2_from_B1:
@ -1884,7 +1884,7 @@ nest1__B2_from_B1:
sta 5
jmp nest1__B2
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
jmp nest1__B2
nest1__B2:
jsr nest2
@ -1912,7 +1912,7 @@ nest2__B1_from_nest2:
sta 6
jmp nest2__B1
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
jmp nest2__B1
nest2__B1:
nest2__B2_from_B1:
@ -1921,7 +1921,7 @@ nest2__B2_from_B1:
sta 7
jmp nest2__B2
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
jmp nest2__B2
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // coptr1=zpby1
@ -1970,7 +1970,7 @@ main__B1_from_main:
sta 2
jmp main__B1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
main__B1:
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
@ -1978,7 +1978,7 @@ main__B2_from_B1:
sta 3
jmp main__B2
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
main__B2:
jsr nest1
main__B5:
@ -2002,7 +2002,7 @@ nest1__B1_from_nest1:
sta 4
jmp nest1__B1
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
nest1__B1:
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
@ -2010,7 +2010,7 @@ nest1__B2_from_B1:
sta 5
jmp nest1__B2
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
nest1__B2:
jsr nest2
nest1__B5:
@ -2034,7 +2034,7 @@ nest2__B1_from_nest2:
sta 6
jmp nest2__B1
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
nest2__B1:
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
@ -2042,7 +2042,7 @@ nest2__B2_from_B1:
sta 7
jmp nest2__B2
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // coptr1=zpby1
lda 7
@ -2078,14 +2078,14 @@ main__B1_from_main:
lda #100
sta 2
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
main__B1:
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
lda #100
sta 3
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
main__B2:
jsr nest1
main__B5:
@ -2108,14 +2108,14 @@ nest1__B1_from_nest1:
lda #100
sta 4
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
nest1__B1:
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
lda #100
sta 5
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
nest1__B2:
jsr nest2
nest1__B5:
@ -2138,14 +2138,14 @@ nest2__B1_from_nest2:
lda #100
sta 6
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
nest2__B1:
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
lda #100
sta 7
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // coptr1=zpby1
lda 7
@ -2224,14 +2224,14 @@ main__B1_from_main:
lda #100
sta 2
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
main__B1:
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
lda #100
sta 3
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
main__B2:
jsr nest1
main__B5:
@ -2254,14 +2254,14 @@ nest1__B1_from_nest1:
lda #100
sta 4
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
nest1__B1:
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
lda #100
sta 5
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
nest1__B2:
jsr nest2
nest1__B5:
@ -2284,14 +2284,14 @@ nest2__B1_from_nest2:
lda #100
sta 6
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
nest2__B1:
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
lda #100
sta 7
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // coptr1=zpby1
lda 7

View File

@ -427,15 +427,15 @@ B5:
// [4] (byte) s#2 ← -- (byte) s#3 [ i#1 s#2 ] // zpby1=_dec_zpby1
dec 3
B1_from_B5:
// (byte) s#3 = (byte) s#2 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#2 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
B4:
// [5] (byte) s#1 ← ++ (byte) s#3 [ i#1 s#1 ] // zpby1=_inc_zpby1
inc 3
B1_from_B4:
// (byte) s#3 = (byte) s#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#1 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
Removing instruction jmp B1
@ -469,15 +469,15 @@ B5:
// [4] (byte) s#2 ← -- (byte) s#3 [ i#1 s#2 ] // zpby1=_dec_zpby1
dec 3
B1_from_B5:
// (byte) s#3 = (byte) s#2 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#2 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
B4:
// [5] (byte) s#1 ← ++ (byte) s#3 [ i#1 s#1 ] // zpby1=_inc_zpby1
inc 3
B1_from_B4:
// (byte) s#3 = (byte) s#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#1 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
Removing instruction bne B2
@ -508,15 +508,15 @@ B5:
// [4] (byte) s#2 ← -- (byte) s#3 [ i#1 s#2 ] // zpby1=_dec_zpby1
dec 3
B1_from_B5:
// (byte) s#3 = (byte) s#2 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#2 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
B4:
// [5] (byte) s#1 ← ++ (byte) s#3 [ i#1 s#1 ] // zpby1=_inc_zpby1
inc 3
B1_from_B4:
// (byte) s#3 = (byte) s#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#1 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
FINAL SYMBOL TABLE
@ -563,14 +563,14 @@ B5:
// [4] (byte) s#2 ← -- (byte) s#3 [ i#1 s#2 ] // zpby1=_dec_zpby1
dec 3
B1_from_B5:
// (byte) s#3 = (byte) s#2 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#2 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
B4:
// [5] (byte) s#1 ← ++ (byte) s#3 [ i#1 s#1 ] // zpby1=_inc_zpby1
inc 3
B1_from_B4:
// (byte) s#3 = (byte) s#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy
// (byte) s#3 = (byte) s#1 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1

View File

@ -301,7 +301,7 @@ B1_from_BBEGIN:
sta 2
jmp B1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
jmp B1
B1:
// [1] (byte~) $0 ← (byte) 2 + (byte) i#2 [ i#2 $0 ] // zpby1=coby1_plus_zpby2
@ -338,7 +338,7 @@ B1_from_BBEGIN:
sta 2
jmp B1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
B1:
// [1] (byte~) $0 ← (byte) 2 + (byte) i#2 [ i#2 $0 ] // zpby1=coby1_plus_zpby2
lda #2
@ -371,7 +371,7 @@ B1_from_BBEGIN:
lda #5
sta 2
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
B1:
// [1] (byte~) $0 ← (byte) 2 + (byte) i#2 [ i#2 $0 ] // zpby1=coby1_plus_zpby2
lda #2
@ -416,7 +416,7 @@ B1_from_BBEGIN:
lda #5
sta 2
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
B1:
// [1] (byte~) $0 ← (byte) 2 + (byte) i#2 [ i#2 $0 ] // zpby1=coby1_plus_zpby2
lda #2

View File

@ -6,12 +6,19 @@ sum_from_BBEGIN:
sta 2
jsr sum
B2:
lda 2
sta 4
sum_from_B2:
lda #13
sta 3
lda #9
sta 2
jsr sum
B3:
lda 4
clc
adc 2
sta 4
BEND:
sum:
lda 2

View File

@ -1,15 +1,20 @@
@BEGIN: from
[0] call sum param-assignment [ ]
[0] call sum param-assignment [ sum::return#0 s1#0 ]
to:@2
@2: from @BEGIN
[1] call sum param-assignment [ ]
[1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ]
[2] call sum param-assignment [ sum::return#0 s1#0 ]
to:@3
@3: from @2
[3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ]
[4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ]
to:@END
@END: from @2
@END: from @3
sum: from @2 @BEGIN
[2] (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) [ sum::a#2 sum::b#2 ]
[2] (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) [ sum::a#2 sum::b#2 ]
[3] (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ s1#0 ]
[5] (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) [ s1#0 sum::a#2 sum::b#2 ]
[5] (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) [ s1#0 sum::a#2 sum::b#2 ]
[6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ]
to:sum::@return
sum::@return: from sum
[4] return (byte) s1#0 [ ]
[7] return [ sum::return#0 s1#0 ]
to:@RETURN

View File

@ -1,5 +1,6 @@
byte s1=sum(1,2);
byte s2=sum(9,13);
byte s3=s1+s2;
byte sum(byte a, byte b) {
return a+b;
}
@ -9,6 +10,8 @@ PROGRAM
(byte) s1 ← (byte~) $0
(byte~) $1 ← call sum (byte) 9 (byte) 13
(byte) s2 ← (byte~) $1
(byte~) $2 ← (byte) s1 + (byte) s2
(byte) s3 ← (byte~) $2
proc (byte()) sum((byte) sum::a , (byte) sum::b)
(byte~) sum::$0 ← (byte) sum::a + (byte) sum::b
(byte) sum::return ← (byte~) sum::$0
@ -21,8 +24,10 @@ sum::@return:
SYMBOLS
(byte~) $0
(byte~) $1
(byte~) $2
(byte) s1
(byte) s2
(byte) s3
(byte()) sum((byte) sum::a , (byte) sum::b)
(byte~) sum::$0
(label) sum::@return
@ -37,6 +42,8 @@ INITIAL CONTROL FLOW GRAPH
(byte) s1 ← (byte~) $0
(byte~) $1 ← call sum (byte) 9 (byte) 13
(byte) s2 ← (byte~) $1
(byte~) $2 ← (byte) s1 + (byte) s2
(byte) s3 ← (byte~) $2
to:@1
sum: from
(byte~) sum::$0 ← (byte) sum::a + (byte) sum::b
@ -60,6 +67,8 @@ CONTROL FLOW GRAPH
(byte) s1 ← (byte~) $0
(byte~) $1 ← call sum (byte) 9 (byte) 13
(byte) s2 ← (byte~) $1
(byte~) $2 ← (byte) s1 + (byte) s2
(byte) s3 ← (byte~) $2
to:@END
sum: from
(byte~) sum::$0 ← (byte) sum::a + (byte) sum::b
@ -87,6 +96,8 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL
@3: from @2
(byte~) $1 ← (byte) sum::return
(byte) s2 ← (byte~) $1
(byte~) $2 ← (byte) s1 + (byte) s2
(byte) s3 ← (byte~) $2
to:@END
sum: from @2 @BEGIN
(byte~) sum::$0 ← (byte) sum::a + (byte) sum::b
@ -114,9 +125,12 @@ CONTROL FLOW GRAPH SSA
(byte) sum::return#1 ← call sum param-assignment
to:@3
@3: from @2
(byte) s1#1 ← phi( @2/(byte) s1#0 )
(byte) sum::return#5 ← phi( @2/(byte) sum::return#1 )
(byte~) $1 ← (byte) sum::return#5
(byte) s2#0 ← (byte~) $1
(byte~) $2 ← (byte) s1#1 + (byte) s2#0
(byte) s3#0 ← (byte~) $2
to:@END
sum: from @2 @BEGIN
(byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 )
@ -148,9 +162,12 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN
(byte) sum::return#1 ← (byte) sum::return#3
to:@3
@3: from @2
(byte) s1#1 ← phi( @2/(byte) s1#0 )
(byte) sum::return#5 ← phi( @2/(byte) sum::return#1 )
(byte~) $1 ← (byte) sum::return#5
(byte) s2#0 ← (byte~) $1
(byte~) $2 ← (byte) s1#1 + (byte) s2#0
(byte) s3#0 ← (byte~) $2
to:@END
sum: from @2 @BEGIN
(byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 )
@ -161,7 +178,7 @@ sum: from @2 @BEGIN
sum::@return: from sum
(byte) sum::return#6 ← phi( sum/(byte) sum::return#2 )
(byte) sum::return#3 ← (byte) sum::return#6
return (byte) sum::return#3
return
to:@RETURN
@END: from @3
@ -183,9 +200,12 @@ CONTROL FLOW GRAPH
(byte) sum::return#1 ← (byte) sum::return#3
to:@3
@3: from @2
(byte) s1#1 ← phi( @2/(byte) s1#0 )
(byte) sum::return#5 ← phi( @2/(byte) sum::return#1 )
(byte~) $1 ← (byte) sum::return#5
(byte) s2#0 ← (byte~) $1
(byte~) $2 ← (byte) s1#1 + (byte) s2#0
(byte) s3#0 ← (byte~) $2
to:@END
sum: from @2 @BEGIN
(byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 )
@ -196,115 +216,132 @@ sum: from @2 @BEGIN
sum::@return: from sum
(byte) sum::return#6 ← phi( sum/(byte) sum::return#2 )
(byte) sum::return#3 ← (byte) sum::return#6
return (byte) sum::return#3
return
to:@RETURN
@END: from @3
Alias (byte) s1#0 = (byte) sum::return#0 (byte) sum::return#3 (byte) sum::return#4 (byte~) $0 (byte) sum::return#1 (byte) sum::return#5 (byte~) $1 (byte) s2#0 (byte) sum::return#2 (byte~) sum::$0 (byte) sum::return#6
Not aliassing across scopes: $0 sum::return#4
Not aliassing across scopes: $1 sum::return#5
Alias (byte) sum::return#0 = (byte) sum::return#3 (byte) sum::return#4 (byte) sum::return#1 (byte) sum::return#5 (byte) sum::return#2 (byte~) sum::$0 (byte) sum::return#6
Alias (byte) s1#0 = (byte~) $0 (byte) s1#1
Alias (byte) s2#0 = (byte~) $1
Alias (byte) s3#0 = (byte~) $2
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@BEGIN: from
call sum param-assignment
to:@2
@2: from @BEGIN
(byte) s1#0 ← (byte) sum::return#0
call sum param-assignment
to:@3
@3: from @2
(byte) s2#0 ← (byte) sum::return#0
(byte) s3#0 ← (byte) s1#0 + (byte) s2#0
to:@END
sum: from @2 @BEGIN
(byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 )
(byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 )
(byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2
(byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2
to:sum::@return
sum::@return: from sum
return (byte) s1#0
return
to:@RETURN
@END: from @3
Culled Empty Block (label) @3
Succesful SSA optimization Pass2CullEmptyBlocks
CONTROL FLOW GRAPH
@BEGIN: from
call sum param-assignment
to:@2
@2: from @BEGIN
call sum param-assignment
to:@END
sum: from @2 @BEGIN
(byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 )
(byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 )
(byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2
to:sum::@return
sum::@return: from sum
return (byte) s1#0
to:@RETURN
@END: from @2
Block Sequence Planned @BEGIN @2 @END sum sum::@return
Block Sequence Planned @BEGIN @2 @END sum sum::@return
Not aliassing across scopes: s1#0 sum::return#0
Not aliassing across scopes: s2#0 sum::return#0
Block Sequence Planned @BEGIN @2 @3 @END sum sum::@return
Block Sequence Planned @BEGIN @2 @3 @END sum sum::@return
CONTROL FLOW GRAPH - PHI LIFTED
@BEGIN: from
call sum param-assignment
to:@2
@2: from @BEGIN
(byte) s1#0 ← (byte) sum::return#0
call sum param-assignment
to:@3
@3: from @2
(byte) s2#0 ← (byte) sum::return#0
(byte) s3#0 ← (byte) s1#0 + (byte) s2#0
to:@END
@END: from @2
@END: from @3
sum: from @2 @BEGIN
(byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 )
(byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 )
(byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2
(byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2
to:sum::@return
sum::@return: from sum
return (byte) s1#0
return
to:@RETURN
Adding empty live range for unused variable s3#0
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
CONTROL FLOW GRAPH - LIVE RANGES
@BEGIN: from
[0] call sum param-assignment [ ]
[0] call sum param-assignment [ sum::return#0 s1#0 ]
to:@2
@2: from @BEGIN
[1] call sum param-assignment [ ]
[1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ]
[2] call sum param-assignment [ sum::return#0 s1#0 ]
to:@3
@3: from @2
[3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ]
[4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ]
to:@END
@END: from @2
@END: from @3
sum: from @2 @BEGIN
[2] (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) [ sum::a#2 sum::b#2 ]
[2] (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) [ sum::a#2 sum::b#2 ]
[3] (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ s1#0 ]
[5] (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) [ s1#0 sum::a#2 sum::b#2 ]
[5] (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) [ s1#0 sum::a#2 sum::b#2 ]
[6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ]
to:sum::@return
sum::@return: from sum
[4] return (byte) s1#0 [ ]
[7] return [ sum::return#0 s1#0 ]
to:@RETURN
Created 2 initial phi equivalence classes
Coalesced down to 2 phi equivalence classes
Block Sequence Planned @BEGIN @2 @END sum sum::@return
Block Sequence Planned @BEGIN @2 @3 @END sum sum::@return
Adding empty live range for unused variable s3#0
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
CONTROL FLOW GRAPH - PHI MEM COALESCED
@BEGIN: from
[0] call sum param-assignment [ ]
[0] call sum param-assignment [ sum::return#0 s1#0 ]
to:@2
@2: from @BEGIN
[1] call sum param-assignment [ ]
[1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ]
[2] call sum param-assignment [ sum::return#0 s1#0 ]
to:@3
@3: from @2
[3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ]
[4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ]
to:@END
@END: from @2
@END: from @3
sum: from @2 @BEGIN
[2] (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) [ sum::a#2 sum::b#2 ]
[2] (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) [ sum::a#2 sum::b#2 ]
[3] (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ s1#0 ]
[5] (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) [ s1#0 sum::a#2 sum::b#2 ]
[5] (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) [ s1#0 sum::a#2 sum::b#2 ]
[6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ]
to:sum::@return
sum::@return: from sum
[4] return (byte) s1#0 [ ]
[7] return [ sum::return#0 s1#0 ]
to:@RETURN
CALL GRAPH
Calls in [] to 0:sum 1:sum
Calls in [] to 0:sum 2:sum
DOMINATORS
@BEGIN dominated by @BEGIN
@2 dominated by @BEGIN @2
@END dominated by @BEGIN @2 @END
@3 dominated by @BEGIN @2 @3
@END dominated by @BEGIN @2 @3 @END
sum dominated by @BEGIN sum
sum::@return dominated by @BEGIN sum::@return sum
@ -320,14 +357,23 @@ Initial phi equivalence classes
Copy Coalesced equivalence classes
[ sum::a#2 ]
[ sum::b#2 ]
Added variable s1#0 to zero page equivalence class [ sum::a#2 s1#0 ]
Added variable s1#0 to zero page equivalence class [ s1#0 ]
Added variable s2#0 to zero page equivalence class [ s2#0 ]
Added variable s3#0 to zero page equivalence class [ s1#0 s3#0 ]
Added variable sum::return#0 to zero page equivalence class [ sum::a#2 sum::return#0 ]
Complete equivalence classes
[ sum::a#2 s1#0 ]
[ sum::a#2 sum::return#0 ]
[ sum::b#2 ]
Allocated zp byte:2 to zp byte:2 [ sum::a#2 s1#0 ]
[ s1#0 s3#0 ]
[ s2#0 ]
Allocated zp byte:2 to zp byte:2 [ sum::a#2 sum::return#0 ]
Allocated zp byte:3 to zp byte:3 [ sum::b#2 ]
Allocated zp byte:4 to zp byte:4 [ s1#0 s3#0 ]
Allocated zp byte:5 to zp byte:5 [ s2#0 ]
Coalescing zero page register [ zp byte:2 [ sum::a#2 sum::return#0 ] ] with [ zp byte:5 [ s2#0 ] ]
Re-allocated ZP register from zp byte:2 to zp byte:2
Re-allocated ZP register from zp byte:3 to zp byte:3
Re-allocated ZP register from zp byte:4 to zp byte:4
INITIAL ASM
BBEGIN:
sum_from_BBEGIN:
@ -340,6 +386,9 @@ sum_from_BBEGIN:
jsr sum
jmp B2
B2:
// [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] // zpby1=zpby2
lda 2
sta 4
sum_from_B2:
// (byte) sum::b#2 = (byte) 13 // zpby1=coby1
lda #13
@ -348,10 +397,18 @@ sum_from_B2:
lda #9
sta 2
jsr sum
jmp B3
B3:
// (byte) s2#0 = (byte) sum::return#0 // register copy zp byte:2
// [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby1_plus_zpby2
lda 4
clc
adc 2
sta 4
jmp BEND
BEND:
sum:
// [3] (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ s1#0 ] // zpby1=zpby1_plus_zpby2
// [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby1_plus_zpby2
lda 2
clc
adc 3
@ -361,6 +418,7 @@ sum__Breturn:
rts
Removing instruction jmp B2
Removing instruction jmp B3
Removing instruction jmp BEND
Removing instruction jmp sum__Breturn
Succesful ASM optimization Pass5NextJumpElimination
@ -375,6 +433,9 @@ sum_from_BBEGIN:
sta 2
jsr sum
B2:
// [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] // zpby1=zpby2
lda 2
sta 4
sum_from_B2:
// (byte) sum::b#2 = (byte) 13 // zpby1=coby1
lda #13
@ -383,9 +444,16 @@ sum_from_B2:
lda #9
sta 2
jsr sum
B3:
// (byte) s2#0 = (byte) sum::return#0 // register copy zp byte:2
// [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby1_plus_zpby2
lda 4
clc
adc 2
sta 4
BEND:
sum:
// [3] (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ s1#0 ] // zpby1=zpby1_plus_zpby2
// [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby1_plus_zpby2
lda 2
clc
adc 3
@ -395,11 +463,15 @@ sum__Breturn:
FINAL SYMBOL TABLE
(label) @2
(label) @3
(label) @BEGIN
(label) @END
(byte) s1
(byte) s1#0 zp byte:2
(byte) s1#0 zp byte:4
(byte) s2
(byte) s2#0 zp byte:2
(byte) s3
(byte) s3#0 zp byte:4
(byte()) sum((byte) sum::a , (byte) sum::b)
(label) sum::@return
(byte) sum::a
@ -407,10 +479,12 @@ FINAL SYMBOL TABLE
(byte) sum::b
(byte) sum::b#2 zp byte:3
(byte) sum::return
(byte) sum::return#0 zp byte:2
zp byte:2 [ sum::a#2 s1#0 ]
zp byte:2 [ sum::a#2 sum::return#0 s2#0 ]
zp byte:3 [ sum::b#2 ]
zp byte:4 [ s1#0 s3#0 ]
FINAL CODE
BBEGIN:
@ -423,6 +497,9 @@ sum_from_BBEGIN:
sta 2
jsr sum
B2:
// [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] // zpby1=zpby2
lda 2
sta 4
sum_from_B2:
// (byte) sum::b#2 = (byte) 13 // zpby1=coby1
lda #13
@ -431,9 +508,16 @@ sum_from_B2:
lda #9
sta 2
jsr sum
B3:
// (byte) s2#0 = (byte) sum::return#0 // register copy zp byte:2
// [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby1_plus_zpby2
lda 4
clc
adc 2
sta 4
BEND:
sum:
// [3] (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ s1#0 ] // zpby1=zpby1_plus_zpby2
// [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby1_plus_zpby2
lda 2
clc
adc 3

View File

@ -1,9 +1,13 @@
(label) @2
(label) @3
(label) @BEGIN
(label) @END
(byte) s1
(byte) s1#0 zp byte:2
(byte) s1#0 zp byte:4
(byte) s2
(byte) s2#0 zp byte:2
(byte) s3
(byte) s3#0 zp byte:4
(byte()) sum((byte) sum::a , (byte) sum::b)
(label) sum::@return
(byte) sum::a
@ -11,4 +15,9 @@
(byte) sum::b
(byte) sum::b#2 zp byte:3
(byte) sum::return
(byte) sum::return#0 zp byte:2
zp byte:2 [ sum::a#2 sum::return#0 s2#0 ]
zp byte:3 [ sum::b#2 ]
zp byte:4 [ s1#0 s3#0 ]

View File

@ -1,5 +1,6 @@
byte s1=sum(1,2);
byte s2=sum(9,13);
byte s3=s1+s2;
byte sum(byte a, byte b) {
return a+b;
}