diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 44dfece28..fe299e48b 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -63,30 +63,24 @@ public class Compiler { pass1GenerateStatementSequence.generate(file); StatementSequence statementSequence = pass1GenerateStatementSequence.getSequence(); ProgramScope programScope = pass1GenerateStatementSequence.getProgramScope(); - - statementSequence = (new Pass1FixLvalueLoHi(statementSequence, programScope, log)).fix(); - + statementSequence = new Pass1FixLvalueLoHi(statementSequence, programScope, log).fix(); Pass1TypeInference pass1TypeInference = new Pass1TypeInference(programScope); pass1TypeInference.inferTypes(statementSequence); Program program = new Program(programScope, log); - log.append("PROGRAM"); log.append(statementSequence.toString(program)); log.append("SYMBOLS"); log.append(programScope.getSymbolTableContents(program)); - - Pass1GenerateControlFlowGraph pass1GenerateControlFlowGraph = new Pass1GenerateControlFlowGraph(programScope); - ControlFlowGraph controlFlowGraph = pass1GenerateControlFlowGraph.generate(statementSequence); - program.setGraph(controlFlowGraph); + program.setGraph(new Pass1GenerateControlFlowGraph(programScope).generate(statementSequence)); new Pass1AddTypePromotions(program).execute(); - log.append("INITIAL CONTROL FLOW GRAPH"); log.append(program.getGraph().toString(program)); new Pass1ExtractInlineStrings(program).execute(); new Pass1EliminateUncalledProcedures(program).execute(); + new Pass1EliminateUnusedVars(program).execute(); new Pass1EliminateEmptyBlocks(program).execute(); log.append("CONTROL FLOW GRAPH"); log.append(program.getGraph().toString(program)); diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java index f2dbc99cb..34684a629 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java @@ -159,6 +159,10 @@ public class AsmFragment { } else { return "$ffff & " + getAsmConstant(program, operand, Operator.BOOL_AND.getPrecedence(), codeScope); } + } else if (Operator.INCREMENT.equals(operator) ) { + return getAsmConstant(program, operand, Operator.PLUS.getPrecedence(), codeScope)+"+1"; + } else if (Operator.DECREMENT.equals(operator) ) { + return getAsmConstant(program, operand, Operator.PLUS.getPrecedence(), codeScope)+"-1"; } else { return operator.getOperator() + getAsmConstant(program, operand, operator.getPrecedence(), codeScope); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUnusedVars.java b/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUnusedVars.java new file mode 100644 index 000000000..72a278641 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUnusedVars.java @@ -0,0 +1,131 @@ +package dk.camelot64.kickc.passes; + +import dk.camelot64.kickc.model.*; + +import java.util.*; + +/** + * Eliminate unused variables + */ +public class Pass1EliminateUnusedVars extends Pass1Base { + + public Pass1EliminateUnusedVars(Program program) { + super(program); + } + + @Override + boolean executeStep() { + Collection allUsedVars = getAllVarUsage(); + + boolean modified = false; + for (ControlFlowBlock block : getGraph().getAllBlocks()) { + ListIterator stmtIt = block.getStatements().listIterator(); + while (stmtIt.hasNext()) { + Statement statement = stmtIt.next(); + if (statement instanceof StatementAssignment) { + StatementAssignment assignment = (StatementAssignment) statement; + LValue lValue = assignment.getlValue(); + if (lValue instanceof VariableRef && !allUsedVars.contains(lValue)) { + getLog().append("Eliminating unused variable "+ lValue.toString(getProgram()) + " and assignment "+ assignment.toString(getProgram(), false)); + stmtIt.remove(); + Variable variable = getScope().getVariable((VariableRef) lValue); + variable.getScope().remove(variable); + modified = true; + } + } else if(statement instanceof StatementCall) { + StatementCall call = (StatementCall) statement; + LValue lValue = call.getlValue(); + if(lValue instanceof VariableRef && !allUsedVars.contains(lValue)) { + getLog().append("Eliminating unused variable - keeping the call "+ lValue.toString(getProgram())); + Variable variable = getScope().getVariable((VariableRef) lValue); + variable.getScope().remove(variable); + call.setlValue(null); + modified = true; + } + } + } + } + return modified; + } + + /** + * Get all Variable or Constant usage in RValues. + * + * @return Collection containing VariableRef and ConstantRef for all used vars/constants. + */ + private Collection getAllVarUsage() { + Collection allRvalues = new LinkedHashSet<>(); + for (ControlFlowBlock block : getGraph().getAllBlocks()) { + for (Statement statement : block.getStatements()) { + if (statement instanceof StatementAssignment) { + addLvalueUses(allRvalues, ((StatementAssignment) statement).getlValue()); + addRvalueUses(allRvalues, ((StatementAssignment) statement).getrValue1()); + addRvalueUses(allRvalues, ((StatementAssignment) statement).getrValue2()); + } else if (statement instanceof StatementCall) { + addLvalueUses(allRvalues, ((StatementCall) statement).getlValue()); + for (RValue param : ((StatementCall) statement).getParameters()) { + addRvalueUses(allRvalues, param); + } + } else if (statement instanceof StatementConditionalJump) { + addRvalueUses(allRvalues, ((StatementConditionalJump) statement).getrValue1()); + addRvalueUses(allRvalues, ((StatementConditionalJump) statement).getrValue2()); + } else if (statement instanceof StatementReturn) { + addRvalueUses(allRvalues, ((StatementReturn) statement).getValue()); + } else if (statement instanceof StatementPhiBlock) { + for (StatementPhiBlock.PhiVariable phiVariable : ((StatementPhiBlock) statement).getPhiVariables()) { + addLvalueUses(allRvalues, phiVariable.getVariable()); + for (StatementPhiBlock.PhiRValue phiRValue : phiVariable.getValues()) { + addRvalueUses(allRvalues, phiRValue.getrValue()); + } + } + } + } + } + return allRvalues; + } + + private void addLvalueUses(Collection allUses, LValue lValue) { + if (lValue == null) { + return; + } else if (lValue instanceof VariableRef) { + return; + } else if (lValue instanceof LvalueLoHiByte) { + addRvalueUses(allUses, ((LvalueLoHiByte) lValue).getVariable()); + } else if (lValue instanceof PointerDereferenceSimple) { + addRvalueUses(allUses, ((PointerDereference) lValue).getPointer()); + } else if (lValue instanceof PointerDereferenceIndexed) { + addRvalueUses(allUses, ((PointerDereferenceIndexed) lValue).getPointer()); + addRvalueUses(allUses, ((PointerDereferenceIndexed) lValue).getIndex()); + } else { + throw new RuntimeException("Unknown LValue type " + lValue); + } + } + + private void addRvalueUses(Collection allUses, RValue rValue) { + if (rValue == null) { + return; + } else if (rValue instanceof VariableRef || rValue instanceof ConstantRef) { + allUses.add(rValue); + } else if (rValue instanceof LValue) { + addLvalueUses(allUses, (LValue) rValue); + } else if (rValue instanceof ConstantString || rValue instanceof ConstantInteger || rValue instanceof ConstantBool || rValue instanceof ConstantChar || rValue instanceof ConstantDouble) { + return; + } else if (rValue instanceof ConstantArray) { + for (ConstantValue constantValue : ((ConstantArray) rValue).getElements()) { + addRvalueUses(allUses, constantValue); + } + } else if (rValue instanceof ValueArray) { + for (RValue value : ((ValueArray) rValue).getList()) { + addRvalueUses(allUses, value); + } + } else if (rValue instanceof ConstantUnary) { + addRvalueUses(allUses, ((ConstantUnary) rValue).getOperand()); + } else if (rValue instanceof ConstantBinary) { + addRvalueUses(allUses, ((ConstantBinary) rValue).getLeft()); + addRvalueUses(allUses, ((ConstantBinary) rValue).getRight()); + } else { + throw new RuntimeException("Unknown RValue type " + rValue); + } + } + +} diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java index 9cffd1e58..68f4fc538 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java @@ -55,7 +55,7 @@ public class Pass1ProcedureCallParameters extends ControlFlowGraphCopyVisitor { currentBlockScope = currentBlockSymbol.getScope(); } splitCurrentBlock(currentBlockScope.addLabelIntermediate().getRef()); - if(!SymbolType.VOID.equals(procedure.getReturnType())) { + if(!SymbolType.VOID.equals(procedure.getReturnType()) && origCall.getlValue()!=null) { addStatementToCurrentBlock(new StatementAssignment(origCall.getlValue(), procReturnVarRef)); } else { // No return type. Remove variable receiving the result. diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm index f8f160271..695935623 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm @@ -1,20 +1,13 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log index 38c2c11e5..c9a0665a1 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log @@ -1134,6 +1134,29 @@ init_screen::@return: scope:[init_screen] from init_screen::@4 to:@end @end: scope:[] from @10 +Eliminating unused variable (byte*) COLS and assignment (byte*) COLS ← ((byte*)) (word) 55296 +Eliminating unused variable (byte*) SCROLL and assignment (byte*) SCROLL ← ((byte*)) (word) 53270 +Eliminating unused variable (byte) RST8 and assignment (byte) RST8 ← (byte/word/signed word) 128 +Eliminating unused variable (byte) ECM and assignment (byte) ECM ← (byte/signed byte/word/signed word) 64 +Eliminating unused variable (byte*) D016 and assignment (byte*) D016 ← ((byte*)) (word) 53270 +Eliminating unused variable (byte) MCM and assignment (byte) MCM ← (byte/signed byte/word/signed word) 16 +Eliminating unused variable (byte) CSEL and assignment (byte) CSEL ← (byte/signed byte/word/signed word) 8 +Eliminating unused variable - keeping the call (void~) main::$3 +Eliminating unused variable - keeping the call (void~) main::$4 +Eliminating unused variable - keeping the call (void~) main::$5 +Eliminating unused variable - keeping the call (void~) lines::$6 +Eliminating unused variable - keeping the call (void~) line::$9 +Eliminating unused variable - keeping the call (void~) line::$8 +Eliminating unused variable - keeping the call (void~) line::$14 +Eliminating unused variable - keeping the call (void~) line::$13 +Eliminating unused variable - keeping the call (void~) line::$22 +Eliminating unused variable - keeping the call (void~) line::$21 +Eliminating unused variable - keeping the call (void~) line::$27 +Eliminating unused variable - keeping the call (void~) line::$26 +Eliminating unused variable - keeping the call (void~) line_xdyi::$1 +Eliminating unused variable - keeping the call (void~) line_xdyd::$1 +Eliminating unused variable - keeping the call (void~) line_ydxi::$1 +Eliminating unused variable - keeping the call (void~) line_ydxd::$1 Removing empty block main::@2 Removing empty block @1 Removing empty block lines::@2 @@ -1167,20 +1190,13 @@ Removing empty block @9 Removing empty block init_screen::@4 CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS ← ((byte*)) (word) 55296 (byte*) BGCOL ← ((byte*)) (word) 53280 (byte*) FGCOL ← ((byte*)) (word) 53281 - (byte*) SCROLL ← ((byte*)) (word) 53270 (byte*) D018 ← ((byte*)) (word) 53272 (byte*) D011 ← ((byte*)) (word) 53265 - (byte) RST8 ← (byte/word/signed word) 128 - (byte) ECM ← (byte/signed byte/word/signed word) 64 (byte) BMM ← (byte/signed byte/word/signed word) 32 (byte) DEN ← (byte/signed byte/word/signed word) 16 (byte) RSEL ← (byte/signed byte/word/signed word) 8 - (byte*) D016 ← ((byte*)) (word) 53270 - (byte) MCM ← (byte/signed byte/word/signed word) 16 - (byte) CSEL ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo ← ((byte*)) (word/signed word) 4096 @@ -1200,11 +1216,11 @@ main: scope:[main] from (byte~) main::$2 ← (byte~) main::$1 | (byte/signed byte/word/signed word) 3 *((byte*) D011) ← (byte~) main::$2 *((byte*) D018) ← (byte/signed byte/word/signed word) 24 - (void~) main::$3 ← call init_screen - (void~) main::$4 ← call init_plot_tables + call init_screen + call init_plot_tables to:main::@1 main::@1: scope:[main] from main main::@1 - (void~) main::$5 ← call lines + call lines if(true) goto main::@1 to:main::@return main::@return: scope:[main] from main::@1 @@ -1220,7 +1236,7 @@ lines::@1: scope:[lines] from lines lines::@1 (byte~) lines::$3 ← (byte[]) lines_y *idx (byte) lines::l (byte~) lines::$4 ← (byte) lines::l + (byte/signed byte/word/signed word) 1 (byte~) lines::$5 ← (byte[]) lines_y *idx (byte~) lines::$4 - (void~) lines::$6 ← call line (byte~) lines::$0 (byte~) lines::$2 (byte~) lines::$3 (byte~) lines::$5 + call line (byte~) lines::$0 (byte~) lines::$2 (byte~) lines::$3 (byte~) lines::$5 (byte) lines::l ← ++ (byte) lines::l (boolean~) lines::$7 ← (byte) lines::l < (byte) lines_cnt if((boolean~) lines::$7) goto lines::@1 @@ -1262,16 +1278,16 @@ line::@16: scope:[line] from line::@15 if((boolean~) line::$7) goto line::@3 to:line::@17 line::@3: scope:[line] from line::@16 - (void~) line::$9 ← call line_ydxi (byte) line::y0 (byte) line::x0 (byte) line::y1 (byte) line::yd (byte) line::xd + call line_ydxi (byte) line::y0 (byte) line::x0 (byte) line::y1 (byte) line::yd (byte) line::xd to:line::@return line::@17: scope:[line] from line::@16 - (void~) line::$8 ← call line_xdyi (byte) line::x0 (byte) line::y0 (byte) line::x1 (byte) line::xd (byte) line::yd + call line_xdyi (byte) line::x0 (byte) line::y0 (byte) line::x1 (byte) line::xd (byte) line::yd to:line::@return line::@6: scope:[line] from line::@2 - (void~) line::$14 ← call line_ydxd (byte) line::y1 (byte) line::x1 (byte) line::y0 (byte) line::yd (byte) line::xd + call line_ydxd (byte) line::y1 (byte) line::x1 (byte) line::y0 (byte) line::yd (byte) line::xd to:line::@return line::@20: scope:[line] from line::@2 - (void~) line::$13 ← call line_xdyd (byte) line::x0 (byte) line::y0 (byte) line::x1 (byte) line::xd (byte) line::yd + call line_xdyd (byte) line::x0 (byte) line::y0 (byte) line::x1 (byte) line::xd (byte) line::yd to:line::@return line::@9: scope:[line] from line::@1 (byte~) line::$23 ← (byte) line::y0 - (byte) line::y1 @@ -1288,16 +1304,16 @@ line::@23: scope:[line] from line::@1 if((boolean~) line::$20) goto line::@10 to:line::@24 line::@10: scope:[line] from line::@23 - (void~) line::$22 ← call line_ydxd (byte) line::y0 (byte) line::x0 (byte) line::y1 (byte) line::yd (byte) line::xd + call line_ydxd (byte) line::y0 (byte) line::x0 (byte) line::y1 (byte) line::yd (byte) line::xd to:line::@return line::@24: scope:[line] from line::@23 - (void~) line::$21 ← call line_xdyd (byte) line::x1 (byte) line::y1 (byte) line::x0 (byte) line::xd (byte) line::yd + call line_xdyd (byte) line::x1 (byte) line::y1 (byte) line::x0 (byte) line::xd (byte) line::yd to:line::@return line::@13: scope:[line] from line::@9 - (void~) line::$27 ← call line_ydxi (byte) line::y1 (byte) line::x1 (byte) line::y0 (byte) line::yd (byte) line::xd + call line_ydxi (byte) line::y1 (byte) line::x1 (byte) line::y0 (byte) line::yd (byte) line::xd to:line::@return line::@27: scope:[line] from line::@9 - (void~) line::$26 ← call line_xdyi (byte) line::x1 (byte) line::y1 (byte) line::x0 (byte) line::xd (byte) line::yd + call line_xdyi (byte) line::x1 (byte) line::y1 (byte) line::x0 (byte) line::xd (byte) line::yd to:line::@return line::@return: scope:[line] from line::@10 line::@13 line::@17 line::@20 line::@24 line::@27 line::@3 line::@6 return @@ -1307,7 +1323,7 @@ line_xdyi: scope:[line_xdyi] from (byte) line_xdyi::e ← (byte~) line_xdyi::$0 to:line_xdyi::@1 line_xdyi::@1: scope:[line_xdyi] from line_xdyi line_xdyi::@2 - (void~) line_xdyi::$1 ← call plot (byte) line_xdyi::x (byte) line_xdyi::y + call plot (byte) line_xdyi::x (byte) line_xdyi::y (byte~) line_xdyi::$2 ← (byte) line_xdyi::x + (byte/signed byte/word/signed word) 1 (byte) line_xdyi::x ← (byte~) line_xdyi::$2 (byte~) line_xdyi::$3 ← (byte) line_xdyi::e + (byte) line_xdyi::yd @@ -1335,7 +1351,7 @@ line_xdyd: scope:[line_xdyd] from (byte) line_xdyd::e ← (byte~) line_xdyd::$0 to:line_xdyd::@1 line_xdyd::@1: scope:[line_xdyd] from line_xdyd line_xdyd::@2 - (void~) line_xdyd::$1 ← call plot (byte) line_xdyd::x (byte) line_xdyd::y + call plot (byte) line_xdyd::x (byte) line_xdyd::y (byte~) line_xdyd::$2 ← (byte) line_xdyd::x + (byte/signed byte/word/signed word) 1 (byte) line_xdyd::x ← (byte~) line_xdyd::$2 (byte~) line_xdyd::$3 ← (byte) line_xdyd::e + (byte) line_xdyd::yd @@ -1363,7 +1379,7 @@ line_ydxi: scope:[line_ydxi] from (byte) line_ydxi::e ← (byte~) line_ydxi::$0 to:line_ydxi::@1 line_ydxi::@1: scope:[line_ydxi] from line_ydxi line_ydxi::@2 - (void~) line_ydxi::$1 ← call plot (byte) line_ydxi::x (byte) line_ydxi::y + call plot (byte) line_ydxi::x (byte) line_ydxi::y (byte~) line_ydxi::$2 ← (byte) line_ydxi::y + (byte/signed byte/word/signed word) 1 (byte) line_ydxi::y ← (byte~) line_ydxi::$2 (byte~) line_ydxi::$3 ← (byte) line_ydxi::e + (byte) line_ydxi::xd @@ -1391,7 +1407,7 @@ line_ydxd: scope:[line_ydxd] from (byte) line_ydxd::e ← (byte~) line_ydxd::$0 to:line_ydxd::@1 line_ydxd::@1: scope:[line_ydxd] from line_ydxd line_ydxd::@2 - (void~) line_ydxd::$1 ← call plot (byte) line_ydxd::x (byte) line_ydxd::y + call plot (byte) line_ydxd::x (byte) line_ydxd::y (byte~) line_ydxd::$2 ← (byte) line_ydxd::y + (byte/signed byte/word/signed word) 1 (byte) line_ydxd::y ← (byte~) line_ydxd::$2 (byte~) line_ydxd::$3 ← (byte) line_ydxd::e + (byte) line_ydxd::xd @@ -1518,20 +1534,13 @@ PROCEDURE MODIFY VARIABLE ANALYSIS CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @begin: scope:[] from - (byte*) COLS ← ((byte*)) (word) 55296 (byte*) BGCOL ← ((byte*)) (word) 53280 (byte*) FGCOL ← ((byte*)) (word) 53281 - (byte*) SCROLL ← ((byte*)) (word) 53270 (byte*) D018 ← ((byte*)) (word) 53272 (byte*) D011 ← ((byte*)) (word) 53265 - (byte) RST8 ← (byte/word/signed word) 128 - (byte) ECM ← (byte/signed byte/word/signed word) 64 (byte) BMM ← (byte/signed byte/word/signed word) 32 (byte) DEN ← (byte/signed byte/word/signed word) 16 (byte) RSEL ← (byte/signed byte/word/signed word) 8 - (byte*) D016 ← ((byte*)) (word) 53270 - (byte) MCM ← (byte/signed byte/word/signed word) 16 - (byte) CSEL ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo ← ((byte*)) (word/signed word) 4096 @@ -1964,20 +1973,13 @@ Completing Phi functions... Completing Phi functions... CONTROL FLOW GRAPH SSA @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -2913,20 +2915,13 @@ init_screen::@return: scope:[init_screen] from init_screen::@2 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -3884,16 +3879,10 @@ INITIAL SSA SYMBOL TABLE (byte) BMM#0 (byte) BMM#1 (byte) BMM#2 -(byte*) COLS -(byte*) COLS#0 -(byte) CSEL -(byte) CSEL#0 (byte*) D011 (byte*) D011#0 (byte*) D011#1 (byte*) D011#2 -(byte*) D016 -(byte*) D016#0 (byte*) D018 (byte*) D018#0 (byte*) D018#1 @@ -3902,20 +3891,14 @@ INITIAL SSA SYMBOL TABLE (byte) DEN#0 (byte) DEN#1 (byte) DEN#2 -(byte) ECM -(byte) ECM#0 (byte*) FGCOL (byte*) FGCOL#0 (byte*) FGCOL#1 (byte*) FGCOL#2 -(byte) MCM -(byte) MCM#0 (byte) RSEL (byte) RSEL#0 (byte) RSEL#1 (byte) RSEL#2 -(byte) RST8 -(byte) RST8#0 (byte*) SCREEN (byte*) SCREEN#0 (byte*) SCREEN#1 @@ -3924,8 +3907,6 @@ INITIAL SSA SYMBOL TABLE (byte*) SCREEN#4 (byte*) SCREEN#5 (byte*) SCREEN#6 -(byte*) SCROLL -(byte*) SCROLL#0 (void()) init_plot_tables() (byte~) init_plot_tables::$0 (byte~) init_plot_tables::$1 @@ -4748,20 +4729,13 @@ Culled Empty Block (label) @11 Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -5693,20 +5667,13 @@ Inversing boolean not (boolean~) init_plot_tables::$12 ← (byte~) init_plot_tab Succesful SSA optimization Pass2UnaryNotSimplification CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -6895,20 +6862,13 @@ Alias (byte[]) plot_yhi#0 = (byte[]) plot_yhi#47 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -7684,20 +7644,13 @@ Alias (byte[]) plot_yhi#18 = (byte[]) plot_yhi#7 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -8442,20 +8395,13 @@ Self Phi Eliminated (byte*) SCREEN#2 Succesful SSA optimization Pass2SelfPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -9116,20 +9062,13 @@ Redundant Phi (byte*) SCREEN#2 (byte*) SCREEN#1 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -9553,20 +9492,13 @@ Redundant Phi (byte[]) plot_bit#1 (byte[]) plot_bit#0 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -10002,20 +9934,13 @@ Simple Condition (boolean~) init_screen::$3 if((byte*) init_screen::c#1!=(byte*~ Succesful SSA optimization Pass2ConditionalJumpSimplification CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 (byte[]) plot_xlo#0 ← ((byte*)) (word/signed word) 4096 @@ -10404,20 +10329,13 @@ init_screen::@return: scope:[init_screen] from init_screen::@2 to:@end @end: scope:[] from @10 -Constant (const byte*) COLS#0 = ((byte*))55296 Constant (const byte*) BGCOL#0 = ((byte*))53280 Constant (const byte*) FGCOL#0 = ((byte*))53281 -Constant (const byte*) SCROLL#0 = ((byte*))53270 Constant (const byte*) D018#0 = ((byte*))53272 Constant (const byte*) D011#0 = ((byte*))53265 -Constant (const byte) RST8#0 = 128 -Constant (const byte) ECM#0 = 64 Constant (const byte) BMM#0 = 32 Constant (const byte) DEN#0 = 16 Constant (const byte) RSEL#0 = 8 -Constant (const byte*) D016#0 = ((byte*))53270 -Constant (const byte) MCM#0 = 16 -Constant (const byte) CSEL#0 = 8 Constant (const byte*) SCREEN#0 = ((byte*))1024 Constant (const byte*) BITMAP#0 = ((byte*))8192 Constant (const byte[]) plot_xlo#0 = ((byte*))4096 @@ -13715,32 +13633,18 @@ FINAL SYMBOL TABLE (const byte*) BITMAP#0 = ((byte*))(word/signed word) 8192 (byte) BMM (const byte) BMM#0 = (byte/signed byte/word/signed word) 32 -(byte*) COLS -(const byte*) COLS#0 = ((byte*))(word) 55296 -(byte) CSEL -(const byte) CSEL#0 = (byte/signed byte/word/signed word) 8 (byte*) D011 (const byte*) D011#0 = ((byte*))(word) 53265 -(byte*) D016 -(const byte*) D016#0 = ((byte*))(word) 53270 (byte*) D018 (const byte*) D018#0 = ((byte*))(word) 53272 (byte) DEN (const byte) DEN#0 = (byte/signed byte/word/signed word) 16 -(byte) ECM -(const byte) ECM#0 = (byte/signed byte/word/signed word) 64 (byte*) FGCOL (const byte*) FGCOL#0 = ((byte*))(word) 53281 -(byte) MCM -(const byte) MCM#0 = (byte/signed byte/word/signed word) 16 (byte) RSEL (const byte) RSEL#0 = (byte/signed byte/word/signed word) 8 -(byte) RST8 -(const byte) RST8#0 = (byte/word/signed word) 128 (byte*) SCREEN (const byte*) SCREEN#0 = ((byte*))(word/signed word) 1024 -(byte*) SCROLL -(const byte*) SCROLL#0 = ((byte*))(word) 53270 (void()) init_plot_tables() (byte~) init_plot_tables::$0 (byte~) init_plot_tables::$10 @@ -16059,19 +15963,12 @@ VARIABLE REGISTER WEIGHTS (byte*) BGCOL (byte*) BITMAP (byte) BMM -(byte*) COLS -(byte) CSEL (byte*) D011 -(byte*) D016 (byte*) D018 (byte) DEN -(byte) ECM (byte*) FGCOL -(byte) MCM (byte) RSEL -(byte) RST8 (byte*) SCREEN -(byte*) SCROLL (void()) init_plot_tables() (byte~) init_plot_tables::$0 22.0 (byte~) init_plot_tables::$10 22.0 @@ -16506,20 +16403,13 @@ INITIAL ASM :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -17996,20 +17886,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -18942,20 +18825,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -19923,20 +19799,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -20869,20 +20738,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -21718,20 +21580,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -22567,20 +22422,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -23419,20 +23267,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -24262,20 +24103,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -25104,20 +24938,13 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 @@ -25947,32 +25774,18 @@ FINAL SYMBOL TABLE (const byte*) BITMAP#0 BITMAP = ((byte*))(word/signed word) 8192 (byte) BMM (const byte) BMM#0 BMM = (byte/signed byte/word/signed word) 32 -(byte*) COLS -(const byte*) COLS#0 COLS = ((byte*))(word) 55296 -(byte) CSEL -(const byte) CSEL#0 CSEL = (byte/signed byte/word/signed word) 8 (byte*) D011 (const byte*) D011#0 D011 = ((byte*))(word) 53265 -(byte*) D016 -(const byte*) D016#0 D016 = ((byte*))(word) 53270 (byte*) D018 (const byte*) D018#0 D018 = ((byte*))(word) 53272 (byte) DEN (const byte) DEN#0 DEN = (byte/signed byte/word/signed word) 16 -(byte) ECM -(const byte) ECM#0 ECM = (byte/signed byte/word/signed word) 64 (byte*) FGCOL (const byte*) FGCOL#0 FGCOL = ((byte*))(word) 53281 -(byte) MCM -(const byte) MCM#0 MCM = (byte/signed byte/word/signed word) 16 (byte) RSEL (const byte) RSEL#0 RSEL = (byte/signed byte/word/signed word) 8 -(byte) RST8 -(const byte) RST8#0 RST8 = (byte/word/signed word) 128 (byte*) SCREEN (const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 -(byte*) SCROLL -(const byte*) SCROLL#0 SCROLL = ((byte*))(word) 53270 (void()) init_plot_tables() (byte~) init_plot_tables::$0 reg byte a 22.0 (byte~) init_plot_tables::$10 reg byte a 22.0 @@ -26297,20 +26110,13 @@ FINAL CODE :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels - .const COLS = $d800 .const BGCOL = $d020 .const FGCOL = $d021 - .const SCROLL = $d016 .const D018 = $d018 .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const SCREEN = $400 .const BITMAP = $2000 .const plot_xlo = $1000 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym index ef1dfd840..4b1eada90 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym @@ -7,32 +7,18 @@ (const byte*) BITMAP#0 BITMAP = ((byte*))(word/signed word) 8192 (byte) BMM (const byte) BMM#0 BMM = (byte/signed byte/word/signed word) 32 -(byte*) COLS -(const byte*) COLS#0 COLS = ((byte*))(word) 55296 -(byte) CSEL -(const byte) CSEL#0 CSEL = (byte/signed byte/word/signed word) 8 (byte*) D011 (const byte*) D011#0 D011 = ((byte*))(word) 53265 -(byte*) D016 -(const byte*) D016#0 D016 = ((byte*))(word) 53270 (byte*) D018 (const byte*) D018#0 D018 = ((byte*))(word) 53272 (byte) DEN (const byte) DEN#0 DEN = (byte/signed byte/word/signed word) 16 -(byte) ECM -(const byte) ECM#0 ECM = (byte/signed byte/word/signed word) 64 (byte*) FGCOL (const byte*) FGCOL#0 FGCOL = ((byte*))(word) 53281 -(byte) MCM -(const byte) MCM#0 MCM = (byte/signed byte/word/signed word) 16 (byte) RSEL (const byte) RSEL#0 RSEL = (byte/signed byte/word/signed word) 8 -(byte) RST8 -(const byte) RST8#0 RST8 = (byte/word/signed word) 128 (byte*) SCREEN (const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 -(byte*) SCROLL -(const byte*) SCROLL#0 SCROLL = ((byte*))(word) 53270 (void()) init_plot_tables() (byte~) init_plot_tables::$0 reg byte a 22.0 (byte~) init_plot_tables::$10 reg byte a 22.0 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm index 08918e3d6..046ebc5ee 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm @@ -2,19 +2,13 @@ :BasicUpstart(main) .pc = $80d "Program" .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log index 539524b7d..0c7fe3bb0 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log @@ -530,6 +530,16 @@ init_screen::@return: scope:[init_screen] from init_screen::@4 to:@end @end: scope:[] from @5 +Eliminating unused variable (byte) RST8 and assignment (byte) RST8 ← (byte/word/signed word) 128 +Eliminating unused variable (byte) ECM and assignment (byte) ECM ← (byte/signed byte/word/signed word) 64 +Eliminating unused variable (byte*) D016 and assignment (byte*) D016 ← ((byte*)) (word) 53270 +Eliminating unused variable (byte) MCM and assignment (byte) MCM ← (byte/signed byte/word/signed word) 16 +Eliminating unused variable (byte) CSEL and assignment (byte) CSEL ← (byte/signed byte/word/signed word) 8 +Eliminating unused variable (byte*) COLS and assignment (byte*) COLS ← ((byte*)) (word) 55296 +Eliminating unused variable - keeping the call (void~) main::$3 +Eliminating unused variable - keeping the call (void~) main::$4 +Eliminating unused variable - keeping the call (void~) main::$6 +Eliminating unused variable - keeping the call (void~) plots::$2 Removing empty block main::@4 Removing empty block plots::@2 Removing empty block @3 @@ -539,19 +549,13 @@ Removing empty block init_screen::@4 CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011 ← ((byte*)) (word) 53265 - (byte) RST8 ← (byte/word/signed word) 128 - (byte) ECM ← (byte/signed byte/word/signed word) 64 (byte) BMM ← (byte/signed byte/word/signed word) 32 (byte) DEN ← (byte/signed byte/word/signed word) 16 (byte) RSEL ← (byte/signed byte/word/signed word) 8 (byte*) RASTER ← ((byte*)) (word) 53266 - (byte*) D016 ← ((byte*)) (word) 53270 - (byte) MCM ← (byte/signed byte/word/signed word) 16 - (byte) CSEL ← (byte/signed byte/word/signed word) 8 (byte*) D018 ← ((byte*)) (word) 53272 (byte*) BGCOL ← ((byte*)) (word) 53280 (byte*) FGCOL ← ((byte*)) (word) 53281 - (byte*) COLS ← ((byte*)) (word) 55296 (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP ← ((byte*)) (word/signed word) 8192 to:@1 @@ -563,8 +567,8 @@ main: scope:[main] from (byte~) main::$2 ← (byte~) main::$1 | (byte/signed byte/word/signed word) 3 *((byte*) D011) ← (byte~) main::$2 *((byte*) D018) ← (byte/signed byte/word/signed word) 24 - (void~) main::$3 ← call init_screen - (void~) main::$4 ← call init_plot_tables + call init_screen + call init_plot_tables to:main::@2 main::@1: scope:[main] from main::@3 to:main::@2 @@ -574,7 +578,7 @@ main::@2: scope:[main] from main main::@1 main::@2 to:main::@3 main::@3: scope:[main] from main::@2 *((byte*) BGCOL) ← ++ *((byte*) BGCOL) - (void~) main::$6 ← call plots + call plots *((byte*) BGCOL) ← -- *((byte*) BGCOL) if(true) goto main::@1 to:main::@return @@ -592,7 +596,7 @@ plots: scope:[plots] from plots::@1: scope:[plots] from plots plots::@1 (byte~) plots::$0 ← (byte[]) plots_x *idx (byte) plots::i (byte~) plots::$1 ← (byte[]) plots_y *idx (byte) plots::i - (void~) plots::$2 ← call plot (byte~) plots::$0 (byte~) plots::$1 + call plot (byte~) plots::$0 (byte~) plots::$1 (byte) plots::i ← ++ (byte) plots::i (boolean~) plots::$3 ← (byte) plots::i < (byte) plots_cnt if((boolean~) plots::$3) goto plots::@1 @@ -712,19 +716,13 @@ PROCEDURE MODIFY VARIABLE ANALYSIS CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @begin: scope:[] from (byte*) D011 ← ((byte*)) (word) 53265 - (byte) RST8 ← (byte/word/signed word) 128 - (byte) ECM ← (byte/signed byte/word/signed word) 64 (byte) BMM ← (byte/signed byte/word/signed word) 32 (byte) DEN ← (byte/signed byte/word/signed word) 16 (byte) RSEL ← (byte/signed byte/word/signed word) 8 (byte*) RASTER ← ((byte*)) (word) 53266 - (byte*) D016 ← ((byte*)) (word) 53270 - (byte) MCM ← (byte/signed byte/word/signed word) 16 - (byte) CSEL ← (byte/signed byte/word/signed word) 8 (byte*) D018 ← ((byte*)) (word) 53272 (byte*) BGCOL ← ((byte*)) (word) 53280 (byte*) FGCOL ← ((byte*)) (word) 53281 - (byte*) COLS ← ((byte*)) (word) 55296 (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP ← ((byte*)) (word/signed word) 8192 to:@1 @@ -905,19 +903,13 @@ Completing Phi functions... CONTROL FLOW GRAPH SSA @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -1292,19 +1284,13 @@ init_screen::@return: scope:[init_screen] from init_screen::@2 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -1714,18 +1700,12 @@ INITIAL SSA SYMBOL TABLE (byte) BMM#2 (byte) BMM#3 (byte) BMM#4 -(byte*) COLS -(byte*) COLS#0 -(byte) CSEL -(byte) CSEL#0 (byte*) D011 (byte*) D011#0 (byte*) D011#1 (byte*) D011#2 (byte*) D011#3 (byte*) D011#4 -(byte*) D016 -(byte*) D016#0 (byte*) D018 (byte*) D018#0 (byte*) D018#1 @@ -1738,16 +1718,12 @@ INITIAL SSA SYMBOL TABLE (byte) DEN#2 (byte) DEN#3 (byte) DEN#4 -(byte) ECM -(byte) ECM#0 (byte*) FGCOL (byte*) FGCOL#0 (byte*) FGCOL#1 (byte*) FGCOL#2 (byte*) FGCOL#3 (byte*) FGCOL#4 -(byte) MCM -(byte) MCM#0 (byte*) RASTER (byte*) RASTER#0 (byte*) RASTER#1 @@ -1766,8 +1742,6 @@ INITIAL SSA SYMBOL TABLE (byte) RSEL#2 (byte) RSEL#3 (byte) RSEL#4 -(byte) RST8 -(byte) RST8#0 (byte*) SCREEN (byte*) SCREEN#0 (byte*) SCREEN#1 @@ -2038,19 +2012,13 @@ Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -2426,19 +2394,13 @@ Succesful SSA optimization Pass2UnaryNotSimplification CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -2921,19 +2883,13 @@ Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -3253,19 +3209,13 @@ Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -3606,19 +3556,13 @@ Succesful SSA optimization Pass2SelfPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -3932,19 +3876,13 @@ Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -4126,19 +4064,13 @@ Succesful SSA optimization Pass2ConditionalJumpSimplification CONTROL FLOW GRAPH @begin: scope:[] from (byte*) D011#0 ← ((byte*)) (word) 53265 - (byte) RST8#0 ← (byte/word/signed word) 128 - (byte) ECM#0 ← (byte/signed byte/word/signed word) 64 (byte) BMM#0 ← (byte/signed byte/word/signed word) 32 (byte) DEN#0 ← (byte/signed byte/word/signed word) 16 (byte) RSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) RASTER#0 ← ((byte*)) (word) 53266 - (byte*) D016#0 ← ((byte*)) (word) 53270 - (byte) MCM#0 ← (byte/signed byte/word/signed word) 16 - (byte) CSEL#0 ← (byte/signed byte/word/signed word) 8 (byte*) D018#0 ← ((byte*)) (word) 53272 (byte*) BGCOL#0 ← ((byte*)) (word) 53280 (byte*) FGCOL#0 ← ((byte*)) (word) 53281 - (byte*) COLS#0 ← ((byte*)) (word) 55296 (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte*) BITMAP#0 ← ((byte*)) (word/signed word) 8192 to:@1 @@ -4301,19 +4233,13 @@ init_screen::@return: scope:[init_screen] from init_screen::@2 @end: scope:[] from @5 Constant (const byte*) D011#0 = ((byte*))53265 -Constant (const byte) RST8#0 = 128 -Constant (const byte) ECM#0 = 64 Constant (const byte) BMM#0 = 32 Constant (const byte) DEN#0 = 16 Constant (const byte) RSEL#0 = 8 Constant (const byte*) RASTER#0 = ((byte*))53266 -Constant (const byte*) D016#0 = ((byte*))53270 -Constant (const byte) MCM#0 = 16 -Constant (const byte) CSEL#0 = 8 Constant (const byte*) D018#0 = ((byte*))53272 Constant (const byte*) BGCOL#0 = ((byte*))53280 Constant (const byte*) FGCOL#0 = ((byte*))53281 -Constant (const byte*) COLS#0 = ((byte*))55296 Constant (const byte*) SCREEN#0 = ((byte*))1024 Constant (const byte*) BITMAP#0 = ((byte*))8192 Constant (const byte[]) plots_x#0 = { 60, 80, 110, 80, 60, 40, 10, 40 } @@ -5256,30 +5182,18 @@ FINAL SYMBOL TABLE (const byte*) BITMAP#0 = ((byte*))(word/signed word) 8192 (byte) BMM (const byte) BMM#0 = (byte/signed byte/word/signed word) 32 -(byte*) COLS -(const byte*) COLS#0 = ((byte*))(word) 55296 -(byte) CSEL -(const byte) CSEL#0 = (byte/signed byte/word/signed word) 8 (byte*) D011 (const byte*) D011#0 = ((byte*))(word) 53265 -(byte*) D016 -(const byte*) D016#0 = ((byte*))(word) 53270 (byte*) D018 (const byte*) D018#0 = ((byte*))(word) 53272 (byte) DEN (const byte) DEN#0 = (byte/signed byte/word/signed word) 16 -(byte) ECM -(const byte) ECM#0 = (byte/signed byte/word/signed word) 64 (byte*) FGCOL (const byte*) FGCOL#0 = ((byte*))(word) 53281 -(byte) MCM -(const byte) MCM#0 = (byte/signed byte/word/signed word) 16 (byte*) RASTER (const byte*) RASTER#0 = ((byte*))(word) 53266 (byte) RSEL (const byte) RSEL#0 = (byte/signed byte/word/signed word) 8 -(byte) RST8 -(const byte) RST8#0 = (byte/word/signed word) 128 (byte*) SCREEN (const byte*) SCREEN#0 = ((byte*))(word/signed word) 1024 (void()) init_plot_tables() @@ -6090,18 +6004,12 @@ VARIABLE REGISTER WEIGHTS (byte*) BGCOL (byte*) BITMAP (byte) BMM -(byte*) COLS -(byte) CSEL (byte*) D011 -(byte*) D016 (byte*) D018 (byte) DEN -(byte) ECM (byte*) FGCOL -(byte) MCM (byte*) RASTER (byte) RSEL -(byte) RST8 (byte*) SCREEN (void()) init_plot_tables() (byte~) init_plot_tables::$0 22.0 @@ -6259,19 +6167,13 @@ INITIAL ASM .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -6846,19 +6748,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -7215,19 +7111,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -7599,19 +7489,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -7966,19 +7850,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -8294,19 +8172,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -8622,19 +8494,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -8953,19 +8819,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -9275,19 +9135,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -9596,19 +9450,13 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 @@ -9917,30 +9765,18 @@ FINAL SYMBOL TABLE (const byte*) BITMAP#0 BITMAP = ((byte*))(word/signed word) 8192 (byte) BMM (const byte) BMM#0 BMM = (byte/signed byte/word/signed word) 32 -(byte*) COLS -(const byte*) COLS#0 COLS = ((byte*))(word) 55296 -(byte) CSEL -(const byte) CSEL#0 CSEL = (byte/signed byte/word/signed word) 8 (byte*) D011 (const byte*) D011#0 D011 = ((byte*))(word) 53265 -(byte*) D016 -(const byte*) D016#0 D016 = ((byte*))(word) 53270 (byte*) D018 (const byte*) D018#0 D018 = ((byte*))(word) 53272 (byte) DEN (const byte) DEN#0 DEN = (byte/signed byte/word/signed word) 16 -(byte) ECM -(const byte) ECM#0 ECM = (byte/signed byte/word/signed word) 64 (byte*) FGCOL (const byte*) FGCOL#0 FGCOL = ((byte*))(word) 53281 -(byte) MCM -(const byte) MCM#0 MCM = (byte/signed byte/word/signed word) 16 (byte*) RASTER (const byte*) RASTER#0 RASTER = ((byte*))(word) 53266 (byte) RSEL (const byte) RSEL#0 RSEL = (byte/signed byte/word/signed word) 8 -(byte) RST8 -(const byte) RST8#0 RST8 = (byte/word/signed word) 128 (byte*) SCREEN (const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 (void()) init_plot_tables() @@ -10062,19 +9898,13 @@ FINAL CODE .pc = $80d "Program" //SEG1 Global Constants & labels .const D011 = $d011 - .const RST8 = $80 - .const ECM = $40 .const BMM = $20 .const DEN = $10 .const RSEL = 8 .const RASTER = $d012 - .const D016 = $d016 - .const MCM = $10 - .const CSEL = 8 .const D018 = $d018 .const BGCOL = $d020 .const FGCOL = $d021 - .const COLS = $d800 .const SCREEN = $400 .const BITMAP = $2000 .const plots_cnt = 8 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.sym b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.sym index 23d272c22..775b366be 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.sym @@ -7,30 +7,18 @@ (const byte*) BITMAP#0 BITMAP = ((byte*))(word/signed word) 8192 (byte) BMM (const byte) BMM#0 BMM = (byte/signed byte/word/signed word) 32 -(byte*) COLS -(const byte*) COLS#0 COLS = ((byte*))(word) 55296 -(byte) CSEL -(const byte) CSEL#0 CSEL = (byte/signed byte/word/signed word) 8 (byte*) D011 (const byte*) D011#0 D011 = ((byte*))(word) 53265 -(byte*) D016 -(const byte*) D016#0 D016 = ((byte*))(word) 53270 (byte*) D018 (const byte*) D018#0 D018 = ((byte*))(word) 53272 (byte) DEN (const byte) DEN#0 DEN = (byte/signed byte/word/signed word) 16 -(byte) ECM -(const byte) ECM#0 ECM = (byte/signed byte/word/signed word) 64 (byte*) FGCOL (const byte*) FGCOL#0 FGCOL = ((byte*))(word) 53281 -(byte) MCM -(const byte) MCM#0 MCM = (byte/signed byte/word/signed word) 16 (byte*) RASTER (const byte*) RASTER#0 RASTER = ((byte*))(word) 53266 (byte) RSEL (const byte) RSEL#0 RSEL = (byte/signed byte/word/signed word) 8 -(byte) RST8 -(const byte) RST8#0 RST8 = (byte/word/signed word) 128 (byte*) SCREEN (const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 (void()) init_plot_tables() diff --git a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log index f3bb09805..01b58e927 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log @@ -87,6 +87,8 @@ line::@return: scope:[line] from line::@2 to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 Removing empty block @1 Removing empty block line::@2 CONTROL FLOW GRAPH @@ -94,8 +96,8 @@ CONTROL FLOW GRAPH (byte*) screen ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from - (void~) main::$0 ← call line (byte/signed byte/word/signed word) 1 (byte/signed byte/word/signed word) 2 - (void~) main::$1 ← call line (byte/signed byte/word/signed word) 3 (byte/signed byte/word/signed word) 5 + call line (byte/signed byte/word/signed word) 1 (byte/signed byte/word/signed word) 2 + call line (byte/signed byte/word/signed word) 3 (byte/signed byte/word/signed word) 5 to:main::@return main::@return: scope:[main] from main return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/casting.log b/src/main/java/dk/camelot64/kickc/test/ref/casting.log index f9db092f8..3f8563f8c 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/casting.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/casting.log @@ -180,6 +180,7 @@ w::@return: scope:[w] from w::@2 to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$5 Removing empty block @1 Removing empty block w::@2 CONTROL FLOW GRAPH @@ -212,7 +213,7 @@ main::@1: scope:[main] from main main::@1 if((boolean~) main::$4) goto main::@1 to:main::@2 main::@2: scope:[main] from main::@1 - (void~) main::$5 ← call w + call w to:main::@return main::@return: scope:[main] from main::@2 return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/const-identification.log b/src/main/java/dk/camelot64/kickc/test/ref/const-identification.log index 2ee02905b..d630c83fd 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/const-identification.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/const-identification.log @@ -176,6 +176,9 @@ plot::@return: scope:[plot] from plot to:@end @end: scope:[] from @3 +Eliminating unused variable - keeping the call (void~) main::$1 +Eliminating unused variable - keeping the call (void~) line::$4 +Eliminating unused variable - keeping the call (void~) line::$2 Removing empty block main::@3 Removing empty block main::@4 Removing empty block @1 @@ -199,7 +202,7 @@ main::@1: scope:[main] from main main::@1 if((boolean~) main::$0) goto main::@1 to:main::@2 main::@2: scope:[main] from main::@1 main::@2 - (void~) main::$1 ← call line (byte/signed byte/word/signed word) 0 (byte/signed byte/word/signed word) 10 + call line (byte/signed byte/word/signed word) 0 (byte/signed byte/word/signed word) 10 if(true) goto main::@2 to:main::@return main::@return: scope:[main] from main::@2 @@ -211,13 +214,13 @@ line: scope:[line] from if((boolean~) line::$1) goto line::@1 to:line::@4 line::@1: scope:[line] from line - (void~) line::$4 ← call plot (byte) line::x0 + call plot (byte) line::x0 to:line::@return line::@4: scope:[line] from line (byte) line::x ← (byte) line::x0 to:line::@2 line::@2: scope:[line] from line::@2 line::@4 - (void~) line::$2 ← call plot (byte) line::x + call plot (byte) line::x (byte) line::x ← ++ (byte) line::x (boolean~) line::$3 ← (byte) line::x <= (byte) line::x1 if((boolean~) line::$3) goto line::@2 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/fillscreen.log b/src/main/java/dk/camelot64/kickc/test/ref/fillscreen.log index c57277a94..f53a1f5d3 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/fillscreen.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/fillscreen.log @@ -108,6 +108,7 @@ fillscreen::@return: scope:[fillscreen] from fillscreen::@2 to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 Removing empty block @1 Removing empty block fillscreen::@2 CONTROL FLOW GRAPH @@ -116,7 +117,7 @@ CONTROL FLOW GRAPH to:@2 main: scope:[main] from (byte) main::c ← *((byte*) SCREEN) - (void~) main::$0 ← call fillscreen (byte) main::c + call fillscreen (byte) main::c to:main::@return main::@return: scope:[main] from main return 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 7f1dc8d77..a02701b77 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 @@ -337,6 +337,9 @@ plot::@return: scope:[plot] from plot::@4 to:@end @end: scope:[] from @4 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$4 +Eliminating unused variable - keeping the call (void~) main::$5 Removing empty block main::@5 Removing empty block main::@8 Removing empty block @1 @@ -353,7 +356,7 @@ CONTROL FLOW GRAPH (byte*) RASTER ← ((byte*)) (word) 53266 to:@4 main: scope:[main] from - (void~) main::$0 ← call prepare + call prepare to:main::@1 main::@1: scope:[main] from main main::@7 (byte) main::c ← (byte/signed byte/word/signed word) 25 @@ -374,8 +377,8 @@ main::@6: scope:[main] from main::@4 if((boolean~) main::$3) goto main::@2 to:main::@7 main::@7: scope:[main] from main::@6 - (void~) main::$4 ← call flip - (void~) main::$5 ← call plot + call flip + call plot if(true) goto main::@1 to:main::@return main::@return: scope:[main] from main::@7 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/halfscii.asm b/src/main/java/dk/camelot64/kickc/test/ref/halfscii.asm index dcbe671c3..5a4fb8381 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/halfscii.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/halfscii.asm @@ -2,7 +2,6 @@ :BasicUpstart(main) .pc = $80d "Program" .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/halfscii.log b/src/main/java/dk/camelot64/kickc/test/ref/halfscii.log index c678ff86e..c14a71dba 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/halfscii.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/halfscii.log @@ -336,10 +336,10 @@ main::@return: scope:[main] from main::@12 to:@end @end: scope:[] from @1 +Eliminating unused variable (byte*) CHARSET and assignment (byte*) CHARSET ← ((byte*)) (word/signed word) 8192 CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN ← ((byte*)) (word) 53248 (byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018 ← ((byte*)) (word) 53272 @@ -463,7 +463,6 @@ PROCEDURE MODIFY VARIABLE ANALYSIS CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @begin: scope:[] from (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN ← ((byte*)) (word) 53248 (byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018 ← ((byte*)) (word) 53272 @@ -597,7 +596,6 @@ Completing Phi functions... CONTROL FLOW GRAPH SSA @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -817,7 +815,6 @@ main::@return: scope:[main] from main::@12 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -1052,8 +1049,6 @@ INITIAL SSA SYMBOL TABLE (byte*) CHARGEN#7 (byte*) CHARGEN#8 (byte*) CHARGEN#9 -(byte*) CHARSET -(byte*) CHARSET#0 (byte*) CHARSET4 (byte*) CHARSET4#0 (byte*) CHARSET4#1 @@ -1240,7 +1235,6 @@ Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -1463,7 +1457,6 @@ Succesful SSA optimization Pass2UnaryNotSimplification CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -1741,7 +1734,6 @@ Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -1913,7 +1905,6 @@ Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -2053,7 +2044,6 @@ Succesful SSA optimization Pass2SelfPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -2191,7 +2181,6 @@ Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -2309,7 +2298,6 @@ Succesful SSA optimization Pass2ConditionalJumpSimplification CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) CHARSET#0 ← ((byte*)) (word/signed word) 8192 (byte*) CHARGEN#0 ← ((byte*)) (word) 53248 (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word) 1 (byte*) D018#0 ← ((byte*)) (word) 53272 @@ -2412,7 +2400,6 @@ main::@return: scope:[main] from main::@12 @end: scope:[] from @1 Constant (const byte*) SCREEN#0 = ((byte*))1024 -Constant (const byte*) CHARSET#0 = ((byte*))8192 Constant (const byte*) CHARGEN#0 = ((byte*))53248 Constant (const byte*) PROCPORT#0 = ((byte*))1 Constant (const byte*) D018#0 = ((byte*))53272 @@ -2762,8 +2749,6 @@ FINAL SYMBOL TABLE (label) @end (byte*) CHARGEN (const byte*) CHARGEN#0 = ((byte*))(word) 53248 -(byte*) CHARSET -(const byte*) CHARSET#0 = ((byte*))(word/signed word) 8192 (byte*) CHARSET4 (const byte*) CHARSET4#0 = ((byte*))(word/signed word) 10240 (byte*) D018 @@ -3407,7 +3392,6 @@ Loop head: main::@6 tails: main::@6 blocks: main::@6 depth: 1 VARIABLE REGISTER WEIGHTS (byte*) CHARGEN -(byte*) CHARSET (byte*) CHARSET4 (byte*) D018 (byte*) PROCPORT @@ -3571,7 +3555,6 @@ INITIAL ASM .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 @@ -4115,7 +4098,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 @@ -4391,7 +4373,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 @@ -4678,7 +4659,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 @@ -4944,7 +4924,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 @@ -5190,7 +5169,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 @@ -5430,8 +5408,6 @@ FINAL SYMBOL TABLE (label) @end (byte*) CHARGEN (const byte*) CHARGEN#0 CHARGEN = ((byte*))(word) 53248 -(byte*) CHARSET -(const byte*) CHARSET#0 CHARSET = ((byte*))(word/signed word) 8192 (byte*) CHARSET4 (const byte*) CHARSET4#0 CHARSET4 = ((byte*))(word/signed word) 10240 (byte*) D018 @@ -5541,7 +5517,6 @@ FINAL CODE .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const CHARSET = $2000 .const CHARGEN = $d000 .const PROCPORT = 1 .const D018 = $d018 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/halfscii.sym b/src/main/java/dk/camelot64/kickc/test/ref/halfscii.sym index a42ac70ea..9de4d1097 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/halfscii.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/halfscii.sym @@ -3,8 +3,6 @@ (label) @end (byte*) CHARGEN (const byte*) CHARGEN#0 CHARGEN = ((byte*))(word) 53248 -(byte*) CHARSET -(const byte*) CHARSET#0 CHARSET = ((byte*))(word/signed word) 8192 (byte*) CHARSET4 (const byte*) CHARSET4#0 CHARSET4 = ((byte*))(word/signed word) 10240 (byte*) D018 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/inline-string.log b/src/main/java/dk/camelot64/kickc/test/ref/inline-string.log index 7abafef85..44669fdcd 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/inline-string.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/inline-string.log @@ -106,6 +106,9 @@ print::@return: scope:[print] from print::@3 @end: scope:[] from @2 Creating constant string variable for inline (const byte[]) main::msg "message 3 @" +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 +Eliminating unused variable - keeping the call (void~) main::$2 Removing empty block print::@4 Removing empty block print::@3 Removing empty block print::@5 @@ -116,9 +119,9 @@ CONTROL FLOW GRAPH to:@1 main: scope:[main] from (byte[]) main::msg2 ← (string) "message 2 @" - (void~) main::$0 ← call print (byte[]) msg1 - (void~) main::$1 ← call print (byte[]) main::msg2 - (void~) main::$2 ← call print (const byte[]) main::msg + call print (byte[]) msg1 + call print (byte[]) main::msg2 + call print (const byte[]) main::msg to:main::@return main::@return: scope:[main] from main return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/liverange-call-problem.log b/src/main/java/dk/camelot64/kickc/test/ref/liverange-call-problem.log index e7787a487..b0074d536 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/liverange-call-problem.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/liverange-call-problem.log @@ -93,6 +93,10 @@ incw2::@return: scope:[incw2] from incw2 to:@end @end: scope:[] from @3 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 +Eliminating unused variable - keeping the call (void~) main::$2 +Eliminating unused variable - keeping the call (void~) main::$3 Removing empty block @1 Removing empty block @2 CONTROL FLOW GRAPH @@ -101,10 +105,10 @@ CONTROL FLOW GRAPH (word) w2 ← (byte/signed byte/word/signed word) 0 to:@3 main: scope:[main] from - (void~) main::$0 ← call incw1 - (void~) main::$1 ← call incw2 - (void~) main::$2 ← call incw1 - (void~) main::$3 ← call incw2 + call incw1 + call incw2 + call incw1 + call incw2 to:main::@return main::@return: scope:[main] from main return 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 df853ca63..38a09a14d 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log @@ -94,6 +94,7 @@ nest::@return: scope:[nest] from nest::@2 to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 Removing empty block main::@2 Removing empty block @1 Removing empty block nest::@2 @@ -105,7 +106,7 @@ main: scope:[main] from (byte) main::i ← (byte/signed byte/word/signed word) 100 to:main::@1 main::@1: scope:[main] from main main::@1 - (void~) main::$0 ← call nest + call nest (byte) main::i ← -- (byte) main::i (boolean~) main::$1 ← (byte) main::i > (byte/signed byte/word/signed word) 0 if((boolean~) main::$1) goto main::@1 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 d1e8b0cdb..24a895a7c 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log @@ -194,6 +194,8 @@ nest2::@return: scope:[nest2] from nest2::@4 to:@end @end: scope:[] from @3 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) nest1::$0 Removing empty block main::@4 Removing empty block @1 Removing empty block nest1::@4 @@ -210,7 +212,7 @@ main::@1: scope:[main] from main main::@3 (byte) main::j ← (byte/signed byte/word/signed word) 100 to:main::@2 main::@2: scope:[main] from main::@1 main::@2 - (void~) main::$0 ← call nest1 + call nest1 (byte) main::j ← -- (byte) main::j (boolean~) main::$1 ← (byte) main::j > (byte/signed byte/word/signed word) 0 if((boolean~) main::$1) goto main::@2 @@ -230,7 +232,7 @@ nest1::@1: scope:[nest1] from nest1 nest1::@3 (byte) nest1::j ← (byte/signed byte/word/signed word) 100 to:nest1::@2 nest1::@2: scope:[nest1] from nest1::@1 nest1::@2 - (void~) nest1::$0 ← call nest2 + call nest2 (byte) nest1::j ← -- (byte) nest1::j (boolean~) nest1::$1 ← (byte) nest1::j > (byte/signed byte/word/signed word) 0 if((boolean~) nest1::$1) goto nest1::@2 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 9c94f7984..3887839fd 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/modglobalmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/modglobalmin.log @@ -78,6 +78,8 @@ inccnt::@return: scope:[inccnt] from inccnt to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 Removing empty block @1 CONTROL FLOW GRAPH @begin: scope:[] from @@ -85,10 +87,10 @@ CONTROL FLOW GRAPH (byte[256]) SCREEN ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from - (void~) main::$0 ← call inccnt + call inccnt *((byte[256]) SCREEN + (byte/signed byte/word/signed word) 0) ← (byte) cnt (byte) cnt ← ++ (byte) cnt - (void~) main::$1 ← call inccnt + call inccnt (byte) cnt ← ++ (byte) cnt *((byte[256]) SCREEN + (byte/signed byte/word/signed word) 1) ← (byte) cnt to:main::@return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation-2.log b/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation-2.log index 1869fe29a..56f5b8a73 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation-2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation-2.log @@ -124,6 +124,10 @@ plot::@return: scope:[plot] from plot to:@end @end: scope:[] from @3 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$2 +Eliminating unused variable - keeping the call (void~) line::$0 +Eliminating unused variable - keeping the call (void~) line::$2 Removing empty block main::@4 Removing empty block @1 Removing empty block @2 @@ -135,7 +139,7 @@ main: scope:[main] from (byte) main::i ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 - (void~) main::$0 ← call line (byte) main::i + call line (byte) main::i (byte) main::i ← ++ (byte) main::i (boolean~) main::$1 ← (byte) main::i != (byte/signed byte/word/signed word) 9 if((boolean~) main::$1) goto main::@1 @@ -144,7 +148,7 @@ main::@3: scope:[main] from main::@1 (byte) main::j ← (byte/signed byte/word/signed word) 10 to:main::@2 main::@2: scope:[main] from main::@2 main::@3 - (void~) main::$2 ← call line (byte) main::j + call line (byte) main::j (byte) main::j ← ++ (byte) main::j (boolean~) main::$3 ← (byte) main::j != (byte/signed byte/word/signed word) 19 if((boolean~) main::$3) goto main::@2 @@ -153,9 +157,9 @@ main::@return: scope:[main] from main::@2 return to:@return line: scope:[line] from - (void~) line::$0 ← call plot (byte) line::l + call plot (byte) line::l (byte~) line::$1 ← (byte) line::l + (byte/signed byte/word/signed word) 20 - (void~) line::$2 ← call plot (byte~) line::$1 + call plot (byte~) line::$1 to:line::@return line::@return: scope:[line] from line return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation.log b/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation.log index bf149844e..ae2a7afd3 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/overlap-allocation.log @@ -119,6 +119,9 @@ plot::@return: scope:[plot] from plot to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$2 +Eliminating unused variable - keeping the call (void~) main::$4 Removing empty block main::@6 Removing empty block @1 CONTROL FLOW GRAPH @@ -129,7 +132,7 @@ main: scope:[main] from (byte) main::i ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 - (void~) main::$0 ← call plot (byte) main::i + call plot (byte) main::i (byte) main::i ← ++ (byte) main::i (boolean~) main::$1 ← (byte) main::i != (byte/signed byte/word/signed word) 11 if((boolean~) main::$1) goto main::@1 @@ -138,7 +141,7 @@ main::@4: scope:[main] from main::@1 (byte) main::j ← (byte/signed byte/word/signed word) 0 to:main::@2 main::@2: scope:[main] from main::@2 main::@4 - (void~) main::$2 ← call plot (byte) main::j + call plot (byte) main::j (byte) main::j ← ++ (byte) main::j (boolean~) main::$3 ← (byte) main::j != (byte/signed byte/word/signed word) 11 if((boolean~) main::$3) goto main::@2 @@ -147,7 +150,7 @@ main::@5: scope:[main] from main::@2 (byte) main::k ← (byte/signed byte/word/signed word) 0 to:main::@3 main::@3: scope:[main] from main::@3 main::@5 - (void~) main::$4 ← call plot (byte) main::k + call plot (byte) main::k (byte) main::k ← ++ (byte) main::k (boolean~) main::$5 ← (byte) main::k != (byte/signed byte/word/signed word) 11 if((boolean~) main::$5) goto main::@3 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/print-problem.log b/src/main/java/dk/camelot64/kickc/test/ref/print-problem.log index 631e5920d..1360785dc 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/print-problem.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/print-problem.log @@ -85,6 +85,9 @@ ln::@return: scope:[ln] from ln to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 +Eliminating unused variable - keeping the call (void~) main::$2 Removing empty block @1 CONTROL FLOW GRAPH @begin: scope:[] from @@ -92,11 +95,11 @@ CONTROL FLOW GRAPH (byte) char ← (byte) line to:@2 main: scope:[main] from - (void~) main::$0 ← call ln + call ln (byte) char ← ++ (byte) char - (void~) main::$1 ← call ln + call ln (byte) char ← ++ (byte) char - (void~) main::$2 ← call ln + call ln to:main::@return main::@return: scope:[main] from main return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/print.log b/src/main/java/dk/camelot64/kickc/test/ref/print.log index f60cee5b0..f0c9b77b8 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/print.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/print.log @@ -166,6 +166,12 @@ print_ln::@return: scope:[print_ln] from print_ln::@2 to:@end @end: scope:[] from @3 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 +Eliminating unused variable - keeping the call (void~) main::$2 +Eliminating unused variable - keeping the call (void~) main::$3 +Eliminating unused variable - keeping the call (void~) main::$4 +Eliminating unused variable - keeping the call (void~) main::$5 Removing empty block print_str::@4 Removing empty block print_str::@3 Removing empty block print_str::@5 @@ -178,12 +184,12 @@ CONTROL FLOW GRAPH (byte[]) msg3 ← (string) "hello 2017! @" to:@1 main: scope:[main] from - (void~) main::$0 ← call print_str (byte[]) msg - (void~) main::$1 ← call print_ln - (void~) main::$2 ← call print_str (byte[]) msg2 - (void~) main::$3 ← call print_ln - (void~) main::$4 ← call print_str (byte[]) msg3 - (void~) main::$5 ← call print_ln + call print_str (byte[]) msg + call print_ln + call print_str (byte[]) msg2 + call print_ln + call print_str (byte[]) msg3 + call print_ln to:main::@return main::@return: scope:[main] from main return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.asm b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.asm index 607570594..ae07174bd 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.asm @@ -9,7 +9,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - lda screen+$50 ldx #0 b1: txa diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.cfg b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.cfg index d64b5d0b7..aecee5f45 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.cfg +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.cfg @@ -8,7 +8,7 @@ @end: scope:[] from @1 [3] phi() [ ] ( ) main: scope:[main] from @1 - [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) + [4] phi() [ ] ( main:2 [ ] ) to:main::@1 main::@1: scope:[main] from main main::@1 [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] ( main:2 [ main::i#2 ] ) diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.log b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.log index 613af03ea..4d7810c17 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.log @@ -180,13 +180,19 @@ main::@return: scope:[main] from main::@4 to:@end @end: scope:[] from @1 +Eliminating unused variable (byte) main::a and assignment (byte) main::a ← *((byte*~) main::$0) +Eliminating unused variable (byte*~) main::$14 and assignment (byte*~) main::$14 ← ((byte*)) (word) 53280 +Eliminating unused variable (byte*~) main::$15 and assignment (byte*~) main::$15 ← ((byte*)) (word) 53280 +Eliminating unused variable (byte*~) main::$19 and assignment (byte*~) main::$19 ← ((byte*)) (word~) main::$18 +Eliminating unused variable (byte*~) main::$21 and assignment (byte*~) main::$21 ← ((byte*)) (word~) main::$20 +Eliminating unused variable (byte*~) main::$0 and assignment (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word) 80 +Eliminating unused variable (word~) main::$18 and assignment (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 +Eliminating unused variable (word~) main::$20 and assignment (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from (byte*) main::screen ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word) 80 - (byte) main::a ← *((byte*~) main::$0) (byte) main::i ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -220,15 +226,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL ← ((byte*)) (word) 53280 *((byte*) main::BGCOL) ← ++ *((byte*) main::BGCOL) to:main::@return @@ -247,8 +247,6 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL to:@1 main: scope:[main] from @1 (byte*) main::screen ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word) 80 - (byte) main::a ← *((byte*~) main::$0) (byte) main::i ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -282,15 +280,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL ← ((byte*)) (word) 53280 *((byte*) main::BGCOL) ← ++ *((byte*) main::BGCOL) to:main::@return @@ -310,8 +302,6 @@ CONTROL FLOW GRAPH SSA to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -350,15 +340,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -377,8 +361,6 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -417,15 +399,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -445,21 +421,14 @@ INITIAL SSA SYMBOL TABLE (label) @begin (label) @end (void()) main() -(byte*~) main::$0 (byte*~) main::$1 (byte*~) main::$10 (byte*~) main::$11 (boolean~) main::$12 (byte*~) main::$13 -(byte*~) main::$14 -(byte*~) main::$15 (word~) main::$16 (byte*~) main::$17 -(word~) main::$18 -(byte*~) main::$19 (byte*~) main::$2 -(word~) main::$20 -(byte*~) main::$21 (boolean~) main::$3 (byte*~) main::$4 (byte*~) main::$5 @@ -474,8 +443,6 @@ INITIAL SSA SYMBOL TABLE (label) main::@return (byte*) main::BGCOL (byte*) main::BGCOL#0 -(byte) main::a -(byte) main::a#0 (byte) main::i (byte) main::i#0 (byte) main::i#1 @@ -499,8 +466,6 @@ CONTROL FLOW GRAPH to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -539,15 +504,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -568,8 +527,6 @@ CONTROL FLOW GRAPH to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -606,15 +563,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -635,8 +586,6 @@ CONTROL FLOW GRAPH to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -673,15 +622,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -701,8 +644,6 @@ CONTROL FLOW GRAPH to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -737,15 +678,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -765,8 +700,6 @@ CONTROL FLOW GRAPH to:@1 main: scope:[main] from @1 (byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024 - (byte*~) main::$0 ← (byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 to:main::@1 main::@1: scope:[main] from main main::@1 @@ -799,15 +732,9 @@ main::@2: scope:[main] from main::@2 main::@3 main::@4: scope:[main] from main::@2 (byte*~) main::$13 ← ((byte*)) (word) 53280 *((byte*~) main::$13) ← ++ *((byte*~) main::$13) - (byte*~) main::$14 ← ((byte*)) (word) 53280 - (byte*~) main::$15 ← ((byte*)) (word) 53280 (word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33 (byte*~) main::$17 ← ((byte*)) (word~) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$19 ← ((byte*)) (word~) main::$18 - (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 - (byte*~) main::$21 ← ((byte*)) (word~) main::$20 (byte*) main::BGCOL#0 ← ((byte*)) (word) 53280 *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0) to:main::@return @@ -823,19 +750,13 @@ Constant (const byte*) main::screen#0 = ((byte*))1024 Constant (const byte) main::i#0 = 0 Constant (const byte) main::j#0 = 0 Constant (const byte*) main::$13 = ((byte*))53280 -Constant (const byte*) main::$14 = ((byte*))53280 -Constant (const byte*) main::$15 = ((byte*))53280 Constant (const word) main::$16 = 53248+33 -Constant (const word) main::$18 = 53248+33 -Constant (const word) main::$20 = 53248+33 Constant (const byte*) main::BGCOL#0 = ((byte*))53280 Succesful SSA optimization Pass2ConstantIdentification CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte*~) main::$0 ← (const byte*) main::screen#0 + (byte/signed byte/word/signed word) 80 - (byte) main::a#0 ← *((byte*~) main::$0) to:main::@1 main::@1: scope:[main] from main main::@1 (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 ) @@ -867,8 +788,6 @@ main::@4: scope:[main] from main::@2 *((const byte*) main::$13) ← ++ *((const byte*) main::$13) (byte*~) main::$17 ← ((byte*)) (const word) main::$16 *((byte*~) main::$17) ← -- *((byte*~) main::$17) - (byte*~) main::$19 ← ((byte*)) (const word) main::$18 - (byte*~) main::$21 ← ((byte*)) (const word) main::$20 *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) to:main::@return main::@return: scope:[main] from main::@4 @@ -879,7 +798,6 @@ main::@return: scope:[main] from main::@4 to:@end @end: scope:[] from @1 -Constant (const byte*) main::$0 = main::screen#0+80 Constant (const byte*) main::$1 = main::screen#0+40 Constant (const byte*) main::sc2#0 = main::screen#0+81 Constant (const byte*) main::$5 = main::screen#0+121 @@ -888,14 +806,11 @@ Constant (const byte*) main::$7 = main::screen#0+122 Constant (const byte*) main::$8 = main::screen#0+160 Constant (const byte*) main::$10 = main::screen#0+200 Constant (const byte*) main::$17 = ((byte*))main::$16 -Constant (const byte*) main::$19 = ((byte*))main::$18 -Constant (const byte*) main::$21 = ((byte*))main::$20 Succesful SSA optimization Pass2ConstantIdentification CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte) main::a#0 ← *((const byte*) main::$0) to:main::@1 main::@1: scope:[main] from main main::@1 (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 ) @@ -941,30 +856,22 @@ Inlining constant with var siblings (const byte) main::i#0 Inlining constant with var siblings (const byte) main::i#0 Inlining constant with var siblings (const byte) main::j#0 Inlining constant with var siblings (const byte) main::j#0 -Constant inlined main::$13 = ((byte*))(word) 53280 -Constant inlined main::$14 = ((byte*))(word) 53280 -Constant inlined main::$15 = ((byte*))(word) 53280 -Constant inlined main::$20 = (word) 53248+(byte/signed byte/word/signed word) 33 -Constant inlined main::$10 = (const byte*) main::screen#0+(byte/word/signed word) 200 -Constant inlined main::$21 = ((byte*))(word) 53248+(byte/signed byte/word/signed word) 33 Constant inlined main::$16 = (word) 53248+(byte/signed byte/word/signed word) 33 Constant inlined main::$1 = (const byte*) main::screen#0+(byte/signed byte/word/signed word) 40 Constant inlined main::$17 = ((byte*))(word) 53248+(byte/signed byte/word/signed word) 33 -Constant inlined main::$18 = (word) 53248+(byte/signed byte/word/signed word) 33 -Constant inlined main::$0 = (const byte*) main::screen#0+(byte/signed byte/word/signed word) 80 -Constant inlined main::$19 = ((byte*))(word) 53248+(byte/signed byte/word/signed word) 33 Constant inlined main::$5 = (const byte*) main::screen#0+(byte/signed byte/word/signed word) 121 Constant inlined main::i#0 = (byte/signed byte/word/signed word) 0 +Constant inlined main::$13 = ((byte*))(word) 53280 Constant inlined main::$6 = (const byte*) main::screen#0+(byte/signed byte/word/signed word) 82 Constant inlined main::j#0 = (byte/signed byte/word/signed word) 0 Constant inlined main::$7 = (const byte*) main::screen#0+(byte/signed byte/word/signed word) 122 +Constant inlined main::$10 = (const byte*) main::screen#0+(byte/word/signed word) 200 Constant inlined main::$8 = (const byte*) main::screen#0+(byte/word/signed word) 160 Succesful SSA optimization Pass2ConstantInlining CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) to:main::@1 main::@1: scope:[main] from main main::@1 (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word) 0 main::@1/(byte) main::i#1 ) @@ -1013,8 +920,6 @@ FINAL SYMBOL TABLE (label) main::@return (byte*) main::BGCOL (const byte*) main::BGCOL#0 = ((byte*))(word) 53280 -(byte) main::a -(byte) main::a#0 (byte) main::i (byte) main::i#1 (byte) main::i#2 @@ -1038,7 +943,6 @@ CONTROL FLOW GRAPH - PHI LIFTED to:@end @end: scope:[] from @1 main: scope:[main] from @1 - (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) to:main::@1 main::@1: scope:[main] from main main::@5 (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word) 0 main::@5/(byte~) main::i#3 ) @@ -1077,6 +981,7 @@ main::@5: scope:[main] from main::@1 Adding NOP phi() at start of @begin Adding NOP phi() at start of @1 Adding NOP phi() at start of @end +Adding NOP phi() at start of main CALL GRAPH Calls in [] to main:2 @@ -1094,7 +999,7 @@ CONTROL FLOW GRAPH - LIVE RANGES FOUND @end: scope:[] from @1 [3] phi() [ ] main: scope:[main] from @1 - [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] + [4] phi() [ ] to:main::@1 main::@1: scope:[main] from main main::@5 [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word) 0 main::@5/(byte~) main::i#3 ) [ main::i#2 ] @@ -1140,6 +1045,7 @@ Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@4 m Adding NOP phi() at start of @begin Adding NOP phi() at start of @1 Adding NOP phi() at start of @end +Adding NOP phi() at start of main Propagating live ranges... Propagating live ranges... Propagating live ranges... @@ -1154,7 +1060,7 @@ CONTROL FLOW GRAPH - BEFORE EFFECTIVE LIVE RANGES @end: scope:[] from @1 [3] phi() [ ] main: scope:[main] from @1 - [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] + [4] phi() [ ] to:main::@1 main::@1: scope:[main] from main main::@1 [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] @@ -1195,7 +1101,7 @@ CONTROL FLOW GRAPH - PHI MEM COALESCED @end: scope:[] from @1 [3] phi() [ ] ( ) main: scope:[main] from @1 - [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) + [4] phi() [ ] ( main:2 [ ] ) to:main::@1 main::@1: scope:[main] from main main::@1 [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] ( main:2 [ main::i#2 ] ) @@ -1259,8 +1165,6 @@ VARIABLE REGISTER WEIGHTS (byte*~) main::$2 22.0 (byte*~) main::$9 11.0 (byte*) main::BGCOL -(byte) main::a -(byte) main::a#0 20.0 (byte) main::i (byte) main::i#1 16.5 (byte) main::i#2 14.666666666666666 @@ -1273,23 +1177,20 @@ VARIABLE REGISTER WEIGHTS Initial phi equivalence classes [ main::i#2 main::i#1 ] [ main::j#2 main::j#1 ] -Added variable main::a#0 to zero page equivalence class [ main::a#0 ] Added variable main::$2 to zero page equivalence class [ main::$2 ] Added variable main::$9 to zero page equivalence class [ main::$9 ] Added variable main::$11 to zero page equivalence class [ main::$11 ] Complete equivalence classes [ main::i#2 main::i#1 ] [ main::j#2 main::j#1 ] -[ main::a#0 ] [ main::$2 ] [ main::$9 ] [ main::$11 ] Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] Allocated zp ZP_BYTE:3 [ main::j#2 main::j#1 ] -Allocated zp ZP_BYTE:4 [ main::a#0 ] -Allocated zp ZP_PTR_BYTE:5 [ main::$2 ] -Allocated zp ZP_PTR_BYTE:7 [ main::$9 ] -Allocated zp ZP_PTR_BYTE:9 [ main::$11 ] +Allocated zp ZP_PTR_BYTE:4 [ main::$2 ] +Allocated zp ZP_PTR_BYTE:6 [ main::$9 ] +Allocated zp ZP_PTR_BYTE:8 [ main::$11 ] INITIAL ASM //SEG0 Basic Upstart .pc = $801 "Basic" @@ -1304,26 +1205,24 @@ b1_from_bbegin: //SEG4 @1 b1: //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] +main_from_b1: jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] +//SEG7 [3] phi from @1 to @end [phi:@1->@end] bend_from_b1: jmp bend -//SEG7 @end +//SEG8 @end bend: -//SEG8 main +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 .const sc2 = screen+$51 - .label _2 = 5 - .label _9 = 7 - .label _11 = 9 - .label a = 4 + .label _2 = 4 + .label _9 = 6 + .label _11 = 8 .label i = 2 .label j = 3 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- zpby1=_deref_cowo1 - lda screen+$50 - sta a //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- zpby1=coby1 @@ -1440,20 +1339,19 @@ Statement [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/si Statement [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] ) always clobbers reg byte a reg byte y Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , Potential registers zp ZP_BYTE:3 [ main::j#2 main::j#1 ] : zp ZP_BYTE:3 , reg byte x , -Potential registers zp ZP_BYTE:4 [ main::a#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , -Potential registers zp ZP_PTR_BYTE:5 [ main::$2 ] : zp ZP_PTR_BYTE:5 , -Potential registers zp ZP_PTR_BYTE:7 [ main::$9 ] : zp ZP_PTR_BYTE:7 , -Potential registers zp ZP_PTR_BYTE:9 [ main::$11 ] : zp ZP_PTR_BYTE:9 , +Potential registers zp ZP_PTR_BYTE:4 [ main::$2 ] : zp ZP_PTR_BYTE:4 , +Potential registers zp ZP_PTR_BYTE:6 [ main::$9 ] : zp ZP_PTR_BYTE:6 , +Potential registers zp ZP_PTR_BYTE:8 [ main::$11 ] : zp ZP_PTR_BYTE:8 , REGISTER UPLIFT SCOPES -Uplift Scope [main] 31.17: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 27.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 22: zp ZP_PTR_BYTE:5 [ main::$2 ] 22: zp ZP_PTR_BYTE:9 [ main::$11 ] 20: zp ZP_BYTE:4 [ main::a#0 ] 11: zp ZP_PTR_BYTE:7 [ main::$9 ] +Uplift Scope [main] 31.17: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 27.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 22: zp ZP_PTR_BYTE:4 [ main::$2 ] 22: zp ZP_PTR_BYTE:8 [ main::$11 ] 11: zp ZP_PTR_BYTE:6 [ main::$9 ] Uplift Scope [] -Uplifting [main] best 1199 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] zp ZP_PTR_BYTE:5 [ main::$2 ] zp ZP_PTR_BYTE:9 [ main::$11 ] reg byte a [ main::a#0 ] zp ZP_PTR_BYTE:7 [ main::$9 ] -Uplifting [] best 1199 combination -Coalescing zero page register [ zp ZP_PTR_BYTE:5 [ main::$2 ] ] with [ zp ZP_PTR_BYTE:7 [ main::$9 ] ] -Allocated (was zp ZP_PTR_BYTE:5) zp ZP_PTR_BYTE:2 [ main::$2 main::$9 ] -Allocated (was zp ZP_PTR_BYTE:9) zp ZP_PTR_BYTE:4 [ main::$11 ] +Uplifting [main] best 1195 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] zp ZP_PTR_BYTE:4 [ main::$2 ] zp ZP_PTR_BYTE:8 [ main::$11 ] zp ZP_PTR_BYTE:6 [ main::$9 ] +Uplifting [] best 1195 combination +Coalescing zero page register [ zp ZP_PTR_BYTE:4 [ main::$2 ] ] with [ zp ZP_PTR_BYTE:6 [ main::$9 ] ] +Allocated (was zp ZP_PTR_BYTE:4) zp ZP_PTR_BYTE:2 [ main::$2 main::$9 ] +Allocated (was zp ZP_PTR_BYTE:8) zp ZP_PTR_BYTE:4 [ main::$11 ] Removing instruction jmp b1 Removing instruction jmp bend Removing instruction jmp b1 @@ -1475,12 +1373,14 @@ b1_from_bbegin: //SEG4 @1 b1: //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] +main_from_b1: jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] +//SEG7 [3] phi from @1 to @end [phi:@1->@end] bend_from_b1: -//SEG7 @end +//SEG8 @end bend: -//SEG8 main +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 @@ -1488,8 +1388,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- aby=_deref_cowo1 - lda screen+$50 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 @@ -1590,12 +1488,14 @@ b1_from_bbegin: //SEG4 @1 b1: //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] +main_from_b1: jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] +//SEG7 [3] phi from @1 to @end [phi:@1->@end] bend_from_b1: -//SEG7 @end +//SEG8 @end bend: -//SEG8 main +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 @@ -1603,8 +1503,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- aby=_deref_cowo1 - lda screen+$50 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 @@ -1693,6 +1591,7 @@ Replacing label b1_from_b1 with b1 Replacing label b2_from_b2 with b2 Removing instruction bbegin: Removing instruction b1_from_bbegin: +Removing instruction main_from_b1: Removing instruction bend_from_b1: Removing instruction b1_from_b1: Removing instruction b2_from_b2: @@ -1708,11 +1607,12 @@ ASSEMBLER //SEG4 @1 b1: //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] -//SEG7 @end +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +//SEG8 @end bend: -//SEG8 main +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 @@ -1720,8 +1620,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- aby=_deref_cowo1 - lda screen+$50 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 @@ -1822,10 +1720,11 @@ ASSEMBLER //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] //SEG4 @1 //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] -//SEG7 @end -//SEG8 main +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +//SEG8 @end +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 @@ -1833,8 +1732,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- aby=_deref_cowo1 - lda screen+$50 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 ldx #0 @@ -1925,10 +1822,11 @@ ASSEMBLER //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] //SEG4 @1 //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] -//SEG7 @end -//SEG8 main +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +//SEG8 @end +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 @@ -1936,8 +1834,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- aby=_deref_cowo1 - lda screen+$50 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 ldx #0 @@ -2028,8 +1924,6 @@ FINAL SYMBOL TABLE (label) main::@return (byte*) main::BGCOL (const byte*) main::BGCOL#0 BGCOL = ((byte*))(word) 53280 -(byte) main::a -(byte) main::a#0 reg byte a 20.0 (byte) main::i (byte) main::i#1 reg byte x 16.5 (byte) main::i#2 reg byte x 14.666666666666666 @@ -2043,7 +1937,6 @@ FINAL SYMBOL TABLE reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] -reg byte a [ main::a#0 ] zp ZP_PTR_BYTE:2 [ main::$2 main::$9 ] zp ZP_PTR_BYTE:4 [ main::$11 ] @@ -2057,10 +1950,11 @@ FINAL CODE //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] //SEG4 @1 //SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @1 to main [phi:@1->main] jsr main -//SEG6 [3] phi from @1 to @end [phi:@1->@end] -//SEG7 @end -//SEG8 main +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +//SEG8 @end +//SEG9 main main: { .const screen = $400 .const BGCOL = $d020 @@ -2068,8 +1962,6 @@ main: { .label _2 = 2 .label _9 = 2 .label _11 = 4 - //SEG9 [4] (byte) main::a#0 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 80) [ ] ( main:2 [ ] ) -- aby=_deref_cowo1 - lda screen+$50 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 ldx #0 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.sym b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.sym index 8d3f28050..f3289e9ac 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptr-complex.sym @@ -12,8 +12,6 @@ (label) main::@return (byte*) main::BGCOL (const byte*) main::BGCOL#0 BGCOL = ((byte*))(word) 53280 -(byte) main::a -(byte) main::a#0 reg byte a 20.0 (byte) main::i (byte) main::i#1 reg byte x 16.5 (byte) main::i#2 reg byte x 14.666666666666666 @@ -27,6 +25,5 @@ reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] -reg byte a [ main::a#0 ] zp ZP_PTR_BYTE:2 [ main::$2 main::$9 ] zp ZP_PTR_BYTE:4 [ main::$11 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.asm b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.asm index 2116c11f8..c1e9c22e6 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.asm @@ -3,14 +3,12 @@ .pc = $80d "Program" jsr main main: { - .const SCREEN = $400 ldx #2 b1: cpx #$a bcc b2 rts b2: - lda SCREEN,x inx jmp b1 } diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.cfg b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.cfg index 99c5a4de0..ab3559c5f 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.cfg +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.cfg @@ -18,6 +18,5 @@ main::@return: scope:[main] from main::@1 [7] return [ ] ( main:2 [ ] ) to:@return main::@2: scope:[main] from main::@1 - [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) - [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) + [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) to:main::@1 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 5fedf139e..9031ca56e 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.log @@ -80,6 +80,9 @@ main::@return: scope:[main] from main::@3 to:@end @end: scope:[] from @1 +Eliminating unused variable (byte) main::b and assignment (byte) main::b ← (byte~) main::$1 +Eliminating unused variable (byte~) main::$1 and assignment (byte~) main::$1 ← (byte[1024]) main::SCREEN *idx (byte) main::i +Eliminating unused variable (byte[1024]) main::SCREEN and assignment (byte[1024]) main::SCREEN ← ((byte*)) (word/signed word) 1024 Removing empty block main::@4 Removing empty block main::@3 Removing empty block main::@5 @@ -88,7 +91,6 @@ CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from - (byte[1024]) main::SCREEN ← ((byte*)) (word/signed word) 1024 (byte) main::i ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 @@ -96,8 +98,6 @@ main::@1: scope:[main] from main main::@2 if((boolean~) main::$0) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte~) main::$1 ← (byte[1024]) main::SCREEN *idx (byte) main::i - (byte) main::b ← (byte~) main::$1 (byte) main::i ← ++ (byte) main::i to:main::@1 main::@return: scope:[main] from main::@1 @@ -114,7 +114,6 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte[1024]) main::SCREEN ← ((byte*)) (word/signed word) 1024 (byte) main::i ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 @@ -122,8 +121,6 @@ main::@1: scope:[main] from main main::@2 if((boolean~) main::$0) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte~) main::$1 ← (byte[1024]) main::SCREEN *idx (byte) main::i - (byte) main::b ← (byte~) main::$1 (byte) main::i ← ++ (byte) main::i to:main::@1 main::@return: scope:[main] from main::@1 @@ -136,26 +133,20 @@ main::@return: scope:[main] from main::@1 to:@end @end: scope:[] from @2 -Completing Phi functions... Completing Phi functions... CONTROL FLOW GRAPH SSA @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 - (byte[1024]) main::SCREEN#2 ← phi( main/(byte[1024]) main::SCREEN#0 main::@2/(byte[1024]) main::SCREEN#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) (boolean~) main::$0 ← (byte) main::i#2 < (byte/signed byte/word/signed word) 10 if((boolean~) main::$0) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 ) - (byte[1024]) main::SCREEN#1 ← phi( main::@1/(byte[1024]) main::SCREEN#2 ) - (byte~) main::$1 ← (byte[1024]) main::SCREEN#1 *idx (byte) main::i#3 - (byte) main::b#0 ← (byte~) main::$1 (byte) main::i#1 ← ++ (byte) main::i#3 to:main::@1 main::@return: scope:[main] from main::@1 @@ -172,20 +163,15 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 - (byte[1024]) main::SCREEN#2 ← phi( main/(byte[1024]) main::SCREEN#0 main::@2/(byte[1024]) main::SCREEN#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) (boolean~) main::$0 ← (byte) main::i#2 < (byte/signed byte/word/signed word) 10 if((boolean~) main::$0) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 ) - (byte[1024]) main::SCREEN#1 ← phi( main::@1/(byte[1024]) main::SCREEN#2 ) - (byte~) main::$1 ← (byte[1024]) main::SCREEN#1 *idx (byte) main::i#3 - (byte) main::b#0 ← (byte~) main::$1 (byte) main::i#1 ← ++ (byte) main::i#3 to:main::@1 main::@return: scope:[main] from main::@1 @@ -205,16 +191,9 @@ INITIAL SSA SYMBOL TABLE (label) @end (void()) main() (boolean~) main::$0 -(byte~) main::$1 (label) main::@1 (label) main::@2 (label) main::@return -(byte[1024]) main::SCREEN -(byte[1024]) main::SCREEN#0 -(byte[1024]) main::SCREEN#1 -(byte[1024]) main::SCREEN#2 -(byte) main::b -(byte) main::b#0 (byte) main::i (byte) main::i#0 (byte) main::i#1 @@ -227,20 +206,15 @@ CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 - (byte[1024]) main::SCREEN#2 ← phi( main/(byte[1024]) main::SCREEN#0 main::@2/(byte[1024]) main::SCREEN#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) (boolean~) main::$0 ← (byte) main::i#2 < (byte/signed byte/word/signed word) 10 if((boolean~) main::$0) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 ) - (byte[1024]) main::SCREEN#1 ← phi( main::@1/(byte[1024]) main::SCREEN#2 ) - (byte~) main::$1 ← (byte[1024]) main::SCREEN#1 *idx (byte) main::i#3 - (byte) main::b#0 ← (byte~) main::$1 (byte) main::i#1 ← ++ (byte) main::i#3 to:main::@1 main::@return: scope:[main] from main::@1 @@ -251,69 +225,12 @@ main::@return: scope:[main] from main::@1 to:@end @end: scope:[] from @1 -Alias (byte[1024]) main::SCREEN#1 = (byte[1024]) main::SCREEN#2 Alias (byte) main::i#2 = (byte) main::i#3 -Alias (byte) main::b#0 = (byte~) main::$1 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 - to:main::@1 -main::@1: scope:[main] from main main::@2 - (byte[1024]) main::SCREEN#1 ← phi( main/(byte[1024]) main::SCREEN#0 main::@2/(byte[1024]) main::SCREEN#1 ) - (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) - (boolean~) main::$0 ← (byte) main::i#2 < (byte/signed byte/word/signed word) 10 - if((boolean~) main::$0) goto main::@2 - to:main::@return -main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (byte[1024]) main::SCREEN#1 *idx (byte) main::i#2 - (byte) main::i#1 ← ++ (byte) main::i#2 - to:main::@1 -main::@return: scope:[main] from main::@1 - return - to:@return -@1: scope:[] from @begin - call main param-assignment - to:@end -@end: scope:[] from @1 - -Self Phi Eliminated (byte[1024]) main::SCREEN#1 -Succesful SSA optimization Pass2SelfPhiElimination -CONTROL FLOW GRAPH -@begin: scope:[] from - to:@1 -main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 - to:main::@1 -main::@1: scope:[main] from main main::@2 - (byte[1024]) main::SCREEN#1 ← phi( main/(byte[1024]) main::SCREEN#0 ) - (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) - (boolean~) main::$0 ← (byte) main::i#2 < (byte/signed byte/word/signed word) 10 - if((boolean~) main::$0) goto main::@2 - to:main::@return -main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (byte[1024]) main::SCREEN#1 *idx (byte) main::i#2 - (byte) main::i#1 ← ++ (byte) main::i#2 - to:main::@1 -main::@return: scope:[main] from main::@1 - return - to:@return -@1: scope:[] from @begin - call main param-assignment - to:@end -@end: scope:[] from @1 - -Redundant Phi (byte[1024]) main::SCREEN#1 (byte[1024]) main::SCREEN#0 -Succesful SSA optimization Pass2RedundantPhiElimination -CONTROL FLOW GRAPH -@begin: scope:[] from - to:@1 -main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 @@ -322,7 +239,6 @@ main::@1: scope:[main] from main main::@2 if((boolean~) main::$0) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@1 main::@return: scope:[main] from main::@1 @@ -339,7 +255,6 @@ CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from @1 - (byte[1024]) main::SCREEN#0 ← ((byte*)) (word/signed word) 1024 (byte) main::i#0 ← (byte/signed byte/word/signed word) 2 to:main::@1 main::@1: scope:[main] from main main::@2 @@ -347,7 +262,6 @@ main::@1: scope:[main] from main main::@2 if((byte) main::i#2<(byte/signed byte/word/signed word) 10) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@1 main::@return: scope:[main] from main::@1 @@ -358,7 +272,6 @@ main::@return: scope:[main] from main::@1 to:@end @end: scope:[] from @1 -Constant (const byte[1024]) main::SCREEN#0 = ((byte*))1024 Constant (const byte) main::i#0 = 2 Succesful SSA optimization Pass2ConstantIdentification CONTROL FLOW GRAPH @@ -371,7 +284,6 @@ main::@1: scope:[main] from main main::@2 if((byte) main::i#2<(byte/signed byte/word/signed word) 10) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@1 main::@return: scope:[main] from main::@1 @@ -382,8 +294,6 @@ main::@return: scope:[main] from main::@1 to:@end @end: scope:[] from @1 -Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 -Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Inlining constant with var siblings (const byte) main::i#0 Inlining constant with var siblings (const byte) main::i#0 Constant inlined main::i#0 = (byte/signed byte/word/signed word) 2 @@ -398,7 +308,6 @@ main::@1: scope:[main] from main main::@2 if((byte) main::i#2<(byte/signed byte/word/signed word) 10) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@1 main::@return: scope:[main] from main::@1 @@ -417,10 +326,6 @@ FINAL SYMBOL TABLE (label) main::@1 (label) main::@2 (label) main::@return -(byte[1024]) main::SCREEN -(const byte[1024]) main::SCREEN#0 = ((byte*))(word/signed word) 1024 -(byte) main::b -(byte) main::b#0 (byte) main::i (byte) main::i#1 (byte) main::i#2 @@ -444,7 +349,6 @@ main::@return: scope:[main] from main::@1 return to:@return main::@2: scope:[main] from main::@1 - (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2 (byte~) main::i#4 ← (byte) main::i#1 to:main::@1 @@ -479,13 +383,12 @@ main::@return: scope:[main] from main::@1 [7] return [ ] to:@return main::@2: scope:[main] from main::@1 - [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] - [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] - [10] (byte~) main::i#4 ← (byte) main::i#1 [ main::i#4 ] + [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] + [9] (byte~) main::i#4 ← (byte) main::i#1 [ main::i#4 ] to:main::@1 Created 1 initial phi equivalence classes -Coalesced [10] main::i#4 ← main::i#1 +Coalesced [9] main::i#4 ← main::i#1 Coalesced down to 1 phi equivalence classes Block Sequence Planned @begin @1 @end main main::@1 main::@return main::@2 Adding NOP phi() at start of @begin @@ -515,8 +418,7 @@ main::@return: scope:[main] from main::@1 [7] return [ ] to:@return main::@2: scope:[main] from main::@1 - [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] - [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] + [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] to:main::@1 CONTROL FLOW GRAPH - PHI MEM COALESCED @@ -540,8 +442,7 @@ main::@return: scope:[main] from main::@1 [7] return [ ] ( main:2 [ ] ) to:@return main::@2: scope:[main] from main::@1 - [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) - [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) + [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) to:main::@1 DOMINATORS @@ -567,21 +468,15 @@ Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 depth: 1 VARIABLE REGISTER WEIGHTS (void()) main() -(byte[1024]) main::SCREEN -(byte) main::b -(byte) main::b#0 110.0 (byte) main::i (byte) main::i#1 22.0 -(byte) main::i#2 14.666666666666666 +(byte) main::i#2 16.5 Initial phi equivalence classes [ main::i#2 main::i#1 ] -Added variable main::b#0 to zero page equivalence class [ main::b#0 ] Complete equivalence classes [ main::i#2 main::i#1 ] -[ main::b#0 ] Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] -Allocated zp ZP_BYTE:3 [ main::b#0 ] INITIAL ASM //SEG0 Basic Upstart .pc = $801 "Basic" @@ -606,8 +501,6 @@ bend_from_b1: bend: //SEG9 main main: { - .const SCREEN = $400 - .label b = 3 .label i = 2 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: @@ -628,28 +521,23 @@ main: { rts //SEG16 main::@2 b2: - //SEG17 [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- zpby1=cowo1_derefidx_zpby2 - ldx i - lda SCREEN,x - sta b - //SEG18 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- zpby1=_inc_zpby1 + //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- zpby1=_inc_zpby1 inc i - //SEG19 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + //SEG18 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] b1_from_b2: - //SEG20 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + //SEG19 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy jmp b1 } REGISTER UPLIFT POTENTIAL REGISTERS Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , -Potential registers zp ZP_BYTE:3 [ main::b#0 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , REGISTER UPLIFT SCOPES -Uplift Scope [main] 110: zp ZP_BYTE:3 [ main::b#0 ] 36.67: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Uplift Scope [main] 38.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] Uplift Scope [] -Uplifting [main] best 238 combination reg byte a [ main::b#0 ] reg byte x [ main::i#2 main::i#1 ] -Uplifting [] best 238 combination +Uplifting [main] best 193 combination reg byte x [ main::i#2 main::i#1 ] +Uplifting [] best 193 combination Removing instruction jmp b1 Removing instruction jmp bend Removing instruction jmp b1 @@ -677,7 +565,6 @@ bend_from_b1: bend: //SEG9 main main: { - .const SCREEN = $400 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 2 [phi:main->main::@1#0] -- xby=coby1 @@ -693,13 +580,11 @@ main: { rts //SEG16 main::@2 b2: - //SEG17 [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- aby=cowo1_derefidx_xby - lda SCREEN,x - //SEG18 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby inx - //SEG19 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + //SEG18 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] b1_from_b2: - //SEG20 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + //SEG19 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy jmp b1 } @@ -726,7 +611,6 @@ b1: bend: //SEG9 main main: { - .const SCREEN = $400 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 2 [phi:main->main::@1#0] -- xby=coby1 @@ -742,13 +626,11 @@ main: { rts //SEG16 main::@2 b2: - //SEG17 [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- aby=cowo1_derefidx_xby - lda SCREEN,x - //SEG18 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby inx - //SEG19 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + //SEG18 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] b1_from_b2: - //SEG20 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + //SEG19 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy jmp b1 } @@ -774,7 +656,6 @@ ASSEMBLER //SEG8 @end //SEG9 main main: { - .const SCREEN = $400 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 2 [phi:main->main::@1#0] -- xby=coby1 ldx #2 @@ -788,12 +669,10 @@ main: { rts //SEG16 main::@2 b2: - //SEG17 [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- aby=cowo1_derefidx_xby - lda SCREEN,x - //SEG18 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby inx - //SEG19 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] - //SEG20 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + //SEG18 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + //SEG19 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy jmp b1 } @@ -805,16 +684,11 @@ FINAL SYMBOL TABLE (label) main::@1 (label) main::@2 (label) main::@return -(byte[1024]) main::SCREEN -(const byte[1024]) main::SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 -(byte) main::b -(byte) main::b#0 reg byte a 110.0 (byte) main::i (byte) main::i#1 reg byte x 22.0 -(byte) main::i#2 reg byte x 14.666666666666666 +(byte) main::i#2 reg byte x 16.5 reg byte x [ main::i#2 main::i#1 ] -reg byte a [ main::b#0 ] FINAL CODE //SEG0 Basic Upstart @@ -832,7 +706,6 @@ FINAL CODE //SEG8 @end //SEG9 main main: { - .const SCREEN = $400 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 2 [phi:main->main::@1#0] -- xby=coby1 ldx #2 @@ -846,12 +719,10 @@ main: { rts //SEG16 main::@2 b2: - //SEG17 [8] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- aby=cowo1_derefidx_xby - lda SCREEN,x - //SEG18 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby inx - //SEG19 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] - //SEG20 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + //SEG18 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + //SEG19 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy jmp b1 } diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.sym b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.sym index 01967a768..446dc1a1b 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtestmin.sym @@ -5,13 +5,8 @@ (label) main::@1 (label) main::@2 (label) main::@return -(byte[1024]) main::SCREEN -(const byte[1024]) main::SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 -(byte) main::b -(byte) main::b#0 reg byte a 110.0 (byte) main::i (byte) main::i#1 reg byte x 22.0 -(byte) main::i#2 reg byte x 14.666666666666666 +(byte) main::i#2 reg byte x 16.5 reg byte x [ main::i#2 main::i#1 ] -reg byte a [ main::b#0 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.asm b/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.asm index 337524b7c..3c2e5fa85 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.asm @@ -2,7 +2,6 @@ :BasicUpstart(main) .pc = $80d "Program" .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" jsr main main: { diff --git a/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.log b/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.log index 9e6bb1c8f..245584527 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.log @@ -94,11 +94,11 @@ main::@return: scope:[main] from main::@4 to:@end @end: scope:[] from @1 +Eliminating unused variable (byte*) SCROLL and assignment (byte*) SCROLL ← ((byte*)) (word) 53270 Removing empty block main::@4 CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL ← ((byte*)) (word) 53270 (byte[]) TEXT ← (string) "01234567@" to:@1 main: scope:[main] from @@ -134,7 +134,6 @@ PROCEDURE MODIFY VARIABLE ANALYSIS CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @begin: scope:[] from (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL ← ((byte*)) (word) 53270 (byte[]) TEXT ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -174,7 +173,6 @@ Completing Phi functions... CONTROL FLOW GRAPH SSA @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -226,7 +224,6 @@ main::@return: scope:[main] from main::@2 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -287,8 +284,6 @@ INITIAL SSA SYMBOL TABLE (byte*) SCREEN#3 (byte*) SCREEN#4 (byte*) SCREEN#5 -(byte*) SCROLL -(byte*) SCROLL#0 (byte[]) TEXT (byte[]) TEXT#0 (byte[]) TEXT#1 @@ -325,7 +320,6 @@ Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -377,7 +371,6 @@ Succesful SSA optimization Pass2UnaryNotSimplification CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -436,7 +429,6 @@ Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -488,7 +480,6 @@ Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -536,7 +527,6 @@ Succesful SSA optimization Pass2SelfPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -582,7 +572,6 @@ Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -621,7 +610,6 @@ Succesful SSA optimization Pass2ConditionalJumpSimplification CONTROL FLOW GRAPH @begin: scope:[] from (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 - (byte*) SCROLL#0 ← ((byte*)) (word) 53270 (byte[]) TEXT#0 ← (string) "01234567@" to:@1 main: scope:[main] from @1 @@ -655,7 +643,6 @@ main::@return: scope:[main] from main::@2 @end: scope:[] from @1 Constant (const byte*) SCREEN#0 = ((byte*))1024 -Constant (const byte*) SCROLL#0 = ((byte*))53270 Constant (const byte[]) TEXT#0 = "01234567@" Constant (const byte) main::i#0 = 0 Succesful SSA optimization Pass2ConstantIdentification @@ -772,8 +759,6 @@ FINAL SYMBOL TABLE (label) @end (byte*) SCREEN (const byte*) SCREEN#0 = ((byte*))(word/signed word) 1024 -(byte*) SCROLL -(const byte*) SCROLL#0 = ((byte*))(word) 53270 (byte[]) TEXT (const byte[]) TEXT#0 = (string) "01234567@" (void()) main() @@ -1003,7 +988,6 @@ Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 main::@3 depth: 1 VARIABLE REGISTER WEIGHTS (byte*) SCREEN -(byte*) SCROLL (byte[]) TEXT (void()) main() (byte) main::c @@ -1036,7 +1020,6 @@ INITIAL ASM .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin bbegin: @@ -1157,7 +1140,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin bbegin: @@ -1252,7 +1234,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] @@ -1339,7 +1320,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] @@ -1415,7 +1395,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] @@ -1491,7 +1470,6 @@ ASSEMBLER .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] @@ -1561,8 +1539,6 @@ FINAL SYMBOL TABLE (label) @end (byte*) SCREEN (const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 -(byte*) SCROLL -(const byte*) SCROLL#0 SCROLL = ((byte*))(word) 53270 (byte[]) TEXT (const byte[]) TEXT#0 TEXT = (string) "01234567@" (void()) main() @@ -1593,7 +1569,6 @@ FINAL CODE .pc = $80d "Program" //SEG1 Global Constants & labels .const SCREEN = $400 - .const SCROLL = $d016 TEXT: .text "01234567@" //SEG2 @begin //SEG3 [1] phi from @begin to @1 [phi:@begin->@1] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.sym b/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.sym index 93201afc8..9d3baef57 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.sym @@ -3,8 +3,6 @@ (label) @end (byte*) SCREEN (const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 -(byte*) SCROLL -(const byte*) SCROLL#0 SCROLL = ((byte*))(word) 53270 (byte[]) TEXT (const byte[]) TEXT#0 TEXT = (string) "01234567@" (void()) main() diff --git a/src/main/java/dk/camelot64/kickc/test/ref/scroll.log b/src/main/java/dk/camelot64/kickc/test/ref/scroll.log index ba8c65399..a8249cd36 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/scroll.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/scroll.log @@ -243,6 +243,7 @@ fillscreen::@return: scope:[fillscreen] from fillscreen::@2 to:@end @end: scope:[] from @2 +Eliminating unused variable - keeping the call (void~) main::$0 Removing empty block main::@7 Removing empty block main::@12 Removing empty block @1 @@ -256,7 +257,7 @@ CONTROL FLOW GRAPH (byte*) TEXT ← (string) "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @" to:@2 main: scope:[main] from - (void~) main::$0 ← call fillscreen (byte*) SCREEN (byte/signed byte/word/signed word) 32 + call fillscreen (byte*) SCREEN (byte/signed byte/word/signed word) 32 (byte) main::scroll ← (byte/signed byte/word/signed word) 7 (byte*) main::nxt ← (byte*) TEXT (byte*~) main::$1 ← (byte*) SCREEN + (byte/signed byte/word/signed word) 40 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/scrollbig.log b/src/main/java/dk/camelot64/kickc/test/ref/scrollbig.log index c0330b74f..f63448ce4 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/scrollbig.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/scrollbig.log @@ -611,6 +611,10 @@ fillscreen::@return: scope:[fillscreen] from fillscreen::@2 to:@end @end: scope:[] from @6 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$3 +Eliminating unused variable - keeping the call (void~) scroll_soft::$2 +Eliminating unused variable - keeping the call (void~) scroll_bit::$6 Removing empty block main::@4 Removing empty block main::@6 Removing empty block next_char::@3 @@ -629,7 +633,7 @@ CONTROL FLOW GRAPH (byte*) TEXT ← (string) "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @" to:@1 main: scope:[main] from - (void~) main::$0 ← call fillscreen (byte*) SCREEN (byte/signed byte/word/signed word) 32 + call fillscreen (byte*) SCREEN (byte/signed byte/word/signed word) 32 to:main::@2 main::@1: scope:[main] from main::@5 to:main::@2 @@ -643,7 +647,7 @@ main::@3: scope:[main] from main::@2 main::@3 to:main::@5 main::@5: scope:[main] from main::@3 *((byte*) BGCOL) ← ++ *((byte*) BGCOL) - (void~) main::$3 ← call scroll_soft + call scroll_soft *((byte*) BGCOL) ← -- *((byte*) BGCOL) if(true) goto main::@1 to:main::@return @@ -664,7 +668,7 @@ scroll_soft::@1: scope:[scroll_soft] from scroll_soft scroll_soft::@2 to:scroll_soft::@return scroll_soft::@2: scope:[scroll_soft] from scroll_soft (byte) scroll ← (byte/signed byte/word/signed word) 7 - (void~) scroll_soft::$2 ← call scroll_bit + call scroll_bit to:scroll_soft::@1 scroll_soft::@return: scope:[scroll_soft] from scroll_soft::@1 return @@ -681,7 +685,7 @@ scroll_bit: scope:[scroll_bit] from if((boolean~) scroll_bit::$2) goto scroll_bit::@1 to:scroll_bit::@4 scroll_bit::@1: scope:[scroll_bit] from scroll_bit scroll_bit::@4 - (void~) scroll_bit::$6 ← call scroll_hard + call scroll_hard asm { sei } *((byte*) PROCPORT) ← (byte/signed byte/word/signed word) 50 (byte*~) scroll_bit::$7 ← (byte*) SCREEN + (byte/signed byte/word/signed word) 40 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.asm b/src/main/java/dk/camelot64/kickc/test/ref/summin.asm index 7217dd145..7383d3fb0 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.asm @@ -1,31 +1,33 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + .const screen = $400 jsr main main: { .label s1 = 2 .label s3 = 3 lda #2 - ldy #1 + ldx #1 jsr sum sta s1 lda #4 - ldy #3 + ldx #3 jsr sum - tax + tay lda #$d - ldy #9 + ldx #9 jsr sum sta s3 - txa + tya clc adc s1 clc adc s3 + sta screen rts } sum: { - sty $ff + stx $ff clc adc $ff rts diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.cfg b/src/main/java/dk/camelot64/kickc/test/ref/summin.cfg index e789dfd4c..b84e41673 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.cfg +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.cfg @@ -25,16 +25,17 @@ main::@2: scope:[main] from main::@1 main::@3: scope:[main] from main::@2 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) - [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) + [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) + [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) to:main::@return main::@return: scope:[main] from main::@3 - [16] return [ ] ( main:2 [ ] ) + [17] return [ ] ( main:2 [ ] ) to:@return sum: scope:[sum] from main main::@1 main::@2 - [17] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) - [17] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) - [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + [18] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) + [18] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) + [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) to:sum::@return sum::@return: scope:[sum] from sum - [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) to:@return 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 0b483cb56..f380476dc 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.log @@ -1,8 +1,11 @@ +byte* screen = $0400; + void main() { byte s1=sum(1,2); byte s2=sum(3,4); byte s3=sum(9,13); byte s4=s1+s2+s3; + *screen = s4; } byte sum(byte a, byte b) { @@ -10,6 +13,7 @@ byte sum(byte a, byte b) { } PROGRAM + (byte*) screen ← (word/signed word) 1024 proc (void()) main() (byte~) main::$0 ← call sum (byte/signed byte/word/signed word) 1 (byte/signed byte/word/signed word) 2 (byte) main::s1 ← (byte~) main::$0 @@ -20,6 +24,7 @@ proc (void()) main() (byte~) main::$3 ← (byte) main::s1 + (byte) main::s2 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3 (byte) main::s4 ← (byte~) main::$4 + *((byte*) screen) ← (byte) main::s4 main::@return: return endproc // main() @@ -45,6 +50,7 @@ SYMBOLS (byte) main::s2 (byte) main::s3 (byte) main::s4 +(byte*) screen (byte()) sum((byte) sum::a , (byte) sum::b) (byte~) sum::$0 (label) sum::@return @@ -52,8 +58,10 @@ SYMBOLS (byte) sum::b (byte) sum::return +Promoting word/signed word to byte* in screen ← ((byte*)) 1024 INITIAL CONTROL FLOW GRAPH @begin: scope:[] from + (byte*) screen ← ((byte*)) (word/signed word) 1024 to:@1 main: scope:[main] from (byte~) main::$0 ← call sum (byte/signed byte/word/signed word) 1 (byte/signed byte/word/signed word) 2 @@ -65,6 +73,7 @@ main: scope:[main] from (byte~) main::$3 ← (byte) main::s1 + (byte) main::s2 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3 (byte) main::s4 ← (byte~) main::$4 + *((byte*) screen) ← (byte) main::s4 to:main::@return main::@return: scope:[main] from main return @@ -90,6 +99,7 @@ Removing empty block @1 Removing empty block sum::@1 CONTROL FLOW GRAPH @begin: scope:[] from + (byte*) screen ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from (byte~) main::$0 ← call sum (byte/signed byte/word/signed word) 1 (byte/signed byte/word/signed word) 2 @@ -101,6 +111,7 @@ main: scope:[main] from (byte~) main::$3 ← (byte) main::s1 + (byte) main::s2 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3 (byte) main::s4 ← (byte~) main::$4 + *((byte*) screen) ← (byte) main::s4 to:main::@return main::@return: scope:[main] from main return @@ -122,6 +133,7 @@ PROCEDURE MODIFY VARIABLE ANALYSIS CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @begin: scope:[] from + (byte*) screen ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from @2 (byte) sum::a ← (byte/signed byte/word/signed word) 1 @@ -148,6 +160,7 @@ main::@3: scope:[main] from main::@2 (byte~) main::$3 ← (byte) main::s1 + (byte) main::s2 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3 (byte) main::s4 ← (byte~) main::$4 + *((byte*) screen) ← (byte) main::s4 to:main::@return main::@return: scope:[main] from main::@3 return @@ -167,17 +180,23 @@ sum::@return: scope:[sum] from sum to:@end @end: scope:[] from @3 +Completing Phi functions... +Completing Phi functions... +Completing Phi functions... Completing Phi functions... Completing Phi functions... CONTROL FLOW GRAPH SSA @begin: scope:[] from + (byte*) screen#0 ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from @2 + (byte*) screen#4 ← phi( @2/(byte*) screen#5 ) (byte) sum::a#0 ← (byte/signed byte/word/signed word) 1 (byte) sum::b#0 ← (byte/signed byte/word/signed word) 2 (byte) sum::return#0 ← call sum param-assignment to:main::@1 main::@1: scope:[main] from main + (byte*) screen#3 ← phi( main/(byte*) screen#4 ) (byte) sum::return#5 ← phi( main/(byte) sum::return#0 ) (byte~) main::$0 ← (byte) sum::return#5 (byte) main::s1#0 ← (byte~) main::$0 @@ -186,6 +205,7 @@ main::@1: scope:[main] from main (byte) sum::return#1 ← call sum param-assignment to:main::@2 main::@2: scope:[main] from main::@1 + (byte*) screen#2 ← phi( main::@1/(byte*) screen#3 ) (byte) main::s1#2 ← phi( main::@1/(byte) main::s1#0 ) (byte) sum::return#6 ← phi( main::@1/(byte) sum::return#1 ) (byte~) main::$1 ← (byte) sum::return#6 @@ -195,6 +215,7 @@ main::@2: scope:[main] from main::@1 (byte) sum::return#2 ← call sum param-assignment to:main::@3 main::@3: scope:[main] from main::@2 + (byte*) screen#1 ← phi( main::@2/(byte*) screen#2 ) (byte) main::s2#1 ← phi( main::@2/(byte) main::s2#0 ) (byte) main::s1#1 ← phi( main::@2/(byte) main::s1#2 ) (byte) sum::return#7 ← phi( main::@2/(byte) sum::return#2 ) @@ -203,6 +224,7 @@ main::@3: scope:[main] from main::@2 (byte~) main::$3 ← (byte) main::s1#1 + (byte) main::s2#1 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3#0 (byte) main::s4#0 ← (byte~) main::$4 + *((byte*) screen#1) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -219,6 +241,7 @@ sum::@return: scope:[sum] from sum return (byte) sum::return#4 to:@return @2: scope:[] from @begin + (byte*) screen#5 ← phi( @begin/(byte*) screen#0 ) call main param-assignment to:@3 @3: scope:[] from @2 @@ -227,14 +250,17 @@ sum::@return: scope:[sum] from sum CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from + (byte*) screen#0 ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from @2 + (byte*) screen#4 ← phi( @2/(byte*) screen#5 ) (byte) sum::a#0 ← (byte/signed byte/word/signed word) 1 (byte) sum::b#0 ← (byte/signed byte/word/signed word) 2 call sum param-assignment (byte) sum::return#0 ← (byte) sum::return#4 to:main::@1 main::@1: scope:[main] from main + (byte*) screen#3 ← phi( main/(byte*) screen#4 ) (byte) sum::return#5 ← phi( main/(byte) sum::return#0 ) (byte~) main::$0 ← (byte) sum::return#5 (byte) main::s1#0 ← (byte~) main::$0 @@ -244,6 +270,7 @@ main::@1: scope:[main] from main (byte) sum::return#1 ← (byte) sum::return#4 to:main::@2 main::@2: scope:[main] from main::@1 + (byte*) screen#2 ← phi( main::@1/(byte*) screen#3 ) (byte) main::s1#2 ← phi( main::@1/(byte) main::s1#0 ) (byte) sum::return#6 ← phi( main::@1/(byte) sum::return#1 ) (byte~) main::$1 ← (byte) sum::return#6 @@ -254,6 +281,7 @@ main::@2: scope:[main] from main::@1 (byte) sum::return#2 ← (byte) sum::return#4 to:main::@3 main::@3: scope:[main] from main::@2 + (byte*) screen#1 ← phi( main::@2/(byte*) screen#2 ) (byte) main::s2#1 ← phi( main::@2/(byte) main::s2#0 ) (byte) main::s1#1 ← phi( main::@2/(byte) main::s1#2 ) (byte) sum::return#7 ← phi( main::@2/(byte) sum::return#2 ) @@ -262,6 +290,7 @@ main::@3: scope:[main] from main::@2 (byte~) main::$3 ← (byte) main::s1#1 + (byte) main::s2#1 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3#0 (byte) main::s4#0 ← (byte~) main::$4 + *((byte*) screen#1) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -278,6 +307,7 @@ sum::@return: scope:[sum] from sum return to:@return @2: scope:[] from @begin + (byte*) screen#5 ← phi( @begin/(byte*) screen#0 ) call main param-assignment to:@3 @3: scope:[] from @2 @@ -310,6 +340,13 @@ INITIAL SSA SYMBOL TABLE (byte) main::s3#0 (byte) main::s4 (byte) main::s4#0 +(byte*) screen +(byte*) screen#0 +(byte*) screen#1 +(byte*) screen#2 +(byte*) screen#3 +(byte*) screen#4 +(byte*) screen#5 (byte()) sum((byte) sum::a , (byte) sum::b) (byte~) sum::$0 (label) sum::@return @@ -338,14 +375,17 @@ Culled Empty Block (label) @3 Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @begin: scope:[] from + (byte*) screen#0 ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from @2 + (byte*) screen#4 ← phi( @2/(byte*) screen#5 ) (byte) sum::a#0 ← (byte/signed byte/word/signed word) 1 (byte) sum::b#0 ← (byte/signed byte/word/signed word) 2 call sum param-assignment (byte) sum::return#0 ← (byte) sum::return#4 to:main::@1 main::@1: scope:[main] from main + (byte*) screen#3 ← phi( main/(byte*) screen#4 ) (byte) sum::return#5 ← phi( main/(byte) sum::return#0 ) (byte~) main::$0 ← (byte) sum::return#5 (byte) main::s1#0 ← (byte~) main::$0 @@ -355,6 +395,7 @@ main::@1: scope:[main] from main (byte) sum::return#1 ← (byte) sum::return#4 to:main::@2 main::@2: scope:[main] from main::@1 + (byte*) screen#2 ← phi( main::@1/(byte*) screen#3 ) (byte) main::s1#2 ← phi( main::@1/(byte) main::s1#0 ) (byte) sum::return#6 ← phi( main::@1/(byte) sum::return#1 ) (byte~) main::$1 ← (byte) sum::return#6 @@ -365,6 +406,7 @@ main::@2: scope:[main] from main::@1 (byte) sum::return#2 ← (byte) sum::return#4 to:main::@3 main::@3: scope:[main] from main::@2 + (byte*) screen#1 ← phi( main::@2/(byte*) screen#2 ) (byte) main::s2#1 ← phi( main::@2/(byte) main::s2#0 ) (byte) main::s1#1 ← phi( main::@2/(byte) main::s1#2 ) (byte) sum::return#7 ← phi( main::@2/(byte) sum::return#2 ) @@ -373,6 +415,7 @@ main::@3: scope:[main] from main::@2 (byte~) main::$3 ← (byte) main::s1#1 + (byte) main::s2#1 (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3#0 (byte) main::s4#0 ← (byte~) main::$4 + *((byte*) screen#1) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -389,10 +432,12 @@ sum::@return: scope:[sum] from sum return to:@return @2: scope:[] from @begin + (byte*) screen#5 ← phi( @begin/(byte*) screen#0 ) call main param-assignment to:@end @end: scope:[] from @2 +Not aliassing across scopes: screen#4 screen#5 Not aliassing across scopes: sum::return#0 sum::return#4 Not aliassing across scopes: main::$0 sum::return#5 Not aliassing across scopes: sum::return#1 sum::return#4 @@ -402,6 +447,7 @@ Not aliassing across scopes: main::$2 sum::return#7 Not aliassing across scopes: sum::a#3 sum::a#0 Not aliassing across scopes: sum::b#3 sum::b#0 Alias (byte) sum::return#0 = (byte) sum::return#5 +Alias (byte*) screen#1 = (byte*) screen#3 (byte*) screen#4 (byte*) screen#2 Alias (byte) main::s1#0 = (byte~) main::$0 (byte) main::s1#2 (byte) main::s1#1 Alias (byte) sum::return#1 = (byte) sum::return#6 Alias (byte) main::s2#0 = (byte~) main::$1 (byte) main::s2#1 @@ -409,9 +455,69 @@ Alias (byte) sum::return#2 = (byte) sum::return#7 Alias (byte) main::s3#0 = (byte~) main::$2 Alias (byte) main::s4#0 = (byte~) main::$4 Alias (byte) sum::return#3 = (byte~) sum::$0 (byte) sum::return#8 (byte) sum::return#4 +Alias (byte*) screen#0 = (byte*) screen#5 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from + (byte*) screen#0 ← ((byte*)) (word/signed word) 1024 + to:@2 +main: scope:[main] from @2 + (byte*) screen#1 ← phi( @2/(byte*) screen#0 ) + (byte) sum::a#0 ← (byte/signed byte/word/signed word) 1 + (byte) sum::b#0 ← (byte/signed byte/word/signed word) 2 + call sum param-assignment + (byte) sum::return#0 ← (byte) sum::return#3 + to:main::@1 +main::@1: scope:[main] from main + (byte) main::s1#0 ← (byte) sum::return#0 + (byte) sum::a#1 ← (byte/signed byte/word/signed word) 3 + (byte) sum::b#1 ← (byte/signed byte/word/signed word) 4 + call sum param-assignment + (byte) sum::return#1 ← (byte) sum::return#3 + to:main::@2 +main::@2: scope:[main] from main::@1 + (byte) main::s2#0 ← (byte) sum::return#1 + (byte) sum::a#2 ← (byte/signed byte/word/signed word) 9 + (byte) sum::b#2 ← (byte/signed byte/word/signed word) 13 + call sum param-assignment + (byte) sum::return#2 ← (byte) sum::return#3 + to:main::@3 +main::@3: scope:[main] from main::@2 + (byte) main::s3#0 ← (byte) sum::return#2 + (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 + (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 + *((byte*) screen#1) ← (byte) main::s4#0 + to:main::@return +main::@return: scope:[main] from main::@3 + return + to:@return +sum: scope:[sum] from main main::@1 main::@2 + (byte) sum::b#3 ← phi( main/(byte) sum::b#0 main::@1/(byte) sum::b#1 main::@2/(byte) sum::b#2 ) + (byte) sum::a#3 ← phi( main/(byte) sum::a#0 main::@1/(byte) sum::a#1 main::@2/(byte) sum::a#2 ) + (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 + to:sum::@return +sum::@return: scope:[sum] from sum + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@end +@end: scope:[] from @2 + +Not aliassing across scopes: screen#1 screen#0 +Not aliassing across scopes: sum::return#0 sum::return#3 +Not aliassing across scopes: main::s1#0 sum::return#0 +Not aliassing across scopes: sum::return#1 sum::return#3 +Not aliassing across scopes: main::s2#0 sum::return#1 +Not aliassing across scopes: sum::return#2 sum::return#3 +Not aliassing across scopes: main::s3#0 sum::return#2 +Not aliassing across scopes: sum::a#3 sum::a#0 +Not aliassing across scopes: sum::b#3 sum::b#0 +Redundant Phi (byte*) screen#1 (byte*) screen#0 +Succesful SSA optimization Pass2RedundantPhiElimination +CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) screen#0 ← ((byte*)) (word/signed word) 1024 to:@2 main: scope:[main] from @2 (byte) sum::a#0 ← (byte/signed byte/word/signed word) 1 @@ -437,6 +543,7 @@ main::@3: scope:[main] from main::@2 (byte) main::s3#0 ← (byte) sum::return#2 (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 + *((byte*) screen#0) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -454,14 +561,7 @@ sum::@return: scope:[sum] from sum to:@end @end: scope:[] from @2 -Not aliassing across scopes: sum::return#0 sum::return#3 -Not aliassing across scopes: main::s1#0 sum::return#0 -Not aliassing across scopes: sum::return#1 sum::return#3 -Not aliassing across scopes: main::s2#0 sum::return#1 -Not aliassing across scopes: sum::return#2 sum::return#3 -Not aliassing across scopes: main::s3#0 sum::return#2 -Not aliassing across scopes: sum::a#3 sum::a#0 -Not aliassing across scopes: sum::b#3 sum::b#0 +Constant (const byte*) screen#0 = ((byte*))1024 Constant (const byte) sum::a#0 = 1 Constant (const byte) sum::b#0 = 2 Constant (const byte) sum::a#1 = 3 @@ -490,6 +590,7 @@ main::@3: scope:[main] from main::@2 (byte) main::s3#0 ← (byte) sum::return#2 (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 + *((const byte*) screen#0) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -559,6 +660,7 @@ main::@3: scope:[main] from main::@2 (byte) main::s3#0 ← (byte) sum::return#2 (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 + *((const byte*) screen#0) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -594,6 +696,8 @@ FINAL SYMBOL TABLE (byte) main::s3#0 (byte) main::s4 (byte) main::s4#0 +(byte*) screen +(const byte*) screen#0 = ((byte*))(word/signed word) 1024 (byte()) sum((byte) sum::a , (byte) sum::b) (label) sum::@return (byte) sum::a @@ -633,6 +737,7 @@ main::@3: scope:[main] from main::@2 (byte) main::s3#0 ← (byte) sum::return#2 (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 + *((const byte*) screen#0) ← (byte) main::s4#0 to:main::@return main::@return: scope:[main] from main::@3 return @@ -690,18 +795,19 @@ main::@2: scope:[main] from main::@1 main::@3: scope:[main] from main::@2 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] - [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] + [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] + [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] to:main::@return main::@return: scope:[main] from main::@3 - [16] return [ ] + [17] return [ ] to:@return sum: scope:[sum] from main main::@1 main::@2 - [17] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] - [17] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] - [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] + [18] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] + [18] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] + [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] to:sum::@return sum::@return: scope:[sum] from sum - [19] return [ sum::return#3 ] + [20] return [ sum::return#3 ] to:@return Created 2 initial phi equivalence classes @@ -747,18 +853,19 @@ main::@2: scope:[main] from main::@1 main::@3: scope:[main] from main::@2 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] - [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] + [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] + [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] to:main::@return main::@return: scope:[main] from main::@3 - [16] return [ ] + [17] return [ ] to:@return sum: scope:[sum] from main main::@1 main::@2 - [17] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] - [17] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] - [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] + [18] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] + [18] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] + [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] to:sum::@return sum::@return: scope:[sum] from sum - [19] return [ sum::return#3 ] + [20] return [ sum::return#3 ] to:@return CONTROL FLOW GRAPH - PHI MEM COALESCED @@ -789,18 +896,19 @@ main::@2: scope:[main] from main::@1 main::@3: scope:[main] from main::@2 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) - [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) + [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) + [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) to:main::@return main::@return: scope:[main] from main::@3 - [16] return [ ] ( main:2 [ ] ) + [17] return [ ] ( main:2 [ ] ) to:@return sum: scope:[sum] from main main::@1 main::@2 - [17] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) - [17] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) - [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + [18] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word) 2 main::@1/(byte/signed byte/word/signed word) 4 main::@2/(byte/signed byte/word/signed word) 13 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) + [18] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word) 1 main::@1/(byte/signed byte/word/signed word) 3 main::@2/(byte/signed byte/word/signed word) 9 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] ) + [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) to:sum::@return sum::@return: scope:[sum] from sum - [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) to:@return DOMINATORS @@ -833,7 +941,8 @@ VARIABLE REGISTER WEIGHTS (byte) main::s3 (byte) main::s3#0 2.0 (byte) main::s4 -(byte) main::s4#0 20.0 +(byte) main::s4#0 4.0 +(byte*) screen (byte()) sum((byte) sum::a , (byte) sum::b) (byte) sum::a (byte) sum::a#3 2.0 @@ -886,6 +995,7 @@ INITIAL ASM :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels + .const screen = $400 //SEG2 @begin bbegin: //SEG3 [1] phi from @begin to @2 [phi:@begin->@2] @@ -910,12 +1020,12 @@ main: { .label s3 = 9 .label s4 = $b //SEG10 [5] call sum param-assignment [ sum::return#3 ] ( main:2 [ sum::return#3 ] ) - //SEG11 [17] phi from main to sum [phi:main->sum] + //SEG11 [18] phi from main to sum [phi:main->sum] sum_from_main: - //SEG12 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- zpby1=coby1 + //SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- zpby1=coby1 lda #2 sta sum.b - //SEG13 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- zpby1=coby1 + //SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- zpby1=coby1 lda #1 sta sum.a jsr sum @@ -929,12 +1039,12 @@ main: { lda sum.return sta s1 //SEG17 [8] call sum param-assignment [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] ) - //SEG18 [17] phi from main::@1 to sum [phi:main::@1->sum] + //SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum] sum_from_b1: - //SEG19 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- zpby1=coby1 + //SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- zpby1=coby1 lda #4 sta sum.b - //SEG20 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- zpby1=coby1 + //SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- zpby1=coby1 lda #3 sta sum.a jsr sum @@ -948,12 +1058,12 @@ main: { lda sum.return_1 sta s2 //SEG24 [11] call sum param-assignment [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] ) - //SEG25 [17] phi from main::@2 to sum [phi:main::@2->sum] + //SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum] sum_from_b2: - //SEG26 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- zpby1=coby1 + //SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- zpby1=coby1 lda #$d sta sum.b - //SEG27 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- zpby1=coby1 + //SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- zpby1=coby1 lda #9 sta sum.a jsr sum @@ -971,18 +1081,21 @@ main: { clc adc s2 sta _3 - //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) -- zpby1=zpby2_plus_zpby3 + //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- zpby1=zpby2_plus_zpby3 lda _3 clc adc s3 sta s4 + //SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_cowo1=zpby1 + lda s4 + sta screen jmp breturn - //SEG33 main::@return + //SEG34 main::@return breturn: - //SEG34 [16] return [ ] ( main:2 [ ] ) + //SEG35 [17] return [ ] ( main:2 [ ] ) rts } -//SEG35 sum +//SEG36 sum sum: { .label return = 4 .label return_1 = 6 @@ -990,15 +1103,15 @@ sum: { .label return_3 = $c .label a = 2 .label b = 3 - //SEG36 [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- zpby1=zpby2_plus_zpby3 + //SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- zpby1=zpby2_plus_zpby3 lda a clc adc b sta return_3 jmp breturn - //SEG37 sum::@return + //SEG38 sum::@return breturn: - //SEG38 [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + //SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) rts } @@ -1016,17 +1129,17 @@ Potential registers zp ZP_BYTE:11 [ main::s4#0 ] : zp ZP_BYTE:11 , reg byte a , Potential registers zp ZP_BYTE:12 [ sum::return#3 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y , REGISTER UPLIFT SCOPES -Uplift Scope [main] 20: zp ZP_BYTE:11 [ main::s4#0 ] 4: zp ZP_BYTE:10 [ main::$3 ] 2: zp ZP_BYTE:9 [ main::s3#0 ] 1: zp ZP_BYTE:7 [ main::s2#0 ] 0.57: zp ZP_BYTE:5 [ main::s1#0 ] Uplift Scope [sum] 4: zp ZP_BYTE:4 [ sum::return#0 ] 4: zp ZP_BYTE:6 [ sum::return#1 ] 4: zp ZP_BYTE:8 [ sum::return#2 ] 2: zp ZP_BYTE:2 [ sum::a#3 ] 2: zp ZP_BYTE:3 [ sum::b#3 ] 1.6: zp ZP_BYTE:12 [ sum::return#3 ] +Uplift Scope [main] 4: zp ZP_BYTE:10 [ main::$3 ] 4: zp ZP_BYTE:11 [ main::s4#0 ] 2: zp ZP_BYTE:9 [ main::s3#0 ] 1: zp ZP_BYTE:7 [ main::s2#0 ] 0.57: zp ZP_BYTE:5 [ main::s1#0 ] Uplift Scope [] -Uplifting [main] best 143 combination reg byte a [ main::s4#0 ] reg byte a [ main::$3 ] zp ZP_BYTE:9 [ main::s3#0 ] reg byte x [ main::s2#0 ] zp ZP_BYTE:5 [ main::s1#0 ] -Uplifting [sum] best 99 combination reg byte a [ sum::return#0 ] reg byte a [ sum::return#1 ] reg byte a [ sum::return#2 ] reg byte y [ sum::a#3 ] reg byte a [ sum::b#3 ] reg byte a [ sum::return#3 ] -Uplifting [] best 99 combination +Uplifting [sum] best 117 combination reg byte a [ sum::return#0 ] reg byte a [ sum::return#1 ] reg byte a [ sum::return#2 ] reg byte x [ sum::a#3 ] reg byte a [ sum::b#3 ] reg byte a [ sum::return#3 ] +Uplifting [main] best 103 combination reg byte a [ main::$3 ] reg byte a [ main::s4#0 ] zp ZP_BYTE:9 [ main::s3#0 ] reg byte y [ main::s2#0 ] zp ZP_BYTE:5 [ main::s1#0 ] +Uplifting [] best 103 combination Attempting to uplift remaining variables inzp ZP_BYTE:9 [ main::s3#0 ] -Uplifting [main] best 99 combination zp ZP_BYTE:9 [ main::s3#0 ] +Uplifting [main] best 103 combination zp ZP_BYTE:9 [ main::s3#0 ] Attempting to uplift remaining variables inzp ZP_BYTE:5 [ main::s1#0 ] -Uplifting [main] best 99 combination zp ZP_BYTE:5 [ main::s1#0 ] +Uplifting [main] best 103 combination zp ZP_BYTE:5 [ main::s1#0 ] Allocated (was zp ZP_BYTE:5) zp ZP_BYTE:2 [ main::s1#0 ] Allocated (was zp ZP_BYTE:9) zp ZP_BYTE:3 [ main::s3#0 ] Removing instruction jmp b2 @@ -1043,6 +1156,7 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels + .const screen = $400 //SEG2 @begin bbegin: //SEG3 [1] phi from @begin to @2 [phi:@begin->@2] @@ -1062,12 +1176,12 @@ main: { .label s1 = 2 .label s3 = 3 //SEG10 [5] call sum param-assignment [ sum::return#3 ] ( main:2 [ sum::return#3 ] ) - //SEG11 [17] phi from main to sum [phi:main->sum] + //SEG11 [18] phi from main to sum [phi:main->sum] sum_from_main: - //SEG12 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 + //SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 lda #2 - //SEG13 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- yby=coby1 - ldy #1 + //SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- xby=coby1 + ldx #1 jsr sum //SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] ) // (byte) sum::return#0 = (byte) sum::return#3 // register copy reg byte a @@ -1076,26 +1190,26 @@ main: { //SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- zpby1=aby sta s1 //SEG17 [8] call sum param-assignment [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] ) - //SEG18 [17] phi from main::@1 to sum [phi:main::@1->sum] + //SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum] sum_from_b1: - //SEG19 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 + //SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 lda #4 - //SEG20 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- yby=coby1 - ldy #3 + //SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- xby=coby1 + ldx #3 jsr sum //SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] ) // (byte) sum::return#1 = (byte) sum::return#3 // register copy reg byte a //SEG22 main::@2 b2: - //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- xby=aby - tax + //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- yby=aby + tay //SEG24 [11] call sum param-assignment [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] ) - //SEG25 [17] phi from main::@2 to sum [phi:main::@2->sum] + //SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum] sum_from_b2: - //SEG26 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 + //SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 lda #$d - //SEG27 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- yby=coby1 - ldy #9 + //SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- xby=coby1 + ldx #9 jsr sum //SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] ) // (byte) sum::return#2 = (byte) sum::return#3 // register copy reg byte a @@ -1103,27 +1217,29 @@ main: { b3: //SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- zpby1=aby sta s3 - //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_xby - txa + //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_yby + tya clc adc s1 - //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) -- aby=aby_plus_zpby1 + //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- aby=aby_plus_zpby1 clc adc s3 - //SEG33 main::@return + //SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_cowo1=aby + sta screen + //SEG34 main::@return breturn: - //SEG34 [16] return [ ] ( main:2 [ ] ) + //SEG35 [17] return [ ] ( main:2 [ ] ) rts } -//SEG35 sum +//SEG36 sum sum: { - //SEG36 [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=yby_plus_aby - sty $ff + //SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=xby_plus_aby + stx $ff clc adc $ff - //SEG37 sum::@return + //SEG38 sum::@return breturn: - //SEG38 [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + //SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) rts } @@ -1138,6 +1254,7 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels + .const screen = $400 //SEG2 @begin //SEG3 [1] phi from @begin to @2 [phi:@begin->@2] //SEG4 @2 @@ -1153,12 +1270,12 @@ main: { .label s1 = 2 .label s3 = 3 //SEG10 [5] call sum param-assignment [ sum::return#3 ] ( main:2 [ sum::return#3 ] ) - //SEG11 [17] phi from main to sum [phi:main->sum] + //SEG11 [18] phi from main to sum [phi:main->sum] sum_from_main: - //SEG12 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 + //SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 lda #2 - //SEG13 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- yby=coby1 - ldy #1 + //SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- xby=coby1 + ldx #1 jsr sum //SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] ) // (byte) sum::return#0 = (byte) sum::return#3 // register copy reg byte a @@ -1167,26 +1284,26 @@ main: { //SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- zpby1=aby sta s1 //SEG17 [8] call sum param-assignment [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] ) - //SEG18 [17] phi from main::@1 to sum [phi:main::@1->sum] + //SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum] sum_from_b1: - //SEG19 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 + //SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 lda #4 - //SEG20 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- yby=coby1 - ldy #3 + //SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- xby=coby1 + ldx #3 jsr sum //SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] ) // (byte) sum::return#1 = (byte) sum::return#3 // register copy reg byte a //SEG22 main::@2 b2: - //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- xby=aby - tax + //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- yby=aby + tay //SEG24 [11] call sum param-assignment [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] ) - //SEG25 [17] phi from main::@2 to sum [phi:main::@2->sum] + //SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum] sum_from_b2: - //SEG26 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 + //SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 lda #$d - //SEG27 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- yby=coby1 - ldy #9 + //SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- xby=coby1 + ldx #9 jsr sum //SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] ) // (byte) sum::return#2 = (byte) sum::return#3 // register copy reg byte a @@ -1194,27 +1311,29 @@ main: { b3: //SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- zpby1=aby sta s3 - //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_xby - txa + //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_yby + tya clc adc s1 - //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) -- aby=aby_plus_zpby1 + //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- aby=aby_plus_zpby1 clc adc s3 - //SEG33 main::@return + //SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_cowo1=aby + sta screen + //SEG34 main::@return breturn: - //SEG34 [16] return [ ] ( main:2 [ ] ) + //SEG35 [17] return [ ] ( main:2 [ ] ) rts } -//SEG35 sum +//SEG36 sum sum: { - //SEG36 [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=yby_plus_aby - sty $ff + //SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=xby_plus_aby + stx $ff clc adc $ff - //SEG37 sum::@return + //SEG38 sum::@return breturn: - //SEG38 [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + //SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) rts } @@ -1235,6 +1354,7 @@ ASSEMBLER :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels + .const screen = $400 //SEG2 @begin //SEG3 [1] phi from @begin to @2 [phi:@begin->@2] //SEG4 @2 @@ -1248,11 +1368,11 @@ main: { .label s1 = 2 .label s3 = 3 //SEG10 [5] call sum param-assignment [ sum::return#3 ] ( main:2 [ sum::return#3 ] ) - //SEG11 [17] phi from main to sum [phi:main->sum] - //SEG12 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 + //SEG11 [18] phi from main to sum [phi:main->sum] + //SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 lda #2 - //SEG13 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- yby=coby1 - ldy #1 + //SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- xby=coby1 + ldx #1 jsr sum //SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] ) // (byte) sum::return#0 = (byte) sum::return#3 // register copy reg byte a @@ -1260,48 +1380,50 @@ main: { //SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- zpby1=aby sta s1 //SEG17 [8] call sum param-assignment [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] ) - //SEG18 [17] phi from main::@1 to sum [phi:main::@1->sum] - //SEG19 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 + //SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum] + //SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 lda #4 - //SEG20 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- yby=coby1 - ldy #3 + //SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- xby=coby1 + ldx #3 jsr sum //SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] ) // (byte) sum::return#1 = (byte) sum::return#3 // register copy reg byte a //SEG22 main::@2 - //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- xby=aby - tax + //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- yby=aby + tay //SEG24 [11] call sum param-assignment [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] ) - //SEG25 [17] phi from main::@2 to sum [phi:main::@2->sum] - //SEG26 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 + //SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum] + //SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 lda #$d - //SEG27 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- yby=coby1 - ldy #9 + //SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- xby=coby1 + ldx #9 jsr sum //SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] ) // (byte) sum::return#2 = (byte) sum::return#3 // register copy reg byte a //SEG29 main::@3 //SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- zpby1=aby sta s3 - //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_xby - txa + //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_yby + tya clc adc s1 - //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) -- aby=aby_plus_zpby1 + //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- aby=aby_plus_zpby1 clc adc s3 - //SEG33 main::@return - //SEG34 [16] return [ ] ( main:2 [ ] ) + //SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_cowo1=aby + sta screen + //SEG34 main::@return + //SEG35 [17] return [ ] ( main:2 [ ] ) rts } -//SEG35 sum +//SEG36 sum sum: { - //SEG36 [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=yby_plus_aby - sty $ff + //SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=xby_plus_aby + stx $ff clc adc $ff - //SEG37 sum::@return - //SEG38 [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + //SEG38 sum::@return + //SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) rts } @@ -1318,15 +1440,17 @@ FINAL SYMBOL TABLE (byte) main::s1 (byte) main::s1#0 s1 zp ZP_BYTE:2 0.5714285714285714 (byte) main::s2 -(byte) main::s2#0 reg byte x 1.0 +(byte) main::s2#0 reg byte y 1.0 (byte) main::s3 (byte) main::s3#0 s3 zp ZP_BYTE:3 2.0 (byte) main::s4 -(byte) main::s4#0 reg byte a 20.0 +(byte) main::s4#0 reg byte a 4.0 +(byte*) screen +(const byte*) screen#0 screen = ((byte*))(word/signed word) 1024 (byte()) sum((byte) sum::a , (byte) sum::b) (label) sum::@return (byte) sum::a -(byte) sum::a#3 reg byte y 2.0 +(byte) sum::a#3 reg byte x 2.0 (byte) sum::b (byte) sum::b#3 reg byte a 2.0 (byte) sum::return @@ -1335,12 +1459,12 @@ FINAL SYMBOL TABLE (byte) sum::return#2 reg byte a 4.0 (byte) sum::return#3 reg byte a 1.6 -reg byte y [ sum::a#3 ] +reg byte x [ sum::a#3 ] reg byte a [ sum::b#3 ] reg byte a [ sum::return#0 ] zp ZP_BYTE:2 [ main::s1#0 ] reg byte a [ sum::return#1 ] -reg byte x [ main::s2#0 ] +reg byte y [ main::s2#0 ] reg byte a [ sum::return#2 ] zp ZP_BYTE:3 [ main::s3#0 ] reg byte a [ main::$3 ] @@ -1353,6 +1477,7 @@ FINAL CODE :BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels + .const screen = $400 //SEG2 @begin //SEG3 [1] phi from @begin to @2 [phi:@begin->@2] //SEG4 @2 @@ -1366,11 +1491,11 @@ main: { .label s1 = 2 .label s3 = 3 //SEG10 [5] call sum param-assignment [ sum::return#3 ] ( main:2 [ sum::return#3 ] ) - //SEG11 [17] phi from main to sum [phi:main->sum] - //SEG12 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 + //SEG11 [18] phi from main to sum [phi:main->sum] + //SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 2 [phi:main->sum#0] -- aby=coby1 lda #2 - //SEG13 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- yby=coby1 - ldy #1 + //SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 1 [phi:main->sum#1] -- xby=coby1 + ldx #1 jsr sum //SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] ) // (byte) sum::return#0 = (byte) sum::return#3 // register copy reg byte a @@ -1378,48 +1503,50 @@ main: { //SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- zpby1=aby sta s1 //SEG17 [8] call sum param-assignment [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] ) - //SEG18 [17] phi from main::@1 to sum [phi:main::@1->sum] - //SEG19 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 + //SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum] + //SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 4 [phi:main::@1->sum#0] -- aby=coby1 lda #4 - //SEG20 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- yby=coby1 - ldy #3 + //SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 3 [phi:main::@1->sum#1] -- xby=coby1 + ldx #3 jsr sum //SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] ) // (byte) sum::return#1 = (byte) sum::return#3 // register copy reg byte a //SEG22 main::@2 - //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- xby=aby - tax + //SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- yby=aby + tay //SEG24 [11] call sum param-assignment [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] ) - //SEG25 [17] phi from main::@2 to sum [phi:main::@2->sum] - //SEG26 [17] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 + //SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum] + //SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word) 13 [phi:main::@2->sum#0] -- aby=coby1 lda #$d - //SEG27 [17] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- yby=coby1 - ldy #9 + //SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word) 9 [phi:main::@2->sum#1] -- xby=coby1 + ldx #9 jsr sum //SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] ) // (byte) sum::return#2 = (byte) sum::return#3 // register copy reg byte a //SEG29 main::@3 //SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- zpby1=aby sta s3 - //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_xby - txa + //SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- aby=zpby1_plus_yby + tya clc adc s1 - //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ ] ( main:2 [ ] ) -- aby=aby_plus_zpby1 + //SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- aby=aby_plus_zpby1 clc adc s3 - //SEG33 main::@return - //SEG34 [16] return [ ] ( main:2 [ ] ) + //SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_cowo1=aby + sta screen + //SEG34 main::@return + //SEG35 [17] return [ ] ( main:2 [ ] ) rts } -//SEG35 sum +//SEG36 sum sum: { - //SEG36 [18] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=yby_plus_aby - sty $ff + //SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- aby=xby_plus_aby + stx $ff clc adc $ff - //SEG37 sum::@return - //SEG38 [19] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) + //SEG38 sum::@return + //SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) rts } diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.sym b/src/main/java/dk/camelot64/kickc/test/ref/summin.sym index 81a2362a9..093aa1a84 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.sym @@ -10,15 +10,17 @@ (byte) main::s1 (byte) main::s1#0 s1 zp ZP_BYTE:2 0.5714285714285714 (byte) main::s2 -(byte) main::s2#0 reg byte x 1.0 +(byte) main::s2#0 reg byte y 1.0 (byte) main::s3 (byte) main::s3#0 s3 zp ZP_BYTE:3 2.0 (byte) main::s4 -(byte) main::s4#0 reg byte a 20.0 +(byte) main::s4#0 reg byte a 4.0 +(byte*) screen +(const byte*) screen#0 screen = ((byte*))(word/signed word) 1024 (byte()) sum((byte) sum::a , (byte) sum::b) (label) sum::@return (byte) sum::a -(byte) sum::a#3 reg byte y 2.0 +(byte) sum::a#3 reg byte x 2.0 (byte) sum::b (byte) sum::b#3 reg byte a 2.0 (byte) sum::return @@ -27,12 +29,12 @@ (byte) sum::return#2 reg byte a 4.0 (byte) sum::return#3 reg byte a 1.6 -reg byte y [ sum::a#3 ] +reg byte x [ sum::a#3 ] reg byte a [ sum::b#3 ] reg byte a [ sum::return#0 ] zp ZP_BYTE:2 [ main::s1#0 ] reg byte a [ sum::return#1 ] -reg byte x [ main::s2#0 ] +reg byte y [ main::s2#0 ] reg byte a [ sum::return#2 ] zp ZP_BYTE:3 [ main::s3#0 ] reg byte a [ main::$3 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.asm b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.asm new file mode 100644 index 000000000..af5ad6f08 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.asm @@ -0,0 +1,24 @@ +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .const SCREEN = $400 + jsr main +main: { + .const col = 2 + .const COLS = $d800 + jsr s + ldx #0 + b1: + lda #col + sta COLS,x + lda #(2>>1)+1+1 + sta SCREEN,x + inx + cpx #$65 + bne b1 + rts +} +s: { + .const return = 2 + rts +} diff --git a/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.cfg b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.cfg new file mode 100644 index 000000000..48a9b0c80 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.cfg @@ -0,0 +1,29 @@ +@begin: scope:[] from + [0] phi() [ ] ( ) + to:@2 +@2: scope:[] from @begin + [1] phi() [ ] ( ) + [2] call main param-assignment [ ] ( ) + to:@end +@end: scope:[] from @2 + [3] phi() [ ] ( ) +main: scope:[main] from @2 + [4] phi() [ ] ( main:2 [ ] ) + [5] call s param-assignment [ ] ( main:2 [ ] ) + to:main::@1 +main::@1: scope:[main] from main main::@1 + [6] (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main/(byte/signed byte/word/signed word) 0 ) [ main::i#2 ] ( main:2 [ main::i#2 ] ) + [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) + [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) + [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) + [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) + to:main::@return +main::@return: scope:[main] from main::@1 + [11] return [ ] ( main:2 [ ] ) + to:@return +s: scope:[s] from main + [12] phi() [ ] ( main:2::s:5 [ ] ) + to:s::@return +s::@return: scope:[s] from s + [13] return [ ] ( main:2::s:5 [ ] ) + to:@return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.log b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.log new file mode 100644 index 000000000..1f5092cfa --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.log @@ -0,0 +1,1498 @@ +// used vars +const byte* SCREEN = $0400; +byte b=2>>1; + +// unused vars +const byte* BGCOL = $d021; +byte[] msg = "hello world@"; +byte[] arr = { 7, 8, 9}; +byte c=1; +const byte c2=1; +word d=1000; + +void main() { + // used vars + byte col=2; + byte* COLS=$d800; + // unused vars + byte e=3+3+3+s(); // The call to s() should survive even when e is eliminated + word f=2000+2000+d+b++; // b++ should survive even when f is eliminated. + byte[] g = {4, 5, 6}; + byte[] h = "goodbye sky "; + for(byte i : 0..100) { + // the last unused var + signed byte x = -13; + COLS[i] = col; + SCREEN[i] = b; + } +} + +byte s() { + b++; + return 2; +} + +Adding pre/post-modifier (byte) b ← ++ (byte) b +Adding pre/post-modifier (byte) b ← ++ (byte) b +PROGRAM + (byte*) SCREEN ← (word/signed word) 1024 + (byte~) $0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + (byte) b ← (byte~) $0 + (byte*) BGCOL ← (word) 53281 + (byte[]) msg ← (string) "hello world@" + (byte[]) arr ← { (byte/signed byte/word/signed word) 7, (byte/signed byte/word/signed word) 8, (byte/signed byte/word/signed word) 9 } + (byte) c ← (byte/signed byte/word/signed word) 1 + (byte) c2 ← (byte/signed byte/word/signed word) 1 + (word) d ← (word/signed word) 1000 +proc (void()) main() + (byte) main::col ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS ← (word) 55296 + (byte/signed byte/word/signed word~) main::$0 ← (byte/signed byte/word/signed word) 3 + (byte/signed byte/word/signed word) 3 + (byte~) main::$1 ← (byte/signed byte/word/signed word~) main::$0 + (byte/signed byte/word/signed word) 3 + (byte~) main::$2 ← call s + (byte~) main::$3 ← (byte~) main::$1 + (byte~) main::$2 + (byte) main::e ← (byte~) main::$3 + (word/signed word~) main::$4 ← (word/signed word) 2000 + (word/signed word) 2000 + (word~) main::$5 ← (word/signed word~) main::$4 + (word) d + (word~) main::$6 ← (word~) main::$5 + (byte) b + (word) main::f ← (word~) main::$6 + (byte) b ← ++ (byte) b + (byte[]) main::g ← { (byte/signed byte/word/signed word) 4, (byte/signed byte/word/signed word) 5, (byte/signed byte/word/signed word) 6 } + (byte[]) main::h ← (string) "goodbye sky " + (byte) main::i ← (byte/signed byte/word/signed word) 0 +main::@1: + (signed byte/signed word~) main::$7 ← - (byte/signed byte/word/signed word) 13 + (signed byte) main::x ← (signed byte/signed word~) main::$7 + *((byte*) main::COLS + (byte) main::i) ← (byte) main::col + *((byte*) SCREEN + (byte) main::i) ← (byte) b + (byte) main::i ← ++ (byte) main::i + (boolean~) main::$8 ← (byte) main::i != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 +main::@return: + return +endproc // main() +proc (byte()) s() + (byte) b ← ++ (byte) b + (byte) s::return ← (byte/signed byte/word/signed word) 2 + goto s::@return +s::@return: + (byte) s::return ← (byte) s::return + return (byte) s::return +endproc // s() + call main + +SYMBOLS +(byte~) $0 +(byte*) BGCOL +(byte*) SCREEN +(byte[]) arr +(byte) b +(byte) c +(byte) c2 +(word) d +(void()) main() +(byte/signed byte/word/signed word~) main::$0 +(byte~) main::$1 +(byte~) main::$2 +(byte~) main::$3 +(word/signed word~) main::$4 +(word~) main::$5 +(word~) main::$6 +(signed byte/signed word~) main::$7 +(boolean~) main::$8 +(label) main::@1 +(label) main::@return +(byte*) main::COLS +(byte) main::col +(byte) main::e +(word) main::f +(byte[]) main::g +(byte[]) main::h +(byte) main::i +(signed byte) main::x +(byte[]) msg +(byte()) s() +(label) s::@return +(byte) s::return + +Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024 +Promoting word to byte* in BGCOL ← ((byte*)) 53281 +Promoting word to byte* in main::COLS ← ((byte*)) 55296 +INITIAL CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 + (byte~) $0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + (byte) b ← (byte~) $0 + (byte*) BGCOL ← ((byte*)) (word) 53281 + (byte[]) msg ← (string) "hello world@" + (byte[]) arr ← { (byte/signed byte/word/signed word) 7, (byte/signed byte/word/signed word) 8, (byte/signed byte/word/signed word) 9 } + (byte) c ← (byte/signed byte/word/signed word) 1 + (byte) c2 ← (byte/signed byte/word/signed word) 1 + (word) d ← (word/signed word) 1000 + to:@1 +main: scope:[main] from + (byte) main::col ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS ← ((byte*)) (word) 55296 + (byte/signed byte/word/signed word~) main::$0 ← (byte/signed byte/word/signed word) 3 + (byte/signed byte/word/signed word) 3 + (byte~) main::$1 ← (byte/signed byte/word/signed word~) main::$0 + (byte/signed byte/word/signed word) 3 + (byte~) main::$2 ← call s + (byte~) main::$3 ← (byte~) main::$1 + (byte~) main::$2 + (byte) main::e ← (byte~) main::$3 + (word/signed word~) main::$4 ← (word/signed word) 2000 + (word/signed word) 2000 + (word~) main::$5 ← (word/signed word~) main::$4 + (word) d + (word~) main::$6 ← (word~) main::$5 + (byte) b + (word) main::f ← (word~) main::$6 + (byte) b ← ++ (byte) b + (byte[]) main::g ← { (byte/signed byte/word/signed word) 4, (byte/signed byte/word/signed word) 5, (byte/signed byte/word/signed word) 6 } + (byte[]) main::h ← (string) "goodbye sky " + (byte) main::i ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main main::@1 + (signed byte/signed word~) main::$7 ← - (byte/signed byte/word/signed word) 13 + (signed byte) main::x ← (signed byte/signed word~) main::$7 + *((byte*) main::COLS + (byte) main::i) ← (byte) main::col + *((byte*) SCREEN + (byte) main::i) ← (byte) b + (byte) main::i ← ++ (byte) main::i + (boolean~) main::$8 ← (byte) main::i != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@2 +main::@2: scope:[main] from main::@1 + to:main::@return +main::@return: scope:[main] from main::@2 + return + to:@return +@1: scope:[] from @begin + to:@2 +s: scope:[s] from + (byte) b ← ++ (byte) b + (byte) s::return ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s s::@1 + (byte) s::return ← (byte) s::return + return (byte) s::return + to:@return +s::@1: scope:[s] from + to:s::@return +@2: scope:[] from @1 + call main + to:@end +@end: scope:[] from @2 + +Eliminating unused variable (byte*) BGCOL and assignment (byte*) BGCOL ← ((byte*)) (word) 53281 +Eliminating unused variable (byte[]) msg and assignment (byte[]) msg ← (string) "hello world@" +Eliminating unused variable (byte[]) arr and assignment (byte[]) arr ← { (byte/signed byte/word/signed word) 7, (byte/signed byte/word/signed word) 8, (byte/signed byte/word/signed word) 9 } +Eliminating unused variable (byte) c and assignment (byte) c ← (byte/signed byte/word/signed word) 1 +Eliminating unused variable (byte) c2 and assignment (byte) c2 ← (byte/signed byte/word/signed word) 1 +Eliminating unused variable (byte) main::e and assignment (byte) main::e ← (byte~) main::$3 +Eliminating unused variable (word) main::f and assignment (word) main::f ← (word~) main::$6 +Eliminating unused variable (byte[]) main::g and assignment (byte[]) main::g ← { (byte/signed byte/word/signed word) 4, (byte/signed byte/word/signed word) 5, (byte/signed byte/word/signed word) 6 } +Eliminating unused variable (byte[]) main::h and assignment (byte[]) main::h ← (string) "goodbye sky " +Eliminating unused variable (signed byte) main::x and assignment (signed byte) main::x ← (signed byte/signed word~) main::$7 +Eliminating unused variable (byte~) main::$3 and assignment (byte~) main::$3 ← (byte~) main::$1 + (byte~) main::$2 +Eliminating unused variable (word~) main::$6 and assignment (word~) main::$6 ← (word~) main::$5 + (byte) b +Eliminating unused variable (signed byte/signed word~) main::$7 and assignment (signed byte/signed word~) main::$7 ← - (byte/signed byte/word/signed word) 13 +Eliminating unused variable (byte~) main::$1 and assignment (byte~) main::$1 ← (byte/signed byte/word/signed word~) main::$0 + (byte/signed byte/word/signed word) 3 +Eliminating unused variable - keeping the call (byte~) main::$2 +Eliminating unused variable (word~) main::$5 and assignment (word~) main::$5 ← (word/signed word~) main::$4 + (word) d +Eliminating unused variable (word) d and assignment (word) d ← (word/signed word) 1000 +Eliminating unused variable (byte/signed byte/word/signed word~) main::$0 and assignment (byte/signed byte/word/signed word~) main::$0 ← (byte/signed byte/word/signed word) 3 + (byte/signed byte/word/signed word) 3 +Eliminating unused variable (word/signed word~) main::$4 and assignment (word/signed word~) main::$4 ← (word/signed word) 2000 + (word/signed word) 2000 +Removing empty block main::@2 +Removing empty block @1 +Removing empty block s::@1 +CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 + (byte~) $0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + (byte) b ← (byte~) $0 + to:@2 +main: scope:[main] from + (byte) main::col ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS ← ((byte*)) (word) 55296 + call s + (byte) b ← ++ (byte) b + (byte) main::i ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main main::@1 + *((byte*) main::COLS + (byte) main::i) ← (byte) main::col + *((byte*) SCREEN + (byte) main::i) ← (byte) b + (byte) main::i ← ++ (byte) main::i + (boolean~) main::$8 ← (byte) main::i != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from + (byte) b ← ++ (byte) b + (byte) s::return ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + (byte) s::return ← (byte) s::return + return (byte) s::return + to:@return +@2: scope:[] from @begin + call main + to:@end +@end: scope:[] from @2 + +PROCEDURE MODIFY VARIABLE ANALYSIS +main modifies b +s modifies b + +CONTROL FLOW GRAPH WITH ASSIGNMENT CALL +@begin: scope:[] from + (byte*) SCREEN ← ((byte*)) (word/signed word) 1024 + (byte~) $0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + (byte) b ← (byte~) $0 + to:@2 +main: scope:[main] from @2 + (byte) main::col ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS ← ((byte*)) (word) 55296 + (byte) s::return ← call s param-assignment + to:main::@3 +main::@3: scope:[main] from main + (byte) b ← (byte) b + (byte) b ← ++ (byte) b + (byte) main::i ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + *((byte*) main::COLS + (byte) main::i) ← (byte) main::col + *((byte*) SCREEN + (byte) main::i) ← (byte) b + (byte) main::i ← ++ (byte) main::i + (boolean~) main::$8 ← (byte) main::i != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + (byte) b ← (byte) b + return + to:@return +s: scope:[s] from main + (byte) b ← ++ (byte) b + (byte) s::return ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + (byte) s::return ← (byte) s::return + (byte) b ← (byte) b + return (byte) s::return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + (byte) b ← (byte) b + to:@end +@end: scope:[] from @3 + +Completing Phi functions... +Completing Phi functions... +Completing Phi functions... +Completing Phi functions... +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 + (byte~) $0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + (byte) b#0 ← (byte~) $0 + to:@2 +main: scope:[main] from @2 + (byte*) SCREEN#3 ← phi( @2/(byte*) SCREEN#4 ) + (byte) b#13 ← phi( @2/(byte) b#14 ) + (byte) main::col#0 ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS#0 ← ((byte*)) (word) 55296 + (byte) s::return#0 ← call s param-assignment + to:main::@3 +main::@3: scope:[main] from main + (byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 ) + (byte*) main::COLS#2 ← phi( main/(byte*) main::COLS#0 ) + (byte) main::col#2 ← phi( main/(byte) main::col#0 ) + (byte) b#7 ← phi( main/(byte) b#13 ) + (byte) b#1 ← (byte) b#7 + (byte) b#2 ← ++ (byte) b#1 + (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#1 main::@3/(byte*) SCREEN#2 ) + (byte) b#8 ← phi( main::@1/(byte) b#8 main::@3/(byte) b#2 ) + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 ) + (byte*) main::COLS#1 ← phi( main::@1/(byte*) main::COLS#1 main::@3/(byte*) main::COLS#2 ) + (byte) main::col#1 ← phi( main::@1/(byte) main::col#1 main::@3/(byte) main::col#2 ) + *((byte*) main::COLS#1 + (byte) main::i#2) ← (byte) main::col#1 + *((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) b#8 + (byte) main::i#1 ← ++ (byte) main::i#2 + (boolean~) main::$8 ← (byte) main::i#1 != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + (byte) b#9 ← phi( main::@1/(byte) b#8 ) + (byte) b#3 ← (byte) b#9 + return + to:@return +s: scope:[s] from main + (byte) b#10 ← phi( main/(byte) b#13 ) + (byte) b#4 ← ++ (byte) b#10 + (byte) s::return#1 ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + (byte) b#11 ← phi( s/(byte) b#4 ) + (byte) s::return#3 ← phi( s/(byte) s::return#1 ) + (byte) s::return#2 ← (byte) s::return#3 + (byte) b#5 ← (byte) b#11 + return (byte) s::return#2 + to:@return +@2: scope:[] from @begin + (byte*) SCREEN#4 ← phi( @begin/(byte*) SCREEN#0 ) + (byte) b#14 ← phi( @begin/(byte) b#0 ) + call main param-assignment + to:@3 +@3: scope:[] from @2 + (byte) b#12 ← phi( @2/(byte) b#14 ) + (byte) b#6 ← (byte) b#12 + to:@end +@end: scope:[] from @3 + +CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN +@begin: scope:[] from + (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 + (byte~) $0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + (byte) b#0 ← (byte~) $0 + to:@2 +main: scope:[main] from @2 + (byte*) SCREEN#3 ← phi( @2/(byte*) SCREEN#4 ) + (byte) b#13 ← phi( @2/(byte) b#14 ) + (byte) main::col#0 ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS#0 ← ((byte*)) (word) 55296 + call s param-assignment + (byte) s::return#0 ← (byte) s::return#2 + to:main::@3 +main::@3: scope:[main] from main + (byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 ) + (byte*) main::COLS#2 ← phi( main/(byte*) main::COLS#0 ) + (byte) main::col#2 ← phi( main/(byte) main::col#0 ) + (byte) b#7 ← phi( main/(byte) b#5 ) + (byte) b#1 ← (byte) b#7 + (byte) b#2 ← ++ (byte) b#1 + (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#1 main::@3/(byte*) SCREEN#2 ) + (byte) b#8 ← phi( main::@1/(byte) b#8 main::@3/(byte) b#2 ) + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 ) + (byte*) main::COLS#1 ← phi( main::@1/(byte*) main::COLS#1 main::@3/(byte*) main::COLS#2 ) + (byte) main::col#1 ← phi( main::@1/(byte) main::col#1 main::@3/(byte) main::col#2 ) + *((byte*) main::COLS#1 + (byte) main::i#2) ← (byte) main::col#1 + *((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) b#8 + (byte) main::i#1 ← ++ (byte) main::i#2 + (boolean~) main::$8 ← (byte) main::i#1 != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + (byte) b#9 ← phi( main::@1/(byte) b#8 ) + (byte) b#3 ← (byte) b#9 + return + to:@return +s: scope:[s] from main + (byte) b#10 ← phi( main/(byte) b#13 ) + (byte) b#4 ← ++ (byte) b#10 + (byte) s::return#1 ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + (byte) b#11 ← phi( s/(byte) b#4 ) + (byte) s::return#3 ← phi( s/(byte) s::return#1 ) + (byte) s::return#2 ← (byte) s::return#3 + (byte) b#5 ← (byte) b#11 + return + to:@return +@2: scope:[] from @begin + (byte*) SCREEN#4 ← phi( @begin/(byte*) SCREEN#0 ) + (byte) b#14 ← phi( @begin/(byte) b#0 ) + call main param-assignment + to:@3 +@3: scope:[] from @2 + (byte) b#12 ← phi( @2/(byte) b#3 ) + (byte) b#6 ← (byte) b#12 + to:@end +@end: scope:[] from @3 + +INITIAL SSA SYMBOL TABLE +(byte~) $0 +(label) @2 +(label) @3 +(label) @begin +(label) @end +(byte*) SCREEN +(byte*) SCREEN#0 +(byte*) SCREEN#1 +(byte*) SCREEN#2 +(byte*) SCREEN#3 +(byte*) SCREEN#4 +(byte) b +(byte) b#0 +(byte) b#1 +(byte) b#10 +(byte) b#11 +(byte) b#12 +(byte) b#13 +(byte) b#14 +(byte) b#2 +(byte) b#3 +(byte) b#4 +(byte) b#5 +(byte) b#6 +(byte) b#7 +(byte) b#8 +(byte) b#9 +(void()) main() +(boolean~) main::$8 +(label) main::@1 +(label) main::@3 +(label) main::@return +(byte*) main::COLS +(byte*) main::COLS#0 +(byte*) main::COLS#1 +(byte*) main::COLS#2 +(byte) main::col +(byte) main::col#0 +(byte) main::col#1 +(byte) main::col#2 +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte()) s() +(label) s::@return +(byte) s::return +(byte) s::return#0 +(byte) s::return#1 +(byte) s::return#2 +(byte) s::return#3 + +Not aliassing across scopes: b#13 b#14 +Not aliassing across scopes: SCREEN#3 SCREEN#4 +Not aliassing across scopes: s::return#0 s::return#2 +Not aliassing across scopes: b#7 b#5 +Not aliassing identity: main::col#1 main::col#1 +Not aliassing identity: main::COLS#1 main::COLS#1 +Not aliassing identity: b#8 b#8 +Not aliassing identity: SCREEN#1 SCREEN#1 +Not aliassing across scopes: b#10 b#13 +Not aliassing across scopes: b#12 b#3 +Alias (byte) b#0 = (byte~) $0 (byte) b#14 +Alias (byte) main::col#0 = (byte) main::col#2 +Alias (byte*) main::COLS#0 = (byte*) main::COLS#2 +Alias (byte*) SCREEN#2 = (byte*) SCREEN#3 +Alias (byte) b#1 = (byte) b#7 +Alias (byte) b#3 = (byte) b#9 (byte) b#8 +Alias (byte) s::return#1 = (byte) s::return#3 (byte) s::return#2 +Alias (byte) b#11 = (byte) b#4 (byte) b#5 +Alias (byte*) SCREEN#0 = (byte*) SCREEN#4 +Alias (byte) b#12 = (byte) b#6 +Succesful SSA optimization Pass2AliasElimination +CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 + (byte) b#0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + to:@2 +main: scope:[main] from @2 + (byte*) SCREEN#2 ← phi( @2/(byte*) SCREEN#0 ) + (byte) b#13 ← phi( @2/(byte) b#0 ) + (byte) main::col#0 ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS#0 ← ((byte*)) (word) 55296 + call s param-assignment + (byte) s::return#0 ← (byte) s::return#1 + to:main::@3 +main::@3: scope:[main] from main + (byte) b#1 ← phi( main/(byte) b#11 ) + (byte) b#2 ← ++ (byte) b#1 + (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#1 main::@3/(byte*) SCREEN#2 ) + (byte) b#3 ← phi( main::@1/(byte) b#3 main::@3/(byte) b#2 ) + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 ) + (byte*) main::COLS#1 ← phi( main::@1/(byte*) main::COLS#1 main::@3/(byte*) main::COLS#0 ) + (byte) main::col#1 ← phi( main::@1/(byte) main::col#1 main::@3/(byte) main::col#0 ) + *((byte*) main::COLS#1 + (byte) main::i#2) ← (byte) main::col#1 + *((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) b#3 + (byte) main::i#1 ← ++ (byte) main::i#2 + (boolean~) main::$8 ← (byte) main::i#1 != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + (byte) b#10 ← phi( main/(byte) b#13 ) + (byte) b#11 ← ++ (byte) b#10 + (byte) s::return#1 ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + (byte) b#12 ← phi( @2/(byte) b#3 ) + to:@end +@end: scope:[] from @3 + +Not aliassing across scopes: b#13 b#0 +Not aliassing across scopes: SCREEN#2 SCREEN#0 +Not aliassing across scopes: s::return#0 s::return#1 +Not aliassing across scopes: b#1 b#11 +Not aliassing identity: main::col#1 main::col#1 +Not aliassing identity: main::COLS#1 main::COLS#1 +Not aliassing identity: b#3 b#3 +Not aliassing identity: SCREEN#1 SCREEN#1 +Not aliassing across scopes: b#10 b#13 +Not aliassing across scopes: b#12 b#3 +Self Phi Eliminated (byte) main::col#1 +Self Phi Eliminated (byte*) main::COLS#1 +Self Phi Eliminated (byte) b#3 +Self Phi Eliminated (byte*) SCREEN#1 +Succesful SSA optimization Pass2SelfPhiElimination +CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 + (byte) b#0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + to:@2 +main: scope:[main] from @2 + (byte*) SCREEN#2 ← phi( @2/(byte*) SCREEN#0 ) + (byte) b#13 ← phi( @2/(byte) b#0 ) + (byte) main::col#0 ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS#0 ← ((byte*)) (word) 55296 + call s param-assignment + (byte) s::return#0 ← (byte) s::return#1 + to:main::@3 +main::@3: scope:[main] from main + (byte) b#1 ← phi( main/(byte) b#11 ) + (byte) b#2 ← ++ (byte) b#1 + (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte*) SCREEN#1 ← phi( main::@3/(byte*) SCREEN#2 ) + (byte) b#3 ← phi( main::@3/(byte) b#2 ) + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 ) + (byte*) main::COLS#1 ← phi( main::@3/(byte*) main::COLS#0 ) + (byte) main::col#1 ← phi( main::@3/(byte) main::col#0 ) + *((byte*) main::COLS#1 + (byte) main::i#2) ← (byte) main::col#1 + *((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) b#3 + (byte) main::i#1 ← ++ (byte) main::i#2 + (boolean~) main::$8 ← (byte) main::i#1 != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + (byte) b#10 ← phi( main/(byte) b#13 ) + (byte) b#11 ← ++ (byte) b#10 + (byte) s::return#1 ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + (byte) b#12 ← phi( @2/(byte) b#3 ) + to:@end +@end: scope:[] from @3 + +Redundant Phi (byte) b#13 (byte) b#0 +Redundant Phi (byte*) SCREEN#2 (byte*) SCREEN#0 +Redundant Phi (byte) b#1 (byte) b#11 +Redundant Phi (byte) main::col#1 (byte) main::col#0 +Redundant Phi (byte*) main::COLS#1 (byte*) main::COLS#0 +Redundant Phi (byte) b#3 (byte) b#2 +Redundant Phi (byte*) SCREEN#1 (byte*) SCREEN#2 +Redundant Phi (byte) b#10 (byte) b#13 +Redundant Phi (byte) b#12 (byte) b#3 +Succesful SSA optimization Pass2RedundantPhiElimination +CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 + (byte) b#0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + to:@2 +main: scope:[main] from @2 + (byte) main::col#0 ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS#0 ← ((byte*)) (word) 55296 + call s param-assignment + (byte) s::return#0 ← (byte) s::return#1 + to:main::@3 +main::@3: scope:[main] from main + (byte) b#2 ← ++ (byte) b#11 + (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 ) + *((byte*) main::COLS#0 + (byte) main::i#2) ← (byte) main::col#0 + *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) b#2 + (byte) main::i#1 ← ++ (byte) main::i#2 + (boolean~) main::$8 ← (byte) main::i#1 != (byte/signed byte/word/signed word) 101 + if((boolean~) main::$8) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + (byte) b#11 ← ++ (byte) b#0 + (byte) s::return#1 ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + to:@end +@end: scope:[] from @3 + +Simple Condition (boolean~) main::$8 if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 +Succesful SSA optimization Pass2ConditionalJumpSimplification +CONTROL FLOW GRAPH +@begin: scope:[] from + (byte*) SCREEN#0 ← ((byte*)) (word/signed word) 1024 + (byte) b#0 ← (byte/signed byte/word/signed word) 2 >> (byte/signed byte/word/signed word) 1 + to:@2 +main: scope:[main] from @2 + (byte) main::col#0 ← (byte/signed byte/word/signed word) 2 + (byte*) main::COLS#0 ← ((byte*)) (word) 55296 + call s param-assignment + (byte) s::return#0 ← (byte) s::return#1 + to:main::@3 +main::@3: scope:[main] from main + (byte) b#2 ← ++ (byte) b#11 + (byte) main::i#0 ← (byte/signed byte/word/signed word) 0 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(byte) main::i#0 ) + *((byte*) main::COLS#0 + (byte) main::i#2) ← (byte) main::col#0 + *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) b#2 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + (byte) b#11 ← ++ (byte) b#0 + (byte) s::return#1 ← (byte/signed byte/word/signed word) 2 + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + to:@end +@end: scope:[] from @3 + +Constant (const byte*) SCREEN#0 = ((byte*))1024 +Constant (const byte) b#0 = 2>>1 +Constant (const byte) main::col#0 = 2 +Constant (const byte*) main::COLS#0 = ((byte*))55296 +Constant (const byte) main::i#0 = 0 +Constant (const byte) s::return#1 = 2 +Succesful SSA optimization Pass2ConstantIdentification +CONTROL FLOW GRAPH +@begin: scope:[] from + to:@2 +main: scope:[main] from @2 + call s param-assignment + (byte) s::return#0 ← (const byte) s::return#1 + to:main::@3 +main::@3: scope:[main] from main + (byte) b#2 ← ++ (byte) b#11 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(const byte) main::i#0 ) + *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 + *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) b#2 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + (byte) b#11 ← ++ (const byte) b#0 + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + to:@end +@end: scope:[] from @3 + +Constant (const byte) s::return#0 = s::return#1 +Constant (const byte) b#11 = ++b#0 +Succesful SSA optimization Pass2ConstantIdentification +CONTROL FLOW GRAPH +@begin: scope:[] from + to:@2 +main: scope:[main] from @2 + call s param-assignment + to:main::@3 +main::@3: scope:[main] from main + (byte) b#2 ← ++ (const byte) b#11 + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(const byte) main::i#0 ) + *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 + *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) b#2 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + to:@end +@end: scope:[] from @3 + +Constant (const byte) b#2 = ++b#11 +Succesful SSA optimization Pass2ConstantIdentification +CONTROL FLOW GRAPH +@begin: scope:[] from + to:@2 +main: scope:[main] from @2 + call s param-assignment + to:main::@3 +main::@3: scope:[main] from main + to:main::@1 +main::@1: scope:[main] from main::@1 main::@3 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@3/(const byte) main::i#0 ) + *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 + *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) b#2 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@3 +@3: scope:[] from @2 + to:@end +@end: scope:[] from @3 + +Culled Empty Block (label) main::@3 +Culled Empty Block (label) @3 +Succesful SSA optimization Pass2CullEmptyBlocks +CONTROL FLOW GRAPH +@begin: scope:[] from + to:@2 +main: scope:[main] from @2 + call s param-assignment + to:main::@1 +main::@1: scope:[main] from main main::@1 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main/(const byte) main::i#0 ) + *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 + *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) b#2 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@end +@end: scope:[] from @2 + +Inlining constant with var siblings (const byte) main::i#0 +Inlining constant with var siblings (const byte) main::i#0 +Inlining constant with different constant siblings (const byte) s::return#0 +Inlining constant with different constant siblings (const byte) b#0 +Inlining constant with different constant siblings (const byte) b#0 +Inlining constant with different constant siblings (const byte) b#11 +Inlining constant with different constant siblings (const byte) b#11 +Inlining constant with different constant siblings (const byte) b#2 +Inlining constant with different constant siblings (const byte) b#2 +Constant inlined b#2 = ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 +Constant inlined main::i#0 = (byte/signed byte/word/signed word) 0 +Constant inlined s::return#0 = (const byte) s::return#1 +Constant inlined b#11 = ++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 +Constant inlined b#0 = (byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 +Succesful SSA optimization Pass2ConstantInlining +CONTROL FLOW GRAPH +@begin: scope:[] from + to:@2 +main: scope:[main] from @2 + call s param-assignment + to:main::@1 +main::@1: scope:[main] from main main::@1 + (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main/(byte/signed byte/word/signed word) 0 ) + *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 + *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +s: scope:[s] from main + to:s::@return +s::@return: scope:[s] from s + return + to:@return +@2: scope:[] from @begin + call main param-assignment + to:@end +@end: scope:[] from @2 + +FINAL SYMBOL TABLE +(label) @2 +(label) @begin +(label) @end +(byte*) SCREEN +(const byte*) SCREEN#0 = ((byte*))(word/signed word) 1024 +(byte) b +(void()) main() +(label) main::@1 +(label) main::@return +(byte*) main::COLS +(const byte*) main::COLS#0 = ((byte*))(word) 55296 +(byte) main::col +(const byte) main::col#0 = (byte/signed byte/word/signed word) 2 +(byte) main::i +(byte) main::i#1 +(byte) main::i#2 +(byte()) s() +(label) s::@return +(byte) s::return +(const byte) s::return#1 = (byte/signed byte/word/signed word) 2 + +Block Sequence Planned @begin @2 @end main main::@1 main::@return s s::@return +Added new block during phi lifting main::@4(between main::@1 and main::@1) +Block Sequence Planned @begin @2 @end main main::@1 main::@return main::@4 s s::@return +CONTROL FLOW GRAPH - PHI LIFTED +@begin: scope:[] from + to:@2 +@2: scope:[] from @begin + call main param-assignment + to:@end +@end: scope:[] from @2 +main: scope:[main] from @2 + call s param-assignment + to:main::@1 +main::@1: scope:[main] from main main::@4 + (byte) main::i#2 ← phi( main::@4/(byte~) main::i#3 main/(byte/signed byte/word/signed word) 0 ) + *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 + *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 + (byte) main::i#1 ← ++ (byte) main::i#2 + if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@4 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +main::@4: scope:[main] from main::@1 + (byte~) main::i#3 ← (byte) main::i#1 + to:main::@1 +s: scope:[s] from main + to:s::@return +s::@return: scope:[s] from s + return + to:@return + +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of s +CALL GRAPH +Calls in [] to main:2 +Calls in [main] to s:5 + +Propagating live ranges... +Propagating live ranges... +CONTROL FLOW GRAPH - LIVE RANGES FOUND +@begin: scope:[] from + [0] phi() [ ] + to:@2 +@2: scope:[] from @begin + [1] phi() [ ] + [2] call main param-assignment [ ] + to:@end +@end: scope:[] from @2 + [3] phi() [ ] +main: scope:[main] from @2 + [4] phi() [ ] + [5] call s param-assignment [ ] + to:main::@1 +main::@1: scope:[main] from main main::@4 + [6] (byte) main::i#2 ← phi( main::@4/(byte~) main::i#3 main/(byte/signed byte/word/signed word) 0 ) [ main::i#2 ] + [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] + [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] + [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] + [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@4 [ main::i#1 ] + to:main::@return +main::@return: scope:[main] from main::@1 + [11] return [ ] + to:@return +main::@4: scope:[main] from main::@1 + [12] (byte~) main::i#3 ← (byte) main::i#1 [ main::i#3 ] + to:main::@1 +s: scope:[s] from main + [13] phi() [ ] + to:s::@return +s::@return: scope:[s] from s + [14] return [ ] + to:@return + +Created 1 initial phi equivalence classes +Coalesced [12] main::i#3 ← main::i#1 +Coalesced down to 1 phi equivalence classes +Culled Empty Block (label) main::@4 +Block Sequence Planned @begin @2 @end main main::@1 main::@return s s::@return +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of s +Propagating live ranges... +Propagating live ranges... +CONTROL FLOW GRAPH - BEFORE EFFECTIVE LIVE RANGES +@begin: scope:[] from + [0] phi() [ ] + to:@2 +@2: scope:[] from @begin + [1] phi() [ ] + [2] call main param-assignment [ ] + to:@end +@end: scope:[] from @2 + [3] phi() [ ] +main: scope:[main] from @2 + [4] phi() [ ] + [5] call s param-assignment [ ] + to:main::@1 +main::@1: scope:[main] from main main::@1 + [6] (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main/(byte/signed byte/word/signed word) 0 ) [ main::i#2 ] + [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] + [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] + [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] + [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] + to:main::@return +main::@return: scope:[main] from main::@1 + [11] return [ ] + to:@return +s: scope:[s] from main + [12] phi() [ ] + to:s::@return +s::@return: scope:[s] from s + [13] return [ ] + to:@return + +CONTROL FLOW GRAPH - PHI MEM COALESCED +@begin: scope:[] from + [0] phi() [ ] ( ) + to:@2 +@2: scope:[] from @begin + [1] phi() [ ] ( ) + [2] call main param-assignment [ ] ( ) + to:@end +@end: scope:[] from @2 + [3] phi() [ ] ( ) +main: scope:[main] from @2 + [4] phi() [ ] ( main:2 [ ] ) + [5] call s param-assignment [ ] ( main:2 [ ] ) + to:main::@1 +main::@1: scope:[main] from main main::@1 + [6] (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main/(byte/signed byte/word/signed word) 0 ) [ main::i#2 ] ( main:2 [ main::i#2 ] ) + [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) + [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) + [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) + [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) + to:main::@return +main::@return: scope:[main] from main::@1 + [11] return [ ] ( main:2 [ ] ) + to:@return +s: scope:[s] from main + [12] phi() [ ] ( main:2::s:5 [ ] ) + to:s::@return +s::@return: scope:[s] from s + [13] return [ ] ( main:2::s:5 [ ] ) + to:@return + +DOMINATORS +@begin dominated by @begin +@2 dominated by @2 @begin +@end dominated by @2 @begin @end +main dominated by @2 @begin main +main::@1 dominated by @2 @begin main::@1 main +main::@return dominated by main::@return @2 @begin main::@1 main +s dominated by @2 @begin s main +s::@return dominated by @2 @begin s main s::@return + +Found back edge: Loop head: main::@1 tails: main::@1 blocks: null +Populated: Loop head: main::@1 tails: main::@1 blocks: main::@1 +NATURAL LOOPS +Loop head: main::@1 tails: main::@1 blocks: main::@1 + +Found 0 loops in scope [] +Found 1 loops in scope [main] + Loop head: main::@1 tails: main::@1 blocks: main::@1 +Found 0 loops in scope [s] +NATURAL LOOPS WITH DEPTH +Loop head: main::@1 tails: main::@1 blocks: main::@1 depth: 1 + + +VARIABLE REGISTER WEIGHTS +(byte*) SCREEN +(byte) b +(void()) main() +(byte*) main::COLS +(byte) main::col +(byte) main::i +(byte) main::i#1 16.5 +(byte) main::i#2 14.666666666666666 +(byte()) s() +(byte) s::return + +Initial phi equivalence classes +[ main::i#2 main::i#1 ] +Complete equivalence classes +[ main::i#2 main::i#1 ] +Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +INITIAL ASM +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .const SCREEN = $400 +//SEG2 @begin +bbegin: +//SEG3 [1] phi from @begin to @2 [phi:@begin->@2] +b2_from_bbegin: + jmp b2 +//SEG4 @2 +b2: +//SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @2 to main [phi:@2->main] +main_from_b2: + jsr main +//SEG7 [3] phi from @2 to @end [phi:@2->@end] +bend_from_b2: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + .const col = 2 + .const COLS = $d800 + .label i = 2 + //SEG10 [5] call s param-assignment [ ] ( main:2 [ ] ) + //SEG11 [12] phi from main to s [phi:main->s] + s_from_main: + jsr s + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG13 [6] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- zpby1=coby1 + lda #0 + sta i + jmp b1 + //SEG14 [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG15 [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG16 main::@1 + b1: + //SEG17 [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_zpby1=coby2 + lda #col + ldx i + sta COLS,x + //SEG18 [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_zpby1=coby2 + lda #(2>>1)+1+1 + ldx i + sta SCREEN,x + //SEG19 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- zpby1=_inc_zpby1 + inc i + //SEG20 [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- zpby1_neq_coby1_then_la1 + lda i + cmp #$65 + bne b1_from_b1 + jmp breturn + //SEG21 main::@return + breturn: + //SEG22 [11] return [ ] ( main:2 [ ] ) + rts +} +//SEG23 s +s: { + .const return = 2 + jmp breturn + //SEG24 s::@return + breturn: + //SEG25 [13] return [ ] ( main:2::s:5 [ ] ) + rts +} + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Statement [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Statement [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Statement [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 31.17: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Uplift Scope [s] +Uplift Scope [] + +Uplifting [main] best 375 combination reg byte x [ main::i#2 main::i#1 ] +Uplifting [s] best 375 combination +Uplifting [] best 375 combination +Removing instruction jmp b2 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp breturn +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +ASSEMBLER +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .const SCREEN = $400 +//SEG2 @begin +bbegin: +//SEG3 [1] phi from @begin to @2 [phi:@begin->@2] +b2_from_bbegin: +//SEG4 @2 +b2: +//SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @2 to main [phi:@2->main] +main_from_b2: + jsr main +//SEG7 [3] phi from @2 to @end [phi:@2->@end] +bend_from_b2: +//SEG8 @end +bend: +//SEG9 main +main: { + .const col = 2 + .const COLS = $d800 + //SEG10 [5] call s param-assignment [ ] ( main:2 [ ] ) + //SEG11 [12] phi from main to s [phi:main->s] + s_from_main: + jsr s + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG13 [6] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 + ldx #0 + jmp b1 + //SEG14 [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG15 [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG16 main::@1 + b1: + //SEG17 [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #col + sta COLS,x + //SEG18 [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #(2>>1)+1+1 + sta SCREEN,x + //SEG19 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + inx + //SEG20 [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby_neq_coby1_then_la1 + cpx #$65 + bne b1_from_b1 + //SEG21 main::@return + breturn: + //SEG22 [11] return [ ] ( main:2 [ ] ) + rts +} +//SEG23 s +s: { + .const return = 2 + //SEG24 s::@return + breturn: + //SEG25 [13] return [ ] ( main:2::s:5 [ ] ) + rts +} + +Replacing label b1_from_b1 with b1 +Removing instruction bbegin: +Removing instruction b2_from_bbegin: +Removing instruction main_from_b2: +Removing instruction bend_from_b2: +Removing instruction b1_from_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +ASSEMBLER +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .const SCREEN = $400 +//SEG2 @begin +//SEG3 [1] phi from @begin to @2 [phi:@begin->@2] +//SEG4 @2 +b2: +//SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @2 to main [phi:@2->main] + jsr main +//SEG7 [3] phi from @2 to @end [phi:@2->@end] +//SEG8 @end +bend: +//SEG9 main +main: { + .const col = 2 + .const COLS = $d800 + //SEG10 [5] call s param-assignment [ ] ( main:2 [ ] ) + //SEG11 [12] phi from main to s [phi:main->s] + s_from_main: + jsr s + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG13 [6] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 + ldx #0 + jmp b1 + //SEG14 [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG15 [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG16 main::@1 + b1: + //SEG17 [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #col + sta COLS,x + //SEG18 [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #(2>>1)+1+1 + sta SCREEN,x + //SEG19 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + inx + //SEG20 [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby_neq_coby1_then_la1 + cpx #$65 + bne b1 + //SEG21 main::@return + breturn: + //SEG22 [11] return [ ] ( main:2 [ ] ) + rts +} +//SEG23 s +s: { + .const return = 2 + //SEG24 s::@return + breturn: + //SEG25 [13] return [ ] ( main:2::s:5 [ ] ) + rts +} + +Removing instruction b2: +Removing instruction bend: +Removing instruction s_from_main: +Removing instruction b1_from_main: +Removing instruction breturn: +Removing instruction breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +ASSEMBLER +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .const SCREEN = $400 +//SEG2 @begin +//SEG3 [1] phi from @begin to @2 [phi:@begin->@2] +//SEG4 @2 +//SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @2 to main [phi:@2->main] + jsr main +//SEG7 [3] phi from @2 to @end [phi:@2->@end] +//SEG8 @end +//SEG9 main +main: { + .const col = 2 + .const COLS = $d800 + //SEG10 [5] call s param-assignment [ ] ( main:2 [ ] ) + //SEG11 [12] phi from main to s [phi:main->s] + jsr s + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + //SEG13 [6] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 + ldx #0 + jmp b1 + //SEG14 [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG15 [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG16 main::@1 + b1: + //SEG17 [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #col + sta COLS,x + //SEG18 [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #(2>>1)+1+1 + sta SCREEN,x + //SEG19 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + inx + //SEG20 [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby_neq_coby1_then_la1 + cpx #$65 + bne b1 + //SEG21 main::@return + //SEG22 [11] return [ ] ( main:2 [ ] ) + rts +} +//SEG23 s +s: { + .const return = 2 + //SEG24 s::@return + //SEG25 [13] return [ ] ( main:2::s:5 [ ] ) + rts +} + +Removing instruction jmp b1 +Succesful ASM optimization Pass5NextJumpElimination +ASSEMBLER +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .const SCREEN = $400 +//SEG2 @begin +//SEG3 [1] phi from @begin to @2 [phi:@begin->@2] +//SEG4 @2 +//SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @2 to main [phi:@2->main] + jsr main +//SEG7 [3] phi from @2 to @end [phi:@2->@end] +//SEG8 @end +//SEG9 main +main: { + .const col = 2 + .const COLS = $d800 + //SEG10 [5] call s param-assignment [ ] ( main:2 [ ] ) + //SEG11 [12] phi from main to s [phi:main->s] + jsr s + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + //SEG13 [6] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 + ldx #0 + //SEG14 [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG15 [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG16 main::@1 + b1: + //SEG17 [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #col + sta COLS,x + //SEG18 [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #(2>>1)+1+1 + sta SCREEN,x + //SEG19 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + inx + //SEG20 [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby_neq_coby1_then_la1 + cpx #$65 + bne b1 + //SEG21 main::@return + //SEG22 [11] return [ ] ( main:2 [ ] ) + rts +} +//SEG23 s +s: { + .const return = 2 + //SEG24 s::@return + //SEG25 [13] return [ ] ( main:2::s:5 [ ] ) + rts +} + +FINAL SYMBOL TABLE +(label) @2 +(label) @begin +(label) @end +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 +(byte) b +(void()) main() +(label) main::@1 +(label) main::@return +(byte*) main::COLS +(const byte*) main::COLS#0 COLS = ((byte*))(word) 55296 +(byte) main::col +(const byte) main::col#0 col = (byte/signed byte/word/signed word) 2 +(byte) main::i +(byte) main::i#1 reg byte x 16.5 +(byte) main::i#2 reg byte x 14.666666666666666 +(byte()) s() +(label) s::@return +(byte) s::return +(const byte) s::return#1 return = (byte/signed byte/word/signed word) 2 + +reg byte x [ main::i#2 main::i#1 ] + +FINAL CODE +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .const SCREEN = $400 +//SEG2 @begin +//SEG3 [1] phi from @begin to @2 [phi:@begin->@2] +//SEG4 @2 +//SEG5 [2] call main param-assignment [ ] ( ) +//SEG6 [4] phi from @2 to main [phi:@2->main] + jsr main +//SEG7 [3] phi from @2 to @end [phi:@2->@end] +//SEG8 @end +//SEG9 main +main: { + .const col = 2 + .const COLS = $d800 + //SEG10 [5] call s param-assignment [ ] ( main:2 [ ] ) + //SEG11 [12] phi from main to s [phi:main->s] + jsr s + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + //SEG13 [6] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1 + ldx #0 + //SEG14 [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG15 [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG16 main::@1 + b1: + //SEG17 [7] *((const byte*) main::COLS#0 + (byte) main::i#2) ← (const byte) main::col#0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #col + sta COLS,x + //SEG18 [8] *((const byte*) SCREEN#0 + (byte) main::i#2) ← ++++(byte/signed byte/word/signed word) 2>>(byte/signed byte/word/signed word) 1 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2 + lda #(2>>1)+1+1 + sta SCREEN,x + //SEG19 [9] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby + inx + //SEG20 [10] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby_neq_coby1_then_la1 + cpx #$65 + bne b1 + //SEG21 main::@return + //SEG22 [11] return [ ] ( main:2 [ ] ) + rts +} +//SEG23 s +s: { + .const return = 2 + //SEG24 s::@return + //SEG25 [13] return [ ] ( main:2::s:5 [ ] ) + rts +} + diff --git a/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.sym b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.sym new file mode 100644 index 000000000..9d77ad060 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/unused-vars.sym @@ -0,0 +1,22 @@ +(label) @2 +(label) @begin +(label) @end +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word) 1024 +(byte) b +(void()) main() +(label) main::@1 +(label) main::@return +(byte*) main::COLS +(const byte*) main::COLS#0 COLS = ((byte*))(word) 55296 +(byte) main::col +(const byte) main::col#0 col = (byte/signed byte/word/signed word) 2 +(byte) main::i +(byte) main::i#1 reg byte x 16.5 +(byte) main::i#2 reg byte x 14.666666666666666 +(byte()) s() +(label) s::@return +(byte) s::return +(const byte) s::return#1 return = (byte/signed byte/word/signed word) 2 + +reg byte x [ main::i#2 main::i#1 ] 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 ce242ff34..9aa6fcae2 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/voronoi.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/voronoi.log @@ -618,6 +618,9 @@ findcol::@18: scope:[findcol] from to:@end @end: scope:[] from @5 +Eliminating unused variable - keeping the call (void~) main::$0 +Eliminating unused variable - keeping the call (void~) main::$1 +Eliminating unused variable - keeping the call (void~) main::$2 Removing empty block main::@2 Removing empty block @1 Removing empty block @2 @@ -640,11 +643,11 @@ CONTROL FLOW GRAPH (byte[]) COLS ← { (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 3, (byte/signed byte/word/signed word) 4, (byte/signed byte/word/signed word) 5, (byte/signed byte/word/signed word) 7 } to:@5 main: scope:[main] from - (void~) main::$0 ← call initscreen + call initscreen to:main::@1 main::@1: scope:[main] from main main::@1 - (void~) main::$1 ← call render - (void~) main::$2 ← call animate + call render + call animate if(true) goto main::@1 to:main::@return main::@return: scope:[main] from main::@1 diff --git a/src/main/java/dk/camelot64/kickc/test/summin.kc b/src/main/java/dk/camelot64/kickc/test/summin.kc index b0e6436ca..a3e16e2f5 100644 --- a/src/main/java/dk/camelot64/kickc/test/summin.kc +++ b/src/main/java/dk/camelot64/kickc/test/summin.kc @@ -1,8 +1,11 @@ +byte* screen = $0400; + void main() { byte s1=sum(1,2); byte s2=sum(3,4); byte s3=sum(9,13); byte s4=s1+s2+s3; + *screen = s4; } byte sum(byte a, byte b) { diff --git a/src/main/java/dk/camelot64/kickc/test/unused-vars.kc b/src/main/java/dk/camelot64/kickc/test/unused-vars.kc index e9d492035..b959a49ae 100644 --- a/src/main/java/dk/camelot64/kickc/test/unused-vars.kc +++ b/src/main/java/dk/camelot64/kickc/test/unused-vars.kc @@ -1,12 +1,13 @@ // used vars const byte* SCREEN = $0400; -byte b=0; +byte b=2>>1; // unused vars const byte* BGCOL = $d021; byte[] msg = "hello world@"; byte[] arr = { 7, 8, 9}; byte c=1; +const byte c2=1; word d=1000; void main() { @@ -14,16 +15,19 @@ void main() { byte col=2; byte* COLS=$d800; // unused vars - byte e=3+3+3; - word f=2000+2000+d; + byte e=3+3+3+s(); // The call to s() should survive even when e is eliminated + word f=2000+2000+d+b++; // b++ should survive even when f is eliminated. byte[] g = {4, 5, 6}; byte[] h = "goodbye sky "; - for(byte i : 0..100) { // the last unused var signed byte x = -13; COLS[i] = col; SCREEN[i] = b; } - +} + +byte s() { + b++; + return 2; }