1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-20 02:32:36 +00:00

Inlining constants that are unnamed, single versions of a variable or aliases of other constants

This commit is contained in:
jespergravgaard 2017-10-14 22:36:52 +02:00
parent 1a9ae72668
commit a09ca15dbf
66 changed files with 3517 additions and 3318 deletions

View File

@ -135,17 +135,26 @@ public class Compiler {
public void pass2OptimizeSSA(Program program) {
List<Pass2SsaOptimization> optimizations = new ArrayList<>();
optimizations.add(new Pass2CullEmptyBlocks(program));
optimizations.add(new Pass2ConstantIdentification(program));
optimizations.add(new Pass2ConstantInlining(program));
//optimizations.add(new Pass2ConstantPropagation(program));
//optimizations.add(new Pass2ConstantAdditionElimination(program));
optimizations.add(new Pass2UnaryNotSimplification(program));
optimizations.add(new Pass2AliasElimination(program));
optimizations.add(new Pass2RedundantPhiElimination(program));
optimizations.add(new Pass2SelfPhiElimination(program));
optimizations.add(new Pass2ConditionalJumpSimplification(program));
optimizations.add(new Pass2ConstantIdentification(program));
pass2OptimizeSSA(program, optimizations);
// Constant inlining optimizations - as the last step to ensure that constant identification has been completed
List<Pass2SsaOptimization> constantOptimizations = new ArrayList<>();
constantOptimizations.add(new Pass2ConstantInlining(program));
pass2OptimizeSSA(program, constantOptimizations);
//optimizations.add(new Pass2ConstantPropagation(program));
//optimizations.add(new Pass2ConstantAdditionElimination(program));
}
private void pass2OptimizeSSA(Program program, List<Pass2SsaOptimization> optimizations) {
boolean ssaOptimized = true;
while (ssaOptimized) {
pass2AssertSSA(program);

View File

@ -1,9 +1,12 @@
TODO's for new Constant Solution
+ Live range overlap analysis of register combinations inside methods must also look at registers alive at all calls.
+ Examine why temp-vars are used in flipper.
- Examine why flipper is plotted in a wrong position on the screen.
- Implement constants into the symbol table and support them in code.
+ Examine why flipper is plotted in a wrong position on the screen.
+ Implement constants into the symbol table and support them in code.
- Implement new constant consolidation steps.
- Reintroduce constant addition optimization
+ Add asmName for ConstantVar to remove subscripts
+ Inline constants for "single" versions of vars - such as .const i#0 = 0
+ Look at optimizing liverange.kc's ASM further - atm. there are to many copy-operations into unnecesary registers.
+ In summin.asm the result of the 2nd sum() is clobbered twice during call to sum(). jsr sum, txa, lda #$d, ldx #$9, jsr sum
+ Fix by introducing "effective alive vars" which includes alive vars at all calls to containing methods and using that during clobber check.

View File

@ -5,6 +5,7 @@ import dk.camelot64.kickc.asm.parser.Asm6502BaseVisitor;
import dk.camelot64.kickc.asm.parser.Asm6502Parser;
import dk.camelot64.kickc.icl.*;
import dk.camelot64.kickc.passes.Pass1TypeInference;
import dk.camelot64.kickc.passes.Pass4CodeGeneration;
import java.util.LinkedHashMap;
import java.util.Map;
@ -342,6 +343,10 @@ public class AsmFragment {
String name = "cowo" + nextConstByteIdx++;
bindings.put(name, value);
return name;
} else if (type instanceof SymbolTypePointer) {
String name = "cowo" + nextConstByteIdx++;
bindings.put(name, value);
return name;
} else {
throw new RuntimeException("Unhandled constant type " + type);
}
@ -354,7 +359,7 @@ public class AsmFragment {
}
/**
* Get the value to replace a bound name with from the fragment signature
* Get the value to getReplacement a bound name with from the fragment signature
*
* @param name The name of the bound value in the fragment
* @return The bound value to use in the generated ASM code
@ -389,7 +394,7 @@ public class AsmFragment {
}
} else if (boundValue instanceof Constant) {
Constant boundConst = (Constant) boundValue;
return new AsmParameter(toAsm(boundConst), SymbolTypeBasic.BYTE.equals(boundConst.getType(program.getScope())));
return new AsmParameter(Pass4CodeGeneration.getConstantValueAsm(program, boundConst, false), SymbolTypeBasic.BYTE.equals(boundConst.getType(program.getScope())));
} else if (boundValue instanceof Label) {
String param = ((Label) boundValue).getLocalName().replace('@', 'b').replace(':', '_').replace("$", "_");
return new AsmParameter(param, false);
@ -416,7 +421,7 @@ public class AsmFragment {
*/
private String getAsmParameter(ConstantVar boundVar) {
Scope varScope = boundVar.getScope();
String asmName = boundVar.getLocalName(); // boundVar.getAsmName() == null ? boundVar.getLocalName() : boundVar.getAsmName();
String asmName = boundVar.getAsmName() == null ? boundVar.getLocalName() : boundVar.getAsmName();
return getAsmParameter(varScope, asmName);
}
@ -442,31 +447,6 @@ public class AsmFragment {
}
}
/**
* Return the ASM code for the constant
* @param constant The constant
* @return ASM code
*/
private String toAsm(Constant constant) {
if (constant instanceof ConstantInteger) {
return String.format("$%x", ((ConstantInteger) constant).getNumber());
} else if (constant instanceof ConstantVar) {
ConstantVar constantVar = (ConstantVar) constant;
return getAsmParameter(constantVar);
} else if (constant instanceof ConstantRef) {
ConstantVar constantVar = program.getScope().getConstant((ConstantRef) constant);
return getAsmParameter(constantVar);
} else if (constant instanceof ConstantUnary) {
ConstantUnary unary = (ConstantUnary) constant;
return unary.getOperator().toString() + toAsm(unary.getOperand());
} else if (constant instanceof ConstantBinary) {
ConstantBinary binary = (ConstantBinary) constant;
return toAsm(binary.getLeft()) + binary.getOperator().toString() + toAsm(binary.getRight());
} else {
throw new RuntimeException("Unknown constant type " + constant);
}
}
/** A parameter of an ASM instruction from a bound value. */
public static class AsmParameter {

View File

@ -119,7 +119,7 @@ public class AsmFragmentManager {
Matcher m = p.matcher(signature);
String output = signature;
if (m.find()) {
// replace first number with "number" and second number with the first
// getReplacement first number with "number" and second number with the first
output = m.replaceAll(replace);
}
return output;

View File

@ -138,7 +138,7 @@ public class AsmSegment {
printState.decIndent();
}
out.append(printState.getIndent());
if (line instanceof AsmComment || line instanceof AsmInstruction || line instanceof AsmLabelDecl) {
if (line instanceof AsmComment || line instanceof AsmInstruction || line instanceof AsmLabelDecl || line instanceof AsmConstant) {
out.append(" ");
}
out.append(line.getAsm() + "\n");

View File

@ -18,6 +18,10 @@ public class ConstantVar implements Constant, Symbol {
/** The value of the constant. */
private ConstantValue value;
/** A short name used for the variable in ASM code. If possible variable names of ZP variables are shortened in ASM code. This is possible, when all versions of the var use the same register. */
private String asmName;
public ConstantVar(String name, Scope scope, SymbolType type, ConstantValue value) {
this.name = name;
this.scope = scope;
@ -40,6 +44,15 @@ public class ConstantVar implements Constant, Symbol {
return Scope.getFullName(this);
}
public String getAsmName() {
return asmName;
}
public void setAsmName(String asmName) {
this.asmName = asmName;
}
@Override
public SymbolType getType() {
return type;

View File

@ -2,4 +2,22 @@ package dk.camelot64.kickc.icl;
/** Assignable value (capable of being on the left part of an assignment)*/
public interface LValue extends RValue {
/**
* Singleton signalling that an RValue is never assigned and can safely be discarded as rvalue in phi-functions.
*/
public static RValue VOID = new RValue() {
@Override
public String toString() {
return toString(null);
}
@Override
public String toString(Program program) {
return "VOID";
}
};
}

View File

@ -1,5 +1,7 @@
package dk.camelot64.kickc.icl;
import sun.jvm.hotspot.asm.Register;
/** The different registers available for a program */
public class Registers {
@ -22,7 +24,7 @@ public class Registers {
/** The register type. */
public enum RegisterType {
ZP_BYTE, ZP_BOOL, REG_A_BYTE, REG_ALU_BYTE, REG_Y_BYTE, REG_X_BYTE, ZP_PTR_BYTE, ZP_WORD
ZP_BYTE, ZP_BOOL, REG_A_BYTE, REG_ALU_BYTE, REG_Y_BYTE, REG_X_BYTE, ZP_PTR_BYTE, ZP_WORD, CONSTANT
}
/** A register used for storing a single variable. */
@ -234,4 +236,32 @@ public class Registers {
}
/** Special register used for constants. Has no corresponding CPU register. */
public static class RegisterConstant implements Register {
@Override
public RegisterType getType() {
return RegisterType.CONSTANT;
}
@Override
public boolean isZp() {
return false;
}
@Override
public String toString(Program program) {
return "const";
}
@Override
public int hashCode() {
return 31;
}
@Override
public boolean equals(Object obj) {
return obj instanceof RegisterConstant;
}
}
}

View File

@ -20,4 +20,6 @@ public interface Symbol extends Value {
int getScopeDepth();
void setScope(Scope scope);
SymbolRef getRef();
}

View File

@ -48,7 +48,11 @@ public class SymbolRef implements Value {
if (program == null) {
return fullName;
} else {
return program.getScope().getSymbol(fullName).toString(program);
try {
return program.getScope().getSymbol(fullName).toString(program);
} catch (NullPointerException e) {
throw e;
}
}
}

View File

@ -1,15 +1,17 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.icl.ConstantRef;
import dk.camelot64.kickc.icl.ConstantValue;
import dk.camelot64.kickc.icl.ConstantVar;
import dk.camelot64.kickc.icl.Program;
import dk.camelot64.kickc.icl.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/** Compiler Pass consolidating unnamed constants into the place using them (instructions or the definition of another constant value) */
/** Compiler Pass consolidating unnamed constants and constant aliasses into the place using them (instructions or the definition of another constant value).
* <ul>
* <li> Unnamed constant: $1 = VIC+$20 </li>
* <li> Constant alias: i#1 = i#0 </li>
* </ul>
* */
public class Pass2ConstantInlining extends Pass2SsaOptimization {
public Pass2ConstantInlining(Program program) {
@ -22,21 +24,69 @@ public class Pass2ConstantInlining extends Pass2SsaOptimization {
*/
@Override
public boolean optimize() {
Map<ConstantRef, ConstantValue> unnamedConstants = findUnnamedConstants();
Map<ConstantRef, ConstantValue> inline = new HashMap<>();
inline.putAll(findUnnamedConstants());
inline.putAll(findAliasConstants());
inline.putAll(findConstVarVersions());
// Replace all usages of the unnamed constants
replaceVariables(unnamedConstants);
// Perform alias replacement within the constant values inside the aliases
replaceInValues(inline);
// Replace all usages of the constants in the control flow graph
replaceVariables(inline);
// Remove from symbol table
deleteSymbols(unnamedConstants.keySet());
deleteSymbols(inline.keySet());
// Replace all usages of the constants in constant definitions inside the symbol table
replaceInSymbolTable(inline);
for (ConstantRef constantRef : unnamedConstants.keySet()) {
getLog().append("Constant inlined " + constantRef.toString()+" = "+unnamedConstants.get(constantRef).toString(getProgram()));
for (ConstantRef constantRef : inline.keySet()) {
getLog().append("Constant inlined " + constantRef.toString()+" = "+inline.get(constantRef).toString(getProgram()));
}
return unnamedConstants.size()>0;
return inline.size()>0;
}
/**
* Replace any alias within the constant defimtions inside the symbol table
* @param inline The replacements to make
*/
private void replaceInSymbolTable(Map<ConstantRef, ConstantValue> inline) {
VariableReplacer replacer = new VariableReplacer(inline);
Collection<ConstantVar> allConstants = getProgram().getScope().getAllConstants(true);
for (ConstantVar constantVar : allConstants) {
ConstantValue constantValue = constantVar.getValue();
RValue replacement = replacer.getReplacement(constantValue);
if(replacement!=null) {
constantVar.setValue((ConstantValue) replacement);
}
}
}
/**
* Replace any aliases within the constant values themselves
* @param inline The replacements
*/
private void replaceInValues(Map<ConstantRef, ConstantValue> inline) {
VariableReplacer replacer = new VariableReplacer(inline);
boolean replaced = true;
while(replaced) {
replaced = false;
for (ConstantRef constantRef : inline.keySet()) {
ConstantValue constantValue = inline.get(constantRef);
ConstantValue replacement = (ConstantValue) replacer.getReplacement(constantValue);
if (replacement != null) {
replaced = true;
inline.put(constantRef, replacement);
}
}
}
}
/**
* Find all unnamed constants $1 = VIC+$20
* @return Map from constant name to constant value
*/
private Map<ConstantRef, ConstantValue> findUnnamedConstants() {
Map<ConstantRef, ConstantValue> unnamed = new HashMap<>();
Collection<ConstantVar> allConstants = getProgram().getScope().getAllConstants(true);
@ -48,5 +98,46 @@ public class Pass2ConstantInlining extends Pass2SsaOptimization {
return unnamed;
}
/**
* Find all constant aliases. An alias is a constant with the exact same value as another constant eg. i#2 = i#0
* @return Map from constant name to constant value
*/
private Map<ConstantRef, ConstantValue> findAliasConstants() {
Map<ConstantRef, ConstantValue> aliases = new HashMap<>();
Collection<ConstantVar> allConstants = getProgram().getScope().getAllConstants(true);
for (ConstantVar constant : allConstants) {
ConstantValue constantValue = constant.getValue();
if(constantValue instanceof ConstantRef) {
aliases.put(constant.getRef(), constant.getValue());
}
}
return aliases;
}
/**
* Find single variable versions that are constant eg. i#0 = 0
* @return Map from constant name to constant value
*/
private Map<ConstantRef, ConstantValue> findConstVarVersions() {
Map<ConstantRef, ConstantValue> aliases = new HashMap<>();
Collection<ConstantVar> allConstants = getProgram().getScope().getAllConstants(true);
for (ConstantVar constant : allConstants) {
if(constant.getRef().isVersion()) {
// Constant is a version - find the other versions
String baseName = constant.getRef().getFullNameUnversioned();
Collection<Symbol> scopeSymbols = constant.getScope().getAllSymbols();
for (Symbol symbol : scopeSymbols) {
if(symbol.getRef().isVersion() && symbol.getRef().getFullNameUnversioned().equals(baseName)) {
if(symbol instanceof Variable) {
aliases.put(constant.getRef(), constant.getValue());
}
}
}
}
}
return aliases;
}
}

View File

@ -53,7 +53,7 @@ public class Pass2RedundantPhiElimination extends Pass2SsaOptimization {
}
if(found) {
VariableRef variable = phiVariable.getVariable();
if(rValue==null) {rValue = VOID;}
if(rValue==null) {rValue = LValue.VOID;}
aliases.put(variable, rValue);
}
}

View File

@ -40,21 +40,6 @@ public abstract class Pass2SsaOptimization {
*/
public abstract boolean optimize();
/**
* Singleton signalling that an RValue is never assigned and can safely be discarded as rvalue in phi-functions.
*/
public static RValue VOID = new RValue() {
@Override
public String toString() {
return toString(null);
}
@Override
public String toString(Program program) {
return "VOID";
}
};
/**
* Replace all usages of variables in statements with aliases.
@ -62,127 +47,8 @@ public abstract class Pass2SsaOptimization {
* @param aliases Variables that have alias values.
*/
public void replaceVariables(final Map<? extends SymbolRef, ? extends RValue> aliases) {
ControlFlowGraphBaseVisitor<Void> visitor = new ControlFlowGraphBaseVisitor<Void>() {
@Override
public Void visitAssignment(StatementAssignment assignment) {
LValue lValue = assignment.getlValue();
if (getAlias(aliases, lValue) != null) {
RValue alias = getAlias(aliases, lValue);
if (alias instanceof LValue) {
assignment.setlValue((LValue) alias);
} else {
throw new RuntimeException("Error replacing LValue variable " + lValue + " with " + alias);
}
}
if (getAlias(aliases, assignment.getrValue1()) != null) {
assignment.setrValue1(getAlias(aliases, assignment.getrValue1()));
}
if (getAlias(aliases, assignment.getrValue2()) != null) {
assignment.setrValue2(getAlias(aliases, assignment.getrValue2()));
}
// Handle pointer dereference in LValue
if (lValue instanceof PointerDereferenceSimple) {
PointerDereferenceSimple deref = (PointerDereferenceSimple) lValue;
RValue pointer = deref.getPointer();
if (getAlias(aliases, pointer) != null) {
RValue alias = getAlias(aliases, pointer);
deref.setPointer(alias);
}
}
if (lValue instanceof PointerDereferenceIndexed) {
PointerDereferenceIndexed deref = (PointerDereferenceIndexed) lValue;
RValue pointer = deref.getPointer();
if (getAlias(aliases, pointer) != null) {
RValue alias = getAlias(aliases, pointer);
deref.setPointer( alias);
}
RValue index = deref.getIndex();
if (getAlias(aliases, index) != null) {
RValue alias = getAlias(aliases, index);
deref.setIndex(alias);
}
}
return null;
}
@Override
public Void visitConditionalJump(StatementConditionalJump conditionalJump) {
if (getAlias(aliases, conditionalJump.getrValue1()) != null) {
conditionalJump.setrValue1(getAlias(aliases, conditionalJump.getrValue1()));
}
if (getAlias(aliases, conditionalJump.getrValue2()) != null) {
conditionalJump.setrValue2(getAlias(aliases, conditionalJump.getrValue2()));
}
return null;
}
@Override
public Void visitReturn(StatementReturn aReturn) {
if (getAlias(aliases, aReturn.getValue()) != null) {
aReturn.setValue(getAlias(aliases, aReturn.getValue()));
}
return null;
}
@Override
public Void visitCall(StatementCall call) {
if(call.getParameters()!=null) {
List<RValue> newParams = new ArrayList<>();
for (RValue parameter : call.getParameters()) {
RValue newParam = parameter;
if (getAlias(aliases, parameter) != null) {
newParam = getAlias(aliases, parameter);
}
newParams.add(newParam);
}
call.setParameters(newParams);
}
return null;
}
@Override
public Void visitPhiBlock(StatementPhiBlock phi) {
for (StatementPhiBlock.PhiVariable phiVariable : phi.getPhiVariables()) {
if (getAlias(aliases, phiVariable.getVariable()) != null) {
RValue alias = getAlias(aliases, phiVariable.getVariable());
if (alias instanceof LValue) {
phiVariable.setVariable((VariableRef) alias);
}
}
List<StatementPhiBlock.PhiRValue> phirValues = phiVariable.getValues();
Iterator<StatementPhiBlock.PhiRValue> it = phirValues.iterator();
while (it.hasNext()) {
StatementPhiBlock.PhiRValue phirValue = it.next();
if (getAlias(aliases, phirValue.getrValue()) != null) {
RValue alias = getAlias(aliases, phirValue.getrValue());
if (VOID.equals(alias)) {
it.remove();
} else {
phirValue.setrValue(alias);
}
}
}
}
return null;
}
};
visitor.visitGraph(getGraph());
}
/**
* Get the alias to use for an RValue.
*
* @param aliases The alias map
* @param rValue The RValue to find an alias for
* @return The alias to use. Null if no alias exists.
*/
private static RValue getAlias(Map<? extends SymbolRef, ? extends RValue> aliases, RValue rValue) {
RValue alias = aliases.get(rValue);
while (aliases.get(alias) != null) {
alias = aliases.get(alias);
}
return alias;
VariableReplacer replacer = new VariableReplacer(aliases);
replacer.getReplacement(getGraph());
}
/**
@ -195,7 +61,7 @@ public abstract class Pass2SsaOptimization {
visitor.visitBlock(block);
}
/** Creates a visitor that can replace labels. */
/** Creates a visitor that can getReplacement labels. */
private ControlFlowGraphBaseVisitor<Void> getLabelReplaceVisitor(final Map<LabelRef, LabelRef> replacements) {
return new ControlFlowGraphBaseVisitor<Void>() {

View File

@ -29,7 +29,7 @@ public class Pass2UnaryNotSimplification extends Pass2SsaOptimization {
}
/**
* Examine all unary nots. If they are the only usage of a reversable unary not replace the unary not with the reversed comparison - and eliminate the riginal variable.
* Examine all unary nots. If they are the only usage of a reversable unary not getReplacement the unary not with the reversed comparison - and eliminate the riginal variable.
*
* @param assignments Assignments to examine
* @param usages All variable usages

View File

@ -55,7 +55,7 @@ public class Pass3PhiLifting {
Statement lastPredecessorStatement = predecessorStatements.get(predecessorStatements.size() - 1);
StatementAssignment newAssignment = new StatementAssignment(newVar, phiRValue.getrValue());
if (lastPredecessorStatement instanceof StatementConditionalJump) {
// Use or Create a new block between the predecessor and this one - replace labels where appropriate
// Use or Create a new block between the predecessor and this one - getReplacement labels where appropriate
ControlFlowBlock newBlock;
LabelRef newBlockRef = newBlocks.get(predecessorRef);
if(newBlockRef==null) {

View File

@ -29,7 +29,7 @@ public class Pass4CodeGeneration {
ScopeRef currentScope = ScopeRef.ROOT;
// Generate global ZP labels
asm.startSegment(null, "Global ZP labels");
asm.startSegment(null, "Global Constants & labels");
addConstants(asm, currentScope);
addZpLabels(asm, currentScope);
for (ControlFlowBlock block : getGraph().getAllBlocks()) {
@ -88,10 +88,10 @@ public class Pass4CodeGeneration {
Scope scope = program.getScope().getScope(scopeRef);
Collection<ConstantVar> scopeConstants = scope.getAllConstants(false);
Set<String> added = new LinkedHashSet<>();
for (ConstantVar scopeConstant : scopeConstants) {
String asmName = scopeConstant.getLocalName(); // scopeConstant.getAsmName()
for (ConstantVar constantVar : scopeConstants) {
String asmName = constantVar.getAsmName() == null ? constantVar.getLocalName() : constantVar.getAsmName();
if (asmName != null && !added.contains(asmName)) {
asm.addConstant(asmName.replace("#", "_").replace("$", "_"), getConstantValueAsm(scopeConstant.getValue(), false));
asm.addConstant(asmName.replace("#", "_").replace("$", "_"), getConstantValueAsm(program, constantVar.getValue(), false));
added.add(asmName);
}
}
@ -105,12 +105,13 @@ public class Pass4CodeGeneration {
*
* @return The ASM string representing the constant value
*/
private String getConstantValueAsm(Constant value, boolean subOperator) {
public static String getConstantValueAsm(Program program, Constant value, boolean subOperator) {
if (value instanceof ConstantRef) {
value = program.getScope().getConstant((ConstantRef) value);
}
if (value instanceof ConstantVar) {
String asmName = ((ConstantVar) value).getLocalName(); // xxx.getAsmName()
ConstantVar constantVar = (ConstantVar) value;
String asmName = constantVar.getAsmName() == null ? constantVar.getLocalName() : constantVar.getAsmName();
return asmName.replace("#", "_").replace("$", "_");
} else if (value instanceof ConstantInteger) {
return String.format("$%x", ((ConstantInteger) value).getNumber());
@ -119,15 +120,15 @@ public class Pass4CodeGeneration {
return
(subOperator ? "(" : "") +
unary.getOperator().getOperator() +
getConstantValueAsm(unary.getOperand(), true) +
getConstantValueAsm(program, unary.getOperand(), true) +
(subOperator ? ")" : "");
} else if (value instanceof ConstantBinary) {
ConstantBinary binary = (ConstantBinary) value;
return
(subOperator ? "(" : "") +
getConstantValueAsm(binary.getLeft(), true) +
getConstantValueAsm(program, binary.getLeft(), true) +
binary.getOperator().getOperator() +
getConstantValueAsm(binary.getRight(), true) +
getConstantValueAsm(program, binary.getRight(), true) +
(subOperator ? ")" : "");
} else {
throw new RuntimeException("Constant type not supported " + value);

View File

@ -40,15 +40,19 @@ public class Pass4RegistersFinalize extends Pass2Base {
variable.setAsmName(null);
}
}
for (ConstantVar constantVar : scope.getAllConstants(false)) {
constantVar.setAsmName(constantVar.getLocalName());
}
// Find short asm names for all variables if possible
Map<String, Registers.Register> shortNames = new LinkedHashMap<>();
for (Variable variable : scope.getAllVariables(false)) {
Registers.Register allocation = variable.getAllocation();
if (allocation != null && allocation.isZp()) {
String asmName = variable.getAsmName();
if (asmName.contains("#")) {
String shortName = asmName.substring(0, variable.getAsmName().indexOf("#"));
String shortName = asmName.substring(0, asmName.indexOf("#"));
if (shortNames.get(shortName) == null || shortNames.get(shortName).equals(allocation)) {
// Short name is usable!
variable.setAsmName(shortName);
@ -62,11 +66,36 @@ public class Pass4RegistersFinalize extends Pass2Base {
shortNames.put(asmName, allocation);
continue;
} else {
// Be unhappy (if tyhis triggers in the future extend with ability to create new names by adding suffixes)
// Be unhappy (if this triggers in the future extend with ability to create new names by adding suffixes)
throw new RuntimeException("ASM name already used "+asmName);
}
}
}
for (ConstantVar constantVar : scope.getAllConstants(false)) {
String asmName = constantVar.getAsmName();
Registers.Register allocation = new Registers.RegisterConstant();
if (asmName.contains("#")) {
String shortName = asmName.substring(0, asmName.indexOf("#"));
if (shortNames.get(shortName) == null || shortNames.get(shortName).equals(allocation)) {
// Short name is usable!
constantVar.setAsmName(shortName);
shortNames.put(shortName, allocation);
continue;
}
}
if (shortNames.get(asmName) == null || shortNames.get(asmName).equals(allocation)) {
// Try the full name instead
constantVar.setAsmName(asmName);
shortNames.put(asmName, allocation);
continue;
} else {
// Be unhappy (if this triggers in the future extend with ability to create new names by adding suffixes)
throw new RuntimeException("ASM name already used "+asmName);
}
}
}
}

View File

@ -0,0 +1,177 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.icl.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* A replacer capable to getReplacement all usages of a variable (or constant var) with a suitable replacement
*/
public class VariableReplacer {
private Map<? extends SymbolRef, ? extends RValue> aliases;
public VariableReplacer(Map<? extends SymbolRef, ? extends RValue> aliases) {
this.aliases = aliases;
}
public void getReplacement(ControlFlowGraph graph) {
ControlFlowGraphBaseVisitor<Void> visitor = new GraphReplacer();
visitor.visitGraph(graph);
}
/**
* Get the alias to use for an RValue.
* Also looks inside any constant values for replacements.
* If a replacement is found the replacement is performed and the new value is returned. If no replacement is found null is returned.
*
* @param rValue The RValue to find an alias for
* @return The alias to use. Null if no alias exists.
*/
public RValue getReplacement(RValue rValue) {
if(rValue instanceof SymbolRef) {
RValue alias = aliases.get(rValue);
if(alias!=null) {
RValue replacement = getReplacement(alias);
if(replacement!=null) {
return replacement;
} else {
return alias;
}
}
} else if (rValue instanceof ConstantUnary) {
ConstantUnary constantUnary = (ConstantUnary) rValue;
ConstantValue alias = (ConstantValue) getReplacement(constantUnary.getOperand());
if (alias != null) {
return new ConstantUnary(constantUnary.getOperator(), alias);
}
} else if (rValue instanceof ConstantBinary) {
ConstantBinary constantBinary = (ConstantBinary) rValue;
Constant aliasLeft = (Constant) getReplacement(constantBinary.getLeft());
Constant aliasRight = (Constant) getReplacement(constantBinary.getRight());
if (aliasLeft != null || aliasRight != null) {
if (aliasLeft == null) {
aliasLeft = constantBinary.getLeft();
}
if (aliasRight == null) {
aliasRight = constantBinary.getRight();
}
return new ConstantBinary(aliasLeft, constantBinary.getOperator(), aliasRight);
}
}
// No replacement found - return null
return null;
}
/**
* Visitor capable of handling replacements in an entire flow graph.
*/
private class GraphReplacer extends ControlFlowGraphBaseVisitor<Void> {
@Override
public Void visitAssignment(StatementAssignment assignment) {
LValue lValue = assignment.getlValue();
if (getReplacement(lValue) != null) {
RValue alias = getReplacement(lValue);
if (alias instanceof LValue) {
assignment.setlValue((LValue) alias);
} else {
throw new RuntimeException("Error replacing LValue variable " + lValue + " with " + alias);
}
}
if (getReplacement(assignment.getrValue1()) != null) {
assignment.setrValue1(getReplacement(assignment.getrValue1()));
}
if (getReplacement(assignment.getrValue2()) != null) {
assignment.setrValue2(getReplacement(assignment.getrValue2()));
}
// Handle pointer dereference in LValue
if (lValue instanceof PointerDereferenceSimple) {
PointerDereferenceSimple deref = (PointerDereferenceSimple) lValue;
RValue pointer = deref.getPointer();
if (getReplacement(pointer) != null) {
deref.setPointer(getReplacement(pointer));
}
}
if (lValue instanceof PointerDereferenceIndexed) {
PointerDereferenceIndexed deref = (PointerDereferenceIndexed) lValue;
RValue pointer = deref.getPointer();
if (getReplacement(pointer) != null) {
deref.setPointer(getReplacement(pointer));
}
RValue index = deref.getIndex();
if (getReplacement(index) != null) {
deref.setIndex(getReplacement(index));
}
}
return null;
}
@Override
public Void visitConditionalJump(StatementConditionalJump conditionalJump) {
if (getReplacement(conditionalJump.getrValue1()) != null) {
conditionalJump.setrValue1(getReplacement(conditionalJump.getrValue1()));
}
if (getReplacement(conditionalJump.getrValue2()) != null) {
conditionalJump.setrValue2(getReplacement(conditionalJump.getrValue2()));
}
return null;
}
@Override
public Void visitReturn(StatementReturn aReturn) {
if (getReplacement(aReturn.getValue()) != null) {
aReturn.setValue(getReplacement(aReturn.getValue()));
}
return null;
}
@Override
public Void visitCall(StatementCall call) {
if (call.getParameters() != null) {
List<RValue> newParams = new ArrayList<>();
for (RValue parameter : call.getParameters()) {
RValue newParam = parameter;
if (getReplacement(parameter) != null) {
newParam = getReplacement(parameter);
}
newParams.add(newParam);
}
call.setParameters(newParams);
}
return null;
}
@Override
public Void visitPhiBlock(StatementPhiBlock phi) {
for (StatementPhiBlock.PhiVariable phiVariable : phi.getPhiVariables()) {
if (getReplacement(phiVariable.getVariable()) != null) {
RValue alias = getReplacement(phiVariable.getVariable());
if (alias instanceof LValue) {
phiVariable.setVariable((VariableRef) alias);
}
}
List<StatementPhiBlock.PhiRValue> phirValues = phiVariable.getValues();
Iterator<StatementPhiBlock.PhiRValue> it = phirValues.iterator();
while (it.hasNext()) {
StatementPhiBlock.PhiRValue phirValue = it.next();
if (getReplacement(phirValue.getrValue()) != null) {
RValue alias = getReplacement(phirValue.getrValue());
if (LValue.VOID.equals(alias)) {
it.remove();
} else {
phirValue.setrValue(alias);
}
}
}
}
return null;
}
}
}

View File

@ -1,20 +1,26 @@
.const STAR = $51
.const SCREEN = $400
jsr main
main: {
.const x1 = $27
.const y1 = $18
.const xd = x1-$0
.const yd = y1-$0
.label x = 4
.label cursor = 2
.label y = 5
lda #$0
sta y
ldx #$c
ldx #yd/$2
lda #$0
sta x
lda #<$400
lda #<(SCREEN+($0*$28))+$0
sta cursor
lda #>$400
lda #>(SCREEN+($0*$28))+$0
sta cursor+$1
b1:
ldy #$0
lda #$51
lda #STAR
sta (cursor),y
inc x
inc cursor
@ -23,9 +29,9 @@ main: {
!:
txa
clc
adc #$18
adc #yd
tax
cpx #$27
cpx #xd
bcc b2
inc y
lda cursor
@ -37,11 +43,11 @@ main: {
!:
txa
sec
sbc #$27
sbc #xd
tax
b2:
lda x
cmp #$28
cmp #x1+$1
bcc b1
rts
}

View File

@ -7,25 +7,25 @@ main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
[2] (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[2] (byte) main::e#3 ← phi( main/(byte) 12 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[2] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte) 2 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[2] (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[2] (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[3] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[2] (byte*) main::cursor#3 ← phi( main/(const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[3] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[4] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ]
[5] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ]
[6] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ]
[7] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ]
[6] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ]
[7] if((const byte) main::xd#0>=(byte) main::e#1) goto main::@2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ]
to:main::@3
main::@3: scope:[main] from main::@1
[8] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ]
[9] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ]
[10] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ]
[10] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[11] (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[11] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[11] (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[12] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[12] if((byte) main::x#1<(const byte) main::x1#0+(byte) 1) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
to:main::@return
main::@return: scope:[main] from main::@2
[13] return [ ]

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,9 @@
(label) @begin
(label) @end
(byte[1000]) SCREEN
(const byte[1000]) SCREEN#0 = (word) 1024
(byte) STAR
(const byte) STAR#0 = (byte) 81
(void()) main()
(label) main::@1
(label) main::@2
@ -22,14 +24,18 @@
(byte) main::x#2 x zp ZP_BYTE:4 11.0
(byte) main::x0
(byte) main::x1
(const byte) main::x1#0 = (byte) 39
(byte) main::xd
(const byte) main::xd#0 = (const byte) main::x1#0-(byte) 0
(byte) main::y
(byte) main::y#1 y zp ZP_BYTE:5 7.333333333333333
(byte) main::y#2 y zp ZP_BYTE:5 5.5
(byte) main::y#4 y zp ZP_BYTE:5 16.5
(byte) main::y0
(byte) main::y1
(const byte) main::y1#0 = (byte) 24
(byte) main::yd
(const byte) main::yd#0 = (const byte) main::y1#0-(byte) 0
zp ZP_PTR_BYTE:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
zp ZP_BYTE:4 [ main::x#2 main::x#1 ]

View File

@ -1,24 +1,30 @@
.const STAR = $51
.const screen = $400
.const x1 = $27
.const y1 = $18
.const xd = x1-$0
.const yd = y1-$0
.label idx = 2
.label y = 4
lda #$0
sta y
ldy #$c
ldy #yd/$2
ldx #$0
lda #$0
lda #$0+($0*$28)
sta idx
lda #$0
sta idx+$1
b1:
lda #<$400
lda #<screen
clc
adc idx
sta !s++$1
lda #>$400
lda #>screen
adc idx+$1
sta !s++$2
lda #$51
lda #STAR
!s:
sta $400
sta screen
inx
inc idx
bne !+
@ -26,9 +32,9 @@ b1:
!:
tya
clc
adc #$18
adc #yd
tay
cpy #$27
cpy #xd
bcc b2
inc y
lda idx
@ -40,8 +46,8 @@ b1:
!:
tya
sec
sbc #$27
sbc #xd
tay
b2:
cpx #$28
cpx #x1+$1
bcc b1

View File

@ -2,24 +2,24 @@
to:@1
@1: scope:[] from @2 @begin
[0] (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) [ idx#3 x#2 e#3 y#2 ]
[0] (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) 12 ) [ idx#3 x#2 e#3 y#2 ]
[0] (byte) e#3 ← phi( @2/(byte) e#5 @begin/(const byte) yd#0/(byte) 2 ) [ idx#3 x#2 e#3 y#2 ]
[0] (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) [ idx#3 x#2 e#3 y#2 ]
[0] (word) idx#3 ← phi( @2/(word) idx#5 @begin/(byte) 0 ) [ idx#3 x#2 e#3 y#2 ]
[1] *((word) 1024 + (word) idx#3) ← (byte) 81 [ idx#3 x#2 e#3 y#2 ]
[0] (word) idx#3 ← phi( @2/(word) idx#5 @begin/(byte) 0+(byte) 0*(byte) 40 ) [ idx#3 x#2 e#3 y#2 ]
[1] *((const byte[1000]) screen#0 + (word) idx#3) ← (const byte) STAR#0 [ idx#3 x#2 e#3 y#2 ]
[2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ idx#3 e#3 y#2 x#1 ]
[3] (word) idx#1 ← (word) idx#3 + (byte) 1 [ e#3 y#2 x#1 idx#1 ]
[4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ y#2 x#1 idx#1 e#1 ]
[5] if((byte) 39>=(byte) e#1) goto @2 [ y#2 x#1 idx#1 e#1 ]
[4] (byte) e#1 ← (byte) e#3 + (const byte) yd#0 [ y#2 x#1 idx#1 e#1 ]
[5] if((const byte) xd#0>=(byte) e#1) goto @2 [ y#2 x#1 idx#1 e#1 ]
to:@3
@3: scope:[] from @1
[6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 idx#1 e#1 y#1 ]
[7] (word) idx#2 ← (word) idx#1 + (byte) 40 [ x#1 e#1 y#1 idx#2 ]
[8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 y#1 idx#2 e#2 ]
[8] (byte) e#2 ← (byte) e#1 - (const byte) xd#0 [ x#1 y#1 idx#2 e#2 ]
to:@2
@2: scope:[] from @1 @3
[9] (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) [ idx#5 x#1 e#5 y#4 ]
[9] (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) [ idx#5 x#1 e#5 y#4 ]
[9] (word) idx#5 ← phi( @1/(word) idx#1 @3/(word) idx#2 ) [ idx#5 x#1 e#5 y#4 ]
[10] if((byte) x#1<(byte) 40) goto @1 [ idx#5 x#1 e#5 y#4 ]
[10] if((byte) x#1<(const byte) x1#0+(byte) 1) goto @1 [ idx#5 x#1 e#5 y#4 ]
to:@end
@end: scope:[] from @2

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
(label) @begin
(label) @end
(byte) STAR
(const byte) STAR#0 = (byte) 81
(byte) e
(byte) e#1 reg byte y 11.0
(byte) e#2 reg byte y 22.0
@ -15,19 +16,24 @@
(word) idx#3 idx zp ZP_WORD:2 11.0
(word) idx#5 idx zp ZP_WORD:2 16.5
(byte[1000]) screen
(const byte[1000]) screen#0 = (word) 1024
(byte) x
(byte) x#1 reg byte x 3.666666666666667
(byte) x#2 reg byte x 11.0
(byte) x0
(byte) x1
(const byte) x1#0 = (byte) 39
(byte) xd
(const byte) xd#0 = (const byte) x1#0-(byte) 0
(byte) y
(byte) y#1 y zp ZP_BYTE:4 7.333333333333333
(byte) y#2 y zp ZP_BYTE:4 5.5
(byte) y#4 y zp ZP_BYTE:4 16.5
(byte) y0
(byte) y1
(const byte) y1#0 = (byte) 24
(byte) yd
(const byte) yd#0 = (const byte) y1#0-(byte) 0
zp ZP_WORD:2 [ idx#3 idx#5 idx#1 idx#2 ]
reg byte x [ x#2 x#1 ]

View File

@ -1,14 +1,18 @@
.const SCREEN = $400
.const buffer1 = $1000
.const buffer2 = $1100
.const RASTER = $d012
jsr main
main: {
jsr prepare
b3_from_b11:
ldx #$19
b3:
lda $d012
lda RASTER
cmp #$fe
bne b3
b4:
lda $d012
lda RASTER
cmp #$ff
bne b4
dex
@ -24,15 +28,15 @@ plot: {
.label y = 4
lda #$10
sta y
lda #<$4d4
lda #<(SCREEN+($5*$28))+$c
sta line
lda #>$4d4
lda #>(SCREEN+($5*$28))+$c
sta line+$1
ldx #$0
b1:
ldy #$0
b2:
lda $1000,x
lda buffer1,x
sta (line),y
inx
iny
@ -61,8 +65,8 @@ flip: {
lda #$10
sta c
b2:
lda $1000,x
sta $1100,y
lda buffer1,x
sta buffer2,y
inx
tya
clc
@ -77,8 +81,8 @@ flip: {
bne b1
ldx #$0
b3:
lda $1100,x
sta $1000,x
lda buffer2,x
sta buffer1,x
inx
cpx #$0
bne b3
@ -88,7 +92,7 @@ prepare: {
ldx #$0
b1:
txa
sta $1000,x
sta buffer1,x
inx
cpx #$0
bne b1

View File

@ -8,11 +8,11 @@ main: scope:[main] from @begin
to:main::@3
main::@3: scope:[main] from main main::@11 main::@3 main::@6
[3] (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) [ main::c#2 ]
[4] (byte~) main::$1 ← * (word) 53266 [ main::c#2 main::$1 ]
[4] (byte~) main::$1 ← * (const byte*) RASTER#0 [ main::c#2 main::$1 ]
[5] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ]
to:main::@4
main::@4: scope:[main] from main::@3 main::@4
[6] (byte~) main::$3 ← * (word) 53266 [ main::c#2 main::$3 ]
[6] (byte~) main::$3 ← * (const byte*) RASTER#0 [ main::c#2 main::$3 ]
[7] if((byte~) main::$3!=(byte) 255) goto main::@4 [ main::c#2 ]
to:main::@6
main::@6: scope:[main] from main::@4
@ -36,13 +36,13 @@ plot: scope:[plot] from main::@10
to:plot::@1
plot::@1: scope:[plot] from plot plot::@3
[15] (byte) plot::y#2 ← phi( plot/(byte) 16 plot::@3/(byte) plot::y#1 ) [ plot::i#3 plot::line#2 plot::y#2 ]
[15] (byte*) plot::line#2 ← phi( plot/(word) 1236 plot::@3/(byte*) plot::line#1 ) [ plot::i#3 plot::line#2 plot::y#2 ]
[15] (byte*) plot::line#2 ← phi( plot/(const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12 plot::@3/(byte*) plot::line#1 ) [ plot::i#3 plot::line#2 plot::y#2 ]
[15] (byte) plot::i#3 ← phi( plot/(byte) 0 plot::@3/(byte) plot::i#1 ) [ plot::i#3 plot::line#2 plot::y#2 ]
to:plot::@2
plot::@2: scope:[plot] from plot::@1 plot::@2
[16] (byte) plot::x#2 ← phi( plot::@1/(byte) 0 plot::@2/(byte) plot::x#1 ) [ plot::line#2 plot::y#2 plot::i#2 plot::x#2 ]
[16] (byte) plot::i#2 ← phi( plot::@1/(byte) plot::i#3 plot::@2/(byte) plot::i#1 ) [ plot::line#2 plot::y#2 plot::i#2 plot::x#2 ]
[17] (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 [ plot::line#2 plot::y#2 plot::i#2 plot::x#2 plot::$3 ]
[17] (byte~) plot::$3 ← (const byte[256]) buffer1#0 *idx (byte) plot::i#2 [ plot::line#2 plot::y#2 plot::i#2 plot::x#2 plot::$3 ]
[18] *((byte*) plot::line#2 + (byte) plot::x#2) ← (byte~) plot::$3 [ plot::line#2 plot::y#2 plot::i#2 plot::x#2 ]
[19] (byte) plot::i#1 ← ++ (byte) plot::i#2 [ plot::line#2 plot::y#2 plot::i#1 plot::x#2 ]
[20] (byte) plot::x#1 ← ++ (byte) plot::x#2 [ plot::line#2 plot::y#2 plot::i#1 plot::x#1 ]
@ -68,8 +68,8 @@ flip::@2: scope:[flip] from flip::@1 flip::@2
[28] (byte) flip::c#2 ← phi( flip::@1/(byte) 16 flip::@2/(byte) flip::c#1 ) [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ]
[28] (byte) flip::dstIdx#3 ← phi( flip::@1/(byte) flip::dstIdx#5 flip::@2/(byte) flip::dstIdx#1 ) [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ]
[28] (byte) flip::srcIdx#2 ← phi( flip::@1/(byte) flip::srcIdx#3 flip::@2/(byte) flip::srcIdx#1 ) [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ]
[29] (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 flip::$0 ]
[30] *((word) 4352 + (byte) flip::dstIdx#3) ← (byte~) flip::$0 [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ]
[29] (byte~) flip::$0 ← (const byte[256]) buffer1#0 *idx (byte) flip::srcIdx#2 [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 flip::$0 ]
[30] *((const byte[256]) buffer2#0 + (byte) flip::dstIdx#3) ← (byte~) flip::$0 [ flip::r#2 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ]
[31] (byte) flip::srcIdx#1 ← ++ (byte) flip::srcIdx#2 [ flip::r#2 flip::srcIdx#1 flip::dstIdx#3 flip::c#2 ]
[32] (byte) flip::dstIdx#1 ← (byte) flip::dstIdx#3 + (byte) 16 [ flip::r#2 flip::srcIdx#1 flip::c#2 flip::dstIdx#1 ]
[33] (byte) flip::c#1 ← -- (byte) flip::c#2 [ flip::r#2 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ]
@ -82,8 +82,8 @@ flip::@4: scope:[flip] from flip::@2
to:flip::@3
flip::@3: scope:[flip] from flip::@3 flip::@4
[38] (byte) flip::i#2 ← phi( flip::@3/(byte) flip::i#1 flip::@4/(byte) 0 ) [ flip::i#2 ]
[39] (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ]
[40] *((word) 4096 + (byte) flip::i#2) ← (byte~) flip::$4 [ flip::i#2 ]
[39] (byte~) flip::$4 ← (const byte[256]) buffer2#0 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ]
[40] *((const byte[256]) buffer1#0 + (byte) flip::i#2) ← (byte~) flip::$4 [ flip::i#2 ]
[41] (byte) flip::i#1 ← ++ (byte) flip::i#2 [ flip::i#1 ]
[42] if((byte) flip::i#1!=(byte) 0) goto flip::@3 [ flip::i#1 ]
to:flip::@return
@ -95,7 +95,7 @@ prepare: scope:[prepare] from main
to:prepare::@1
prepare::@1: scope:[prepare] from prepare prepare::@1
[45] (byte) prepare::i#2 ← phi( prepare/(byte) 0 prepare::@1/(byte) prepare::i#1 ) [ prepare::i#2 ]
[46] *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ]
[46] *((const byte[256]) buffer1#0 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ]
[47] (byte) prepare::i#1 ← ++ (byte) prepare::i#2 [ prepare::i#1 ]
[48] if((byte) prepare::i#1!=(byte) 0) goto prepare::@1 [ prepare::i#1 ]
to:prepare::@return

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,13 @@
(label) @begin
(label) @end
(byte*) RASTER
(const byte*) RASTER#0 = (word) 53266
(byte[1000]) SCREEN
(const byte[1000]) SCREEN#0 = (word) 1024
(byte[256]) buffer1
(const byte[256]) buffer1#0 = (word) 4096
(byte[256]) buffer2
(const byte[256]) buffer2#0 = (word) 4352
(void()) flip()
(byte~) flip::$0 reg byte a 2002.0
(byte~) flip::$4 reg byte a 202.0

View File

@ -1,9 +1,10 @@
.const SCREEN = $400
jsr main
main: {
ldx #$0
b1:
txa
sta $400,x
sta SCREEN,x
inx
cpx #$64
bne b1

View File

@ -9,7 +9,7 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ]
[3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ]
to:main::@return

View File

@ -208,66 +208,18 @@ main::@return: scope:[main] from main::@1
to:@end
@end: scope:[] from @1
Constant (byte*) SCREEN#0 (word) 1024
Constant (byte) main::i#0 (byte) 0
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
(byte*) SCREEN#2 ← phi( @1/(byte*) SCREEN#3 )
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#2 main::@1/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 100
if((boolean~) main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN#3 ← phi( @begin/(word) 1024 )
call main param-assignment
to:@end
@end: scope:[] from @1
Alias (byte*) SCREEN#2 = (byte*) SCREEN#3
Alias (byte*) SCREEN#0 = (byte*) SCREEN#2 (byte*) SCREEN#3
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
to:@1
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#2 main::@1/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 100
if((boolean~) main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN#2 ← phi( @begin/(word) 1024 )
call main param-assignment
to:@end
@end: scope:[] from @1
Redundant Phi (byte*) SCREEN#2 (word) 1024
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN#1 ← phi( main/(word) 1024 main::@1/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 main::@1/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 100
@ -285,12 +237,14 @@ Self Phi Eliminated (byte*) SCREEN#1
Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
to:@1
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 100
@ -308,12 +262,14 @@ Simple Condition (boolean~) main::$0 if((byte) main::i#1!=(byte) 100) goto main:
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
to:@1
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 100) goto main::@1
@ -326,16 +282,60 @@ main::@return: scope:[main] from main::@1
to:@end
@end: scope:[] from @1
Constant (byte*) SCREEN#1 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Constant (const byte*) SCREEN#0
Constant (const byte) main::i#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((word) 1024 + (byte) main::i#2) ← (byte) main::i#2
(byte*) SCREEN#1 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 100) goto main::@1
to:main::@return
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*) SCREEN#1 (const byte*) SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
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 )
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 100) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 100) goto main::@1
to:main::@return
@ -347,13 +347,12 @@ 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
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@return
@ -375,7 +374,7 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte~) main::i#3 )
*((word) 1024 + (byte) main::i#2) ← (byte) main::i#2
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 100) goto main::@3
to:main::@return
@ -404,7 +403,7 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@3
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte~) main::i#3 ) [ main::i#2 ]
[3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[5] if((byte) main::i#1!=(byte) 100) goto main::@3 [ main::i#1 ]
to:main::@return
@ -435,7 +434,7 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ]
[3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ]
to:main::@return
@ -476,7 +475,8 @@ Complete equivalence classes
[ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
jmp b1
@ -504,10 +504,10 @@ main: {
jmp b1
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby1
//SEG12 [3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby1
ldx i
txa
sta $400,x
sta SCREEN,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1
inc i
//SEG14 [5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ] -- zpby1_neq_coby1_then_la1
@ -536,7 +536,8 @@ Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 @1
@ -559,9 +560,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
@ -579,7 +580,8 @@ Removing instruction main_from_b1:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 @1
b1:
@ -599,9 +601,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
@ -619,7 +621,8 @@ Removing instruction b1_from_main:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 @1
//SEG3 [0] call main param-assignment [ ]
@ -636,9 +639,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
@ -652,7 +655,8 @@ main: {
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 @1
//SEG3 [0] call main param-assignment [ ]
@ -668,9 +672,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
@ -686,6 +690,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@return
@ -696,7 +701,8 @@ FINAL SYMBOL TABLE
reg byte x [ main::i#2 main::i#1 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 @1
//SEG3 [0] call main param-assignment [ ]
@ -712,9 +718,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 100) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1

View File

@ -2,6 +2,7 @@
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@return

View File

@ -1,16 +1,18 @@
.const SCREEN1 = $400
.const SCREEN2 = $500
jsr main
main: {
ldx #$0
b1:
txa
sta $400,x
sta SCREEN1,x
inx
cpx #$0
bne b1
ldx #$64
b2:
txa
sta $500,x
sta SCREEN2,x
dex
cpx #$ff
bne b2

View File

@ -9,13 +9,13 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ]
[3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
[6] (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte) 100 ) [ main::j#2 ]
[7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ]
[7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ]
[8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ]
[9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ]
to:main::@return

View File

@ -317,108 +317,33 @@ main::@return: scope:[main] from main::@2
to:@end
@end: scope:[] from @1
Constant (byte*) SCREEN1#0 (word) 1024
Constant (byte*) SCREEN2#0 (word) 1280
Constant (byte) main::i#0 (byte) 0
Constant (byte) main::j#0 (byte) 100
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
(byte*) SCREEN2#4 ← phi( @1/(byte*) SCREEN2#5 )
(byte*) SCREEN1#2 ← phi( @1/(byte*) SCREEN1#3 )
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#3 ← phi( main/(byte*) SCREEN2#4 main::@1/(byte*) SCREEN2#3 )
(byte*) SCREEN1#1 ← phi( main/(byte*) SCREEN1#2 main::@1/(byte*) SCREEN1#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 0
if((boolean~) main::$0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
(byte*) SCREEN2#2 ← phi( main::@1/(byte*) SCREEN2#3 )
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@2/(byte*) SCREEN2#1 main::@3/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) 100 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
(boolean~) main::$1 ← (byte) main::j#1 != (byte) 255
if((boolean~) main::$1) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN2#5 ← phi( @begin/(word) 1280 )
(byte*) SCREEN1#3 ← phi( @begin/(word) 1024 )
call main param-assignment
to:@end
@end: scope:[] from @1
Alias (byte*) SCREEN1#2 = (byte*) SCREEN1#3
Alias (byte*) SCREEN2#4 = (byte*) SCREEN2#5
Alias (byte*) SCREEN1#0 = (byte*) SCREEN1#2 (byte*) SCREEN1#3
Alias (byte*) SCREEN2#0 = (byte*) SCREEN2#4 (byte*) SCREEN2#5
Alias (byte*) SCREEN2#2 = (byte*) SCREEN2#3
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN1#0 ← (word) 1024
(byte*) SCREEN2#0 ← (word) 1280
to:@1
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(byte*) SCREEN2#4 main::@1/(byte*) SCREEN2#2 )
(byte*) SCREEN1#1 ← phi( main/(byte*) SCREEN1#2 main::@1/(byte*) SCREEN1#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN2#2 ← phi( main/(byte*) SCREEN2#0 main::@1/(byte*) SCREEN2#2 )
(byte*) SCREEN1#1 ← phi( main/(byte*) SCREEN1#0 main::@1/(byte*) SCREEN1#1 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 0
if((boolean~) main::$0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::j#0 ← (byte) 100
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@2/(byte*) SCREEN2#1 main::@3/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) 100 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
(boolean~) main::$1 ← (byte) main::j#1 != (byte) 255
if((boolean~) main::$1) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN2#4 ← phi( @begin/(word) 1280 )
(byte*) SCREEN1#2 ← phi( @begin/(word) 1024 )
call main param-assignment
to:@end
@end: scope:[] from @1
Redundant Phi (byte*) SCREEN1#2 (word) 1024
Redundant Phi (byte*) SCREEN2#4 (word) 1280
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(word) 1280 main::@1/(byte*) SCREEN2#2 )
(byte*) SCREEN1#1 ← phi( main/(word) 1024 main::@1/(byte*) SCREEN1#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 0
if((boolean~) main::$0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@2/(byte*) SCREEN2#1 main::@3/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) 100 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
(boolean~) main::$1 ← (byte) main::j#1 != (byte) 255
@ -438,23 +363,27 @@ Self Phi Eliminated (byte*) SCREEN2#1
Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN1#0 ← (word) 1024
(byte*) SCREEN2#0 ← (word) 1280
to:@1
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(word) 1280 )
(byte*) SCREEN1#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN2#2 ← phi( main/(byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 != (byte) 0
if((boolean~) main::$0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::j#0 ← (byte) 100
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@3/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) 100 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
(boolean~) main::$1 ← (byte) main::j#1 != (byte) 255
@ -472,14 +401,53 @@ Simple Condition (boolean~) main::$0 if((byte) main::i#1!=(byte) 0) goto main::@
Simple Condition (boolean~) main::$1 if((byte) main::j#1!=(byte) 255) goto main::@2
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN1#0 ← (word) 1024
(byte*) SCREEN2#0 ← (word) 1280
to:@1
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::j#0 ← (byte) 100
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@3/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Constant (const byte*) SCREEN1#0
Constant (const byte*) SCREEN2#0
Constant (const byte) main::i#0
Constant (const byte) main::j#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(word) 1280 )
(byte*) SCREEN1#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN2#2 ← phi( main/(const byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(const byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
@ -488,7 +456,7 @@ main::@3: scope:[main] from main::@1
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@3/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) 100 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(const byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
@ -509,16 +477,16 @@ CONTROL FLOW GRAPH
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(word) 1280 )
(byte*) SCREEN1#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte*) SCREEN2#2 ← phi( main/(const byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(const byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
(byte*) SCREEN2#1 ← phi( main::@1/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte) 100 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
@ -531,23 +499,23 @@ main::@return: scope:[main] from main::@2
to:@end
@end: scope:[] from @1
Constant (byte*) SCREEN1#1 (word) 1024
Constant (byte*) SCREEN2#2 (word) 1280
Succesful SSA optimization Pass2ConstantPropagation
Alias (byte*) SCREEN2#1 = (byte*) SCREEN2#2
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((word) 1024 + (byte) main::i#2) ← (byte) main::i#2
(byte*) SCREEN2#1 ← phi( main/(const byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(const byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
(byte*) SCREEN2#1 ← phi( main::@1/(word) 1280 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte) 100 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
@ -560,8 +528,8 @@ main::@return: scope:[main] from main::@2
to:@end
@end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Redundant Phi (byte*) SCREEN2#1 (word) 1280
Redundant Phi (byte*) SCREEN1#1 (const byte*) SCREEN1#0
Redundant Phi (byte*) SCREEN2#1 (const byte*) SCREEN2#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
@ -569,14 +537,42 @@ CONTROL FLOW GRAPH
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((word) 1024 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte) 100 )
*((word) 1280 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 )
*((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Constant inlined main::j#0 = (byte) 100
Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte) 100 )
*((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
@ -588,14 +584,14 @@ main::@return: scope:[main] from main::@2
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::j#2
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN1
(const byte*) SCREEN1#0 = (word) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 = (word) 1280
(void()) main()
(label) main::@1
(label) main::@2
@ -622,13 +618,13 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@5
(byte) main::i#2 ← phi( main/(byte) 0 main::@5/(byte~) main::i#3 )
*((word) 1024 + (byte) main::i#2) ← (byte) main::i#2
*((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@5
to:main::@2
main::@2: scope:[main] from main::@1 main::@6
(byte) main::j#2 ← phi( main::@6/(byte~) main::j#3 main::@1/(byte) 100 )
*((word) 1280 + (byte) main::j#2) ← (byte) main::j#2
*((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@6
to:main::@return
@ -660,13 +656,13 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@5
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@5/(byte~) main::i#3 ) [ main::i#2 ]
[3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[5] if((byte) main::i#1!=(byte) 0) goto main::@5 [ main::i#1 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@6
[6] (byte) main::j#2 ← phi( main::@6/(byte~) main::j#3 main::@1/(byte) 100 ) [ main::j#2 ]
[7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ]
[7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ]
[8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ]
[9] if((byte) main::j#1!=(byte) 255) goto main::@6 [ main::j#1 ]
to:main::@return
@ -702,13 +698,13 @@ main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
[2] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ]
[3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ]
[4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
[6] (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(byte) 100 ) [ main::j#2 ]
[7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ]
[7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ]
[8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ]
[9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ]
to:main::@return
@ -762,7 +758,9 @@ Complete equivalence classes
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN1 = $400
.const SCREEN2 = $500
//SEG1 @begin
bbegin:
jmp b1
@ -791,10 +789,10 @@ main: {
jmp b1
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby1
//SEG12 [3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby1
ldx i
txa
sta $400,x
sta SCREEN1,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1
inc i
//SEG14 [5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_neq_0_then_la1
@ -812,10 +810,10 @@ main: {
jmp b2
//SEG19 main::@2
b2:
//SEG20 [7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_zpby1=zpby1
//SEG20 [7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_zpby1=zpby1
ldx j
txa
sta $500,x
sta SCREEN2,x
//SEG21 [8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] -- zpby1=_dec_zpby1
dec j
//SEG22 [9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ] -- zpby1_neq_coby1_then_la1
@ -846,7 +844,9 @@ Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN1 = $400
.const SCREEN2 = $500
//SEG1 @begin
bbegin:
//SEG2 @1
@ -869,9 +869,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN1,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ] -- xby_neq_0_then_la1
@ -887,9 +887,9 @@ main: {
//SEG18 [6] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
//SEG20 [7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
txa
sta $500,x
sta SCREEN2,x
//SEG21 [8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] -- xby=_dec_xby
dex
//SEG22 [9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ] -- xby_neq_coby1_then_la1
@ -909,7 +909,9 @@ Removing instruction b1_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN1 = $400
.const SCREEN2 = $500
//SEG1 @begin
//SEG2 @1
b1:
@ -929,9 +931,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN1,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ] -- xby_neq_0_then_la1
@ -946,9 +948,9 @@ main: {
//SEG18 [6] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
//SEG20 [7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
txa
sta $500,x
sta SCREEN2,x
//SEG21 [8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] -- xby=_dec_xby
dex
//SEG22 [9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ] -- xby_neq_coby1_then_la1
@ -967,7 +969,9 @@ Removing instruction b2_from_b1:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN1 = $400
.const SCREEN2 = $500
//SEG1 @begin
//SEG2 @1
//SEG3 [0] call main param-assignment [ ]
@ -984,9 +988,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN1,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ] -- xby_neq_0_then_la1
@ -1000,9 +1004,9 @@ main: {
//SEG18 [6] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
//SEG20 [7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
txa
sta $500,x
sta SCREEN2,x
//SEG21 [8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] -- xby=_dec_xby
dex
//SEG22 [9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ] -- xby_neq_coby1_then_la1
@ -1017,7 +1021,9 @@ Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN1 = $400
.const SCREEN2 = $500
//SEG1 @begin
//SEG2 @1
//SEG3 [0] call main param-assignment [ ]
@ -1033,9 +1039,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN1,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ] -- xby_neq_0_then_la1
@ -1048,9 +1054,9 @@ main: {
//SEG18 [6] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
//SEG20 [7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
txa
sta $500,x
sta SCREEN2,x
//SEG21 [8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] -- xby=_dec_xby
dex
//SEG22 [9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ] -- xby_neq_coby1_then_la1
@ -1066,7 +1072,9 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN1
(const byte*) SCREEN1#0 = (word) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 = (word) 1280
(void()) main()
(label) main::@1
(label) main::@2
@ -1082,7 +1090,9 @@ reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::j#2 main::j#1 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN1 = $400
.const SCREEN2 = $500
//SEG1 @begin
//SEG2 @1
//SEG3 [0] call main param-assignment [ ]
@ -1098,9 +1108,9 @@ main: {
//SEG10 [2] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1
b1:
//SEG12 [3] *((word) 1024 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
//SEG12 [3] *((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] -- cowo1_staridx_xby=xby
txa
sta $400,x
sta SCREEN1,x
//SEG13 [4] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG14 [5] if((byte) main::i#1!=(byte) 0) goto main::@1 [ main::i#1 ] -- xby_neq_0_then_la1
@ -1113,9 +1123,9 @@ main: {
//SEG18 [6] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] *((word) 1280 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
//SEG20 [7] *((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2 [ main::j#2 ] -- cowo1_staridx_xby=xby
txa
sta $500,x
sta SCREEN2,x
//SEG21 [8] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 ] -- xby=_dec_xby
dex
//SEG22 [9] if((byte) main::j#1!=(byte) 255) goto main::@2 [ main::j#1 ] -- xby_neq_coby1_then_la1

View File

@ -2,7 +2,9 @@
(label) @begin
(label) @end
(byte*) SCREEN1
(const byte*) SCREEN1#0 = (word) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 = (word) 1280
(void()) main()
(label) main::@1
(label) main::@2

View File

@ -1,10 +1,11 @@
.const SCREEN = $400
jsr main
main: {
ldx #$0
b1:
cpx #$32
bcs b2
stx $400
stx SCREEN
b2:
inx
cpx #$64

View File

@ -10,7 +10,7 @@ main::@1: scope:[main] from main main::@2
[3] if((byte) main::i#2>=(byte) 50) goto main::@2 [ main::i#2 ]
to:main::@3
main::@3: scope:[main] from main::@1
[4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ]
[4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]

View File

@ -263,52 +263,20 @@ main::@return: scope:[main] from main::@2
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#0 (word) 1024
Constant (byte) main::i#0 (byte) 0
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#3 ← phi( @begin/(word) 1024 )
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 main::@2/(byte*) SCREEN#4 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
(boolean~) main::$0 ← (byte) main::i#2 < (byte) 50
(boolean~) main::$1 ← ! (boolean~) main::$0
if((boolean~) main::$1) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1 main::@3
(byte*) SCREEN#4 ← phi( main::@1/(byte*) SCREEN#2 main::@3/(byte*) SCREEN#1 )
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 main::@3/(byte) main::i#4 )
(byte) main::i#1 ← ++ (byte) main::i#3
(boolean~) main::$2 ← (byte) main::i#1 < (byte) 100
if((boolean~) main::$2) goto main::@1
to:main::@return
main::@3: scope:[main] from main::@1
(byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#2 )
(byte) main::i#4 ← phi( main::@1/(byte) main::i#2 )
*((byte*) SCREEN#1) ← (byte) main::i#4
to:main::@2
main::@return: scope:[main] from main::@2
return
to:@return
@end: scope:[] from @begin
Inversing boolean not (boolean~) main::$1 ← (byte) main::i#2 >= (byte) 50 from (boolean~) main::$0 ← (byte) main::i#2 < (byte) 50
Succesful SSA optimization Pass2UnaryNotSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#3 ← phi( @begin/(word) 1024 )
(byte*) SCREEN#3 ← phi( @begin/(byte*) SCREEN#0 )
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 main::@2/(byte*) SCREEN#4 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(boolean~) main::$1 ← (byte) main::i#2 >= (byte) 50
if((boolean~) main::$1) goto main::@2
to:main::@3
@ -329,19 +297,21 @@ main::@return: scope:[main] from main::@2
to:@return
@end: scope:[] from @begin
Alias (byte*) SCREEN#0 = (byte*) SCREEN#3
Alias (byte) main::i#2 = (byte) main::i#4
Alias (byte*) SCREEN#1 = (byte*) SCREEN#2
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#3 ← phi( @begin/(word) 1024 )
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#3 main::@2/(byte*) SCREEN#4 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 main::@2/(byte*) SCREEN#4 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(boolean~) main::$1 ← (byte) main::i#2 >= (byte) 50
if((boolean~) main::$1) goto main::@2
to:main::@3
@ -360,19 +330,20 @@ main::@return: scope:[main] from main::@2
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#3 (word) 1024
Redundant Phi (byte) main::i#3 (byte) main::i#2
Redundant Phi (byte*) SCREEN#4 (byte*) SCREEN#1
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#1 ← phi( main/(word) 1024 main::@2/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 main::@2/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(boolean~) main::$1 ← (byte) main::i#2 >= (byte) 50
if((boolean~) main::$1) goto main::@2
to:main::@3
@ -393,13 +364,15 @@ Self Phi Eliminated (byte*) SCREEN#1
Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(boolean~) main::$1 ← (byte) main::i#2 >= (byte) 50
if((boolean~) main::$1) goto main::@2
to:main::@3
@ -421,13 +394,15 @@ Simple Condition (boolean~) main::$2 if((byte) main::i#1<(byte) 100) goto main::
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
if((byte) main::i#2>=(byte) 50) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1 main::@3
@ -442,8 +417,58 @@ main::@return: scope:[main] from main::@2
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#1 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Constant (const byte*) SCREEN#0
Constant (const byte) main::i#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#1 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@2/(byte) main::i#1 )
if((byte) main::i#2>=(byte) 50) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1 main::@3
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 100) goto main::@1
to:main::@return
main::@3: scope:[main] from main::@1
*((byte*) SCREEN#1) ← (byte) main::i#2
to:main::@2
main::@return: scope:[main] from main::@2
return
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@2/(byte) main::i#1 )
if((byte) main::i#2>=(byte) 50) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1 main::@3
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 100) goto main::@1
to:main::@return
main::@3: scope:[main] from main::@1
*((const byte*) SCREEN#0) ← (byte) main::i#2
to:main::@2
main::@return: scope:[main] from main::@2
return
to:@return
@end: scope:[] from @begin
Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
@ -459,7 +484,7 @@ main::@2: scope:[main] from main::@1 main::@3
if((byte) main::i#1<(byte) 100) goto main::@1
to:main::@return
main::@3: scope:[main] from main::@1
*((word) 1024) ← (byte) main::i#2
*((const byte*) SCREEN#0) ← (byte) main::i#2
to:main::@2
main::@return: scope:[main] from main::@2
return
@ -470,6 +495,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@2
@ -494,7 +520,7 @@ main::@1: scope:[main] from main main::@5
if((byte) main::i#2>=(byte) 50) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@1
*((word) 1024) ← (byte) main::i#2
*((const byte*) SCREEN#0) ← (byte) main::i#2
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
(byte) main::i#1 ← ++ (byte) main::i#2
@ -526,7 +552,7 @@ main::@1: scope:[main] from main main::@5
[3] if((byte) main::i#2>=(byte) 50) goto main::@2 [ main::i#2 ]
to:main::@3
main::@3: scope:[main] from main::@1
[4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ]
[4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
@ -560,7 +586,7 @@ main::@1: scope:[main] from main main::@2
[3] if((byte) main::i#2>=(byte) 50) goto main::@2 [ main::i#2 ]
to:main::@3
main::@3: scope:[main] from main::@1
[4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ]
[4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
@ -604,7 +630,8 @@ Complete equivalence classes
[ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -636,9 +663,9 @@ main: {
jmp b3
//SEG12 main::@3
b3:
//SEG13 [4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=zpby1
//SEG13 [4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=zpby1
lda i
sta $400
sta SCREEN
jmp b2
//SEG14 main::@2
b2:
@ -671,7 +698,8 @@ Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -697,8 +725,8 @@ main: {
bcs b2
//SEG12 main::@3
b3:
//SEG13 [4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx $400
//SEG13 [4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG14 main::@2
b2:
//SEG15 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
@ -717,7 +745,8 @@ Removing instruction main_from_bbegin:
Removing instruction b1_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -741,8 +770,8 @@ main: {
bcs b2
//SEG12 main::@3
b3:
//SEG13 [4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx $400
//SEG13 [4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG14 main::@2
b2:
//SEG15 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
@ -763,7 +792,8 @@ Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -783,8 +813,8 @@ main: {
cpx #$32
bcs b2
//SEG12 main::@3
//SEG13 [4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx $400
//SEG13 [4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG14 main::@2
b2:
//SEG15 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
@ -800,7 +830,8 @@ main: {
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -819,8 +850,8 @@ main: {
cpx #$32
bcs b2
//SEG12 main::@3
//SEG13 [4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx $400
//SEG13 [4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG14 main::@2
b2:
//SEG15 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
@ -837,6 +868,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@2
@ -849,7 +881,8 @@ FINAL SYMBOL TABLE
reg byte x [ main::i#2 main::i#1 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -868,8 +901,8 @@ main: {
cpx #$32
bcs b2
//SEG12 main::@3
//SEG13 [4] *((word) 1024) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx $400
//SEG13 [4] *((const byte*) SCREEN#0) ← (byte) main::i#2 [ main::i#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG14 main::@2
b2:
//SEG15 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby

View File

@ -1,6 +1,7 @@
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@2

View File

@ -316,85 +316,31 @@ INITIAL SSA SYMBOL TABLE
(byte) main::a#3
(byte) main::a#4
Constant (byte) i#0 (byte) 0
Constant (byte) main::a#0 (byte) 4
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@3
@3: scope:[] from @begin
(byte) i#7 ← phi( @begin/(byte) i#4 )
(byte) i#1 ← (byte) i#7
to:@end
main: scope:[main] from @begin
(byte) i#13 ← phi( @begin/(byte) 0 )
call inc param-assignment
(byte) inc::return#0 ← (byte) inc::return#3
to:main::@1
main::@1: scope:[main] from main
(byte) main::a#3 ← phi( main/(byte) 4 )
(byte) i#8 ← phi( main/(byte) i#6 )
(byte) inc::return#4 ← phi( main/(byte) inc::return#0 )
(byte~) main::$0 ← (byte) inc::return#4
(byte) i#2 ← (byte) i#8
(byte~) main::$1 ← (byte) main::a#3 + (byte~) main::$0
(byte) main::a#1 ← (byte~) main::$1
call inc param-assignment
(byte) inc::return#1 ← (byte) inc::return#3
to:main::@2
main::@2: scope:[main] from main::@1
(byte) main::a#4 ← phi( main::@1/(byte) main::a#1 )
(byte) i#9 ← phi( main::@1/(byte) i#6 )
(byte) inc::return#5 ← phi( main::@1/(byte) inc::return#1 )
(byte~) main::$2 ← (byte) inc::return#5
(byte) i#3 ← (byte) i#9
(byte~) main::$3 ← (byte) main::a#4 + (byte~) main::$2
(byte) main::a#2 ← (byte~) main::$3
to:main::@return
main::@return: scope:[main] from main::@2
(byte) i#10 ← phi( main::@2/(byte) i#3 )
(byte) i#4 ← (byte) i#10
return
to:@return
inc: scope:[inc] from main main::@1
(byte) i#11 ← phi( main/(byte) i#13 main::@1/(byte) i#2 )
(byte~) inc::$0 ← (byte) i#11 + (byte) 7
(byte) i#5 ← (byte~) inc::$0
(byte) inc::return#2 ← (byte) i#5
to:inc::@return
inc::@return: scope:[inc] from inc
(byte) i#12 ← phi( inc/(byte) i#5 )
(byte) inc::return#6 ← phi( inc/(byte) inc::return#2 )
(byte) inc::return#3 ← (byte) inc::return#6
(byte) i#6 ← (byte) i#12
return
to:@return
@end: scope:[] from @3
Not aliassing across scopes: main::$0 inc::return#4
Not aliassing across scopes: main::$2 inc::return#5
Not aliassing across scopes: i#5 inc::$0
Not aliassing across scopes: inc::return#2 i#5
Alias (byte) i#1 = (byte) i#7 (byte) i#4 (byte) i#8 (byte) i#6 (byte) i#2 (byte) i#9 (byte) i#3 (byte) i#10 (byte) i#12 (byte) i#5
Alias (byte) i#0 = (byte) i#13
Alias (byte) inc::return#0 = (byte) inc::return#3 (byte) inc::return#4 (byte) inc::return#1 (byte) inc::return#5 (byte) inc::return#6 (byte) inc::return#2
Alias (byte) main::a#0 = (byte) main::a#3
Alias (byte) main::a#1 = (byte~) main::$1 (byte) main::a#4
Alias (byte) main::a#2 = (byte~) main::$3
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) i#0 ← (byte) 0
call main param-assignment
to:@3
@3: scope:[] from @begin
to:@end
main: scope:[main] from @begin
(byte) i#13 ← phi( @begin/(byte) 0 )
(byte) main::a#0 ← (byte) 4
call inc param-assignment
to:main::@1
main::@1: scope:[main] from main
(byte) main::a#3 ← phi( main/(byte) 4 )
(byte~) main::$0 ← (byte) inc::return#0
(byte) main::a#1 ← (byte) main::a#3 + (byte~) main::$0
(byte) main::a#1 ← (byte) main::a#0 + (byte~) main::$0
call inc param-assignment
to:main::@2
main::@2: scope:[main] from main::@1
@ -405,7 +351,7 @@ main::@return: scope:[main] from main::@2
return
to:@return
inc: scope:[inc] from main main::@1
(byte) i#11 ← phi( main/(byte) i#13 main::@1/(byte) i#1 )
(byte) i#11 ← phi( main/(byte) i#0 main::@1/(byte) i#1 )
(byte~) inc::$0 ← (byte) i#11 + (byte) 7
(byte) i#1 ← (byte~) inc::$0
(byte) inc::return#0 ← (byte) i#1
@ -415,9 +361,9 @@ inc::@return: scope:[inc] from inc
to:@return
@end: scope:[] from @3
Redundant Phi (byte) i#13 (byte) 0
Redundant Phi (byte) main::a#3 (byte) 4
Succesful SSA optimization Pass2RedundantPhiElimination
Constant (const byte) i#0
Constant (const byte) main::a#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
@ -429,7 +375,7 @@ main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inc::return#0
(byte) main::a#1 ← (byte) 4 + (byte~) main::$0
(byte) main::a#1 ← (const byte) main::a#0 + (byte~) main::$0
call inc param-assignment
to:main::@2
main::@2: scope:[main] from main::@1
@ -440,7 +386,7 @@ main::@return: scope:[main] from main::@2
return
to:@return
inc: scope:[inc] from main main::@1
(byte) i#11 ← phi( main/(byte) 0 main::@1/(byte) i#1 )
(byte) i#11 ← phi( main/(const byte) i#0 main::@1/(byte) i#1 )
(byte~) inc::$0 ← (byte) i#11 + (byte) 7
(byte) i#1 ← (byte~) inc::$0
(byte) inc::return#0 ← (byte) i#1
@ -453,6 +399,47 @@ inc::@return: scope:[inc] from inc
Culled Empty Block (label) @3
Succesful SSA optimization Pass2CullEmptyBlocks
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
call inc param-assignment
to:main::@1
main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inc::return#0
(byte) main::a#1 ← (const byte) main::a#0 + (byte~) main::$0
call inc param-assignment
to:main::@2
main::@2: scope:[main] from main::@1
(byte~) main::$2 ← (byte) inc::return#0
(byte) main::a#2 ← (byte) main::a#1 + (byte~) main::$2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
inc: scope:[inc] from main main::@1
(byte) i#11 ← phi( main/(const byte) i#0 main::@1/(byte) i#1 )
(byte~) inc::$0 ← (byte) i#11 + (byte) 7
(byte) i#1 ← (byte~) inc::$0
(byte) inc::return#0 ← (byte) i#1
to:inc::@return
inc::@return: scope:[inc] from inc
return
to:@return
@end: scope:[] from @begin
Not aliassing across scopes: main::$0 inc::return#0
Not aliassing across scopes: main::$2 inc::return#0
Not aliassing across scopes: i#1 inc::$0
Not aliassing across scopes: inc::return#0 i#1
Not aliassing across scopes: main::$0 inc::return#0
Not aliassing across scopes: main::$2 inc::return#0
Not aliassing across scopes: i#1 inc::$0
Not aliassing across scopes: inc::return#0 i#1
Constant inlined main::a#0 = (byte) 4
Constant inlined i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
@ -482,14 +469,6 @@ inc::@return: scope:[inc] from inc
to:@return
@end: scope:[] from @begin
Not aliassing across scopes: main::$0 inc::return#0
Not aliassing across scopes: main::$2 inc::return#0
Not aliassing across scopes: i#1 inc::$0
Not aliassing across scopes: inc::return#0 i#1
Not aliassing across scopes: main::$0 inc::return#0
Not aliassing across scopes: main::$2 inc::return#0
Not aliassing across scopes: i#1 inc::$0
Not aliassing across scopes: inc::return#0 i#1
FINAL SYMBOL TABLE
(label) @begin
(label) @end
@ -680,7 +659,7 @@ Allocated zp ZP_BYTE:5 [ main::$2 ]
Allocated zp ZP_BYTE:6 [ main::a#2 ]
Allocated zp ZP_BYTE:7 [ inc::return#0 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label i = 2
//SEG1 @begin
bbegin:
@ -788,7 +767,7 @@ Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -849,7 +828,7 @@ inc: {
Removing instruction main_from_bbegin:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -916,7 +895,7 @@ Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -993,7 +972,7 @@ reg byte a [ main::a#2 ]
reg byte a [ inc::return#0 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main

View File

@ -179,42 +179,16 @@ INITIAL SSA SYMBOL TABLE
(byte) s#3
(byte) s#4
Constant (byte) i#0 (byte) 10
Constant (byte) s#0 (byte) 0
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @2 @begin
(byte) s#3 ← phi( @2/(byte) s#4 @begin/(byte) 0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) 10 )
(boolean~) $0 ← (byte) i#2 > (byte) 5
(boolean~) $1 ← ! (boolean~) $0
if((boolean~) $1) goto @2
to:@3
@2: scope:[] from @1 @3
(byte) s#4 ← phi( @1/(byte) s#3 @3/(byte) s#1 )
(byte) i#3 ← phi( @1/(byte) i#2 @3/(byte) i#4 )
(byte) i#1 ← -- (byte) i#3
(boolean~) $3 ← (byte) i#1 > (byte) 0
if((boolean~) $3) goto @1
to:@end
@3: scope:[] from @1
(byte) i#4 ← phi( @1/(byte) i#2 )
(byte) s#2 ← phi( @1/(byte) s#3 )
(byte~) $2 ← (byte) s#2 + (byte) i#4
(byte) s#1 ← (byte~) $2
to:@2
@end: scope:[] from @2
Inversing boolean not (boolean~) $1 ← (byte) i#2 <= (byte) 5 from (boolean~) $0 ← (byte) i#2 > (byte) 5
Succesful SSA optimization Pass2UnaryNotSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) i#0 ← (byte) 10
(byte) s#0 ← (byte) 0
to:@1
@1: scope:[] from @2 @begin
(byte) s#3 ← phi( @2/(byte) s#4 @begin/(byte) 0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) 10 )
(byte) s#3 ← phi( @2/(byte) s#4 @begin/(byte) s#0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) i#0 )
(boolean~) $1 ← (byte) i#2 <= (byte) 5
if((boolean~) $1) goto @2
to:@3
@ -239,10 +213,12 @@ Alias (byte) s#1 = (byte~) $2
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) i#0 ← (byte) 10
(byte) s#0 ← (byte) 0
to:@1
@1: scope:[] from @2 @begin
(byte) s#2 ← phi( @2/(byte) s#4 @begin/(byte) 0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) 10 )
(byte) s#2 ← phi( @2/(byte) s#4 @begin/(byte) s#0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) i#0 )
(boolean~) $1 ← (byte) i#2 <= (byte) 5
if((boolean~) $1) goto @2
to:@3
@ -262,10 +238,12 @@ Redundant Phi (byte) i#3 (byte) i#2
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) i#0 ← (byte) 10
(byte) s#0 ← (byte) 0
to:@1
@1: scope:[] from @2 @begin
(byte) s#2 ← phi( @2/(byte) s#4 @begin/(byte) 0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) 10 )
(byte) s#2 ← phi( @2/(byte) s#4 @begin/(byte) s#0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) i#0 )
(boolean~) $1 ← (byte) i#2 <= (byte) 5
if((boolean~) $1) goto @2
to:@3
@ -284,6 +262,50 @@ Simple Condition (boolean~) $1 if((byte) i#2<=(byte) 5) goto @2
Simple Condition (boolean~) $3 if((byte) i#1>(byte) 0) goto @1
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) i#0 ← (byte) 10
(byte) s#0 ← (byte) 0
to:@1
@1: scope:[] from @2 @begin
(byte) s#2 ← phi( @2/(byte) s#4 @begin/(byte) s#0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(byte) i#0 )
if((byte) i#2<=(byte) 5) goto @2
to:@3
@2: scope:[] from @1 @3
(byte) s#4 ← phi( @1/(byte) s#2 @3/(byte) s#1 )
(byte) i#1 ← -- (byte) i#2
if((byte) i#1>(byte) 0) goto @1
to:@end
@3: scope:[] from @1
(byte) s#1 ← (byte) s#2 + (byte) i#2
to:@2
@end: scope:[] from @2
Constant (const byte) i#0
Constant (const byte) s#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @2 @begin
(byte) s#2 ← phi( @2/(byte) s#4 @begin/(const byte) s#0 )
(byte) i#2 ← phi( @2/(byte) i#1 @begin/(const byte) i#0 )
if((byte) i#2<=(byte) 5) goto @2
to:@3
@2: scope:[] from @1 @3
(byte) s#4 ← phi( @1/(byte) s#2 @3/(byte) s#1 )
(byte) i#1 ← -- (byte) i#2
if((byte) i#1>(byte) 0) goto @1
to:@end
@3: scope:[] from @1
(byte) s#1 ← (byte) s#2 + (byte) i#2
to:@2
@end: scope:[] from @2
Constant inlined s#0 = (byte) 0
Constant inlined i#0 = (byte) 10
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @2 @begin
@ -444,7 +466,7 @@ Complete equivalence classes
Allocated zp ZP_BYTE:2 [ i#2 i#1 ]
Allocated zp ZP_BYTE:3 [ s#2 s#4 s#1 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label i = 2
.label s = 3
//SEG1 @begin
@ -508,7 +530,7 @@ Removing instruction jmp b2
Removing instruction jmp bend
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] phi from @begin to @1
@ -557,7 +579,7 @@ Removing instruction b2_from_b1:
Removing instruction b2_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] phi from @begin to @1
@ -598,7 +620,7 @@ Removing instruction b3:
Removing instruction bend:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] phi from @begin to @1
//SEG3 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1
@ -634,7 +656,7 @@ b2:
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] phi from @begin to @1
//SEG3 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1
@ -684,7 +706,7 @@ reg byte x [ i#2 i#1 ]
reg byte a [ s#2 s#4 s#1 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] phi from @begin to @1
//SEG3 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1

View File

@ -1,3 +1,4 @@
.const SCREEN = $400
jsr main
main: {
ldy #$64
@ -11,7 +12,7 @@ main: {
nest: {
ldx #$64
b1:
stx $400
stx SCREEN
dex
cpx #$0
bne b1

View File

@ -21,7 +21,7 @@ nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
[8] (byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 ) [ nest::j#2 ]
[9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ]
[9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ]
[10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ]
[11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ]
to:nest::@return

View File

@ -331,61 +331,21 @@ nest::@return: scope:[nest] from nest::@1
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#0 (word) 1024
Constant (byte) main::i#0 (byte) 100
Constant (byte) nest::j#0 (byte) 100
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#4 ← phi( @begin/(word) 1024 )
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#3 ← phi( main/(byte*) SCREEN#4 main::@3/(byte*) SCREEN#5 )
(byte) main::i#3 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
(byte*) SCREEN#5 ← phi( main::@1/(byte*) SCREEN#3 )
(byte) main::i#2 ← phi( main::@1/(byte) main::i#3 )
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$1 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$1) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest: scope:[nest] from main::@1
(byte*) SCREEN#2 ← phi( main::@1/(byte*) SCREEN#3 )
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(byte*) SCREEN#2 nest::@1/(byte*) SCREEN#1 )
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
(boolean~) nest::$0 ← (byte) nest::j#1 > (byte) 0
if((boolean~) nest::$0) goto nest::@1
to:nest::@return
nest::@return: scope:[nest] from nest::@1
return
to:@return
@end: scope:[] from @begin
Alias (byte*) SCREEN#0 = (byte*) SCREEN#4
Alias (byte) main::i#2 = (byte) main::i#3
Alias (byte*) SCREEN#2 = (byte*) SCREEN#5 (byte*) SCREEN#3
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#4 ← phi( @begin/(word) 1024 )
(byte) main::i#0 ← (byte) 100
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#4 main::@3/(byte*) SCREEN#2 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#0 main::@3/(byte*) SCREEN#2 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
@ -397,46 +357,11 @@ main::@return: scope:[main] from main::@3
return
to:@return
nest: scope:[nest] from main::@1
(byte) nest::j#0 ← (byte) 100
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(byte*) SCREEN#2 nest::@1/(byte*) SCREEN#1 )
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
(boolean~) nest::$0 ← (byte) nest::j#1 > (byte) 0
if((boolean~) nest::$0) goto nest::@1
to:nest::@return
nest::@return: scope:[nest] from nest::@1
return
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#4 (word) 1024
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#2 ← phi( main/(word) 1024 main::@3/(byte*) SCREEN#2 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$1 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$1) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(byte*) SCREEN#2 nest::@1/(byte*) SCREEN#1 )
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
(byte) nest::j#2 ← phi( nest/(byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
(boolean~) nest::$0 ← (byte) nest::j#1 > (byte) 0
@ -452,13 +377,15 @@ Self Phi Eliminated (byte*) SCREEN#1
Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#2 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
@ -470,10 +397,11 @@ main::@return: scope:[main] from main::@3
return
to:@return
nest: scope:[nest] from main::@1
(byte) nest::j#0 ← (byte) 100
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(byte*) SCREEN#2 )
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
(byte) nest::j#2 ← phi( nest/(byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
(boolean~) nest::$0 ← (byte) nest::j#1 > (byte) 0
@ -488,14 +416,53 @@ Simple Condition (boolean~) main::$1 if((byte) main::i#1>(byte) 0) goto main::@1
Simple Condition (boolean~) nest::$0 if((byte) nest::j#1>(byte) 0) goto nest::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::i#1 ← -- (byte) main::i#2
if((byte) main::i#1>(byte) 0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest: scope:[nest] from main::@1
(byte) nest::j#0 ← (byte) 100
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(byte*) SCREEN#2 )
(byte) nest::j#2 ← phi( nest/(byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@1
to:nest::@return
nest::@return: scope:[nest] from nest::@1
return
to:@return
@end: scope:[] from @begin
Constant (const byte*) SCREEN#0
Constant (const byte) main::i#0
Constant (const byte) nest::j#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#2 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#2 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
@ -509,7 +476,7 @@ nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(byte*) SCREEN#2 )
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
(byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@1
@ -519,8 +486,8 @@ nest::@return: scope:[nest] from nest::@1
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#2 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Alias (byte*) SCREEN#1 = (byte*) SCREEN#2
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
@ -528,7 +495,8 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
@ -541,8 +509,7 @@ main::@return: scope:[main] from main::@3
nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(word) 1024 )
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
(byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@1
@ -552,9 +519,42 @@ nest::@return: scope:[nest] from nest::@1
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (word) 1024
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::i#1 ← -- (byte) main::i#2
if((byte) main::i#1>(byte) 0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((const byte*) SCREEN#0) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@1
to:nest::@return
nest::@return: scope:[nest] from nest::@1
return
to:@return
@end: scope:[] from @begin
Constant inlined main::i#0 = (byte) 100
Constant inlined nest::j#0 = (byte) 100
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
@ -575,7 +575,7 @@ nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 )
*((word) 1024) ← (byte) nest::j#2
*((const byte*) SCREEN#0) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@1
to:nest::@return
@ -588,6 +588,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@3
@ -631,7 +632,7 @@ nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@3
(byte) nest::j#2 ← phi( nest/(byte) 100 nest::@3/(byte~) nest::j#3 )
*((word) 1024) ← (byte) nest::j#2
*((const byte*) SCREEN#0) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@3
to:nest::@return
@ -678,7 +679,7 @@ nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@3
[9] (byte) nest::j#2 ← phi( nest/(byte) 100 nest::@3/(byte~) nest::j#3 ) [ nest::j#2 ]
[10] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ]
[10] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ]
[11] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ]
[12] if((byte) nest::j#1>(byte) 0) goto nest::@3 [ nest::j#1 ]
to:nest::@return
@ -725,7 +726,7 @@ nest: scope:[nest] from main::@1
to:nest::@1
nest::@1: scope:[nest] from nest nest::@1
[8] (byte) nest::j#2 ← phi( nest/(byte) 100 nest::@1/(byte) nest::j#1 ) [ nest::j#2 ]
[9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ]
[9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ]
[10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ]
[11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ]
to:nest::@return
@ -782,7 +783,8 @@ Complete equivalence classes
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ nest::j#2 nest::j#1 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -840,9 +842,9 @@ nest: {
jmp b1
//SEG23 nest::@1
b1:
//SEG24 [9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=zpby1
//SEG24 [9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=zpby1
lda j
sta $400
sta SCREEN
//SEG25 [10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ] -- zpby1=_dec_zpby1
dec j
//SEG26 [11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ] -- zpby1_gt_0_then_la1
@ -875,7 +877,8 @@ Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -924,8 +927,8 @@ nest: {
//SEG22 [8] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG23 nest::@1
b1:
//SEG24 [9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx $400
//SEG24 [9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG25 [10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ] -- xby=_dec_xby
dex
//SEG26 [11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ] -- xby_gt_0_then_la1
@ -945,7 +948,8 @@ Removing instruction nest_from_b1:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -990,8 +994,8 @@ nest: {
//SEG22 [8] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG23 nest::@1
b1:
//SEG24 [9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx $400
//SEG24 [9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG25 [10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ] -- xby=_dec_xby
dex
//SEG26 [11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ] -- xby_gt_0_then_la1
@ -1012,7 +1016,8 @@ Removing instruction b1_from_nest:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -1051,8 +1056,8 @@ nest: {
//SEG22 [8] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG23 nest::@1
b1:
//SEG24 [9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx $400
//SEG24 [9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG25 [10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ] -- xby=_dec_xby
dex
//SEG26 [11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ] -- xby_gt_0_then_la1
@ -1067,7 +1072,8 @@ Removing instruction jmp b1
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -1104,8 +1110,8 @@ nest: {
//SEG22 [8] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG23 nest::@1
b1:
//SEG24 [9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx $400
//SEG24 [9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG25 [10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ] -- xby=_dec_xby
dex
//SEG26 [11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ] -- xby_gt_0_then_la1
@ -1120,6 +1126,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@3
@ -1138,7 +1145,8 @@ reg byte y [ main::i#2 main::i#1 ]
reg byte x [ nest::j#2 nest::j#1 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -1175,8 +1183,8 @@ nest: {
//SEG22 [8] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG23 nest::@1
b1:
//SEG24 [9] *((word) 1024) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx $400
//SEG24 [9] *((const byte*) SCREEN#0) ← (byte) nest::j#2 [ nest::j#2 ] -- _star_cowo1=xby
stx SCREEN
//SEG25 [10] (byte) nest::j#1 ← -- (byte) nest::j#2 [ nest::j#1 ] -- xby=_dec_xby
dex
//SEG26 [11] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ nest::j#1 ] -- xby_gt_0_then_la1

View File

@ -1,6 +1,7 @@
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@3

View File

@ -1,3 +1,4 @@
.const SCREEN = $400
jsr main
main: {
.label j = 3
@ -39,7 +40,7 @@ nest2: {
b1:
ldy #$64
b2:
sty $400
sty SCREEN
dey
cpy #$0
bne b2

View File

@ -52,7 +52,7 @@ nest2::@1: scope:[nest2] from nest2 nest2::@3
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
[21] (byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 ) [ nest2::i#2 nest2::j#2 ]
[22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ]
[22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ]
[23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ]
[24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ]
to:nest2::@3

View File

@ -740,108 +740,7 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#0 (word) 1024
Constant (byte) main::i#0 (byte) 100
Constant (byte) main::j#0 (byte) 100
Constant (byte) nest1::i#0 (byte) 100
Constant (byte) nest1::j#0 (byte) 100
Constant (byte) nest2::i#0 (byte) 100
Constant (byte) nest2::j#0 (byte) 100
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#13 ← phi( @begin/(word) 1024 )
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#11 ← phi( main/(byte*) SCREEN#13 main::@3/(byte*) SCREEN#14 )
(byte) main::i#5 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 main::@5/(byte*) SCREEN#12 )
(byte) main::i#4 ← phi( main::@1/(byte) main::i#5 main::@5/(byte) main::i#3 )
(byte) main::j#3 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
(byte*) SCREEN#12 ← phi( main::@2/(byte*) SCREEN#10 )
(byte) main::i#3 ← phi( main::@2/(byte) main::i#4 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#3 )
(byte) main::j#1 ← -- (byte) main::j#2
(boolean~) main::$1 ← (byte) main::j#1 > (byte) 0
if((boolean~) main::$1) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@5
(byte*) SCREEN#14 ← phi( main::@5/(byte*) SCREEN#12 )
(byte) main::i#2 ← phi( main::@5/(byte) main::i#3 )
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$2 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$2) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest1: scope:[nest1] from main::@2
(byte*) SCREEN#8 ← phi( main::@2/(byte*) SCREEN#10 )
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#6 ← phi( nest1/(byte*) SCREEN#8 nest1::@3/(byte*) SCREEN#9 )
(byte) nest1::i#5 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte*) SCREEN#5 ← phi( nest1::@1/(byte*) SCREEN#6 nest1::@5/(byte*) SCREEN#7 )
(byte) nest1::i#4 ← phi( nest1::@1/(byte) nest1::i#5 nest1::@5/(byte) nest1::i#3 )
(byte) nest1::j#3 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
(byte*) SCREEN#7 ← phi( nest1::@2/(byte*) SCREEN#5 )
(byte) nest1::i#3 ← phi( nest1::@2/(byte) nest1::i#4 )
(byte) nest1::j#2 ← phi( nest1::@2/(byte) nest1::j#3 )
(byte) nest1::j#1 ← -- (byte) nest1::j#2
(boolean~) nest1::$1 ← (byte) nest1::j#1 > (byte) 0
if((boolean~) nest1::$1) goto nest1::@2
to:nest1::@3
nest1::@3: scope:[nest1] from nest1::@5
(byte*) SCREEN#9 ← phi( nest1::@5/(byte*) SCREEN#7 )
(byte) nest1::i#2 ← phi( nest1::@5/(byte) nest1::i#3 )
(byte) nest1::i#1 ← -- (byte) nest1::i#2
(boolean~) nest1::$2 ← (byte) nest1::i#1 > (byte) 0
if((boolean~) nest1::$2) goto nest1::@1
to:nest1::@return
nest1::@return: scope:[nest1] from nest1::@3
return
to:@return
nest2: scope:[nest2] from nest1::@2
(byte*) SCREEN#3 ← phi( nest1::@2/(byte*) SCREEN#5 )
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#4 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#2 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#4 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::i#3 ← phi( nest2::@1/(byte) nest2::i#4 nest2::@2/(byte) nest2::i#3 )
(byte*) SCREEN#1 ← phi( nest2::@1/(byte*) SCREEN#2 nest2::@2/(byte*) SCREEN#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
(boolean~) nest2::$0 ← (byte) nest2::j#1 > (byte) 0
if((boolean~) nest2::$0) goto nest2::@2
to:nest2::@3
nest2::@3: scope:[nest2] from nest2::@2
(byte*) SCREEN#4 ← phi( nest2::@2/(byte*) SCREEN#1 )
(byte) nest2::i#2 ← phi( nest2::@2/(byte) nest2::i#3 )
(byte) nest2::i#1 ← -- (byte) nest2::i#2
(boolean~) nest2::$1 ← (byte) nest2::i#1 > (byte) 0
if((boolean~) nest2::$1) goto nest2::@1
to:nest2::@return
nest2::@return: scope:[nest2] from nest2::@3
return
to:@return
@end: scope:[] from @begin
Alias (byte*) SCREEN#0 = (byte*) SCREEN#13
Alias (byte) main::j#2 = (byte) main::j#3
Alias (byte) main::i#2 = (byte) main::i#3 (byte) main::i#4
Alias (byte*) SCREEN#10 = (byte*) SCREEN#12 (byte*) SCREEN#14 (byte*) SCREEN#8
@ -853,19 +752,21 @@ Alias (byte*) SCREEN#1 = (byte*) SCREEN#4
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#13 ← phi( @begin/(word) 1024 )
(byte) main::i#0 ← (byte) 100
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#11 ← phi( main/(byte*) SCREEN#13 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#11 ← phi( main/(byte*) SCREEN#0 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
(byte) main::j#0 ← (byte) 100
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 main::@5/(byte*) SCREEN#10 )
(byte) main::i#2 ← phi( main::@1/(byte) main::i#5 main::@5/(byte) main::i#2 )
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -882,15 +783,17 @@ main::@return: scope:[main] from main::@3
return
to:@return
nest1: scope:[nest1] from main::@2
(byte) nest1::i#0 ← (byte) 100
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#6 ← phi( nest1/(byte*) SCREEN#10 nest1::@3/(byte*) SCREEN#3 )
(byte) nest1::i#5 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::i#5 ← phi( nest1/(byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::j#0 ← (byte) 100
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte*) SCREEN#3 ← phi( nest1::@1/(byte*) SCREEN#6 nest1::@5/(byte*) SCREEN#3 )
(byte) nest1::i#2 ← phi( nest1::@1/(byte) nest1::i#5 nest1::@5/(byte) nest1::i#2 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -907,96 +810,17 @@ nest1::@return: scope:[nest1] from nest1::@3
return
to:@return
nest2: scope:[nest2] from nest1::@2
(byte) nest2::i#0 ← (byte) 100
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#4 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#4 ← phi( nest2/(byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#2 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#1 )
(byte) nest2::j#0 ← (byte) 100
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::i#2 ← phi( nest2::@1/(byte) nest2::i#4 nest2::@2/(byte) nest2::i#2 )
(byte*) SCREEN#1 ← phi( nest2::@1/(byte*) SCREEN#2 nest2::@2/(byte*) SCREEN#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
(boolean~) nest2::$0 ← (byte) nest2::j#1 > (byte) 0
if((boolean~) nest2::$0) goto nest2::@2
to:nest2::@3
nest2::@3: scope:[nest2] from nest2::@2
(byte) nest2::i#1 ← -- (byte) nest2::i#2
(boolean~) nest2::$1 ← (byte) nest2::i#1 > (byte) 0
if((boolean~) nest2::$1) goto nest2::@1
to:nest2::@return
nest2::@return: scope:[nest2] from nest2::@3
return
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#13 (word) 1024
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#11 ← phi( main/(word) 1024 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 main::@5/(byte*) SCREEN#10 )
(byte) main::i#2 ← phi( main::@1/(byte) main::i#5 main::@5/(byte) main::i#2 )
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
(byte) main::j#1 ← -- (byte) main::j#2
(boolean~) main::$1 ← (byte) main::j#1 > (byte) 0
if((boolean~) main::$1) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@5
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$2 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$2) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#6 ← phi( nest1/(byte*) SCREEN#10 nest1::@3/(byte*) SCREEN#3 )
(byte) nest1::i#5 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte*) SCREEN#3 ← phi( nest1::@1/(byte*) SCREEN#6 nest1::@5/(byte*) SCREEN#3 )
(byte) nest1::i#2 ← phi( nest1::@1/(byte) nest1::i#5 nest1::@5/(byte) nest1::i#2 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
(byte) nest1::j#1 ← -- (byte) nest1::j#2
(boolean~) nest1::$1 ← (byte) nest1::j#1 > (byte) 0
if((boolean~) nest1::$1) goto nest1::@2
to:nest1::@3
nest1::@3: scope:[nest1] from nest1::@5
(byte) nest1::i#1 ← -- (byte) nest1::i#2
(boolean~) nest1::$2 ← (byte) nest1::i#1 > (byte) 0
if((boolean~) nest1::$2) goto nest1::@1
to:nest1::@return
nest1::@return: scope:[nest1] from nest1::@3
return
to:@return
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#4 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#2 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#1 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::i#2 ← phi( nest2::@1/(byte) nest2::i#4 nest2::@2/(byte) nest2::i#2 )
(byte*) SCREEN#1 ← phi( nest2::@1/(byte*) SCREEN#2 nest2::@2/(byte*) SCREEN#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
(boolean~) nest2::$0 ← (byte) nest2::j#1 > (byte) 0
@ -1021,18 +845,21 @@ Self Phi Eliminated (byte) nest2::i#2
Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#11 ← phi( main/(word) 1024 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#11 ← phi( main/(byte*) SCREEN#0 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
(byte) main::j#0 ← (byte) 100
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 )
(byte) main::i#2 ← phi( main::@1/(byte) main::i#5 )
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -1049,15 +876,17 @@ main::@return: scope:[main] from main::@3
return
to:@return
nest1: scope:[nest1] from main::@2
(byte) nest1::i#0 ← (byte) 100
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#6 ← phi( nest1/(byte*) SCREEN#10 nest1::@3/(byte*) SCREEN#3 )
(byte) nest1::i#5 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::i#5 ← phi( nest1/(byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::j#0 ← (byte) 100
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte*) SCREEN#3 ← phi( nest1::@1/(byte*) SCREEN#6 )
(byte) nest1::i#2 ← phi( nest1::@1/(byte) nest1::i#5 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -1074,15 +903,17 @@ nest1::@return: scope:[nest1] from nest1::@3
return
to:@return
nest2: scope:[nest2] from nest1::@2
(byte) nest2::i#0 ← (byte) 100
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#4 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#4 ← phi( nest2/(byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#2 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#1 )
(byte) nest2::j#0 ← (byte) 100
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::i#2 ← phi( nest2::@1/(byte) nest2::i#4 )
(byte*) SCREEN#1 ← phi( nest2::@1/(byte*) SCREEN#2 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
(boolean~) nest2::$0 ← (byte) nest2::j#1 > (byte) 0
@ -1106,19 +937,107 @@ Simple Condition (boolean~) nest2::$0 if((byte) nest2::j#1>(byte) 0) goto nest2:
Simple Condition (boolean~) nest2::$1 if((byte) nest2::i#1>(byte) 0) goto nest2::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#11 ← phi( main/(byte*) SCREEN#0 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
(byte) main::j#0 ← (byte) 100
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 )
(byte) main::i#2 ← phi( main::@1/(byte) main::i#5 )
(byte) main::j#2 ← phi( main::@1/(byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1>(byte) 0) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@5
(byte) main::i#1 ← -- (byte) main::i#2
if((byte) main::i#1>(byte) 0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest1: scope:[nest1] from main::@2
(byte) nest1::i#0 ← (byte) 100
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#6 ← phi( nest1/(byte*) SCREEN#10 nest1::@3/(byte*) SCREEN#3 )
(byte) nest1::i#5 ← phi( nest1/(byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::j#0 ← (byte) 100
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte*) SCREEN#3 ← phi( nest1::@1/(byte*) SCREEN#6 )
(byte) nest1::i#2 ← phi( nest1::@1/(byte) nest1::i#5 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
(byte) nest1::j#1 ← -- (byte) nest1::j#2
if((byte) nest1::j#1>(byte) 0) goto nest1::@2
to:nest1::@3
nest1::@3: scope:[nest1] from nest1::@5
(byte) nest1::i#1 ← -- (byte) nest1::i#2
if((byte) nest1::i#1>(byte) 0) goto nest1::@1
to:nest1::@return
nest1::@return: scope:[nest1] from nest1::@3
return
to:@return
nest2: scope:[nest2] from nest1::@2
(byte) nest2::i#0 ← (byte) 100
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#4 ← phi( nest2/(byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#2 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#1 )
(byte) nest2::j#0 ← (byte) 100
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::i#2 ← phi( nest2::@1/(byte) nest2::i#4 )
(byte*) SCREEN#1 ← phi( nest2::@1/(byte*) SCREEN#2 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
to:nest2::@3
nest2::@3: scope:[nest2] from nest2::@2
(byte) nest2::i#1 ← -- (byte) nest2::i#2
if((byte) nest2::i#1>(byte) 0) goto nest2::@1
to:nest2::@return
nest2::@return: scope:[nest2] from nest2::@3
return
to:@return
@end: scope:[] from @begin
Constant (const byte*) SCREEN#0
Constant (const byte) main::i#0
Constant (const byte) main::j#0
Constant (const byte) nest1::i#0
Constant (const byte) nest1::j#0
Constant (const byte) nest2::i#0
Constant (const byte) nest2::j#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#11 ← phi( main/(word) 1024 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#11 ← phi( main/(const byte*) SCREEN#0 main::@3/(byte*) SCREEN#10 )
(byte) main::i#5 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 )
(byte) main::i#2 ← phi( main::@1/(byte) main::i#5 )
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(const byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -1136,12 +1055,12 @@ nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#6 ← phi( nest1/(byte*) SCREEN#10 nest1::@3/(byte*) SCREEN#3 )
(byte) nest1::i#5 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::i#5 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte*) SCREEN#3 ← phi( nest1::@1/(byte*) SCREEN#6 )
(byte) nest1::i#2 ← phi( nest1::@1/(byte) nest1::i#5 )
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(const byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -1158,13 +1077,13 @@ nest1::@return: scope:[nest1] from nest1::@3
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#4 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#4 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#2 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#1 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::i#2 ← phi( nest2::@1/(byte) nest2::i#4 )
(byte*) SCREEN#1 ← phi( nest2::@1/(byte*) SCREEN#2 )
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
@ -1192,11 +1111,11 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#10 ← phi( main/(word) 1024 main::@3/(byte*) SCREEN#10 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#10 ← phi( main/(const byte*) SCREEN#0 main::@3/(byte*) SCREEN#10 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(const byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -1214,10 +1133,10 @@ nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#3 ← phi( nest1/(byte*) SCREEN#10 nest1::@3/(byte*) SCREEN#3 )
(byte) nest1::i#2 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(const byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -1234,11 +1153,11 @@ nest1::@return: scope:[nest1] from nest1::@3
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#2 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#1 ← phi( nest2/(byte*) SCREEN#3 nest2::@3/(byte*) SCREEN#1 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
@ -1263,11 +1182,11 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte*) SCREEN#10 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte*) SCREEN#10 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(const byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -1285,10 +1204,10 @@ nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#3 ← phi( nest1/(byte*) SCREEN#10 )
(byte) nest1::i#2 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(const byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -1305,11 +1224,11 @@ nest1::@return: scope:[nest1] from nest1::@3
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#2 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#1 ← phi( nest2/(byte*) SCREEN#3 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
@ -1323,8 +1242,8 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#10 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Constant (const byte*) SCREEN#10
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
@ -1332,10 +1251,10 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(const byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -1352,11 +1271,11 @@ main::@return: scope:[main] from main::@3
nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#3 ← phi( nest1/(word) 1024 )
(byte) nest1::i#2 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte*) SCREEN#3 ← phi( nest1/(const byte*) SCREEN#10 )
(byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(const byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -1373,11 +1292,11 @@ nest1::@return: scope:[nest1] from nest1::@3
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#2 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#1 ← phi( nest2/(byte*) SCREEN#3 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
@ -1400,10 +1319,10 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 )
(byte) main::j#2 ← phi( main::@1/(const byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
@ -1420,11 +1339,11 @@ main::@return: scope:[main] from main::@3
nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#1 ← phi( nest1/(word) 1024 )
(byte) nest1::i#2 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 )
(byte*) SCREEN#1 ← phi( nest1/(const byte*) SCREEN#10 )
(byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 )
(byte) nest1::j#2 ← phi( nest1::@1/(const byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
@ -1441,10 +1360,10 @@ nest1::@return: scope:[nest1] from nest1::@3
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#2 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 )
(byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
@ -1458,9 +1377,81 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (word) 1024
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#10
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@5
(byte) main::j#2 ← phi( main::@1/(const byte) main::j#0 main::@5/(byte) main::j#1 )
call nest1 param-assignment
to:main::@5
main::@5: scope:[main] from main::@2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1>(byte) 0) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@5
(byte) main::i#1 ← -- (byte) main::i#2
if((byte) main::i#1>(byte) 0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
nest1: scope:[nest1] from main::@2
to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
(byte) nest1::j#2 ← phi( nest1::@1/(const byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
call nest2 param-assignment
to:nest1::@5
nest1::@5: scope:[nest1] from nest1::@2
(byte) nest1::j#1 ← -- (byte) nest1::j#2
if((byte) nest1::j#1>(byte) 0) goto nest1::@2
to:nest1::@3
nest1::@3: scope:[nest1] from nest1::@5
(byte) nest1::i#1 ← -- (byte) nest1::i#2
if((byte) nest1::i#1>(byte) 0) goto nest1::@1
to:nest1::@return
nest1::@return: scope:[nest1] from nest1::@3
return
to:@return
nest2: scope:[nest2] from nest1::@2
to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((const byte*) SCREEN#10) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
to:nest2::@3
nest2::@3: scope:[nest2] from nest2::@2
(byte) nest2::i#1 ← -- (byte) nest2::i#2
if((byte) nest2::i#1>(byte) 0) goto nest2::@1
to:nest2::@return
nest2::@return: scope:[nest2] from nest2::@3
return
to:@return
@end: scope:[] from @begin
Constant inlined nest1::i#0 = (byte) 100
Constant inlined nest1::j#0 = (byte) 100
Constant inlined nest2::i#0 = (byte) 100
Constant inlined nest2::j#0 = (byte) 100
Constant inlined main::j#0 = (byte) 100
Constant inlined main::i#0 = (byte) 100
Constant inlined SCREEN#10 = (const byte*) SCREEN#0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
@ -1511,7 +1502,7 @@ nest2::@1: scope:[nest2] from nest2 nest2::@3
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 )
*((word) 1024) ← (byte) nest2::j#2
*((const byte*) SCREEN#0) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2
to:nest2::@3
@ -1528,6 +1519,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@2
@ -1636,7 +1628,7 @@ nest2::@1: scope:[nest2] from nest2 nest2::@5
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@6
(byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@6/(byte~) nest2::j#3 )
*((word) 1024) ← (byte) nest2::j#2
*((const byte*) SCREEN#0) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@6
to:nest2::@3
@ -1735,7 +1727,7 @@ nest2::@1: scope:[nest2] from nest2 nest2::@5
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@6
[25] (byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@6/(byte~) nest2::j#3 ) [ nest2::i#2 nest2::j#2 ]
[26] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ]
[26] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ]
[27] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ]
[28] if((byte) nest2::j#1>(byte) 0) goto nest2::@6 [ nest2::i#2 nest2::j#1 ]
to:nest2::@3
@ -1832,7 +1824,7 @@ nest2::@1: scope:[nest2] from nest2 nest2::@3
to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
[21] (byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 ) [ nest2::i#2 nest2::j#2 ]
[22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ]
[22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ]
[23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ]
[24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ]
to:nest2::@3
@ -1949,7 +1941,8 @@ Allocated zp ZP_BYTE:5 [ nest1::j#2 nest1::j#1 ]
Allocated zp ZP_BYTE:6 [ nest2::i#2 nest2::i#1 ]
Allocated zp ZP_BYTE:7 [ nest2::j#2 nest2::j#1 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -2095,9 +2088,9 @@ nest2: {
jmp b2
//SEG57 nest2::@2
b2:
//SEG58 [22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=zpby1
//SEG58 [22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=zpby1
lda j
sta $400
sta SCREEN
//SEG59 [23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ] -- zpby1=_dec_zpby1
dec j
//SEG60 [24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ] -- zpby1_gt_0_then_la1
@ -2159,7 +2152,8 @@ Removing instruction jmp b3
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -2287,8 +2281,8 @@ nest2: {
//SEG56 [21] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG57 nest2::@2
b2:
//SEG58 [22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty $400
//SEG58 [22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty SCREEN
//SEG59 [23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ] -- yby=_dec_yby
dey
//SEG60 [24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ] -- yby_gt_0_then_la1
@ -2327,7 +2321,8 @@ Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -2443,8 +2438,8 @@ nest2: {
//SEG56 [21] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG57 nest2::@2
b2:
//SEG58 [22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty $400
//SEG58 [22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty SCREEN
//SEG59 [23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ] -- yby=_dec_yby
dey
//SEG60 [24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ] -- yby_gt_0_then_la1
@ -2478,7 +2473,8 @@ Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -2583,8 +2579,8 @@ nest2: {
//SEG56 [21] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG57 nest2::@2
b2:
//SEG58 [22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty $400
//SEG58 [22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty SCREEN
//SEG59 [23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ] -- yby=_dec_yby
dey
//SEG60 [24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ] -- yby_gt_0_then_la1
@ -2609,7 +2605,8 @@ Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -2708,8 +2705,8 @@ nest2: {
//SEG56 [21] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG57 nest2::@2
b2:
//SEG58 [22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty $400
//SEG58 [22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty SCREEN
//SEG59 [23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ] -- yby=_dec_yby
dey
//SEG60 [24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ] -- yby_gt_0_then_la1
@ -2730,6 +2727,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@2
@ -2774,7 +2772,8 @@ reg byte x [ nest2::i#2 nest2::i#1 ]
reg byte y [ nest2::j#2 nest2::j#1 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -2873,8 +2872,8 @@ nest2: {
//SEG56 [21] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG57 nest2::@2
b2:
//SEG58 [22] *((word) 1024) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty $400
//SEG58 [22] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 [ nest2::i#2 nest2::j#2 ] -- _star_cowo1=yby
sty SCREEN
//SEG59 [23] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::i#2 nest2::j#1 ] -- yby=_dec_yby
dey
//SEG60 [24] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::i#2 nest2::j#1 ] -- yby_gt_0_then_la1

View File

@ -1,6 +1,7 @@
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@1
(label) main::@2

View File

@ -316,44 +316,6 @@ main::@return: scope:[main] from main::@1
to:@return
@end: scope:[] from @begin
Constant (byte) main::i#0 (byte) 100
Constant (byte) main::s#0 (byte) 0
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@4 main::@8
(byte) main::s#6 ← phi( main/(byte) 0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@4/(byte) main::i#4 main::@8/(byte) main::i#5 )
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
(byte) main::s#5 ← phi( main::@1/(byte) main::s#6 )
(byte) main::i#3 ← phi( main::@1/(byte) main::i#1 )
(boolean~) main::$1 ← (byte) main::i#3 > (byte) 50
(boolean~) main::$2 ← ! (boolean~) main::$1
if((boolean~) main::$2) goto main::@4
to:main::@8
main::@4: scope:[main] from main::@2
(byte) main::i#4 ← phi( main::@2/(byte) main::i#3 )
(byte) main::s#3 ← phi( main::@2/(byte) main::s#5 )
(byte) main::s#1 ← -- (byte) main::s#3
to:main::@1
main::@8: scope:[main] from main::@2
(byte) main::i#5 ← phi( main::@2/(byte) main::i#3 )
(byte) main::s#4 ← phi( main::@2/(byte) main::s#5 )
(byte) main::s#2 ← ++ (byte) main::s#4
to:main::@1
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
Inversing boolean not (boolean~) main::$2 ← (byte) main::i#3 <= (byte) 50 from (boolean~) main::$1 ← (byte) main::i#3 > (byte) 50
Succesful SSA optimization Pass2UnaryNotSimplification
CONTROL FLOW GRAPH
@ -361,10 +323,12 @@ CONTROL FLOW GRAPH
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
(byte) main::s#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@4 main::@8
(byte) main::s#6 ← phi( main/(byte) 0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@4/(byte) main::i#4 main::@8/(byte) main::i#5 )
(byte) main::s#6 ← phi( main/(byte) main::s#0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#4 main::@8/(byte) main::i#5 )
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$0) goto main::@2
@ -398,10 +362,12 @@ CONTROL FLOW GRAPH
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
(byte) main::s#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@4 main::@8
(byte) main::s#3 ← phi( main/(byte) 0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(byte) 100 main::@4/(byte) main::i#1 main::@8/(byte) main::i#1 )
(byte) main::s#3 ← phi( main/(byte) main::s#0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#1 main::@8/(byte) main::i#1 )
(byte) main::i#1 ← -- (byte) main::i#2
(boolean~) main::$0 ← (byte) main::i#1 > (byte) 0
if((boolean~) main::$0) goto main::@2
@ -425,6 +391,66 @@ Simple Condition (boolean~) main::$0 if((byte) main::i#1>(byte) 0) goto main::@2
Simple Condition (boolean~) main::$2 if((byte) main::i#1<=(byte) 50) goto main::@4
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 100
(byte) main::s#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@4 main::@8
(byte) main::s#3 ← phi( main/(byte) main::s#0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#1 main::@8/(byte) main::i#1 )
(byte) main::i#1 ← -- (byte) main::i#2
if((byte) main::i#1>(byte) 0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
if((byte) main::i#1<=(byte) 50) goto main::@4
to:main::@8
main::@4: scope:[main] from main::@2
(byte) main::s#1 ← -- (byte) main::s#3
to:main::@1
main::@8: scope:[main] from main::@2
(byte) main::s#2 ← ++ (byte) main::s#3
to:main::@1
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
Constant (const byte) main::i#0
Constant (const byte) main::s#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@4 main::@8
(byte) main::s#3 ← phi( main/(const byte) main::s#0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@4/(byte) main::i#1 main::@8/(byte) main::i#1 )
(byte) main::i#1 ← -- (byte) main::i#2
if((byte) main::i#1>(byte) 0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
if((byte) main::i#1<=(byte) 50) goto main::@4
to:main::@8
main::@4: scope:[main] from main::@2
(byte) main::s#1 ← -- (byte) main::s#3
to:main::@1
main::@8: scope:[main] from main::@2
(byte) main::s#2 ← ++ (byte) main::s#3
to:main::@1
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
Constant inlined main::s#0 = (byte) 0
Constant inlined main::i#0 = (byte) 100
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
@ -623,7 +649,7 @@ Complete equivalence classes
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::s#3 main::s#1 main::s#2 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -699,7 +725,7 @@ Removing instruction jmp breturn
Removing instruction jmp b8
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -755,7 +781,7 @@ Removing instruction main_from_bbegin:
Removing instruction b1_from_b4:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -811,7 +837,7 @@ Removing instruction breturn:
Removing instruction b8:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -876,7 +902,7 @@ reg byte x [ main::i#2 main::i#1 ]
reg byte y [ main::s#3 main::s#1 main::s#2 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main

View File

@ -1,12 +1,13 @@
jsr main
main: {
.const SCREEN = $400
ldx #$2
b1:
cpx #$a
bcc b2
rts
b2:
lda $400,x
lda SCREEN,x
inx
jmp b1
}

View File

@ -13,6 +13,6 @@ main::@return: scope:[main] from main::@1
[4] return [ ]
to:@return
main::@2: scope:[main] from main::@1
[5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ]
[5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ]
[6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
to:main::@1

View File

@ -243,33 +243,6 @@ main::@return: scope:[main] from main::@1
to:@return
@end: scope:[] from @begin
Constant (byte[1024]) main::SCREEN#0 (word) 1024
Constant (byte) main::i#0 (byte) 2
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
(byte[1024]) main::SCREEN#2 ← phi( main/(word) 1024 main::@2/(byte[1024]) main::SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 2 main::@2/(byte) main::i#1 )
(boolean~) main::$0 ← (byte) main::i#2 < (byte) 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
return
to:@return
@end: scope:[] from @begin
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
@ -279,10 +252,12 @@ CONTROL FLOW GRAPH
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte[1024]) main::SCREEN#0 ← (word) 1024
(byte) main::i#0 ← (byte) 2
to:main::@1
main::@1: scope:[main] from main main::@2
(byte[1024]) main::SCREEN#1 ← phi( main/(word) 1024 main::@2/(byte[1024]) main::SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 2 main::@2/(byte) main::i#1 )
(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) 10
if((boolean~) main::$0) goto main::@2
to:main::@return
@ -302,10 +277,12 @@ CONTROL FLOW GRAPH
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte[1024]) main::SCREEN#0 ← (word) 1024
(byte) main::i#0 ← (byte) 2
to:main::@1
main::@1: scope:[main] from main main::@2
(byte[1024]) main::SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 2 main::@2/(byte) main::i#1 )
(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) 10
if((boolean~) main::$0) goto main::@2
to:main::@return
@ -325,10 +302,12 @@ CONTROL FLOW GRAPH
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte[1024]) main::SCREEN#0 ← (word) 1024
(byte) main::i#0 ← (byte) 2
to:main::@1
main::@1: scope:[main] from main main::@2
(byte[1024]) main::SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 2 main::@2/(byte) main::i#1 )
(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 )
if((byte) main::i#2<(byte) 10) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
@ -340,8 +319,52 @@ main::@return: scope:[main] from main::@1
to:@return
@end: scope:[] from @begin
Constant (byte[1024]) main::SCREEN#1 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Constant (const byte[1024]) main::SCREEN#0
Constant (const byte) main::i#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
(byte[1024]) main::SCREEN#1 ← phi( main/(const byte[1024]) main::SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@2/(byte) main::i#1 )
if((byte) main::i#2<(byte) 10) 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
@end: scope:[] from @begin
Redundant Phi (byte[1024]) main::SCREEN#1 (const byte[1024]) main::SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@2/(byte) main::i#1 )
if((byte) main::i#2<(byte) 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
return
to:@return
@end: scope:[] from @begin
Constant inlined main::i#0 = (byte) 2
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
@ -353,7 +376,7 @@ main::@1: scope:[main] from main main::@2
if((byte) main::i#2<(byte) 10) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
(byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2
(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
@ -361,8 +384,6 @@ main::@return: scope:[main] from main::@1
to:@return
@end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
FINAL SYMBOL TABLE
(label) @begin
(label) @end
@ -371,6 +392,7 @@ FINAL SYMBOL TABLE
(label) main::@2
(label) main::@return
(byte[1024]) main::SCREEN
(const byte[1024]) main::SCREEN#0 = (word) 1024
(byte) main::b
(byte) main::b#0
(byte) main::i
@ -394,7 +416,7 @@ main::@return: scope:[main] from main::@1
return
to:@return
main::@2: scope:[main] from main::@1
(byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2
(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
@ -421,7 +443,7 @@ main::@return: scope:[main] from main::@1
[4] return [ ]
to:@return
main::@2: scope:[main] from main::@1
[5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ]
[5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ]
[6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[7] (byte~) main::i#4 ← (byte) main::i#1 [ main::i#4 ]
to:main::@1
@ -449,7 +471,7 @@ main::@return: scope:[main] from main::@1
[4] return [ ]
to:@return
main::@2: scope:[main] from main::@1
[5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ]
[5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ]
[6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
to:main::@1
@ -491,7 +513,7 @@ Complete equivalence classes
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::b#0 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -503,6 +525,7 @@ main_from_bbegin:
bend:
//SEG5 main
main: {
.const SCREEN = $400
.label b = 3
.label i = 2
//SEG6 [2] phi from main to main::@1
@ -524,9 +547,9 @@ main: {
rts
//SEG12 main::@2
b2:
//SEG13 [5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ] -- zpby1=cowo1_staridx_zpby2
//SEG13 [5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] -- zpby1=cowo1_staridx_zpby2
ldx i
lda $400,x
lda SCREEN,x
sta b
//SEG14 [6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1
inc i
@ -551,7 +574,7 @@ Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -562,6 +585,7 @@ main_from_bbegin:
bend:
//SEG5 main
main: {
.const SCREEN = $400
//SEG6 [2] phi from main to main::@1
b1_from_main:
//SEG7 [2] phi (byte) main::i#2 = (byte) 2 -- xby=coby1
@ -577,8 +601,8 @@ main: {
rts
//SEG12 main::@2
b2:
//SEG13 [5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda $400,x
//SEG13 [5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda SCREEN,x
//SEG14 [6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG15 [2] phi from main::@2 to main::@1
@ -590,7 +614,7 @@ main: {
Removing instruction main_from_bbegin:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -600,6 +624,7 @@ bbegin:
bend:
//SEG5 main
main: {
.const SCREEN = $400
//SEG6 [2] phi from main to main::@1
b1_from_main:
//SEG7 [2] phi (byte) main::i#2 = (byte) 2 -- xby=coby1
@ -615,8 +640,8 @@ main: {
rts
//SEG12 main::@2
b2:
//SEG13 [5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda $400,x
//SEG13 [5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda SCREEN,x
//SEG14 [6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG15 [2] phi from main::@2 to main::@1
@ -632,7 +657,7 @@ Removing instruction breturn:
Removing instruction b1_from_b2:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -640,6 +665,7 @@ ASSEMBLER
//SEG4 @end
//SEG5 main
main: {
.const SCREEN = $400
//SEG6 [2] phi from main to main::@1
//SEG7 [2] phi (byte) main::i#2 = (byte) 2 -- xby=coby1
ldx #$2
@ -653,8 +679,8 @@ main: {
rts
//SEG12 main::@2
b2:
//SEG13 [5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda $400,x
//SEG13 [5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda SCREEN,x
//SEG14 [6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG15 [2] phi from main::@2 to main::@1
@ -670,6 +696,7 @@ FINAL SYMBOL TABLE
(label) main::@2
(label) main::@return
(byte[1024]) main::SCREEN
(const byte[1024]) main::SCREEN#0 = (word) 1024
(byte) main::b
(byte) main::b#0 reg byte a 110.0
(byte) main::i
@ -680,7 +707,7 @@ reg byte x [ main::i#2 main::i#1 ]
reg byte a [ main::b#0 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -688,6 +715,7 @@ FINAL CODE
//SEG4 @end
//SEG5 main
main: {
.const SCREEN = $400
//SEG6 [2] phi from main to main::@1
//SEG7 [2] phi (byte) main::i#2 = (byte) 2 -- xby=coby1
ldx #$2
@ -701,8 +729,8 @@ main: {
rts
//SEG12 main::@2
b2:
//SEG13 [5] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda $400,x
//SEG13 [5] (byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
lda SCREEN,x
//SEG14 [6] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx
//SEG15 [2] phi from main::@2 to main::@1

View File

@ -5,6 +5,7 @@
(label) main::@2
(label) main::@return
(byte[1024]) main::SCREEN
(const byte[1024]) main::SCREEN#0 = (word) 1024
(byte) main::b
(byte) main::b#0 reg byte a 110.0
(byte) main::i

View File

@ -274,56 +274,6 @@ INITIAL SSA SYMBOL TABLE
(byte) sum::return#7
(byte) sum::return#8
Constant (byte) sum::a#0 (byte) 1
Constant (byte) sum::b#0 (byte) 2
Constant (byte) sum::a#1 (byte) 3
Constant (byte) sum::b#1 (byte) 4
Constant (byte) sum::a#2 (byte) 9
Constant (byte) sum::b#2 (byte) 13
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call sum param-assignment
(byte) sum::return#0 ← (byte) sum::return#4
to:@2
@2: scope:[] from @begin
(byte) sum::return#5 ← phi( @begin/(byte) sum::return#0 )
(byte~) $0 ← (byte) sum::return#5
(byte) s1#0 ← (byte~) $0
call sum param-assignment
(byte) sum::return#1 ← (byte) sum::return#4
to:@3
@3: scope:[] from @2
(byte) s1#2 ← phi( @2/(byte) s1#0 )
(byte) sum::return#6 ← phi( @2/(byte) sum::return#1 )
(byte~) $1 ← (byte) sum::return#6
(byte) s2#0 ← (byte~) $1
call sum param-assignment
(byte) sum::return#2 ← (byte) sum::return#4
to:@4
@4: scope:[] from @3
(byte) s2#1 ← phi( @3/(byte) s2#0 )
(byte) s1#1 ← phi( @3/(byte) s1#2 )
(byte) sum::return#7 ← phi( @3/(byte) sum::return#2 )
(byte~) $2 ← (byte) sum::return#7
(byte) s3#0 ← (byte~) $2
(byte~) $3 ← (byte) s1#1 + (byte) s2#1
(byte~) $4 ← (byte~) $3 + (byte) s3#0
(byte) s4#0 ← (byte~) $4
to:@end
sum: scope:[sum] from @2 @3 @begin
(byte) sum::b#3 ← phi( @2/(byte) 4 @3/(byte) 13 @begin/(byte) 2 )
(byte) sum::a#3 ← phi( @2/(byte) 3 @3/(byte) 9 @begin/(byte) 1 )
(byte~) sum::$0 ← (byte) sum::a#3 + (byte) sum::b#3
(byte) sum::return#3 ← (byte~) sum::$0
to:sum::@return
sum::@return: scope:[sum] from sum
(byte) sum::return#8 ← phi( sum/(byte) sum::return#3 )
(byte) sum::return#4 ← (byte) sum::return#8
return
to:@return
@end: scope:[] from @4
Not aliassing across scopes: $0 sum::return#5
Not aliassing across scopes: $1 sum::return#6
Not aliassing across scopes: $2 sum::return#7
@ -334,6 +284,83 @@ Alias (byte) s3#0 = (byte~) $2
Alias (byte) s4#0 = (byte~) $4
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) sum::a#0 ← (byte) 1
(byte) sum::b#0 ← (byte) 2
call sum param-assignment
to:@2
@2: scope:[] from @begin
(byte) s1#0 ← (byte) sum::return#0
(byte) sum::a#1 ← (byte) 3
(byte) sum::b#1 ← (byte) 4
call sum param-assignment
to:@3
@3: scope:[] from @2
(byte) s2#0 ← (byte) sum::return#0
(byte) sum::a#2 ← (byte) 9
(byte) sum::b#2 ← (byte) 13
call sum param-assignment
to:@4
@4: scope:[] from @3
(byte) s3#0 ← (byte) sum::return#0
(byte~) $3 ← (byte) s1#0 + (byte) s2#0
(byte) s4#0 ← (byte~) $3 + (byte) s3#0
to:@end
sum: scope:[sum] from @2 @3 @begin
(byte) sum::b#3 ← phi( @2/(byte) sum::b#1 @3/(byte) sum::b#2 @begin/(byte) sum::b#0 )
(byte) sum::a#3 ← phi( @2/(byte) sum::a#1 @3/(byte) sum::a#2 @begin/(byte) sum::a#0 )
(byte) sum::return#0 ← (byte) sum::a#3 + (byte) sum::b#3
to:sum::@return
sum::@return: scope:[sum] from sum
return
to:@return
@end: scope:[] from @4
Constant (const byte) sum::a#0
Constant (const byte) sum::b#0
Constant (const byte) sum::a#1
Constant (const byte) sum::b#1
Constant (const byte) sum::a#2
Constant (const byte) sum::b#2
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call sum param-assignment
to:@2
@2: scope:[] from @begin
(byte) s1#0 ← (byte) sum::return#0
call sum param-assignment
to:@3
@3: scope:[] from @2
(byte) s2#0 ← (byte) sum::return#0
call sum param-assignment
to:@4
@4: scope:[] from @3
(byte) s3#0 ← (byte) sum::return#0
(byte~) $3 ← (byte) s1#0 + (byte) s2#0
(byte) s4#0 ← (byte~) $3 + (byte) s3#0
to:@end
sum: scope:[sum] from @2 @3 @begin
(byte) sum::b#3 ← phi( @2/(const byte) sum::b#1 @3/(const byte) sum::b#2 @begin/(const byte) sum::b#0 )
(byte) sum::a#3 ← phi( @2/(const byte) sum::a#1 @3/(const byte) sum::a#2 @begin/(const byte) sum::a#0 )
(byte) sum::return#0 ← (byte) sum::a#3 + (byte) sum::b#3
to:sum::@return
sum::@return: scope:[sum] from sum
return
to:@return
@end: scope:[] from @4
Not aliassing across scopes: s1#0 sum::return#0
Not aliassing across scopes: s2#0 sum::return#0
Not aliassing across scopes: s3#0 sum::return#0
Constant inlined sum::a#0 = (byte) 1
Constant inlined sum::a#1 = (byte) 3
Constant inlined sum::a#2 = (byte) 9
Constant inlined sum::b#0 = (byte) 2
Constant inlined sum::b#1 = (byte) 4
Constant inlined sum::b#2 = (byte) 13
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call sum param-assignment
to:@2
@ -360,9 +387,6 @@ sum::@return: scope:[sum] from sum
to:@return
@end: scope:[] from @4
Not aliassing across scopes: s1#0 sum::return#0
Not aliassing across scopes: s2#0 sum::return#0
Not aliassing across scopes: s3#0 sum::return#0
FINAL SYMBOL TABLE
(byte~) $3
(label) @2
@ -549,7 +573,7 @@ Allocated zp ZP_BYTE:7 [ $3 ]
Allocated zp ZP_BYTE:8 [ s4#0 ]
Allocated zp ZP_BYTE:9 [ sum::return#0 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label _3 = 7
.label s1 = 4
.label s2 = 5
@ -664,7 +688,7 @@ Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label s1 = 2
.label s3 = 3
//SEG1 @begin
@ -729,7 +753,7 @@ sum: {
Removing instruction sum_from_bbegin:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label s1 = 2
.label s3 = 3
//SEG1 @begin
@ -800,7 +824,7 @@ Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label s1 = 2
.label s3 = 3
//SEG1 @begin
@ -887,7 +911,7 @@ reg byte a [ s4#0 ]
reg byte a [ sum::return#0 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.label s1 = 2
.label s3 = 3
//SEG1 @begin

View File

@ -1,6 +1,7 @@
.const SCREEN = $400
jsr main
main: {
lda #$1
sta $400
sta SCREEN
rts
}

View File

@ -3,7 +3,7 @@
to:@end
@end: scope:[] from @begin
main: scope:[main] from @begin
[1] *((word) 1024) ← (byte) 1 [ ]
[1] *((const byte*) SCREEN#0) ← (byte) 1 [ ]
to:main::@return
main::@return: scope:[main] from main
[2] return [ ]

View File

@ -124,29 +124,29 @@ main::@return: scope:[main] from main
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#0 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Alias (byte*) SCREEN#0 = (byte*) SCREEN#1
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN#0 ← (word) 1024
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#1 ← phi( @begin/(word) 1024 )
*((byte*) SCREEN#1) ← (byte) 1
*((byte*) SCREEN#0) ← (byte) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (word) 1024
Succesful SSA optimization Pass2RedundantPhiElimination
Constant (const byte*) SCREEN#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
*((word) 1024) ← (byte) 1
*((const byte*) SCREEN#0) ← (byte) 1
to:main::@return
main::@return: scope:[main] from main
return
@ -157,6 +157,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@return
@ -168,7 +169,7 @@ CONTROL FLOW GRAPH - PHI LIFTED
to:@end
@end: scope:[] from @begin
main: scope:[main] from @begin
*((word) 1024) ← (byte) 1
*((const byte*) SCREEN#0) ← (byte) 1
to:main::@return
main::@return: scope:[main] from main
return
@ -184,7 +185,7 @@ CONTROL FLOW GRAPH - LIVE RANGES FOUND
to:@end
@end: scope:[] from @begin
main: scope:[main] from @begin
[1] *((word) 1024) ← (byte) 1 [ ]
[1] *((const byte*) SCREEN#0) ← (byte) 1 [ ]
to:main::@return
main::@return: scope:[main] from main
[2] return [ ]
@ -200,7 +201,7 @@ CONTROL FLOW GRAPH - PHI MEM COALESCED
to:@end
@end: scope:[] from @begin
main: scope:[main] from @begin
[1] *((word) 1024) ← (byte) 1 [ ]
[1] *((const byte*) SCREEN#0) ← (byte) 1 [ ]
to:main::@return
main::@return: scope:[main] from main
[2] return [ ]
@ -226,7 +227,8 @@ VARIABLE REGISTER WEIGHTS
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -236,9 +238,9 @@ bbegin:
bend:
//SEG4 main
main: {
//SEG5 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
//SEG5 [1] *((const byte*) SCREEN#0) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1
sta $400
sta SCREEN
jmp breturn
//SEG6 main::@return
breturn:
@ -246,8 +248,8 @@ main: {
rts
}
Statement [1] *((word) 1024) ← (byte) 1 [ ] always clobbers reg byte a
Statement [1] *((word) 1024) ← (byte) 1 [ ] always clobbers reg byte a
Statement [1] *((const byte*) SCREEN#0) ← (byte) 1 [ ] always clobbers reg byte a
Statement [1] *((const byte*) SCREEN#0) ← (byte) 1 [ ] always clobbers reg byte a
REGISTER UPLIFT POTENTIAL REGISTERS
REGISTER UPLIFT SCOPES
@ -260,7 +262,8 @@ Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -269,9 +272,9 @@ bbegin:
bend:
//SEG4 main
main: {
//SEG5 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
//SEG5 [1] *((const byte*) SCREEN#0) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1
sta $400
sta SCREEN
//SEG6 main::@return
breturn:
//SEG7 [2] return [ ]
@ -283,16 +286,17 @@ Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
jsr main
//SEG3 @end
//SEG4 main
main: {
//SEG5 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
//SEG5 [1] *((const byte*) SCREEN#0) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1
sta $400
sta SCREEN
//SEG6 main::@return
//SEG7 [2] return [ ]
rts
@ -302,21 +306,23 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@return
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
jsr main
//SEG3 @end
//SEG4 main
main: {
//SEG5 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
//SEG5 [1] *((const byte*) SCREEN#0) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1
sta $400
sta SCREEN
//SEG6 main::@return
//SEG7 [2] return [ ]
rts

View File

@ -1,6 +1,7 @@
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(void()) main()
(label) main::@return

View File

@ -1,3 +1,5 @@
.const SCREEN = $400
.const SCREEN2 = $400+$28
jsr main
main: {
ldy #$0
@ -11,7 +13,7 @@ main: {
sty sum.a
sta sum.c
jsr sum
sta $400,y
sta SCREEN,y
tya
tax
inx
@ -21,7 +23,7 @@ main: {
sty sum2.a
sta sum2.c
jsr sum2
sta $428,y
sta SCREEN2,y
iny
cpy #$b
bne b1

View File

@ -16,7 +16,7 @@ main::@1: scope:[main] from main main::@4
to:main::@3
main::@3: scope:[main] from main::@1
[9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
[10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ]
[10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ]
[11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ]
[12] (byte~) main::$4 ← (byte) main::i#2 + (byte) 2 [ main::i#2 main::$3 main::$4 ]
[13] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 main::$3 main::$4 sum2::a#0 ]
@ -26,7 +26,7 @@ main::@3: scope:[main] from main::@1
to:main::@4
main::@4: scope:[main] from main::@3
[17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
[18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ]
[18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ]
[19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ]
to:main::@return

View File

@ -588,92 +588,6 @@ sum2::@return: scope:[sum2] from sum2
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN#0 (word) 1024
Constant (word~) $0 (word) 1064
Constant (byte) main::i#0 (byte) 0
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN2#0 ← (word) 1064
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN2#4 ← phi( @begin/(byte*) SCREEN2#0 )
(byte*) SCREEN#3 ← phi( @begin/(word) 1024 )
to:main::@1
main::@1: scope:[main] from main main::@4
(byte*) SCREEN2#3 ← phi( main/(byte*) SCREEN2#4 main::@4/(byte*) SCREEN2#1 )
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 main::@4/(byte*) SCREEN#4 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
(byte) sum::b#0 ← (byte~) main::$0
(byte) sum::c#0 ← (byte~) main::$1
call sum param-assignment
(byte) sum::return#0 ← (byte) sum::return#2
to:main::@3
main::@3: scope:[main] from main::@1
(byte*) SCREEN2#2 ← phi( main::@1/(byte*) SCREEN2#3 )
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
(byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#2 )
(byte) sum::return#3 ← phi( main::@1/(byte) sum::return#0 )
(byte~) main::$2 ← (byte) sum::return#3
*((byte*) SCREEN#1 + (byte) main::i#3) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#3 + (byte) 1
(byte~) main::$4 ← (byte) main::i#3 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#3
(byte) sum2::b#0 ← (byte~) main::$3
(byte) sum2::c#0 ← (byte~) main::$4
call sum2 param-assignment
(byte) sum2::return#0 ← (byte) sum2::return#2
to:main::@4
main::@4: scope:[main] from main::@3
(byte*) SCREEN#4 ← phi( main::@3/(byte*) SCREEN#1 )
(byte) main::i#4 ← phi( main::@3/(byte) main::i#3 )
(byte*) SCREEN2#1 ← phi( main::@3/(byte*) SCREEN2#2 )
(byte) sum2::return#3 ← phi( main::@3/(byte) sum2::return#0 )
(byte~) main::$5 ← (byte) sum2::return#3
*((byte*) SCREEN2#1 + (byte) main::i#4) ← (byte~) main::$5
(byte) main::i#1 ← ++ (byte) main::i#4
(boolean~) main::$6 ← (byte) main::i#1 != (byte) 11
if((boolean~) main::$6) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@4
return
to:@return
sum: scope:[sum] from main::@1
(byte) sum::c#1 ← phi( main::@1/(byte) sum::c#0 )
(byte) sum::b#1 ← phi( main::@1/(byte) sum::b#0 )
(byte) sum::a#1 ← phi( main::@1/(byte) sum::a#0 )
(byte~) sum::$0 ← (byte) sum::a#1 + (byte) sum::b#1
(byte~) sum::$1 ← (byte~) sum::$0 + (byte) sum::c#1
(byte) sum::return#1 ← (byte~) sum::$1
to:sum::@return
sum::@return: scope:[sum] from sum
(byte) sum::return#4 ← phi( sum/(byte) sum::return#1 )
(byte) sum::return#2 ← (byte) sum::return#4
return
to:@return
sum2: scope:[sum2] from main::@3
(byte) sum2::c#1 ← phi( main::@3/(byte) sum2::c#0 )
(byte) sum2::b#1 ← phi( main::@3/(byte) sum2::b#0 )
(byte) sum2::a#1 ← phi( main::@3/(byte) sum2::a#0 )
(byte~) sum2::$0 ← (byte) sum2::a#1 + (byte) sum2::b#1
(byte~) sum2::$1 ← (byte~) sum2::$0 + (byte) sum2::c#1
(byte) sum2::return#1 ← (byte~) sum2::$1
to:sum2::@return
sum2::@return: scope:[sum2] from sum2
(byte) sum2::return#4 ← phi( sum2/(byte) sum2::return#1 )
(byte) sum2::return#2 ← (byte) sum2::return#4
return
to:@return
@end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#3
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#3
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::b#0 main::$0
Not aliassing across scopes: sum::c#0 main::$1
@ -682,7 +596,8 @@ Not aliassing across scopes: sum2::a#0 main::i#3
Not aliassing across scopes: sum2::b#0 main::$3
Not aliassing across scopes: sum2::c#0 main::$4
Not aliassing across scopes: main::$5 sum2::return#3
Alias (byte*) SCREEN2#0 = (byte*) SCREEN2#4
Alias (byte*) SCREEN2#0 = (word~) $0 (byte*) SCREEN2#4
Alias (byte*) SCREEN#0 = (byte*) SCREEN#3
Alias (byte) sum::return#0 = (byte) sum::return#2 (byte) sum::return#3 (byte) sum::return#1 (byte~) sum::$1 (byte) sum::return#4
Alias (byte*) SCREEN#1 = (byte*) SCREEN#2 (byte*) SCREEN#4
Alias (byte) main::i#2 = (byte) main::i#3 (byte) main::i#4
@ -697,72 +612,17 @@ Alias (byte) sum2::c#0 = (byte) sum2::c#1
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN2#0 ← (word) 1064
(byte*) SCREEN#0 ← (word) 1024
(byte*) SCREEN2#0 ← (word) 1024 + (byte) 40
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte*) SCREEN#3 ← phi( @begin/(word) 1024 )
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@4
(byte*) SCREEN2#1 ← phi( main/(byte*) SCREEN2#0 main::@4/(byte*) SCREEN2#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#3 main::@4/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
(byte) sum::b#0 ← (byte~) main::$0
(byte) sum::c#0 ← (byte~) main::$1
call sum param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
(byte~) main::$2 ← (byte) sum::return#0
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#2 + (byte) 1
(byte~) main::$4 ← (byte) main::i#2 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#2
(byte) sum2::b#0 ← (byte~) main::$3
(byte) sum2::c#0 ← (byte~) main::$4
call sum2 param-assignment
to:main::@4
main::@4: scope:[main] from main::@3
(byte~) main::$5 ← (byte) sum2::return#0
*((byte*) SCREEN2#1 + (byte) main::i#2) ← (byte~) main::$5
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$6 ← (byte) main::i#1 != (byte) 11
if((boolean~) main::$6) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@4
return
to:@return
sum: scope:[sum] from main::@1
(byte~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0
(byte) sum::return#0 ← (byte~) sum::$0 + (byte) sum::c#0
to:sum::@return
sum::@return: scope:[sum] from sum
return
to:@return
sum2: scope:[sum2] from main::@3
(byte~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0
(byte) sum2::return#0 ← (byte~) sum2::$0 + (byte) sum2::c#0
to:sum2::@return
sum2::@return: scope:[sum2] from sum2
return
to:@return
@end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#3 (word) 1024
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN2#0 ← (word) 1064
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@4
(byte*) SCREEN2#1 ← phi( main/(byte*) SCREEN2#0 main::@4/(byte*) SCREEN2#1 )
(byte*) SCREEN#1 ← phi( main/(word) 1024 main::@4/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 main::@4/(byte*) SCREEN#1 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
@ -811,15 +671,17 @@ Self Phi Eliminated (byte*) SCREEN2#1
Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN2#0 ← (word) 1064
(byte*) SCREEN#0 ← (word) 1024
(byte*) SCREEN2#0 ← (word) 1024 + (byte) 40
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@4
(byte*) SCREEN2#1 ← phi( main/(byte*) SCREEN2#0 )
(byte*) SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
@ -867,15 +729,17 @@ Simple Condition (boolean~) main::$6 if((byte) main::i#1!=(byte) 11) goto main::
Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN2#0 ← (word) 1064
(byte*) SCREEN#0 ← (word) 1024
(byte*) SCREEN2#0 ← (word) 1024 + (byte) 40
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@4
(byte*) SCREEN2#1 ← phi( main/(byte*) SCREEN2#0 )
(byte*) SCREEN#1 ← phi( main/(word) 1024 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
@ -918,9 +782,10 @@ sum2::@return: scope:[sum2] from sum2
to:@return
@end: scope:[] from @begin
Constant (byte*) SCREEN2#0 (word) 1064
Constant (byte*) SCREEN#1 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
Constant (const byte*) SCREEN#0
Constant (const byte*) SCREEN2#0
Constant (const byte) main::i#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
@ -928,8 +793,9 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@4
(byte*) SCREEN2#1 ← phi( main/(word) 1064 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte*) SCREEN2#1 ← phi( main/(const byte*) SCREEN2#0 )
(byte*) SCREEN#1 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
@ -939,7 +805,7 @@ main::@1: scope:[main] from main main::@4
to:main::@3
main::@3: scope:[main] from main::@1
(byte~) main::$2 ← (byte) sum::return#0
*((word) 1024 + (byte) main::i#2) ← (byte~) main::$2
*((byte*) SCREEN#1 + (byte) main::i#2) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#2 + (byte) 1
(byte~) main::$4 ← (byte) main::i#2 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#2
@ -972,11 +838,6 @@ sum2::@return: scope:[sum2] from sum2
to:@return
@end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::b#0 main::$0
Not aliassing across scopes: sum::c#0 main::$1
@ -985,7 +846,8 @@ Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::b#0 main::$3
Not aliassing across scopes: sum2::c#0 main::$4
Not aliassing across scopes: main::$5 sum2::return#0
Redundant Phi (byte*) SCREEN2#1 (word) 1064
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0
Redundant Phi (byte*) SCREEN2#1 (const byte*) SCREEN2#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
@ -994,7 +856,7 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@4
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
@ -1004,7 +866,7 @@ main::@1: scope:[main] from main main::@4
to:main::@3
main::@3: scope:[main] from main::@1
(byte~) main::$2 ← (byte) sum::return#0
*((word) 1024 + (byte) main::i#2) ← (byte~) main::$2
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#2 + (byte) 1
(byte~) main::$4 ← (byte) main::i#2 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#2
@ -1014,7 +876,7 @@ main::@3: scope:[main] from main::@1
to:main::@4
main::@4: scope:[main] from main::@3
(byte~) main::$5 ← (byte) sum2::return#0
*((word) 1064 + (byte) main::i#2) ← (byte~) main::$5
*((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 11) goto main::@1
to:main::@return
@ -1037,12 +899,6 @@ sum2::@return: scope:[sum2] from sum2
to:@return
@end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::b#0 main::$0
Not aliassing across scopes: sum::c#0 main::$1
@ -1051,11 +907,65 @@ Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::b#0 main::$3
Not aliassing across scopes: sum2::c#0 main::$4
Not aliassing across scopes: main::$5 sum2::return#0
Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@4
(byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 1
(byte~) main::$1 ← (byte) main::i#2 + (byte) 2
(byte) sum::a#0 ← (byte) main::i#2
(byte) sum::b#0 ← (byte~) main::$0
(byte) sum::c#0 ← (byte~) main::$1
call sum param-assignment
to:main::@3
main::@3: scope:[main] from main::@1
(byte~) main::$2 ← (byte) sum::return#0
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#2 + (byte) 1
(byte~) main::$4 ← (byte) main::i#2 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#2
(byte) sum2::b#0 ← (byte~) main::$3
(byte) sum2::c#0 ← (byte~) main::$4
call sum2 param-assignment
to:main::@4
main::@4: scope:[main] from main::@3
(byte~) main::$5 ← (byte) sum2::return#0
*((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 11) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@4
return
to:@return
sum: scope:[sum] from main::@1
(byte~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0
(byte) sum::return#0 ← (byte~) sum::$0 + (byte) sum::c#0
to:sum::@return
sum::@return: scope:[sum] from sum
return
to:@return
sum2: scope:[sum2] from main::@3
(byte~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0
(byte) sum2::return#0 ← (byte~) sum2::$0 + (byte) sum2::c#0
to:sum2::@return
sum2::@return: scope:[sum2] from sum2
return
to:@return
@end: scope:[] from @begin
FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 = (word) 1024+(byte) 40
(void()) main()
(byte~) main::$0
(byte~) main::$1
@ -1114,7 +1024,7 @@ main::@1: scope:[main] from main main::@5
to:main::@3
main::@3: scope:[main] from main::@1
(byte~) main::$2 ← (byte) sum::return#0
*((word) 1024 + (byte) main::i#2) ← (byte~) main::$2
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#2 + (byte) 1
(byte~) main::$4 ← (byte) main::i#2 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#2
@ -1124,7 +1034,7 @@ main::@3: scope:[main] from main::@1
to:main::@4
main::@4: scope:[main] from main::@3
(byte~) main::$5 ← (byte) sum2::return#0
*((word) 1064 + (byte) main::i#2) ← (byte~) main::$5
*((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 11) goto main::@5
to:main::@return
@ -1179,7 +1089,7 @@ main::@1: scope:[main] from main main::@5
to:main::@3
main::@3: scope:[main] from main::@1
[9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
[10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ]
[10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ]
[11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ]
[12] (byte~) main::$4 ← (byte) main::i#2 + (byte) 2 [ main::i#2 main::$3 main::$4 ]
[13] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 main::$3 main::$4 sum2::a#0 ]
@ -1189,7 +1099,7 @@ main::@3: scope:[main] from main::@1
to:main::@4
main::@4: scope:[main] from main::@3
[17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
[18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ]
[18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ]
[19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[20] if((byte) main::i#1!=(byte) 11) goto main::@5 [ main::i#1 ]
to:main::@return
@ -1245,7 +1155,7 @@ main::@1: scope:[main] from main main::@4
to:main::@3
main::@3: scope:[main] from main::@1
[9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
[10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ]
[10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ]
[11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ]
[12] (byte~) main::$4 ← (byte) main::i#2 + (byte) 2 [ main::i#2 main::$3 main::$4 ]
[13] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 main::$3 main::$4 sum2::a#0 ]
@ -1255,7 +1165,7 @@ main::@3: scope:[main] from main::@1
to:main::@4
main::@4: scope:[main] from main::@3
[17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
[18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ]
[18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ]
[19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ]
to:main::@return
@ -1392,7 +1302,9 @@ Allocated zp ZP_BYTE:16 [ sum2::return#0 ]
Allocated zp ZP_BYTE:17 [ sum::$0 ]
Allocated zp ZP_BYTE:18 [ sum::return#0 ]
INITIAL ASM
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
.const SCREEN2 = $400+$28
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -1450,10 +1362,10 @@ main: {
//SEG18 [9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ] -- zpby1=zpby2
lda sum.return
sta _2
//SEG19 [10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby2
//SEG19 [10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby2
lda _2
ldx i
sta $400,x
sta SCREEN,x
//SEG20 [11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ] -- zpby1=zpby2_plus_1
lda i
clc
@ -1481,10 +1393,10 @@ main: {
//SEG27 [17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ] -- zpby1=zpby2
lda sum2.return
sta _5
//SEG28 [18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby2
//SEG28 [18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby2
lda _5
ldx i
sta $428,x
sta SCREEN2,x
//SEG29 [19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1
inc i
//SEG30 [20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ] -- zpby1_neq_coby1_then_la1
@ -1601,7 +1513,9 @@ Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
.const SCREEN2 = $400+$28
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -1642,8 +1556,8 @@ main: {
b3:
//SEG18 [9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
// (byte~) main::$2 = (byte) sum::return#0 // register copy reg byte a
//SEG19 [10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $400,y
//SEG19 [10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN,y
//SEG20 [11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ] -- xby=yby_plus_1
tya
tax
@ -1664,8 +1578,8 @@ main: {
b4:
//SEG27 [17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
// (byte~) main::$5 = (byte) sum2::return#0 // register copy reg byte a
//SEG28 [18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $428,y
//SEG28 [18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN2,y
//SEG29 [19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- yby=_inc_yby
iny
//SEG30 [20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ] -- yby_neq_coby1_then_la1
@ -1714,7 +1628,9 @@ Removing instruction main_from_bbegin:
Removing instruction b1_from_b4:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
.const SCREEN2 = $400+$28
//SEG1 @begin
bbegin:
//SEG2 [0] call main param-assignment [ ]
@ -1753,8 +1669,8 @@ main: {
b3:
//SEG18 [9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
// (byte~) main::$2 = (byte) sum::return#0 // register copy reg byte a
//SEG19 [10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $400,y
//SEG19 [10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN,y
//SEG20 [11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ] -- xby=yby_plus_1
tya
tax
@ -1775,8 +1691,8 @@ main: {
b4:
//SEG27 [17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
// (byte~) main::$5 = (byte) sum2::return#0 // register copy reg byte a
//SEG28 [18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $428,y
//SEG28 [18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN2,y
//SEG29 [19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- yby=_inc_yby
iny
//SEG30 [20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ] -- yby_neq_coby1_then_la1
@ -1830,7 +1746,9 @@ Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
.const SCREEN2 = $400+$28
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -1865,8 +1783,8 @@ main: {
//SEG17 main::@3
//SEG18 [9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
// (byte~) main::$2 = (byte) sum::return#0 // register copy reg byte a
//SEG19 [10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $400,y
//SEG19 [10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN,y
//SEG20 [11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ] -- xby=yby_plus_1
tya
tax
@ -1886,8 +1804,8 @@ main: {
//SEG26 main::@4
//SEG27 [17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
// (byte~) main::$5 = (byte) sum2::return#0 // register copy reg byte a
//SEG28 [18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $428,y
//SEG28 [18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN2,y
//SEG29 [19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- yby=_inc_yby
iny
//SEG30 [20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ] -- yby_neq_coby1_then_la1
@ -1931,7 +1849,9 @@ sum: {
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
.const SCREEN2 = $400+$28
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -1965,8 +1885,8 @@ main: {
//SEG17 main::@3
//SEG18 [9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
// (byte~) main::$2 = (byte) sum::return#0 // register copy reg byte a
//SEG19 [10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $400,y
//SEG19 [10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN,y
//SEG20 [11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ] -- xby=yby_plus_1
tya
tax
@ -1986,8 +1906,8 @@ main: {
//SEG26 main::@4
//SEG27 [17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
// (byte~) main::$5 = (byte) sum2::return#0 // register copy reg byte a
//SEG28 [18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $428,y
//SEG28 [18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN2,y
//SEG29 [19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- yby=_inc_yby
iny
//SEG30 [20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ] -- yby_neq_coby1_then_la1
@ -2032,7 +1952,9 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 = (word) 1024+(byte) 40
(void()) main()
(byte~) main::$0 reg byte x 7.333333333333333
(byte~) main::$1 reg byte a 7.333333333333333
@ -2087,7 +2009,9 @@ reg byte a [ sum::$0 ]
reg byte a [ sum::return#0 ]
FINAL CODE
//SEG0 Global ZP labels
//SEG0 Global Constants & labels
.const SCREEN = $400
.const SCREEN2 = $400+$28
//SEG1 @begin
//SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main
@ -2121,8 +2045,8 @@ main: {
//SEG17 main::@3
//SEG18 [9] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ]
// (byte~) main::$2 = (byte) sum::return#0 // register copy reg byte a
//SEG19 [10] *((word) 1024 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $400,y
//SEG19 [10] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN,y
//SEG20 [11] (byte~) main::$3 ← (byte) main::i#2 + (byte) 1 [ main::i#2 main::$3 ] -- xby=yby_plus_1
tya
tax
@ -2142,8 +2066,8 @@ main: {
//SEG26 main::@4
//SEG27 [17] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ]
// (byte~) main::$5 = (byte) sum2::return#0 // register copy reg byte a
//SEG28 [18] *((word) 1064 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta $428,y
//SEG28 [18] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] -- cowo1_staridx_yby=aby
sta SCREEN2,y
//SEG29 [19] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- yby=_inc_yby
iny
//SEG30 [20] if((byte) main::i#1!=(byte) 11) goto main::@1 [ main::i#1 ] -- yby_neq_coby1_then_la1

View File

@ -1,7 +1,9 @@
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 = (word) 1024+(byte) 40
(void()) main()
(byte~) main::$0 reg byte x 7.333333333333333
(byte~) main::$1 reg byte a 7.333333333333333