diff --git a/src/dk/camelot64/kickc/icl/Procedure.java b/src/dk/camelot64/kickc/icl/Procedure.java index baedcb3af..0a67a0dfb 100644 --- a/src/dk/camelot64/kickc/icl/Procedure.java +++ b/src/dk/camelot64/kickc/icl/Procedure.java @@ -61,7 +61,7 @@ public class Procedure extends Scope { public List getParameters() { ArrayList parameters = new ArrayList<>(); for (String name : parameterNames) { - parameters.add(getScope().getVariable(name)); + parameters.add(this.getVariable(name)); } return parameters; } @@ -133,4 +133,24 @@ public class Procedure extends Scope { public ProcedureRef getRef() { return new ProcedureRef(this.getFullName()); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + + Procedure procedure = (Procedure) o; + + if (returnType != null ? !returnType.equals(procedure.returnType) : procedure.returnType != null) return false; + return parameterNames != null ? parameterNames.equals(procedure.parameterNames) : procedure.parameterNames == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (returnType != null ? returnType.hashCode() : 0); + result = 31 * result + (parameterNames != null ? parameterNames.hashCode() : 0); + return result; + } } diff --git a/src/dk/camelot64/kickc/icl/ProcedureRef.java b/src/dk/camelot64/kickc/icl/ProcedureRef.java index 63a65c490..aa31a4d46 100644 --- a/src/dk/camelot64/kickc/icl/ProcedureRef.java +++ b/src/dk/camelot64/kickc/icl/ProcedureRef.java @@ -1,12 +1,18 @@ package dk.camelot64.kickc.icl; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + /** A reference to a procedure */ public class ProcedureRef extends SymbolRef { - public ProcedureRef(String fullName) { + @JsonCreator + public ProcedureRef( @JsonProperty("fullName") String fullName) { super(fullName); } + @JsonIgnore public LabelRef getLabelRef() { return new LabelRef(getFullName()); } diff --git a/src/dk/camelot64/kickc/icl/Statement.java b/src/dk/camelot64/kickc/icl/Statement.java index fb6a885ce..0796fdf15 100644 --- a/src/dk/camelot64/kickc/icl/Statement.java +++ b/src/dk/camelot64/kickc/icl/Statement.java @@ -16,7 +16,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonSubTypes.Type(value = StatementJump.class, name = "jump"), @JsonSubTypes.Type(value = StatementLabel.class, name = "label"), @JsonSubTypes.Type(value = StatementCall.class, name = "call"), - @JsonSubTypes.Type(value = StatementCall.class, name = "return"), + @JsonSubTypes.Type(value = StatementReturn.class, name = "return"), @JsonSubTypes.Type(value = StatementProcedureBegin.class, name = "procbegin"), @JsonSubTypes.Type(value = StatementProcedureEnd.class, name = "procend") }) diff --git a/src/dk/camelot64/kickc/icl/StatementCall.java b/src/dk/camelot64/kickc/icl/StatementCall.java index 064e7de27..1a2ff91c4 100644 --- a/src/dk/camelot64/kickc/icl/StatementCall.java +++ b/src/dk/camelot64/kickc/icl/StatementCall.java @@ -1,5 +1,9 @@ package dk.camelot64.kickc.icl; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.List; /** @@ -16,13 +20,28 @@ public class StatementCall implements StatementLValue { private List parameters; private boolean parametersByAssignment; - public StatementCall(LValue lValue, String procedureName, List parameters) { + public StatementCall( + LValue lValue, String procedureName, List parameters) { this.lValue = lValue; this.procedureName = procedureName; this.parameters = parameters; this.parametersByAssignment = false; } + @JsonCreator + StatementCall( + @JsonProperty("lValue") LValue lValue, + @JsonProperty("procedureName") String procedureName, + @JsonProperty("procedure") ProcedureRef procedure, + @JsonProperty("parameters") List parameters, + @JsonProperty("parametersByAssignment") boolean parametersByAssignment) { + this.lValue = lValue; + this.procedureName = procedureName; + this.procedure = procedure; + this.parameters = parameters; + this.parametersByAssignment = parametersByAssignment; + } + public LValue getlValue() { return lValue; } @@ -51,6 +70,7 @@ public class StatementCall implements StatementLValue { this.parameters = parameters; } + @JsonIgnore public int getNumParameters() { return parameters.size(); } @@ -124,4 +144,28 @@ public class StatementCall implements StatementLValue { } return res.toString(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + StatementCall that = (StatementCall) o; + + if (parametersByAssignment != that.parametersByAssignment) return false; + if (lValue != null ? !lValue.equals(that.lValue) : that.lValue != null) return false; + if (!procedureName.equals(that.procedureName)) return false; + if (procedure != null ? !procedure.equals(that.procedure) : that.procedure != null) return false; + return parameters != null ? parameters.equals(that.parameters) : that.parameters == null; + } + + @Override + public int hashCode() { + int result = lValue != null ? lValue.hashCode() : 0; + result = 31 * result + procedureName.hashCode(); + result = 31 * result + (procedure != null ? procedure.hashCode() : 0); + result = 31 * result + (parameters != null ? parameters.hashCode() : 0); + result = 31 * result + (parametersByAssignment ? 1 : 0); + return result; + } } diff --git a/src/dk/camelot64/kickc/icl/StatementReturn.java b/src/dk/camelot64/kickc/icl/StatementReturn.java index b8b605362..318366f41 100644 --- a/src/dk/camelot64/kickc/icl/StatementReturn.java +++ b/src/dk/camelot64/kickc/icl/StatementReturn.java @@ -1,5 +1,8 @@ package dk.camelot64.kickc.icl; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * Return Statement inside procedure in Single Static Assignment Form. */ @@ -8,7 +11,8 @@ public class StatementReturn implements Statement { /** Return value. May be null if not returning a value. */ private RValue value; - public StatementReturn(RValue value) { + @JsonCreator + public StatementReturn( @JsonProperty("value") RValue value) { this.value = value; } @@ -32,4 +36,19 @@ public class StatementReturn implements Statement { @Override public String getAsString() { return "return "+(value==null?"":value.getAsString()); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + StatementReturn that = (StatementReturn) o; + + return value != null ? value.equals(that.value) : that.value == null; + } + + @Override + public int hashCode() { + return value != null ? value.hashCode() : 0; + } } diff --git a/src/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java b/src/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java index a948ef886..57042ee76 100644 --- a/src/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java +++ b/src/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java @@ -67,7 +67,7 @@ public class Pass1GenerateControlFlowGraph { } else if(statement instanceof StatementProcedureEnd) { // Procedure strategy implemented is currently variable-based transfer of parameters/return values currentBlock.setDefaultSuccessor(new Label("@RETURN", scope, false).getRef()); - ControlFlowBlock nextBlock = getOrCreateBlock(currentBlockScope.addLabelIntermediate().getRef()); + ControlFlowBlock nextBlock = getOrCreateBlock(scope.addLabelIntermediate().getRef()); blockStack.pop(); ControlFlowBlock prevBlock = blockStack.pop(); prevBlock.setDefaultSuccessor(nextBlock.getLabel()); diff --git a/src/dk/camelot64/kickc/test/TestCompilationOutput.java b/src/dk/camelot64/kickc/test/TestCompilationOutput.java index ab7806f91..43f17c8f8 100644 --- a/src/dk/camelot64/kickc/test/TestCompilationOutput.java +++ b/src/dk/camelot64/kickc/test/TestCompilationOutput.java @@ -39,19 +39,28 @@ public class TestCompilationOutput extends TestCase { tester.testFile("bresenham"); } + public void testSumMin() throws IOException, URISyntaxException { + TestCompilationOutput tester = new TestCompilationOutput(); + tester.testFile("summin"); + } + private void testFile(String fileName) throws IOException, URISyntaxException { String inputPath = testPath + fileName + ".kc"; System.out.println("Testing output for "+inputPath); CharStream input = CharStreams.fromFileName(inputPath); Compiler compiler = new Compiler(); Compiler.CompilationResult output = compiler.compile(input); - assertOutput(fileName, ".asm", output.getAsmProgram().toString(false)); - assertOutput(fileName, ".sym", output.getSymbols().getSymbolTableContents()); - assertOutput(fileName, ".cfg", output.getGraph().getAsTypedString(output.getSymbols())); - assertOutput(fileName, ".log", output.getLog().toString()); + boolean success = true; + success &= testOutput(fileName, ".asm", output.getAsmProgram().toString(false)); + success &= testOutput(fileName, ".sym", output.getSymbols().getSymbolTableContents()); + success &= testOutput(fileName, ".cfg", output.getGraph().getAsTypedString(output.getSymbols())); + success &= testOutput(fileName, ".log", output.getLog().toString()); + if(!success) { + fail("Output does not match reference!"); + } } - private void assertOutput( + private boolean testOutput( String fileName, String extension, String outputString) throws IOException, URISyntaxException { @@ -61,7 +70,8 @@ public class TestCompilationOutput extends TestCase { refLines = loadReferenceLines(fileName, extension); } catch (Exception e) { writeOutputFile(fileName, extension, outputString); - fail("Error loading reference."+e.getMessage()); + System.out.println("Reference file not found "+refPath+fileName+extension); + return false; } // Split output into outLines List outLines = getOutLines(outputString); @@ -71,14 +81,16 @@ public class TestCompilationOutput extends TestCase { String refLine = refLines.get(i); if(!outLine.equals(refLine)) { writeOutputFile(fileName, extension, outputString); - fail( + System.out.println( "Output does not match reference on line "+i+"\n"+ "Reference: "+refLine+"\n"+ "Output: "+outLine ); + return false; } } } + return true; } private List getOutLines(String outputString) throws IOException { diff --git a/src/dk/camelot64/kickc/test/TestIclJson.java b/src/dk/camelot64/kickc/test/TestIclJson.java index 7223ae229..ae3bafbb1 100644 --- a/src/dk/camelot64/kickc/test/TestIclJson.java +++ b/src/dk/camelot64/kickc/test/TestIclJson.java @@ -80,6 +80,21 @@ public class TestIclJson extends TestCase { assertJsonSerialization(program, json, Program.class); } + public void testJsonCodeSumFunction() throws IOException { + String minProgram = "byte s1=sum(1,2);\n" + + "byte s2=sum(9,13);\n" + + "byte sum(byte a, byte b) {\n" + + " return a+b;\n" + + "}\n"; + Compiler compiler = new Compiler(); + CompileLog log = new CompileLog(); + KickCParser.FileContext file = compiler.pass0ParseInput(new ANTLRInputStream(minProgram), log); + Program program = compiler.pass1GenerateSSA(file, log); + String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"s1\":{\"@type\":\"variable_unversioned\",\"name\":\"s1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"s2\":{\"@type\":\"variable_unversioned\",\"name\":\"s2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"sum\":{\"@type\":\"procedure\",\"name\":\"sum\",\"parameterNames\":[\"a\",\"b\"],\"symbols\":{\"@return\":{\"@type\":\"label\",\"name\":\"@return\",\"intermediate\":false},\"return\":{\"@type\":\"variable_unversioned\",\"name\":\"return\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":8,\"inferredType\":false},\"a\":{\"@type\":\"variable_unversioned\",\"name\":\"a\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"b\":{\"@type\":\"variable_unversioned\",\"name\":\"b\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"a#0\":{\"@type\":\"variable_versioned\",\"name\":\"a#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#0\":{\"@type\":\"variable_versioned\",\"name\":\"b#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#0\":{\"@type\":\"variable_versioned\",\"name\":\"return#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#1\":{\"@type\":\"variable_versioned\",\"name\":\"a#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#1\":{\"@type\":\"variable_versioned\",\"name\":\"b#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#1\":{\"@type\":\"variable_versioned\",\"name\":\"return#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#2\":{\"@type\":\"variable_versioned\",\"name\":\"return#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#3\":{\"@type\":\"variable_versioned\",\"name\":\"return#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#4\":{\"@type\":\"variable_versioned\",\"name\":\"return#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#5\":{\"@type\":\"variable_versioned\",\"name\":\"return#5\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#2\":{\"@type\":\"variable_versioned\",\"name\":\"a#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#2\":{\"@type\":\"variable_versioned\",\"name\":\"b#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#6\":{\"@type\":\"variable_versioned\",\"name\":\"return#6\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#7\":{\"@type\":\"variable_versioned\",\"name\":\"return#7\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false}},\"intermediateVarCount\":1,\"intermediateLabelCount\":2,\"returnType\":{\"@type\":\"basic\",\"typeName\":\"byte\"}},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"@3\":{\"@type\":\"label\",\"name\":\"@3\",\"intermediate\":true},\"s1#0\":{\"@type\":\"variable_versioned\",\"name\":\"s1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s1\",\"inferredType\":false},\"s2#0\":{\"@type\":\"variable_versioned\",\"name\":\"s2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s2\",\"inferredType\":false}},\"intermediateVarCount\":2,\"intermediateLabelCount\":4,\"allocation\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":2}},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phi\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"},\"previousVersions\":[{\"block\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"}}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":9}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":13}},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@3\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"statements\":[{\"@type\":\"phi\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"},\"previousVersions\":[{\"block\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"}}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"statements\":[{\"@type\":\"phi\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"},\"previousVersions\":[{\"block\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"}},{\"block\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"}}]},{\"@type\":\"phi\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"previousVersions\":[{\"block\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"}},{\"block\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"}}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum::@return\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"statements\":[{\"@type\":\"phi\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"},\"previousVersions\":[{\"block\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"}},{\"block\":{\"@type\":\"labelref\",\"fullName\":\"sum::@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#7\"}}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"}},{\"@type\":\"return\",\"value\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@RETURN\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum::@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum::@1\"},\"statements\":[{\"@type\":\"phi\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#7\"},\"previousVersions\":[]}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"statements\":[],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null}}"; + assertJsonSerialization(program, json, Program.class); + } + + public void testJsonCodeFib() throws IOException { String minProgram = "byte n1 = 0; byte n2 = 1; byte i = 12; byte fib = 0; while(i>0) { fib = n1 + n2; n1 = n2; n2 = fib; i = i - 1; }"; Compiler compiler = new Compiler(); diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm b/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm index b3abf1fd5..812b175ee 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm @@ -6,7 +6,7 @@ main: main__B2_from_main: ldx #25 jmp main__B2 -main__B2_from_B12: +main__B2_from_B11: ldx #25 main__B2_from_B6: main__B2: @@ -24,10 +24,10 @@ main__B6: bne main__B2_from_B6 main__B7: jsr flip -main__B11: +main__B10: jsr plot -main__B12: - jmp main__B2_from_B12 +main__B11: + jmp main__B2_from_B11 main__Breturn: rts plot: diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg b/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg index f596115fa..604e53ac5 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg @@ -4,8 +4,8 @@ main: from @BEGIN call prepare param-assignment to:main::@2 -main::@2: from main main::@12 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@12/(byte) 25 ) +main::@2: from main main::@11 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 main::@3: from main::@2 main::@3 (byte~) main::$1 ← * (word) 53266 @@ -21,14 +21,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@2 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -75,7 +75,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 to:plot::@1 plot::@1: from plot plot::@3 (byte) plot::y#2 ← phi( plot/(byte) 16 plot::@3/(byte) plot::y#1 ) diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.log b/src/dk/camelot64/kickc/test/ref/flipper-rex2.log index 9f5cc847f..e2ebbf3d0 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.log +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.log @@ -230,7 +230,7 @@ INITIAL CONTROL FLOW GRAPH (byte[256]) buffer2 ← (word) 4352 (byte*) RASTER ← (word) 53266 (void~) $0 ← call main - to:main::@9 + to:@1 main: from (void~) main::$0 ← call prepare to:main::@1 @@ -266,8 +266,8 @@ main::@8: from main::@7 main::@return: from main::@8 return to:@RETURN -main::@9: from @BEGIN - to:prepare::@3 +@1: from @BEGIN + to:@2 prepare: from (byte) prepare::i ← (byte) 0 to:prepare::@1 @@ -282,8 +282,8 @@ prepare::@2: from prepare::@1 prepare::@return: from prepare::@2 return to:@RETURN -prepare::@3: from main::@9 - to:flip::@7 +@2: from @1 + to:@3 flip: from (byte) flip::srcIdx ← (byte) 0 (byte) flip::dstIdx ← (byte) 15 @@ -323,8 +323,8 @@ flip::@6: from flip::@3 flip::@return: from flip::@6 return to:@RETURN -flip::@7: from prepare::@3 - to:plot::@5 +@3: from @2 + to:@4 plot: from (byte~) plot::$0 ← (byte) 5 * (byte) 40 (byte*~) plot::$1 ← (byte[1000]) SCREEN + (byte~) plot::$0 @@ -356,9 +356,9 @@ plot::@4: from plot::@3 plot::@return: from plot::@4 return to:@RETURN -plot::@5: from flip::@7 +@4: from @3 to:@END -@END: from plot::@5 +@END: from @4 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @BEGIN: from @@ -367,15 +367,15 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL (byte[256]) buffer2 ← (word) 4352 (byte*) RASTER ← (word) 53266 call main param-assignment + to:@5 +@5: from @BEGIN to:@1 -@1: from @BEGIN - to:main::@9 main: from @BEGIN call prepare param-assignment - to:main::@10 -main::@10: from main + to:main::@9 +main::@9: from main to:main::@1 -main::@1: from main::@10 main::@12 +main::@1: from main::@11 main::@9 (byte) main::c ← (byte) 25 to:main::@2 main::@2: from main::@1 main::@6 @@ -399,20 +399,20 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@8 -main::@8: from main::@12 +main::@8: from main::@11 to:main::@return main::@return: from main::@8 return to:@RETURN -main::@9: from @1 - to:prepare::@3 +@1: from @5 + to:@2 prepare: from main (byte) prepare::i ← (byte) 0 to:prepare::@1 @@ -427,8 +427,8 @@ prepare::@2: from prepare::@1 prepare::@return: from prepare::@2 return to:@RETURN -prepare::@3: from main::@9 - to:flip::@7 +@2: from @1 + to:@3 flip: from main::@7 (byte) flip::srcIdx ← (byte) 0 (byte) flip::dstIdx ← (byte) 15 @@ -468,9 +468,9 @@ flip::@6: from flip::@3 flip::@return: from flip::@6 return to:@RETURN -flip::@7: from prepare::@3 - to:plot::@5 -plot: from main::@11 +@3: from @2 + to:@4 +plot: from main::@10 (byte~) plot::$0 ← (byte) 5 * (byte) 40 (byte*~) plot::$1 ← (byte[1000]) SCREEN + (byte~) plot::$0 (byte*~) plot::$2 ← (byte*~) plot::$1 + (byte) 12 @@ -501,9 +501,9 @@ plot::@4: from plot::@3 plot::@return: from plot::@4 return to:@RETURN -plot::@5: from flip::@7 +@4: from @3 to:@END -@END: from plot::@5 +@END: from @4 Completing Phi functions... Completing Phi functions... @@ -524,27 +524,27 @@ CONTROL FLOW GRAPH SSA (byte[256]) buffer2#0 ← (word) 4352 (byte*) RASTER#0 ← (word) 53266 call main param-assignment + to:@5 +@5: from @BEGIN to:@1 -@1: from @BEGIN - to:main::@9 main: from @BEGIN (byte[256]) buffer2#16 ← phi( @BEGIN/(byte[256]) buffer2#0 ) (byte[1000]) SCREEN#12 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) (byte*) RASTER#9 ← phi( @BEGIN/(byte*) RASTER#0 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(byte[256]) buffer1#0 ) call prepare param-assignment - to:main::@10 -main::@10: from main - (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#7 ← phi( main/(byte*) RASTER#9 ) + to:main::@9 +main::@9: from main + (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) + (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#22 main::@12/(byte[256]) buffer1#23 ) - (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#14 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#10 main::@12/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#7 main::@12/(byte*) RASTER#8 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) (byte) main::c#0 ← (byte) 25 to:main::@2 main::@2: from main::@1 main::@6 @@ -597,28 +597,28 @@ main::@7: from main::@6 (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment - to:main::@12 -main::@12: from main::@11 - (byte[256]) buffer2#15 ← phi( main::@11/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#23 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#11 ← phi( main::@11/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#8 ← phi( main::@11/(byte*) RASTER#10 ) + to:main::@11 +main::@11: from main::@10 + (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) + (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) if(true) goto main::@1 to:main::@8 -main::@8: from main::@12 +main::@8: from main::@11 to:main::@return main::@return: from main::@8 return to:@RETURN -main::@9: from @1 - to:prepare::@3 +@1: from @5 + to:@2 prepare: from main (byte[256]) buffer1#5 ← phi( main/(byte[256]) buffer1#9 ) (byte) prepare::i#0 ← (byte) 0 @@ -636,8 +636,8 @@ prepare::@2: from prepare::@1 prepare::@return: from prepare::@2 return to:@RETURN -prepare::@3: from main::@9 - to:flip::@7 +@2: from @1 + to:@3 flip: from main::@7 (byte[256]) buffer2#5 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#10 ← phi( main::@7/(byte[256]) buffer1#14 ) @@ -700,11 +700,11 @@ flip::@6: from flip::@3 flip::@return: from flip::@6 return to:@RETURN -flip::@7: from prepare::@3 - to:plot::@5 -plot: from main::@11 - (byte[256]) buffer1#12 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#1 ← phi( main::@11/(byte[1000]) SCREEN#2 ) +@3: from @2 + to:@4 +plot: from main::@10 + (byte[256]) buffer1#12 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#1 ← phi( main::@10/(byte[1000]) SCREEN#2 ) (byte~) plot::$0 ← (byte) 5 * (byte) 40 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte~) plot::$0 (byte*~) plot::$2 ← (byte*~) plot::$1 + (byte) 12 @@ -748,9 +748,9 @@ plot::@4: from plot::@3 plot::@return: from plot::@4 return to:@RETURN -plot::@5: from flip::@7 +@4: from @3 to:@END -@END: from plot::@5 +@END: from @4 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @BEGIN: from @@ -759,27 +759,27 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN (byte[256]) buffer2#0 ← (word) 4352 (byte*) RASTER#0 ← (word) 53266 call main param-assignment + to:@5 +@5: from @BEGIN to:@1 -@1: from @BEGIN - to:main::@9 main: from @BEGIN (byte[256]) buffer2#16 ← phi( @BEGIN/(byte[256]) buffer2#0 ) (byte[1000]) SCREEN#12 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) (byte*) RASTER#9 ← phi( @BEGIN/(byte*) RASTER#0 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(byte[256]) buffer1#0 ) call prepare param-assignment - to:main::@10 -main::@10: from main - (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#7 ← phi( main/(byte*) RASTER#9 ) + to:main::@9 +main::@9: from main + (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) + (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#22 main::@12/(byte[256]) buffer1#23 ) - (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#14 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#10 main::@12/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#7 main::@12/(byte*) RASTER#8 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) (byte) main::c#0 ← (byte) 25 to:main::@2 main::@2: from main::@1 main::@6 @@ -832,28 +832,28 @@ main::@7: from main::@6 (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment - to:main::@12 -main::@12: from main::@11 - (byte[256]) buffer2#15 ← phi( main::@11/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#23 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#11 ← phi( main::@11/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#8 ← phi( main::@11/(byte*) RASTER#10 ) + to:main::@11 +main::@11: from main::@10 + (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) + (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) if(true) goto main::@1 to:main::@8 -main::@8: from main::@12 +main::@8: from main::@11 to:main::@return main::@return: from main::@8 return to:@RETURN -main::@9: from @1 - to:prepare::@3 +@1: from @5 + to:@2 prepare: from main (byte[256]) buffer1#5 ← phi( main/(byte[256]) buffer1#9 ) (byte) prepare::i#0 ← (byte) 0 @@ -871,8 +871,8 @@ prepare::@2: from prepare::@1 prepare::@return: from prepare::@2 return to:@RETURN -prepare::@3: from main::@9 - to:flip::@7 +@2: from @1 + to:@3 flip: from main::@7 (byte[256]) buffer2#5 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#10 ← phi( main::@7/(byte[256]) buffer1#14 ) @@ -935,11 +935,11 @@ flip::@6: from flip::@3 flip::@return: from flip::@6 return to:@RETURN -flip::@7: from prepare::@3 - to:plot::@5 -plot: from main::@11 - (byte[256]) buffer1#12 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#1 ← phi( main::@11/(byte[1000]) SCREEN#2 ) +@3: from @2 + to:@4 +plot: from main::@10 + (byte[256]) buffer1#12 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#1 ← phi( main::@10/(byte[1000]) SCREEN#2 ) (byte~) plot::$0 ← (byte) 5 * (byte) 40 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte~) plot::$0 (byte*~) plot::$2 ← (byte*~) plot::$1 + (byte) 12 @@ -983,19 +983,19 @@ plot::@4: from plot::@3 plot::@return: from plot::@4 return to:@RETURN -plot::@5: from flip::@7 +@4: from @3 to:@END -@END: from plot::@5 +@END: from @4 -Culled Empty Block (label) @1 +Culled Empty Block (label) @5 Culled Empty Block (label) main::@8 -Culled Empty Block (label) main::@9 +Culled Empty Block (label) @1 Culled Empty Block (label) prepare::@2 -Culled Empty Block (label) prepare::@3 +Culled Empty Block (label) @2 Culled Empty Block (label) flip::@6 -Culled Empty Block (label) flip::@7 +Culled Empty Block (label) @3 Culled Empty Block (label) plot::@4 -Culled Empty Block (label) plot::@5 +Culled Empty Block (label) @4 Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @BEGIN: from @@ -1011,18 +1011,18 @@ main: from @BEGIN (byte*) RASTER#9 ← phi( @BEGIN/(byte*) RASTER#0 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(byte[256]) buffer1#0 ) call prepare param-assignment - to:main::@10 -main::@10: from main - (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#7 ← phi( main/(byte*) RASTER#9 ) + to:main::@9 +main::@9: from main + (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) + (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#22 main::@12/(byte[256]) buffer1#23 ) - (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#14 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#10 main::@12/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#7 main::@12/(byte*) RASTER#8 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) (byte) main::c#0 ← (byte) 25 to:main::@2 main::@2: from main::@1 main::@6 @@ -1075,22 +1075,22 @@ main::@7: from main::@6 (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment - to:main::@12 -main::@12: from main::@11 - (byte[256]) buffer2#15 ← phi( main::@11/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#23 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#11 ← phi( main::@11/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#8 ← phi( main::@11/(byte*) RASTER#10 ) + to:main::@11 +main::@11: from main::@10 + (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) + (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -1168,9 +1168,9 @@ flip::@3: from flip::@3 flip::@5 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 - (byte[256]) buffer1#12 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#1 ← phi( main::@11/(byte[1000]) SCREEN#2 ) +plot: from main::@10 + (byte[256]) buffer1#12 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#1 ← phi( main::@10/(byte[1000]) SCREEN#2 ) (byte~) plot::$0 ← (byte) 5 * (byte) 40 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte~) plot::$0 (byte*~) plot::$2 ← (byte*~) plot::$1 + (byte) 12 @@ -1240,18 +1240,18 @@ main: from @BEGIN (byte*) RASTER#9 ← phi( @BEGIN/(word) 53266 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(word) 4096 ) call prepare param-assignment - to:main::@10 -main::@10: from main - (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#7 ← phi( main/(byte*) RASTER#9 ) + to:main::@9 +main::@9: from main + (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) + (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#22 main::@12/(byte[256]) buffer1#23 ) - (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#14 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#10 main::@12/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#7 main::@12/(byte*) RASTER#8 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) to:main::@2 main::@2: from main::@1 main::@6 (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#8 ) @@ -1303,22 +1303,22 @@ main::@7: from main::@6 (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment - to:main::@12 -main::@12: from main::@11 - (byte[256]) buffer2#15 ← phi( main::@11/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#23 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#11 ← phi( main::@11/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#8 ← phi( main::@11/(byte*) RASTER#10 ) + to:main::@11 +main::@11: from main::@10 + (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) + (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -1390,9 +1390,9 @@ flip::@3: from flip::@3 flip::@5 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 - (byte[256]) buffer1#12 ← phi( main::@11/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#1 ← phi( main::@11/(byte[1000]) SCREEN#2 ) +plot: from main::@10 + (byte[256]) buffer1#12 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#1 ← phi( main::@10/(byte[1000]) SCREEN#2 ) (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*~) plot::$2 ← (byte*~) plot::$1 + (byte) 12 (byte*) plot::line#0 ← (byte*~) plot::$2 @@ -1432,19 +1432,19 @@ plot::@return: from plot::@3 to:@RETURN @END: from @BEGIN -Alias (byte[256]) buffer2#14 = (byte[256]) buffer2#16 -Alias (byte[256]) buffer1#22 = (byte[256]) buffer1#9 (byte[256]) buffer1#5 -Alias (byte[1000]) SCREEN#10 = (byte[1000]) SCREEN#12 -Alias (byte*) RASTER#7 = (byte*) RASTER#9 +Alias (byte[256]) buffer2#15 = (byte[256]) buffer2#16 +Alias (byte[256]) buffer1#23 = (byte[256]) buffer1#9 (byte[256]) buffer1#5 +Alias (byte[1000]) SCREEN#11 = (byte[1000]) SCREEN#12 +Alias (byte*) RASTER#8 = (byte*) RASTER#9 Alias (byte[256]) buffer2#10 = (byte[256]) buffer2#11 Alias (byte[256]) buffer1#18 = (byte[256]) buffer1#19 Alias (byte[1000]) SCREEN#6 = (byte[1000]) SCREEN#7 Alias (byte) main::c#4 = (byte) main::c#5 Alias (byte*) RASTER#1 = (byte*) RASTER#4 -Alias (byte[256]) buffer2#15 = (byte[256]) buffer2#8 (byte[256]) buffer2#9 (byte[256]) buffer2#7 (byte[256]) buffer2#17 (byte[256]) buffer2#5 -Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#16 (byte[256]) buffer1#17 (byte[256]) buffer1#14 (byte[256]) buffer1#15 (byte[256]) buffer1#23 (byte[256]) buffer1#12 -Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#4 (byte[1000]) SCREEN#5 (byte[1000]) SCREEN#3 (byte[1000]) SCREEN#2 (byte[1000]) SCREEN#11 -Alias (byte*) RASTER#10 = (byte*) RASTER#6 (byte*) RASTER#2 (byte*) RASTER#11 (byte*) RASTER#8 +Alias (byte[256]) buffer2#14 = (byte[256]) buffer2#8 (byte[256]) buffer2#9 (byte[256]) buffer2#7 (byte[256]) buffer2#17 (byte[256]) buffer2#5 +Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#16 (byte[256]) buffer1#17 (byte[256]) buffer1#14 (byte[256]) buffer1#15 (byte[256]) buffer1#22 (byte[256]) buffer1#12 +Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#4 (byte[1000]) SCREEN#5 (byte[1000]) SCREEN#3 (byte[1000]) SCREEN#2 (byte[1000]) SCREEN#10 +Alias (byte*) RASTER#10 = (byte*) RASTER#6 (byte*) RASTER#2 (byte*) RASTER#11 (byte*) RASTER#7 Alias (byte) main::c#2 = (byte) main::c#3 Alias (byte) flip::dstIdx#1 = (byte~) flip::$1 (byte) flip::dstIdx#4 Alias (byte[256]) buffer2#1 = (byte[256]) buffer2#6 (byte[256]) buffer2#4 @@ -1463,22 +1463,22 @@ CONTROL FLOW GRAPH call main param-assignment to:@END main: from @BEGIN - (byte[256]) buffer2#14 ← phi( @BEGIN/(word) 4352 ) - (byte[1000]) SCREEN#10 ← phi( @BEGIN/(word) 1024 ) - (byte*) RASTER#7 ← phi( @BEGIN/(word) 53266 ) - (byte[256]) buffer1#22 ← phi( @BEGIN/(word) 4096 ) + (byte[256]) buffer2#15 ← phi( @BEGIN/(word) 4352 ) + (byte[1000]) SCREEN#11 ← phi( @BEGIN/(word) 1024 ) + (byte*) RASTER#8 ← phi( @BEGIN/(word) 53266 ) + (byte[256]) buffer1#23 ← phi( @BEGIN/(word) 4096 ) call prepare param-assignment - to:main::@10 -main::@10: from main + to:main::@9 +main::@9: from main to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#22 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#14 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#10 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#7 main::@12/(byte*) RASTER#10 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(byte[256]) buffer1#23 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(byte*) RASTER#8 ) to:main::@2 main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#15 ) + (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -1498,7 +1498,7 @@ main::@5: from main::@3 to:main::@4 main::@4: from main::@4 main::@5 (byte[256]) buffer1#10 ← phi( main::@4/(byte[256]) buffer1#10 main::@5/(byte[256]) buffer1#18 ) - (byte[256]) buffer2#15 ← phi( main::@4/(byte[256]) buffer2#15 main::@5/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#14 ← phi( main::@4/(byte[256]) buffer2#14 main::@5/(byte[256]) buffer2#10 ) (byte[1000]) SCREEN#1 ← phi( main::@4/(byte[1000]) SCREEN#1 main::@5/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@4/(byte) main::c#2 main::@5/(byte) main::c#4 ) (byte*) RASTER#10 ← phi( main::@4/(byte*) RASTER#10 main::@5/(byte*) RASTER#1 ) @@ -1513,20 +1513,20 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main to:prepare::@1 prepare::@1: from prepare prepare::@1 - (byte[256]) buffer1#1 ← phi( prepare/(byte[256]) buffer1#22 prepare::@1/(byte[256]) buffer1#1 ) + (byte[256]) buffer1#1 ← phi( prepare/(byte[256]) buffer1#23 prepare::@1/(byte[256]) buffer1#1 ) (byte) prepare::i#2 ← phi( prepare/(byte) 0 prepare::@1/(byte) prepare::i#1 ) *((byte[256]) buffer1#1 + (byte) prepare::i#2) ← (byte) prepare::i#2 (byte) prepare::i#1 ← ++ (byte) prepare::i#2 @@ -1542,7 +1542,7 @@ flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#15 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) to:flip::@2 flip::@2: from flip::@1 flip::@2 @@ -1581,7 +1581,7 @@ flip::@3: from flip::@3 flip::@5 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -1615,10 +1615,10 @@ plot::@return: from plot::@3 to:@RETURN @END: from @BEGIN -Redundant Phi (byte[256]) buffer2#14 (word) 4352 -Redundant Phi (byte[1000]) SCREEN#10 (word) 1024 -Redundant Phi (byte*) RASTER#7 (word) 53266 -Redundant Phi (byte[256]) buffer1#22 (word) 4096 +Redundant Phi (byte[256]) buffer2#15 (word) 4352 +Redundant Phi (byte[1000]) SCREEN#11 (word) 1024 +Redundant Phi (byte*) RASTER#8 (word) 53266 +Redundant Phi (byte[256]) buffer1#23 (word) 4096 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @BEGIN: from @@ -1626,17 +1626,17 @@ CONTROL FLOW GRAPH to:@END main: from @BEGIN call prepare param-assignment - to:main::@10 -main::@10: from main + to:main::@9 +main::@9: from main to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main::@10/(word) 4352 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main::@10/(word) 53266 main::@12/(byte*) RASTER#10 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#15 ) + (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -1656,7 +1656,7 @@ main::@5: from main::@3 to:main::@4 main::@4: from main::@4 main::@5 (byte[256]) buffer1#10 ← phi( main::@4/(byte[256]) buffer1#10 main::@5/(byte[256]) buffer1#18 ) - (byte[256]) buffer2#15 ← phi( main::@4/(byte[256]) buffer2#15 main::@5/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#14 ← phi( main::@4/(byte[256]) buffer2#14 main::@5/(byte[256]) buffer2#10 ) (byte[1000]) SCREEN#1 ← phi( main::@4/(byte[1000]) SCREEN#1 main::@5/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@4/(byte) main::c#2 main::@5/(byte) main::c#4 ) (byte*) RASTER#10 ← phi( main::@4/(byte*) RASTER#10 main::@5/(byte*) RASTER#1 ) @@ -1671,14 +1671,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -1700,7 +1700,7 @@ flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#15 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) to:flip::@2 flip::@2: from flip::@1 flip::@2 @@ -1739,7 +1739,7 @@ flip::@3: from flip::@3 flip::@5 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -1779,7 +1779,7 @@ Self Phi Eliminated (byte[1000]) SCREEN#6 Self Phi Eliminated (byte) main::c#4 Self Phi Eliminated (byte*) RASTER#1 Self Phi Eliminated (byte[256]) buffer1#10 -Self Phi Eliminated (byte[256]) buffer2#15 +Self Phi Eliminated (byte[256]) buffer2#14 Self Phi Eliminated (byte[1000]) SCREEN#1 Self Phi Eliminated (byte) main::c#2 Self Phi Eliminated (byte*) RASTER#10 @@ -1799,17 +1799,17 @@ CONTROL FLOW GRAPH to:@END main: from @BEGIN call prepare param-assignment - to:main::@10 -main::@10: from main + to:main::@9 +main::@9: from main to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main::@10/(word) 4352 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main::@10/(word) 53266 main::@12/(byte*) RASTER#10 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#15 ) + (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -1829,7 +1829,7 @@ main::@5: from main::@3 to:main::@4 main::@4: from main::@4 main::@5 (byte[256]) buffer1#10 ← phi( main::@5/(byte[256]) buffer1#18 ) - (byte[256]) buffer2#15 ← phi( main::@5/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#14 ← phi( main::@5/(byte[256]) buffer2#10 ) (byte[1000]) SCREEN#1 ← phi( main::@5/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@5/(byte) main::c#4 ) (byte*) RASTER#10 ← phi( main::@5/(byte*) RASTER#1 ) @@ -1844,14 +1844,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -1873,7 +1873,7 @@ flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#15 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) to:flip::@2 flip::@2: from flip::@1 flip::@2 @@ -1912,7 +1912,7 @@ flip::@3: from flip::@3 flip::@5 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -1962,17 +1962,17 @@ CONTROL FLOW GRAPH to:@END main: from @BEGIN call prepare param-assignment - to:main::@10 -main::@10: from main + to:main::@9 +main::@9: from main to:main::@1 -main::@1: from main::@10 main::@12 - (byte[256]) buffer1#21 ← phi( main::@10/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main::@10/(word) 4352 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main::@10/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main::@10/(word) 53266 main::@12/(byte*) RASTER#10 ) +main::@1: from main::@11 main::@9 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#15 ) + (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -1991,7 +1991,7 @@ main::@5: from main::@3 to:main::@4 main::@4: from main::@4 main::@5 (byte[256]) buffer1#10 ← phi( main::@5/(byte[256]) buffer1#18 ) - (byte[256]) buffer2#15 ← phi( main::@5/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#14 ← phi( main::@5/(byte[256]) buffer2#10 ) (byte[1000]) SCREEN#1 ← phi( main::@5/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@5/(byte) main::c#4 ) (byte*) RASTER#10 ← phi( main::@5/(byte*) RASTER#1 ) @@ -2004,14 +2004,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2032,7 +2032,7 @@ flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#15 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) to:flip::@2 flip::@2: from flip::@1 flip::@2 @@ -2068,7 +2068,7 @@ flip::@3: from flip::@3 flip::@5 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2100,7 +2100,7 @@ plot::@return: from plot::@3 to:@RETURN @END: from @BEGIN -Culled Empty Block (label) main::@10 +Culled Empty Block (label) main::@9 Culled Empty Block (label) main::@5 Culled Empty Block (label) flip::@5 Succesful SSA optimization Pass2CullEmptyBlocks @@ -2111,14 +2111,14 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 - (byte[256]) buffer1#21 ← phi( main/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main/(word) 4352 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main/(word) 53266 main::@12/(byte*) RASTER#10 ) +main::@1: from main main::@11 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#15 ) + (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -2135,7 +2135,7 @@ main::@3: from main::@2 main::@3 to:main::@4 main::@4: from main::@3 main::@4 (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 ) - (byte[256]) buffer2#15 ← phi( main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#14 ← phi( main::@3/(byte[256]) buffer2#10 ) (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 ) (byte*) RASTER#10 ← phi( main::@3/(byte*) RASTER#1 ) @@ -2148,14 +2148,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2176,7 +2176,7 @@ flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#15 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) to:flip::@2 flip::@2: from flip::@1 flip::@2 @@ -2210,7 +2210,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2251,14 +2251,14 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 - (byte[256]) buffer1#21 ← phi( main/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main/(word) 4352 main::@12/(byte[256]) buffer2#15 ) - (byte[1000]) SCREEN#9 ← phi( main/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main/(word) 53266 main::@12/(byte*) RASTER#10 ) +main::@1: from main main::@11 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#15 ) + (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -2275,7 +2275,7 @@ main::@3: from main::@2 main::@3 to:main::@4 main::@4: from main::@3 main::@4 (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 ) - (byte[256]) buffer2#15 ← phi( main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#14 ← phi( main::@3/(byte[256]) buffer2#10 ) (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 ) (byte*) RASTER#10 ← phi( main::@3/(byte*) RASTER#1 ) @@ -2288,14 +2288,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2315,7 +2315,7 @@ flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#15 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) to:flip::@2 flip::@2: from flip::@1 flip::@2 @@ -2349,7 +2349,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2384,7 +2384,7 @@ plot::@return: from plot::@3 Multiple usages for variable. Not optimizing sub-constant (byte) prepare::i#2 Multiple usages for variable. Not optimizing sub-constant (byte[1000]) SCREEN#1 Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#18 (byte[256]) buffer1#20 -Alias (byte[256]) buffer2#10 = (byte[256]) buffer2#12 (byte[256]) buffer2#15 +Alias (byte[256]) buffer2#10 = (byte[256]) buffer2#12 (byte[256]) buffer2#14 Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#6 (byte[1000]) SCREEN#8 Alias (byte) main::c#2 = (byte) main::c#4 (byte) main::c#6 Alias (byte*) RASTER#1 = (byte*) RASTER#3 (byte*) RASTER#10 @@ -2402,11 +2402,11 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 - (byte[256]) buffer1#21 ← phi( main/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main/(word) 4352 main::@12/(byte[256]) buffer2#10 ) - (byte[1000]) SCREEN#9 ← phi( main/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main/(word) 53266 main::@12/(byte*) RASTER#1 ) +main::@1: from main main::@11 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#10 main/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#10 ) @@ -2429,14 +2429,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2485,7 +2485,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2529,11 +2529,11 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 - (byte[256]) buffer1#21 ← phi( main/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#13 ← phi( main/(word) 4352 main::@12/(byte[256]) buffer2#10 ) - (byte[1000]) SCREEN#9 ← phi( main/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#5 ← phi( main/(word) 53266 main::@12/(byte*) RASTER#1 ) +main::@1: from main main::@11 + (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#10 main/(word) 4352 ) + (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#13 ) @@ -2556,14 +2556,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2612,7 +2612,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2655,11 +2655,11 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 - (byte[256]) buffer1#10 ← phi( main/(word) 4096 main::@12/(byte[256]) buffer1#10 ) - (byte[256]) buffer2#1 ← phi( main/(word) 4352 main::@12/(byte[256]) buffer2#1 ) - (byte[1000]) SCREEN#1 ← phi( main/(word) 1024 main::@12/(byte[1000]) SCREEN#1 ) - (byte*) RASTER#1 ← phi( main/(word) 53266 main::@12/(byte*) RASTER#1 ) +main::@1: from main main::@11 + (byte[256]) buffer1#10 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[256]) buffer2#1 ← phi( main::@11/(byte[256]) buffer2#1 main/(word) 4352 ) + (byte[1000]) SCREEN#1 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#1 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) to:main::@2 main::@2: from main::@1 main::@6 (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -2678,14 +2678,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2732,7 +2732,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2772,7 +2772,7 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 +main::@1: from main main::@11 (byte[256]) buffer1#10 ← phi( main/(word) 4096 ) (byte[256]) buffer2#1 ← phi( main/(word) 4352 ) (byte[1000]) SCREEN#1 ← phi( main/(word) 1024 ) @@ -2795,14 +2795,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2849,7 +2849,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (byte[1000]) SCREEN#1 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -2889,7 +2889,7 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@1 -main::@1: from main main::@12 +main::@1: from main main::@11 to:main::@2 main::@2: from main::@1 main::@6 (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) @@ -2908,14 +2908,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@1 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -2962,7 +2962,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (word) 1024 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -3004,8 +3004,8 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@2 -main::@2: from main main::@12 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@12/(byte) 25 ) +main::@2: from main main::@11 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 main::@3: from main::@2 main::@3 (byte~) main::$1 ← * (word) 53266 @@ -3021,14 +3021,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@2 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -3075,7 +3075,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*~) plot::$1 ← (word) 1024 + (byte) 200 (byte*) plot::line#0 ← (byte*~) plot::$1 + (byte) 12 to:plot::@1 @@ -3112,8 +3112,8 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@2 -main::@2: from main main::@12 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@12/(byte) 25 ) +main::@2: from main main::@11 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 main::@3: from main::@2 main::@3 (byte~) main::$1 ← * (word) 53266 @@ -3129,14 +3129,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@2 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -3183,7 +3183,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 (byte*) plot::line#0 ← (word) 1224 + (byte) 12 to:plot::@1 plot::@1: from plot plot::@3 @@ -3224,8 +3224,8 @@ CONTROL FLOW GRAPH main: from @BEGIN call prepare param-assignment to:main::@2 -main::@2: from main main::@12 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@12/(byte) 25 ) +main::@2: from main main::@11 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 main::@3: from main::@2 main::@3 (byte~) main::$1 ← * (word) 53266 @@ -3241,14 +3241,14 @@ main::@6: from main::@4 to:main::@7 main::@7: from main::@6 call flip param-assignment - to:main::@11 -main::@11: from main::@7 + to:main::@10 +main::@10: from main::@7 call plot param-assignment - to:main::@12 -main::@12: from main::@11 + to:main::@11 +main::@11: from main::@10 if(true) goto main::@2 to:main::@return -main::@return: from main::@12 +main::@return: from main::@11 return to:@RETURN prepare: from main @@ -3295,7 +3295,7 @@ flip::@3: from flip::@3 flip::@4 flip::@return: from flip::@3 return to:@RETURN -plot: from main::@11 +plot: from main::@10 to:plot::@1 plot::@1: from plot plot::@3 (byte) plot::y#2 ← phi( plot/(byte) 16 plot::@3/(byte) plot::y#1 ) @@ -3342,7 +3342,7 @@ main__B2_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 jmp main__B2 -main__B2_from_B12: +main__B2_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 jmp main__B2 @@ -3374,13 +3374,13 @@ main__B6: jmp main__B7 main__B7: jsr flip + jmp main__B10 +main__B10: + jsr plot jmp main__B11 main__B11: - jsr plot - jmp main__B12 -main__B12: // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B12 + jmp main__B2_from_B11 jmp main__Breturn main__Breturn: rts @@ -3543,8 +3543,8 @@ Removing instruction jmp main__B3 Removing instruction jmp main__B4 Removing instruction jmp main__B6 Removing instruction jmp main__B7 +Removing instruction jmp main__B10 Removing instruction jmp main__B11 -Removing instruction jmp main__B12 Removing instruction jmp main__Breturn Removing instruction jmp plot__B1 Removing instruction jmp plot__B2 @@ -3568,7 +3568,7 @@ main__B2_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 jmp main__B2 -main__B2_from_B12: +main__B2_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 jmp main__B2 @@ -3595,11 +3595,11 @@ main__B6: bne main__B2_from_B6 main__B7: jsr flip -main__B11: +main__B10: jsr plot -main__B12: +main__B11: // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B12 + jmp main__B2_from_B11 main__Breturn: rts plot: @@ -3762,7 +3762,7 @@ main__B2_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 jmp main__B2 -main__B2_from_B12: +main__B2_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 main__B2_from_B6: @@ -3788,11 +3788,11 @@ main__B6: bne main__B2_from_B6 main__B7: jsr flip -main__B11: +main__B10: jsr plot -main__B12: +main__B11: // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B12 + jmp main__B2_from_B11 main__Breturn: rts plot: @@ -3968,8 +3968,8 @@ FINAL SYMBOL TABLE (void()) main() (byte~) main::$1 reg byte a (byte~) main::$3 reg byte a +(label) main::@10 (label) main::@11 -(label) main::@12 (label) main::@2 (label) main::@3 (label) main::@4 @@ -4018,7 +4018,7 @@ main__B2_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 jmp main__B2 -main__B2_from_B12: +main__B2_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 main__B2_from_B6: @@ -4044,11 +4044,11 @@ main__B6: bne main__B2_from_B6 main__B7: jsr flip -main__B11: +main__B10: jsr plot -main__B12: +main__B11: // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B12 + jmp main__B2_from_B11 main__Breturn: rts plot: diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym b/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym index 61f5c9223..c5dd35d21 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym @@ -34,8 +34,8 @@ (void()) main() (byte~) main::$1 reg byte a (byte~) main::$3 reg byte a +(label) main::@10 (label) main::@11 -(label) main::@12 (label) main::@2 (label) main::@3 (label) main::@4 diff --git a/src/dk/camelot64/kickc/test/ref/summin.asm b/src/dk/camelot64/kickc/test/ref/summin.asm new file mode 100644 index 000000000..77b858c98 --- /dev/null +++ b/src/dk/camelot64/kickc/test/ref/summin.asm @@ -0,0 +1,22 @@ +BBEGIN: +sum_from_BBEGIN: + lda #2 + sta 3 + lda #1 + sta 2 + jsr sum +B2: +sum_from_B2: + lda #13 + sta 3 + lda #9 + sta 2 + jsr sum +BEND: +sum: + lda 2 + clc + adc 3 + sta 4 +sum__Breturn: + rts diff --git a/src/dk/camelot64/kickc/test/ref/summin.cfg b/src/dk/camelot64/kickc/test/ref/summin.cfg new file mode 100644 index 000000000..e5cbd8300 --- /dev/null +++ b/src/dk/camelot64/kickc/test/ref/summin.cfg @@ -0,0 +1,15 @@ +@BEGIN: from + call sum param-assignment + to:@2 +@2: from @BEGIN + call sum param-assignment + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) + (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) + (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 + to:sum::@return +sum::@return: from sum + return (byte) s1#0 + to:@RETURN +@END: from @2 diff --git a/src/dk/camelot64/kickc/test/ref/summin.log b/src/dk/camelot64/kickc/test/ref/summin.log new file mode 100644 index 000000000..0030bbb2d --- /dev/null +++ b/src/dk/camelot64/kickc/test/ref/summin.log @@ -0,0 +1,440 @@ +byte s1=sum(1,2); +byte s2=sum(9,13); +byte sum(byte a, byte b) { + return a+b; +} + +PROGRAM + (byte~) $0 ← call sum (byte) 1 (byte) 2 + (byte) s1 ← (byte~) $0 + (byte~) $1 ← call sum (byte) 9 (byte) 13 + (byte) s2 ← (byte~) $1 + proc (byte()) sum((byte) sum::a , (byte) sum::b) + (byte~) sum::$0 ← (byte) sum::a + (byte) sum::b + (byte) sum::return ← (byte~) sum::$0 + goto sum::@return +sum::@return: + (byte) sum::return ← (byte) sum::return + return (byte) sum::return + endproc // sum() + +SYMBOLS +(byte~) $0 +(byte~) $1 +(byte) s1 +(byte) s2 +(byte()) sum((byte) sum::a , (byte) sum::b) +(byte~) sum::$0 +(label) sum::@return +(byte) sum::a +(byte) sum::b +(byte) sum::return + + +INITIAL CONTROL FLOW GRAPH +@BEGIN: from + (byte~) $0 ← call sum (byte) 1 (byte) 2 + (byte) s1 ← (byte~) $0 + (byte~) $1 ← call sum (byte) 9 (byte) 13 + (byte) s2 ← (byte~) $1 + to:@1 +sum: from + (byte~) sum::$0 ← (byte) sum::a + (byte) sum::b + (byte) sum::return ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) sum::return ← (byte) sum::return + return (byte) sum::return + to:@RETURN +sum::@1: from + to:sum::@return +@1: from @BEGIN + to:@END +@END: from @1 + +CONTROL FLOW GRAPH WITH ASSIGNMENT CALL +@BEGIN: from + (byte) sum::a ← (byte) 1 + (byte) sum::b ← (byte) 2 + (byte) sum::return ← call sum param-assignment + to:@2 +@2: from @BEGIN + (byte~) $0 ← (byte) sum::return + (byte) s1 ← (byte~) $0 + (byte) sum::a ← (byte) 9 + (byte) sum::b ← (byte) 13 + (byte) sum::return ← call sum param-assignment + to:@3 +@3: from @2 + (byte~) $1 ← (byte) sum::return + (byte) s2 ← (byte~) $1 + to:@1 +sum: from @2 @BEGIN + (byte~) sum::$0 ← (byte) sum::a + (byte) sum::b + (byte) sum::return ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) sum::return ← (byte) sum::return + return (byte) sum::return + to:@RETURN +sum::@1: from + to:sum::@return +@1: from @3 + to:@END +@END: from @1 + +Completing Phi functions... +Completing Phi functions... +CONTROL FLOW GRAPH SSA +@BEGIN: from + (byte) sum::a#0 ← (byte) 1 + (byte) sum::b#0 ← (byte) 2 + (byte) sum::return#0 ← call sum param-assignment + to:@2 +@2: from @BEGIN + (byte) sum::return#4 ← phi( @BEGIN/(byte) sum::return#0 ) + (byte~) $0 ← (byte) sum::return#4 + (byte) s1#0 ← (byte~) $0 + (byte) sum::a#1 ← (byte) 9 + (byte) sum::b#1 ← (byte) 13 + (byte) sum::return#1 ← call sum param-assignment + to:@3 +@3: from @2 + (byte) sum::return#5 ← phi( @2/(byte) sum::return#1 ) + (byte~) $1 ← (byte) sum::return#5 + (byte) s2#0 ← (byte~) $1 + to:@1 +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 ) + (byte) sum::a#2 ← phi( @2/(byte) sum::a#1 @BEGIN/(byte) sum::a#0 ) + (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 + (byte) sum::return#2 ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) + (byte) sum::return#3 ← (byte) sum::return#6 + return (byte) sum::return#3 + to:@RETURN +sum::@1: from + (byte) sum::return#7 ← phi( ) + to:sum::@return +@1: from @3 + to:@END +@END: from @1 + +CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN +@BEGIN: from + (byte) sum::a#0 ← (byte) 1 + (byte) sum::b#0 ← (byte) 2 + call sum param-assignment + (byte) sum::return#0 ← (byte) sum::return#3 + to:@2 +@2: from @BEGIN + (byte) sum::return#4 ← phi( @BEGIN/(byte) sum::return#0 ) + (byte~) $0 ← (byte) sum::return#4 + (byte) s1#0 ← (byte~) $0 + (byte) sum::a#1 ← (byte) 9 + (byte) sum::b#1 ← (byte) 13 + call sum param-assignment + (byte) sum::return#1 ← (byte) sum::return#3 + to:@3 +@3: from @2 + (byte) sum::return#5 ← phi( @2/(byte) sum::return#1 ) + (byte~) $1 ← (byte) sum::return#5 + (byte) s2#0 ← (byte~) $1 + to:@1 +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 ) + (byte) sum::a#2 ← phi( @2/(byte) sum::a#1 @BEGIN/(byte) sum::a#0 ) + (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 + (byte) sum::return#2 ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) + (byte) sum::return#3 ← (byte) sum::return#6 + return (byte) sum::return#3 + to:@RETURN +sum::@1: from + (byte) sum::return#7 ← phi( ) + to:sum::@return +@1: from @3 + to:@END +@END: from @1 + +Culled Empty Block (label) @1 +Succesful SSA optimization Pass2CullEmptyBlocks +CONTROL FLOW GRAPH +@BEGIN: from + (byte) sum::a#0 ← (byte) 1 + (byte) sum::b#0 ← (byte) 2 + call sum param-assignment + (byte) sum::return#0 ← (byte) sum::return#3 + to:@2 +@2: from @BEGIN + (byte) sum::return#4 ← phi( @BEGIN/(byte) sum::return#0 ) + (byte~) $0 ← (byte) sum::return#4 + (byte) s1#0 ← (byte~) $0 + (byte) sum::a#1 ← (byte) 9 + (byte) sum::b#1 ← (byte) 13 + call sum param-assignment + (byte) sum::return#1 ← (byte) sum::return#3 + to:@3 +@3: from @2 + (byte) sum::return#5 ← phi( @2/(byte) sum::return#1 ) + (byte~) $1 ← (byte) sum::return#5 + (byte) s2#0 ← (byte~) $1 + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 ) + (byte) sum::a#2 ← phi( @2/(byte) sum::a#1 @BEGIN/(byte) sum::a#0 ) + (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 + (byte) sum::return#2 ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) + (byte) sum::return#3 ← (byte) sum::return#6 + return (byte) sum::return#3 + to:@RETURN +sum::@1: from + (byte) sum::return#7 ← phi( ) + to:sum::@return +@END: from @3 + +Constant (byte) sum::a#0 (byte) 1 +Constant (byte) sum::b#0 (byte) 2 +Constant (byte) sum::a#1 (byte) 9 +Constant (byte) sum::b#1 (byte) 13 +Succesful SSA optimization Pass2ConstantPropagation +CONTROL FLOW GRAPH +@BEGIN: from + call sum param-assignment + (byte) sum::return#0 ← (byte) sum::return#3 + to:@2 +@2: from @BEGIN + (byte) sum::return#4 ← phi( @BEGIN/(byte) sum::return#0 ) + (byte~) $0 ← (byte) sum::return#4 + (byte) s1#0 ← (byte~) $0 + call sum param-assignment + (byte) sum::return#1 ← (byte) sum::return#3 + to:@3 +@3: from @2 + (byte) sum::return#5 ← phi( @2/(byte) sum::return#1 ) + (byte~) $1 ← (byte) sum::return#5 + (byte) s2#0 ← (byte~) $1 + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) + (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) + (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 + (byte) sum::return#2 ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) + (byte) sum::return#3 ← (byte) sum::return#6 + return (byte) sum::return#3 + to:@RETURN +sum::@1: from + (byte) sum::return#7 ← phi( ) + to:sum::@return +@END: from @3 + +Alias (byte) s1#0 = (byte) sum::return#0 (byte) sum::return#3 (byte) sum::return#4 (byte~) $0 (byte) sum::return#1 (byte) sum::return#5 (byte~) $1 (byte) s2#0 (byte) sum::return#6 +Alias (byte) sum::return#2 = (byte~) sum::$0 +Succesful SSA optimization Pass2AliasElimination +CONTROL FLOW GRAPH +@BEGIN: from + call sum param-assignment + to:@2 +@2: from @BEGIN + call sum param-assignment + to:@3 +@3: from @2 + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) + (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) + (byte) sum::return#2 ← (byte) sum::a#2 + (byte) sum::b#2 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) s1#0 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) + return (byte) s1#0 + to:@RETURN +sum::@1: from + (byte) sum::return#7 ← phi( ) + to:sum::@return +@END: from @3 + +Redundant Phi (byte) sum::return#7 VOID +Succesful SSA optimization Pass2RedundantPhiElimination +CONTROL FLOW GRAPH +@BEGIN: from + call sum param-assignment + to:@2 +@2: from @BEGIN + call sum param-assignment + to:@3 +@3: from @2 + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) + (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) + (byte) sum::return#2 ← (byte) sum::a#2 + (byte) sum::b#2 + to:sum::@return +sum::@return: from sum sum::@1 + (byte) s1#0 ← phi( sum/(byte) sum::return#2 ) + return (byte) s1#0 + to:@RETURN +sum::@1: from + to:sum::@return +@END: from @3 + +Culled Empty Block (label) @3 +Culled Empty Block (label) sum::@1 +Succesful SSA optimization Pass2CullEmptyBlocks +CONTROL FLOW GRAPH +@BEGIN: from + call sum param-assignment + to:@2 +@2: from @BEGIN + call sum param-assignment + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) + (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) + (byte) sum::return#2 ← (byte) sum::a#2 + (byte) sum::b#2 + to:sum::@return +sum::@return: from sum + (byte) s1#0 ← phi( sum/(byte) sum::return#2 ) + return (byte) s1#0 + to:@RETURN +@END: from @2 + +Alias (byte) s1#0 = (byte) sum::return#2 +Succesful SSA optimization Pass2AliasElimination +CONTROL FLOW GRAPH +@BEGIN: from + call sum param-assignment + to:@2 +@2: from @BEGIN + call sum param-assignment + to:@END +sum: from @2 @BEGIN + (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) + (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) + (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 + to:sum::@return +sum::@return: from sum + return (byte) s1#0 + to:@RETURN +@END: from @2 + +INITIAL ASM +BBEGIN: +sum_from_BBEGIN: + // (byte) sum::b#2 = (byte) 2 // zpby1=coby1 + lda #2 + sta 3 + // (byte) sum::a#2 = (byte) 1 // zpby1=coby1 + lda #1 + sta 2 + jsr sum + jmp B2 +B2: +sum_from_B2: + // (byte) sum::b#2 = (byte) 13 // zpby1=coby1 + lda #13 + sta 3 + // (byte) sum::a#2 = (byte) 9 // zpby1=coby1 + lda #9 + sta 2 + jsr sum + jmp BEND +BEND: +sum: + // (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 // zpby1=zpby2_plus_zpby3 + lda 2 + clc + adc 3 + sta 4 + jmp sum__Breturn +sum__Breturn: + rts + +Removing instruction jmp B2 +Removing instruction jmp BEND +Removing instruction jmp sum__Breturn +Succesful ASM optimization Pass4NextJumpElimination +ASSEMBLER +BBEGIN: +sum_from_BBEGIN: + // (byte) sum::b#2 = (byte) 2 // zpby1=coby1 + lda #2 + sta 3 + // (byte) sum::a#2 = (byte) 1 // zpby1=coby1 + lda #1 + sta 2 + jsr sum +B2: +sum_from_B2: + // (byte) sum::b#2 = (byte) 13 // zpby1=coby1 + lda #13 + sta 3 + // (byte) sum::a#2 = (byte) 9 // zpby1=coby1 + lda #9 + sta 2 + jsr sum +BEND: +sum: + // (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 // zpby1=zpby2_plus_zpby3 + lda 2 + clc + adc 3 + sta 4 +sum__Breturn: + rts + +FINAL SYMBOL TABLE +(label) @2 +(label) @BEGIN +(label) @END +(byte) s1 +(byte) s1#0 zp byte:4 +(byte) s2 +(byte()) sum((byte) sum::a , (byte) sum::b) +(label) sum::@return +(byte) sum::a +(byte) sum::a#2 zp byte:2 +(byte) sum::b +(byte) sum::b#2 zp byte:3 +(byte) sum::return + + +FINAL CODE +BBEGIN: +sum_from_BBEGIN: + // (byte) sum::b#2 = (byte) 2 // zpby1=coby1 + lda #2 + sta 3 + // (byte) sum::a#2 = (byte) 1 // zpby1=coby1 + lda #1 + sta 2 + jsr sum +B2: +sum_from_B2: + // (byte) sum::b#2 = (byte) 13 // zpby1=coby1 + lda #13 + sta 3 + // (byte) sum::a#2 = (byte) 9 // zpby1=coby1 + lda #9 + sta 2 + jsr sum +BEND: +sum: + // (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 // zpby1=zpby2_plus_zpby3 + lda 2 + clc + adc 3 + sta 4 +sum__Breturn: + rts + diff --git a/src/dk/camelot64/kickc/test/ref/summin.sym b/src/dk/camelot64/kickc/test/ref/summin.sym new file mode 100644 index 000000000..0140251c3 --- /dev/null +++ b/src/dk/camelot64/kickc/test/ref/summin.sym @@ -0,0 +1,14 @@ +(label) @2 +(label) @BEGIN +(label) @END +(byte) s1 +(byte) s1#0 zp byte:4 +(byte) s2 +(byte()) sum((byte) sum::a , (byte) sum::b) +(label) sum::@return +(byte) sum::a +(byte) sum::a#2 zp byte:2 +(byte) sum::b +(byte) sum::b#2 zp byte:3 +(byte) sum::return + diff --git a/src/dk/camelot64/kickc/test/summin.kc b/src/dk/camelot64/kickc/test/summin.kc new file mode 100644 index 000000000..84dcb4b53 --- /dev/null +++ b/src/dk/camelot64/kickc/test/summin.kc @@ -0,0 +1,5 @@ +byte s1=sum(1,2); +byte s2=sum(9,13); +byte sum(byte a, byte b) { + return a+b; +}