1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-03 22:29:35 +00:00

Working on classic structs and unions. #197

This commit is contained in:
jespergravgaard 2021-07-25 02:21:25 +02:00
parent 29633a2479
commit f50cbf3cf1
48 changed files with 682 additions and 449 deletions

View File

@ -15265,3 +15265,22 @@ sta {z1}
lda #>{c1}
adc #0
sta {z1}+1
//FRAGMENT vbuz1=_deref_pbuc1_plus__deref_pbuc2
lda {c1}
clc
adc {c2}
sta {z1}
//FRAGMENT vbuaa=_deref_pbuc1_plus__deref_pbuc2
lda {c1}
clc
adc {c2}
//FRAGMENT vbuxx=_deref_pbuc1_plus__deref_pbuc2
lda {c1}
clc
adc {c2}
tax
//FRAGMENT vbuyy=_deref_pbuc1_plus__deref_pbuc2
lda {c1}
clc
adc {c2}
tay

View File

@ -313,6 +313,8 @@ public class Compiler {
new PassNUnwindLValueLists(program).execute();
new Pass1UnwindStructValues(program).execute();
new PassNStructUnwoundPlaceholderRemoval(program).execute();
getLog().append("\nCONTROL FLOW GRAPH SSA");

View File

@ -319,6 +319,7 @@ public class KickC implements Callable<Integer> {
settings = settings.stream().map(String::trim).collect(Collectors.toList());
try {
VariableBuilderConfig config = VariableBuilderConfig.fromSettings(settings, StatementSource.NONE);
config.setStructModelClassic(program.getTargetPlatform().getVariableBuilderConfig().isStructModelClassic());
program.getTargetPlatform().setVariableBuilderConfig(config);
} catch(CompileError e) {
System.err.println(e.getMessage());

View File

@ -85,6 +85,7 @@ public class VariableBuilder {
variable.setMemoryAlignment(this.getAlignment());
variable.setMemoryAddress(this.getAddress());
variable.setDeclarationOnly(this.isDeclarationOnly());
variable.setStructUnwind(this.getStructUnwind());
// Check if the symbol has already been declared
Symbol declaredSymbol = this.scope.getLocalSymbol(this.varName);
@ -114,6 +115,26 @@ public class VariableBuilder {
return variable;
}
private boolean getStructUnwind() {
return isStructUnwind(this.type, getKind(), config);
}
public static boolean isStructUnwind(SymbolType type, Variable.Kind kind, VariableBuilderConfig config) {
if(config.isStructModelClassic())
return false;
if(type instanceof SymbolTypeStruct) {
final SymbolTypeStruct typeStruct = (SymbolTypeStruct) type;
if(typeStruct.isUnion())
return false;
if(Variable.Kind.LOAD_STORE.equals(kind))
return false;
// Unwind non-union, SSA and intermediate struct variables
return true;
}
return false;
}
/**
* Is the type is a simple integer type.
*
@ -312,6 +333,8 @@ public class VariableBuilder {
else if(isVolatile())
// volatile variables must be load/store
return false;
else if(isTypeStruct() && config.isStructModelClassic())
return false;
else {
VariableBuilderConfig.Scope scope = VariableBuilderConfig.getScope(isScopeGlobal(), isScopeLocal(), isScopeIntermediate(), isScopeParameter(), isScopeMember());
VariableBuilderConfig.Type type = VariableBuilderConfig.getType(isTypeInteger(), isArray(), isTypePointer(), isTypeStruct(), isTypeVar());

View File

@ -167,6 +167,9 @@ public class VariableBuilderConfig {
*/
private Map<ScopeType, Setting> settings;
/** Should structs use a classic pointer-friendly model. Defaults to false, but can be changed using #pragma struct_model */
private boolean structModelClassic = false;
public VariableBuilderConfig() {
this.settings = new HashMap<>();
}
@ -325,5 +328,11 @@ public class VariableBuilderConfig {
throw new InternalError("Unknown type!");
}
public boolean isStructModelClassic() {
return structModelClassic;
}
public void setStructModelClassic(boolean structModelClassic) {
this.structModelClassic = structModelClassic;
}
}

View File

@ -6,7 +6,7 @@ import dk.camelot64.kickc.model.types.SymbolTypeStruct;
/**
* A struct definition containing a set of variables.
* The struct definition can either represent a struct (linear consecutive memory layout) or a union (same memory address)
* The struct definition can either represent a struct (member memory-layout is linearly consecutive ) or a union (member start at the same memory address)
*/
public class StructDefinition extends Scope {

View File

@ -1,9 +1,7 @@
package dk.camelot64.kickc.model.symbols;
import dk.camelot64.kickc.model.Comment;
import dk.camelot64.kickc.model.*;
import dk.camelot64.kickc.model.InternalError;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.Registers;
import dk.camelot64.kickc.model.types.SymbolType;
import dk.camelot64.kickc.model.types.SymbolTypePointer;
import dk.camelot64.kickc.model.types.SymbolTypeStruct;
@ -101,7 +99,10 @@ public class Variable implements Symbol {
private Registers.Register allocation;
/** If the variable is only declared and not defined (using the "extern" keyword). */
private boolean isDeclarationOnly;
private boolean declarationOnly;
/** If the variable is a struct that is/should be unwound to variables for each member. */
private boolean structUnwind;
/**
* Create a variable (or constant)
@ -145,6 +146,7 @@ public class Variable implements Symbol {
version.setPermanent(phiMaster.isPermanent());
version.setExport(phiMaster.isExport());
version.setComments(phiMaster.getComments());
version.setStructUnwind(phiMaster.isStructUnwind());
return version;
}
@ -187,6 +189,7 @@ public class Variable implements Symbol {
constVar.setPermanent(variable.isPermanent());
constVar.setExport(variable.isExport());
constVar.setComments(variable.getComments());
constVar.setStructUnwind(variable.isStructUnwind());
return constVar;
}
@ -206,6 +209,7 @@ public class Variable implements Symbol {
copy.setExport(original.isExport());
copy.setRegister(original.getRegister());
copy.setComments(original.getComments());
copy.setStructUnwind(original.isStructUnwind());
return copy;
}
@ -237,6 +241,7 @@ public class Variable implements Symbol {
}
memberVariable.setExport(structVar.isExport());
memberVariable.setPermanent(structVar.isPermanent());
memberVariable.setStructUnwind(memberDefinition.isStructUnwind());
return memberVariable;
}
@ -253,7 +258,7 @@ public class Variable implements Symbol {
return getScope().getLocalVariable(versionOfName);
}
private Kind getKind() {
public Kind getKind() {
return kind;
}
@ -499,18 +504,19 @@ public class Variable implements Symbol {
this.memoryAddress = memoryAddress;
}
public void setStructUnwind(boolean structUnwind) {
this.structUnwind = structUnwind;
}
/**
* Is the variable a struct that should be unwound to member variables
*
* @return true if an unwinding struct
*/
public boolean isStructUnwind() {
if(getType() instanceof SymbolTypeStruct) {
final SymbolTypeStruct typeStruct = (SymbolTypeStruct) getType();
if(!typeStruct.isUnion())
return isKindPhiMaster() || isKindIntermediate() || isKindPhiVersion();
}
return false;
return structUnwind;
}
/**
@ -519,23 +525,18 @@ public class Variable implements Symbol {
* @return true if an classic struct
*/
public boolean isStructClassic() {
if(getType() instanceof SymbolTypeStruct) {
final SymbolTypeStruct typeStruct = (SymbolTypeStruct) getType();
if(typeStruct.isUnion())
return true;
if(isKindLoadStore())
return true;
return !structUnwind;
}
return false;
}
public boolean isDeclarationOnly() {
return isDeclarationOnly;
return declarationOnly;
}
public void setDeclarationOnly(boolean declarationOnly) {
isDeclarationOnly = declarationOnly;
this.declarationOnly = declarationOnly;
}
public List<Comment> getComments() {

View File

@ -44,6 +44,7 @@ public class CParser {
public static final String PRAGMA_ZP_RESERVE = "zp_reserve";
public static final String PRAGMA_CONSTRUCTOR_FOR = "constructor_for";
public static final String PRAGMA_INTERRUPT = "interrupt";
public static final String PRAGMA_STRUCT_MODEL = "struct_model";
/** The Program. */
private Program program;

View File

@ -214,8 +214,18 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
case CParser.PRAGMA_VAR_MODEL:
final List<KickCParser.PragmaParamContext> pragmaParams = ctx.pragmaParam();
List<String> settings = pragmaParams.stream().map(Pass0GenerateStatementSequence::pragmaParamName).collect(Collectors.toList());
final VariableBuilderConfig variableBuilderConfig = VariableBuilderConfig.fromSettings(settings, new StatementSource(ctx));
program.getTargetPlatform().setVariableBuilderConfig(variableBuilderConfig);
final VariableBuilderConfig config = VariableBuilderConfig.fromSettings(settings, new StatementSource(ctx));
config.setStructModelClassic(program.getTargetPlatform().getVariableBuilderConfig().isStructModelClassic());
program.getTargetPlatform().setVariableBuilderConfig(config);
break;
case CParser.PRAGMA_STRUCT_MODEL:
final String modelName = pragmaParamName(pragmaParamSingle(ctx));
if(modelName.equalsIgnoreCase("classic"))
program.getTargetPlatform().getVariableBuilderConfig().setStructModelClassic(true);
else if(modelName.equalsIgnoreCase("unwind"))
program.getTargetPlatform().getVariableBuilderConfig().setStructModelClassic(true);
else
throw new CompileError("Unknown struct model " + modelName, new StatementSource(ctx));
break;
case CParser.PRAGMA_LINKSCRIPT:
final String linkScriptName = pragmaParamString(pragmaParamSingle(ctx));

View File

@ -64,6 +64,7 @@ public class Pass1AddressOfHandling extends Pass2SsaOptimization {
variable.setKind(Variable.Kind.LOAD_STORE);
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
variable.setType(typeQualified);
variable.setStructUnwind(false);
getLog().append("Setting struct to load/store in variable affected by address-of " + stmtStr);
//getLog().append("Setting struct to load/store in variable affected by address-of: " + variable.toString() + " in " + stmtStr);
} else {

View File

@ -42,6 +42,7 @@ public class Pass1AsmUsesHandling extends Pass2SsaOptimization {
variable.setKind(Variable.Kind.LOAD_STORE);
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
variable.setType(typeQualified);
variable.setStructUnwind(false);
getLog().append("Setting struct to load/store in variable affected by address-of: " + variable.toString() + " in " + stmtStr);
} else {
variable.setKind(Variable.Kind.LOAD_STORE);

View File

@ -12,6 +12,7 @@ import dk.camelot64.kickc.model.types.SymbolTypeStruct;
import dk.camelot64.kickc.model.values.*;
import dk.camelot64.kickc.passes.unwinding.ValueSource;
import dk.camelot64.kickc.passes.unwinding.ValueSourceFactory;
import dk.camelot64.kickc.passes.unwinding.ValueSourceVariable;
import java.util.ArrayList;
import java.util.List;
@ -98,7 +99,7 @@ public class Pass1UnwindStructValues extends Pass1Base {
Variable procReturnVar = procedure.getLocalVariable("return");
// TODO: Return-variable has been unwound - detect that instead - use getProgram().getStructVariableMemberUnwinding().getUnwindingMaster() like for parameters
if(procReturnVar != null && procReturnVar.isStructUnwind()) {
if(call.getlValue()!=null && !(call.getlValue() instanceof ValueList)) {
if(call.getlValue() != null && !(call.getlValue() instanceof ValueList)) {
// Return value already unwound - move on
final ValueSource valueSource = ValueSourceFactory.getValueSource(call.getlValue(), getProgram(), getScope(), call, stmtIt, currentBlock);
RValue unwoundLValue = unwindValue(valueSource, call, stmtIt, currentBlock);
@ -118,7 +119,7 @@ public class Pass1UnwindStructValues extends Pass1Base {
boolean anyParameterUnwound = false;
final List<Variable> procParameters = procedure.getParameters();
final List<RValue> callParameters = call.getParameters();
if(callParameters!=null && callParameters.size()>0 ){
if(callParameters != null && callParameters.size() > 0) {
for(int idx_call = 0, idx_proc = 0; idx_call < callParameters.size(); idx_call++) {
final RValue callParameter = callParameters.get(idx_call);
final Variable procParameter = procParameters.get(idx_proc);
@ -188,10 +189,16 @@ public class Pass1UnwindStructValues extends Pass1Base {
*/
private boolean unwindReturn(StatementReturn statementReturn, ListIterator<Statement> stmtIt, ControlFlowBlock currentBlock) {
final RValue returnValue = statementReturn.getValue();
if(returnValue == null)
return false;
if(returnValue instanceof SymbolVariableRef)
if(getScope().getVar((SymbolVariableRef) returnValue).isStructClassic())
return false;
boolean unwound = false;
final ValueSource valueSource = ValueSourceFactory.getValueSource(statementReturn.getValue(), getProgram(), getScope(), statementReturn, stmtIt, currentBlock);
final ValueSource valueSource = ValueSourceFactory.getValueSource(returnValue, getProgram(), getScope(), statementReturn, stmtIt, currentBlock);
RValue unwoundValue = unwindValue(valueSource, statementReturn, stmtIt, currentBlock);
if(unwoundValue != null && !statementReturn.getValue().equals(unwoundValue)) {
if(unwoundValue != null && !returnValue.equals(unwoundValue)) {
statementReturn.setValue(unwoundValue);
if(getLog().isVerboseStructUnwind())
getLog().append("Converted procedure struct return value to member unwinding " + statementReturn.toString(getProgram(), false));
@ -305,6 +312,16 @@ public class Pass1UnwindStructValues extends Pass1Base {
} else if(lValueSource.isUnwindable() && rValueSource.isUnwindable()) {
if(program.getLog().isVerboseStructUnwind())
program.getLog().append("Unwinding value copy " + currentStmt.toString(program, false));
/*
if(lValueSource instanceof ValueSourceVariable) {
final ValueSourceVariable sourceVariable = (ValueSourceVariable) lValueSource;
Statement assignStmt = new StatementAssignment(new PointerDereferenceSimple(new ConstantSymbolPointer(sourceVariable.getVariable().getVariableRef())), new MemsetValue(sourceVariable.getByteSize(program.getScope()), sourceVariable.getSymbolType()), initialAssignment, currentStmt.getSource(), Comment.NO_COMMENTS);
stmtIt.add(assignStmt);
stmtIt.next();
}
*/
for(String memberName : lValueSource.getMemberNames(program.getScope())) {
ValueSource lValueSubSource = lValueSource.getMemberUnwinding(memberName, program, program.getScope(), currentStmt, stmtIt, currentBlock);
ValueSource rValueSubSource = rValueSource.getMemberUnwinding(memberName, program, program.getScope(), currentStmt, stmtIt, currentBlock);

View File

@ -130,7 +130,7 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
VariableRef alias = (VariableRef) assignment.getrValue2();
List<VarAssignments.VarAssignment> assignments = VarAssignments.get(alias, program.getGraph(), program.getScope());
if(assignments.size() == 0)
throw new InternalError("Error! Var is never assigned! " + variable);
throw new InternalError("Error! Var is never assigned! " + alias);
else if(assignments.size() > 1)
// Multiple assignments exist
continue;

View File

@ -1,8 +1,6 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.ControlFlowBlock;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.*;
import dk.camelot64.kickc.model.statements.*;
import dk.camelot64.kickc.model.symbols.Procedure;
import dk.camelot64.kickc.model.symbols.ProgramScope;
@ -141,6 +139,11 @@ public class PassNTypeInference extends Pass2SsaOptimization {
program.getLog().append("Inferred type updated to " + type + " in " + statement.toString(program, false));
}
symbol.setType(type);
// Update struct unwind/classic
if(type instanceof SymbolTypeStruct) {
final VariableBuilderConfig variableBuilderConfig = program.getTargetPlatform().getVariableBuilderConfig();
symbol.setStructUnwind(VariableBuilder.isStructUnwind(type, symbol.getKind(), variableBuilderConfig));
}
}

View File

@ -37,7 +37,7 @@ public abstract class ValueSourceBase implements ValueSource {
return getSymbolType() instanceof SymbolTypeStruct;
}
protected ConstantValue getByteSize(ProgramScope scope) {
public ConstantValue getByteSize(ProgramScope scope) {
return getArraySpec() != null ? getArraySpec().getArraySize() : SizeOfConstants.getSizeOfConstantVar(scope, getSymbolType());
}

View File

@ -43,10 +43,12 @@ public class ValueSourceVariable extends ValueSourceBase {
return variable.isStructClassic();
}
public Variable getVariable() {
return variable;
}
@Override
public RValue getSimpleValue(ProgramScope programScope) {
// Historically this returned a pointer - why?
//return new ConstantSymbolPointer(variable.getRef());
return variable.getRef();
}

View File

@ -2227,6 +2227,17 @@ public class TestProgramsFast extends TestPrograms {
compileAndCompare("struct-directives.c");
}
@Test
public void testIntermediatesStruct() throws IOException {
compileAndCompare("intermediates-struct.c");
}
@Test
public void testIntermediatesSimple() throws IOException {
compileAndCompare("intermediates-simple.c");
}
//@Test
//public void testUnion7() throws IOException {
// compileAndCompare("union-7.c", log().verboseStructUnwind());

View File

@ -0,0 +1,21 @@
// Test intermediate vars
char * const SCREEN = (char*)0x0400;
char idx = 0;
void main() {
for(char i=0;i<5;i++)
for(char j=0;j<5;j++) {
char x = i+j;
SCREEN[idx++] = x;
char y = sum(i,j);
SCREEN[idx++] = y;
}
}
char sum(char a,char b) {
return a+b;
}

View File

@ -0,0 +1,24 @@
// Test intermediate vars
// #pragma struct_model(classic)
char * const SCREEN = (char*)0x0400;
char idx = 0;
struct Data {
char c;
char d;
};
void main() {
struct Data x = sum(1,2);
SCREEN[idx++] = x.c;
struct Data y = sum(3, 4);
SCREEN[idx++] = y.d;
}
struct Data sum(char a,char b) {
__ma struct Data d = { a+b, b };
return d;
}

View File

@ -1,14 +1,14 @@
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment main::point2 = struct-unwound {*(&main::point2)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memset(struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
*((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
*((byte*)&main::point1+OFFSET_STRUCT_POINT_Y) = 3
*(&main::point2) = memcpy(*(&main::point1), struct Point, SIZEOF_STRUCT_POINT)
main::point2 = struct-unwound {*(&main::point2)}
SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
SCREEN[1] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_Y)
to:main::@return
@ -55,11 +55,9 @@ Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment [5] main::point2 = struct-unwound {*(&main::point2)}
Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point2 in [6] SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [6] SCREEN[0] = *((byte*)&main::point2)
Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point2 in [4] SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [4] SCREEN[0] = *((byte*)&main::point2)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -1,10 +1,10 @@
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
SCREEN[1] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_Y)
to:main::@return
@ -42,9 +42,8 @@ Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Simplifying expression containing zero (byte*)&main::point1 in [2] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [2] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1 in [1] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [1] SCREEN[0] = *((byte*)&main::point1)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -1,10 +1,10 @@
Removing C-classic struct-unwound assignment main::v = struct-unwound {*(&main::v)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR)
main::v = struct-unwound {*(&main::v)}
*((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = 2
*((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = 3
*((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = 4
@ -72,16 +72,15 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::v = struct-unwound {*(&main::v)}
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [2] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (struct Point*)&main::v in [2] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = 2
Simplifying expression containing zero (struct Point*)&main::v in [3] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = 3
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [4] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = 4
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [6] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [6] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [6] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [7] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [8] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [1] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (struct Point*)&main::v in [1] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = 2
Simplifying expression containing zero (struct Point*)&main::v in [2] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = 3
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [3] *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = 4
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [5] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [5] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [5] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [6] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [7] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_VECTOR_P
Eliminating unused constant OFFSET_STRUCT_POINT_X

View File

@ -1,10 +1,10 @@
Removing C-classic struct-unwound assignment main::v = struct-unwound {*(&main::v)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::v) = memcpy(*(&$0), struct Vector, SIZEOF_STRUCT_VECTOR)
main::v = struct-unwound {*(&main::v)}
SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
@ -52,12 +52,11 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::v = struct-unwound {*(&main::v)}
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [2] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [2] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [2] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [3] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [4] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [1] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [1] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [1] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [2] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [3] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_VECTOR_P
Eliminating unused constant OFFSET_STRUCT_POINT_X

View File

@ -1,14 +1,14 @@
Removing C-classic struct-unwound assignment main::v = struct-unwound {*(&main::v)}
Removing C-classic struct-unwound assignment main::p1 = struct-unwound {*(&main::p1)}
Removing C-classic struct-unwound assignment main::p2 = struct-unwound {*(&main::p2)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR)
main::v = struct-unwound {*(&main::v)}
*(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::p1 = struct-unwound {*(&main::p1)}
*(&main::p2) = memcpy(*(&$1), struct Point, SIZEOF_STRUCT_POINT)
main::p2 = struct-unwound {*(&main::p2)}
*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q) = memcpy(*(&main::p2), struct Point, SIZEOF_STRUCT_POINT)
SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
@ -62,15 +62,12 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::v = struct-unwound {*(&main::v)}
Removing C-classic struct-unwound assignment [3] main::p1 = struct-unwound {*(&main::p1)}
Removing C-classic struct-unwound assignment [5] main::p2 = struct-unwound {*(&main::p2)}
Simplifying expression containing zero (struct Point*)&main::v in [6] *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [8] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [8] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [8] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [9] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [10] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [3] *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [5] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [5] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [5] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [6] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [7] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_VECTOR_P
Eliminating unused constant OFFSET_STRUCT_POINT_X

View File

@ -1,3 +1,4 @@
Removing C-classic struct-unwound assignment point2 = struct-unwound {*(&point2)}
CONTROL FLOW GRAPH SSA
@ -6,7 +7,6 @@ main: scope:[main] from __start
*((byte*)&point1+OFFSET_STRUCT_POINT_X) = 2
*((byte*)&point1+OFFSET_STRUCT_POINT_Y) = 3
*(&point2) = memcpy(*(&point1), struct Point, SIZEOF_STRUCT_POINT)
point2 = struct-unwound {*(&point2)}
*((byte*)&point2+OFFSET_STRUCT_POINT_X) = 4
main::SCREEN[0] = *((byte*)&point1+OFFSET_STRUCT_POINT_X)
main::SCREEN[1] = *((byte*)&point1+OFFSET_STRUCT_POINT_Y)
@ -66,12 +66,11 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [3] point2 = struct-unwound {*(&point2)}
Simplifying expression containing zero (byte*)&point1 in [0] *((byte*)&point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&point2 in [4] *((byte*)&point2+OFFSET_STRUCT_POINT_X) = 4
Simplifying expression containing zero (byte*)&point1 in [5] main::SCREEN[0] = *((byte*)&point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero main::SCREEN in [5] main::SCREEN[0] = *((byte*)&point1)
Simplifying expression containing zero (byte*)&point2 in [7] main::SCREEN[2] = *((byte*)&point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)&point2 in [3] *((byte*)&point2+OFFSET_STRUCT_POINT_X) = 4
Simplifying expression containing zero (byte*)&point1 in [4] main::SCREEN[0] = *((byte*)&point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero main::SCREEN in [4] main::SCREEN[0] = *((byte*)&point1)
Simplifying expression containing zero (byte*)&point2 in [6] main::SCREEN[2] = *((byte*)&point2+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -1,15 +1,15 @@
Removing C-classic struct-unwound assignment main::p1 = struct-unwound {*(&main::p1)}
Removing C-classic struct-unwound assignment main::p2 = struct-unwound {*(&main::p2)}
Removing C-classic struct-unwound assignment main::v = struct-unwound {*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P), *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::p1 = struct-unwound {*(&main::p1)}
*(&main::p2) = memcpy(*(&$1), struct Point, SIZEOF_STRUCT_POINT)
main::p2 = struct-unwound {*(&main::p2)}
*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q) = memcpy(*(&main::p2), struct Point, SIZEOF_STRUCT_POINT)
main::v = struct-unwound {*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P), *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q)}
SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
@ -60,15 +60,12 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::p1 = struct-unwound {*(&main::p1)}
Removing C-classic struct-unwound assignment [3] main::p2 = struct-unwound {*(&main::p2)}
Removing C-classic struct-unwound assignment [6] main::v = struct-unwound {*((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P), *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q)}
Simplifying expression containing zero (struct Point*)&main::v in [4] *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [7] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [7] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [7] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [8] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [9] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [2] *((struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P) = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P in [4] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v in [4] SCREEN[0] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [4] SCREEN[0] = *((byte*)(struct Point*)&main::v)
Simplifying expression containing zero (struct Point*)&main::v in [5] SCREEN[1] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in [6] SCREEN[2] = *((byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_VECTOR_P
Eliminating unused constant OFFSET_STRUCT_POINT_X

View File

@ -1,11 +1,11 @@
Setting struct to load/store in variable affected by address-of main::ptr = &main::point1
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
main::$2 = (byte*)main::ptr
main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
SCREEN[0] = *main::$0
@ -52,19 +52,18 @@ Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Constant right-side identified [2] main::$2 = (byte*)main::ptr
Constant right-side identified [5] main::$3 = (byte*)main::ptr
Constant right-side identified [1] main::$2 = (byte*)main::ptr
Constant right-side identified [4] main::$3 = (byte*)main::ptr
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$2 = (byte*)main::ptr
Constant main::$3 = (byte*)main::ptr
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [4] SCREEN[0] = *main::$0 -- main::$2[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [7] SCREEN[1] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [3] SCREEN[0] = *main::$0 -- main::$2[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [6] SCREEN[1] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_Y]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$2 in [3] main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$2 in [4] SCREEN[0] = main::$2[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero SCREEN in [4] SCREEN[0] = *main::$2
Simplifying expression containing zero main::$2 in [2] main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$2 in [3] SCREEN[0] = main::$2[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero SCREEN in [3] SCREEN[0] = *main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::$0 and assignment [1] main::$0 = main::$2
Eliminating unused variable main::$1 and assignment [3] main::$1 = main::$3 + OFFSET_STRUCT_POINT_Y

View File

@ -1,12 +1,12 @@
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment main::point2 = struct-unwound {*(&main::point2)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
*(&main::point2) = memcpy(*(&$1), struct Point, SIZEOF_STRUCT_POINT)
main::point2 = struct-unwound {*(&main::point2)}
print::p_x#0 = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
print::p_y#0 = *((byte*)&main::point1+OFFSET_STRUCT_POINT_Y)
call print
@ -75,11 +75,9 @@ Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment [3] main::point2 = struct-unwound {*(&main::point2)}
Simplifying expression containing zero (byte*)&main::point1 in [4] print::p_x#0 = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)&main::point2 in [7] print::p_x#1 = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [12] SCREEN[0] = print::p_x#2
Simplifying expression containing zero (byte*)&main::point1 in [2] print::p_x#0 = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)&main::point2 in [5] print::p_x#1 = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [10] SCREEN[0] = print::p_x#2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -4,6 +4,8 @@ Unwinding list assignment { main::$0_x, main::$0_y } = { getPoint::return_x, get
Unwinding list assignment { main::$1_x, main::$1_y } = { getPoint::return_x, getPoint::return_y }
Unwinding list assignment { getPoint::return_x#0, getPoint::return_y#0 } = { getPoint::return_x#3, getPoint::return_y#3 }
Unwinding list assignment { getPoint::return_x#1, getPoint::return_y#1 } = { getPoint::return_x#3, getPoint::return_y#3 }
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*((byte*)&main::point1+OFFSET_STRUCT_POINT_X), *((byte*)&main::point1+OFFSET_STRUCT_POINT_Y)}
Removing C-classic struct-unwound assignment main::point2 = struct-unwound {*((byte*)&main::point2+OFFSET_STRUCT_POINT_X), *((byte*)&main::point2+OFFSET_STRUCT_POINT_Y)}
CONTROL FLOW GRAPH SSA
@ -22,7 +24,6 @@ main::@1: scope:[main] from main
main::$0_y = getPoint::return_y#4
*((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = main::$0_x
*((byte*)&main::point1+OFFSET_STRUCT_POINT_Y) = main::$0_y
main::point1 = struct-unwound {*((byte*)&main::point1+OFFSET_STRUCT_POINT_X), *((byte*)&main::point1+OFFSET_STRUCT_POINT_Y)}
SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
SCREEN[1] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_Y)
getPoint::x#1 = 4
@ -38,7 +39,6 @@ main::@2: scope:[main] from main::@1
main::$1_y = getPoint::return_y#5
*((byte*)&main::point2+OFFSET_STRUCT_POINT_X) = main::$1_x
*((byte*)&main::point2+OFFSET_STRUCT_POINT_Y) = main::$1_y
main::point2 = struct-unwound {*((byte*)&main::point2+OFFSET_STRUCT_POINT_X), *((byte*)&main::point2+OFFSET_STRUCT_POINT_Y)}
SCREEN[2] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
SCREEN[3] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_Y)
to:main::@return
@ -160,18 +160,16 @@ Alias getPoint::return_y#1 = getPoint::return_y#5
Alias getPoint::return_x#2 = getPoint::p_x#0 getPoint::x#2 getPoint::return_x#6 getPoint::return_x#3
Alias getPoint::return_y#2 = getPoint::p_y#0 getPoint::y#2 getPoint::return_y#6 getPoint::return_y#3
Successful SSA optimization Pass2AliasElimination
Removing C-classic struct-unwound assignment [9] main::point1 = struct-unwound {*((byte*)&main::point1+OFFSET_STRUCT_POINT_X), *((byte*)&main::point1+OFFSET_STRUCT_POINT_Y)}
Removing C-classic struct-unwound assignment [21] main::point2 = struct-unwound {*((byte*)&main::point2+OFFSET_STRUCT_POINT_X), *((byte*)&main::point2+OFFSET_STRUCT_POINT_Y)}
Constant getPoint::x#0 = 2
Constant getPoint::y#0 = 3
Constant getPoint::x#1 = 4
Constant getPoint::y#1 = 5
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero (byte*)&main::point1 in [7] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = main::$0_x
Simplifying expression containing zero (byte*)&main::point1 in [10] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [10] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point2 in [19] *((byte*)&main::point2+OFFSET_STRUCT_POINT_X) = main::$1_x
Simplifying expression containing zero (byte*)&main::point2 in [22] SCREEN[2] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)&main::point1 in [9] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [9] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point2 in [18] *((byte*)&main::point2+OFFSET_STRUCT_POINT_X) = main::$1_x
Simplifying expression containing zero (byte*)&main::point2 in [20] SCREEN[2] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable getPoint::return#0 and assignment [20] getPoint::return#0 = struct-unwound {getPoint::return_x#2, getPoint::return_y#2}
Eliminating unused variable getPoint::return#1 and assignment [21] getPoint::return#1 = struct-unwound {getPoint::return_x#2, getPoint::return_y#2}

View File

@ -2,13 +2,13 @@ Fixing struct type size struct Point to 3
Fixing struct type size struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memset(struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
*((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1] = 'g'
@ -69,12 +69,11 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
Simplifying expression containing zero (byte*)&main::point1 in [5] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [5] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [6] SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
Simplifying expression containing zero (byte*)&main::point1 in [4] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [4] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [5] SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -3,18 +3,18 @@ Fixing struct type size struct Point to 3
Fixing struct type size struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment main::point2 = struct-unwound {*(&main::point2)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memset(struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
*((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1] = 'g'
*(&main::point2) = memcpy(*(&main::point1), struct Point, SIZEOF_STRUCT_POINT)
main::point2 = struct-unwound {*(&main::point2)}
SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
SCREEN[1] = ((byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS)[0]
SCREEN[2] = ((byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS)[1]
@ -73,13 +73,11 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment [6] main::point2 = struct-unwound {*(&main::point2)}
Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
Simplifying expression containing zero (byte*)&main::point2 in [7] SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [7] SCREEN[0] = *((byte*)&main::point2)
Simplifying expression containing zero (byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS in [8] SCREEN[1] = ((byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS)[0]
Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
Simplifying expression containing zero (byte*)&main::point2 in [5] SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [5] SCREEN[0] = *((byte*)&main::point2)
Simplifying expression containing zero (byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS in [6] SCREEN[1] = ((byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS)[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -2,13 +2,13 @@ Fixing struct type size struct Point to 4
Fixing struct type size struct Point to 4
Fixing struct type SIZE_OF struct Point to 4
Fixing struct type SIZE_OF struct Point to 4
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
SCREEN[2] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1]
@ -56,10 +56,9 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Simplifying expression containing zero (byte*)&main::point1 in [2] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [2] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Simplifying expression containing zero (byte*)&main::point1 in [1] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [1] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -2,13 +2,13 @@ Fixing struct type size struct Point to 3
Fixing struct type size struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
SCREEN[2] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1]
@ -56,10 +56,9 @@ Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Simplifying expression containing zero (byte*)&main::point1 in [2] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [2] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Simplifying expression containing zero (byte*)&main::point1 in [1] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [1] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -1,14 +1,14 @@
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment main::point2 = struct-unwound {*(&main::point2)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memset(struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
*((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
*((byte*)&main::point1+OFFSET_STRUCT_POINT_Y) = 3
*(&main::point2) = memcpy(*(&main::point1), struct Point, SIZEOF_STRUCT_POINT)
main::point2 = struct-unwound {*(&main::point2)}
SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
SCREEN[1] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_Y)
to:main::@return
@ -55,11 +55,9 @@ Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Removing C-classic struct-unwound assignment [5] main::point2 = struct-unwound {*(&main::point2)}
Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point2 in [6] SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [6] SCREEN[0] = *((byte*)&main::point2)
Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point2 in [4] SCREEN[0] = *((byte*)&main::point2+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [4] SCREEN[0] = *((byte*)&main::point2)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -1,3 +1,4 @@
Removing C-classic struct-unwound assignment main::to = struct-unwound {*(&main::to)}
CONTROL FLOW GRAPH SSA
@ -11,7 +12,6 @@ main::@1: scope:[main] from main main::@1
main::i#2 = phi( main/main::i#0, main::@1/main::i#1 )
main::$1 = main::i#2 * SIZEOF_STRUCT_SEGMENT
*(&main::to) = memcpy(((struct Vector*)letter_c+OFFSET_STRUCT_SEGMENT_TO)[main::$1], struct Vector, SIZEOF_STRUCT_VECTOR)
main::to = struct-unwound {*(&main::to)}
main::$2 = main::j#3 * SIZEOF_SIGNED_WORD
SCREEN[main::$2] = *((signed word*)&main::to+OFFSET_STRUCT_VECTOR_X)
main::j#1 = ++ main::j#3
@ -66,15 +66,14 @@ struct Vector main::to loadstore
Simplifying constant pointer cast (signed word*) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition main::$0 [14] if(main::i#1!=rangelast(0,2)) goto main::@1
Simple Condition main::$0 [13] if(main::i#1!=rangelast(0,2)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Removing C-classic struct-unwound assignment [5] main::to = struct-unwound {*(&main::to)}
Constant main::j#0 = 0
Constant main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [12] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [14] if(main::i#1!=rangelast(0,2)) goto main::@1 to 3
Simplifying expression containing zero (signed word*)&main::to in [7] SCREEN[main::$2] = *((signed word*)&main::to+OFFSET_STRUCT_VECTOR_X)
Resolved ranged next value [11] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [13] if(main::i#1!=rangelast(0,2)) goto main::@1 to 3
Simplifying expression containing zero (signed word*)&main::to in [6] SCREEN[main::$2] = *((signed word*)&main::to+OFFSET_STRUCT_VECTOR_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_VECTOR_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -1,3 +1,6 @@
Removing C-classic struct-unwound assignment main::v2 = struct-unwound {*((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y)}
Removing C-classic struct-unwound assignment main::v3 = struct-unwound {*((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P), *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q)}
Removing C-classic struct-unwound assignment main::v4 = struct-unwound {*(&main::v4)}
CONTROL FLOW GRAPH SSA
@ -8,12 +11,9 @@ main: scope:[main] from __start
*((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = main::v1_p_y
*((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = main::v1_q_x
*((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = main::v1_q_y
main::v2 = struct-unwound {*((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y)}
*((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P) = memcpy(*((struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P), struct Point, SIZEOF_STRUCT_POINT)
*((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::v3 = struct-unwound {*((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P), *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q)}
*(&main::v4) = memcpy(*(&main::v3), struct Vector, SIZEOF_STRUCT_VECTOR)
main::v4 = struct-unwound {*(&main::v4)}
main::v5_p_x#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
main::v5_p_y#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
SCREEN[main::idx#0] = main::v1_p_x
@ -124,33 +124,30 @@ constant byte main::v5_q_y = 9
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Removing C-classic struct-unwound assignment [5] main::v2 = struct-unwound {*((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X), *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y)}
Removing C-classic struct-unwound assignment [8] main::v3 = struct-unwound {*((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P), *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q)}
Removing C-classic struct-unwound assignment [10] main::v4 = struct-unwound {*(&main::v4)}
Constant main::idx#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero (byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P in [1] *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = main::v1_p_x
Simplifying expression containing zero (struct Point*)&main::v2 in [1] *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P) = main::v1_p_x
Simplifying expression containing zero (struct Point*)&main::v2 in [2] *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = main::v1_p_y
Simplifying expression containing zero (byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q in [3] *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = main::v1_q_x
Simplifying expression containing zero (struct Point*)&main::v2 in [6] *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P) = memcpy(*((struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (struct Point*)&main::v3 in [6] *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P) = memcpy(*((struct Point*)&main::v2), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P in [11] main::v5_p_x#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v4 in [11] main::v5_p_x#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v4 in [12] main::v5_p_y#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero SCREEN in [13] SCREEN[main::idx#0] = main::v1_p_x
Simplifying expression containing zero (byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P in [21] SCREEN[main::idx#4] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v2 in [21] SCREEN[main::idx#4] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v2 in [23] SCREEN[main::idx#5] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q in [25] SCREEN[main::idx#6] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P in [29] SCREEN[main::idx#8] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v3 in [29] SCREEN[main::idx#8] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v3 in [31] SCREEN[main::idx#9] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q in [33] SCREEN[main::idx#10] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P in [37] SCREEN[main::idx#12] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v4 in [37] SCREEN[main::idx#12] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v4 in [39] SCREEN[main::idx#13] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_Q in [41] SCREEN[main::idx#14] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v2 in [5] *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P) = memcpy(*((struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (struct Point*)&main::v3 in [5] *((struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P) = memcpy(*((struct Point*)&main::v2), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P in [8] main::v5_p_x#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v4 in [8] main::v5_p_x#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v4 in [9] main::v5_p_y#0 = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero SCREEN in [10] SCREEN[main::idx#0] = main::v1_p_x
Simplifying expression containing zero (byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P in [18] SCREEN[main::idx#4] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v2 in [18] SCREEN[main::idx#4] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v2 in [20] SCREEN[main::idx#5] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q in [22] SCREEN[main::idx#6] = *((byte*)(struct Point*)&main::v2+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P in [26] SCREEN[main::idx#8] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v3 in [26] SCREEN[main::idx#8] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v3 in [28] SCREEN[main::idx#9] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q in [30] SCREEN[main::idx#10] = *((byte*)(struct Point*)&main::v3+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P in [34] SCREEN[main::idx#12] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point*)&main::v4 in [34] SCREEN[main::idx#12] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero (struct Point*)&main::v4 in [36] SCREEN[main::idx#13] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_Q in [38] SCREEN[main::idx#14] = *((byte*)(struct Point*)&main::v4+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::idx#20 and assignment [48] main::idx#20 = ++ main::idx#19
Eliminating unused constant OFFSET_STRUCT_VECTOR_P

View File

@ -1,4 +1,5 @@
Setting struct to load/store in variable affected by address-of main::$0 = call update &main::s $3e8
Removing C-classic struct-unwound assignment main::s = struct-unwound {*(&main::s)}
CONTROL FLOW GRAPH SSA
@ -19,7 +20,6 @@ update::@return: scope:[update] from update
signed word main()
main: scope:[main] from __start
*(&main::s) = memset(struct myStruct, SIZEOF_STRUCT_MYSTRUCT)
main::s = struct-unwound {*(&main::s)}
update::s#0 = &main::s
update::size#0 = $3e8
call update
@ -84,7 +84,6 @@ Successful SSA optimization Pass2AliasElimination
Identical Phi Values update::s#1 update::s#0
Identical Phi Values update::size#1 update::size#0
Successful SSA optimization Pass2IdenticalPhiElimination
Removing C-classic struct-unwound assignment [8] main::s = struct-unwound {*(&main::s)}
Constant update::s#0 = &main::s
Constant update::size#0 = $3e8
Constant main::return#0 = 0

View File

@ -1,10 +1,10 @@
Removing C-classic struct-unwound assignment main::p = struct-unwound {*(&main::p)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::p = struct-unwound {*(&main::p)}
main::$2 = (byte*)main::q
main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
main::SCREEN[0] = *main::$0
@ -51,19 +51,18 @@ Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::p = struct-unwound {*(&main::p)}
Constant right-side identified [2] main::$2 = (byte*)main::q
Constant right-side identified [5] main::$3 = (byte*)main::q
Constant right-side identified [1] main::$2 = (byte*)main::q
Constant right-side identified [4] main::$3 = (byte*)main::q
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$2 = (byte*)main::q
Constant main::$3 = (byte*)main::q
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [4] main::SCREEN[0] = *main::$0 -- main::$2[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [7] main::SCREEN[1] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [3] main::SCREEN[0] = *main::$0 -- main::$2[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [6] main::SCREEN[1] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_Y]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$2 in [3] main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$2 in [4] main::SCREEN[0] = main::$2[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero main::SCREEN in [4] main::SCREEN[0] = *main::$2
Simplifying expression containing zero main::$2 in [2] main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$2 in [3] main::SCREEN[0] = main::$2[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero main::SCREEN in [3] main::SCREEN[0] = *main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::$0 and assignment [1] main::$0 = main::$2
Eliminating unused variable main::$1 and assignment [3] main::$1 = main::$3 + OFFSET_STRUCT_POINT_Y

View File

@ -1,10 +1,10 @@
Removing C-classic struct-unwound assignment main::p = struct-unwound {*(&main::p)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::p = struct-unwound {*(&main::p)}
set::ptr#0 = main::q
call set
to:main::@1
@ -88,9 +88,8 @@ Finalized unsigned number type (byte) 5
Successful SSA optimization PassNFinalizeNumberTypeConversions
Identical Phi Values set::ptr#1 set::ptr#0
Successful SSA optimization Pass2IdenticalPhiElimination
Removing C-classic struct-unwound assignment [1] main::p = struct-unwound {*(&main::p)}
Constant right-side identified [4] main::$3 = (byte*)main::q
Constant right-side identified [7] main::$4 = (byte*)main::q
Constant right-side identified [3] main::$3 = (byte*)main::q
Constant right-side identified [6] main::$4 = (byte*)main::q
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant set::ptr#0 = main::q
Constant main::$3 = (byte*)main::q
@ -99,16 +98,16 @@ Successful SSA optimization Pass2ConstantIdentification
Constant set::$2 = (byte*)set::ptr#0
Constant set::$3 = (byte*)set::ptr#0
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [6] main::SCREEN[0] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [9] main::SCREEN[1] = *main::$2 -- main::$4[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [14] *set::$0 = 4 -- set::$2[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [17] *set::$1 = 5 -- set::$3[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [5] main::SCREEN[0] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [8] main::SCREEN[1] = *main::$2 -- main::$4[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [13] *set::$0 = 4 -- set::$2[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [16] *set::$1 = 5 -- set::$3[OFFSET_STRUCT_POINT_Y]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$3 in [5] main::$1 = main::$3 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$3 in [6] main::SCREEN[0] = main::$3[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero main::SCREEN in [6] main::SCREEN[0] = *main::$3
Simplifying expression containing zero set::$2 in [13] set::$0 = set::$2 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero set::$2 in [14] set::$2[OFFSET_STRUCT_POINT_X] = 4
Simplifying expression containing zero main::$3 in [4] main::$1 = main::$3 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$3 in [5] main::SCREEN[0] = main::$3[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero main::SCREEN in [5] main::SCREEN[0] = *main::$3
Simplifying expression containing zero set::$2 in [12] set::$0 = set::$2 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero set::$2 in [13] set::$2[OFFSET_STRUCT_POINT_X] = 4
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::$1 and assignment [2] main::$1 = main::$3
Eliminating unused variable main::$2 and assignment [4] main::$2 = main::$4 + OFFSET_STRUCT_POINT_Y

View File

@ -1,5 +1,6 @@
Setting struct to load/store in variable affected by address-of main::ptr = &main::point
Inlined call call __init
Removing C-classic struct-unwound assignment main::point = struct-unwound {*(&main::point)}
CONTROL FLOW GRAPH SSA
@ -7,7 +8,6 @@ void main()
main: scope:[main] from __start::@1
idx#16 = phi( __start::@1/idx#17 )
*(&main::point) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::point = struct-unwound {*(&main::point)}
print::p_x#0 = *((byte*)&main::point+OFFSET_STRUCT_POINT_X)
print::p_y#0 = *((byte*)&main::point+OFFSET_STRUCT_POINT_Y)
call print
@ -126,20 +126,19 @@ Identical Phi Values idx#0 idx#13
Identical Phi Values idx#1 idx#13
Identical Phi Values idx#14 idx#1
Successful SSA optimization Pass2IdenticalPhiElimination
Removing C-classic struct-unwound assignment [2] main::point = struct-unwound {*(&main::point)}
Constant right-side identified [7] main::$4 = (byte*)main::ptr
Constant right-side identified [9] main::$5 = (byte*)main::ptr
Constant right-side identified [6] main::$4 = (byte*)main::ptr
Constant right-side identified [8] main::$5 = (byte*)main::ptr
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$4 = (byte*)main::ptr
Constant main::$5 = (byte*)main::ptr
Constant idx#17 = 0
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [11] print::p_x#1 = *main::$2 -- main::$4[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [12] print::p_y#1 = *main::$3 -- main::$5[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [10] print::p_x#1 = *main::$2 -- main::$4[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [11] print::p_y#1 = *main::$3 -- main::$5[OFFSET_STRUCT_POINT_Y]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero (byte*)&main::point in [3] print::p_x#0 = *((byte*)&main::point+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero main::$4 in [8] main::$2 = main::$4 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$4 in [11] print::p_x#1 = main::$4[OFFSET_STRUCT_POINT_X]
Simplifying expression containing zero (byte*)&main::point in [2] print::p_x#0 = *((byte*)&main::point+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero main::$4 in [7] main::$2 = main::$4 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$4 in [10] print::p_x#1 = main::$4[OFFSET_STRUCT_POINT_X]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::$2 and assignment [4] main::$2 = main::$4
Eliminating unused variable main::$3 and assignment [5] main::$3 = main::$5 + OFFSET_STRUCT_POINT_Y

View File

@ -8,6 +8,8 @@ Fixing struct type SIZE_OF struct Person to 17
Setting struct to load/store in variable affected by address-of main::$0 = call print_person &main::jesper
Setting struct to load/store in variable affected by address-of main::$1 = call print_person &main::henriette
Inlined call call __init
Removing C-classic struct-unwound assignment main::jesper = struct-unwound {*(&main::jesper)}
Removing C-classic struct-unwound assignment main::henriette = struct-unwound {*(&main::henriette)}
CONTROL FLOW GRAPH SSA
@ -15,7 +17,6 @@ void main()
main: scope:[main] from __start::@1
idx#20 = phi( __start::@1/idx#22 )
*(&main::jesper) = memcpy(*(&$0), struct Person, SIZEOF_STRUCT_PERSON)
main::jesper = struct-unwound {*(&main::jesper)}
print_person::person#0 = &main::jesper
call print_person
to:main::@1
@ -23,7 +24,6 @@ main::@1: scope:[main] from main
idx#11 = phi( main/idx#7 )
idx#0 = idx#11
*(&main::henriette) = memcpy(*(&$1), struct Person, SIZEOF_STRUCT_PERSON)
main::henriette = struct-unwound {*(&main::henriette)}
print_person::person#1 = &main::henriette
call print_person
to:main::@2
@ -177,19 +177,17 @@ Identical Phi Values idx#1 idx#17
Identical Phi Values print_person::person#3 print_person::person#2
Identical Phi Values idx#10 idx#1
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition print_person::$6 [24] if(0!=print_person::$1[print_person::i#2]) goto print_person::@2
Simple Condition print_person::$6 [22] if(0!=print_person::$1[print_person::i#2]) goto print_person::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Removing C-classic struct-unwound assignment [2] main::jesper = struct-unwound {*(&main::jesper)}
Removing C-classic struct-unwound assignment [7] main::henriette = struct-unwound {*(&main::henriette)}
Constant print_person::person#0 = &main::jesper
Constant print_person::person#1 = &main::henriette
Constant print_person::i#0 = 0
Constant idx#22 = 0
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [15] SCREEN[idx#14] = DIGIT[*print_person::$0] -- print_person::$3[OFFSET_STRUCT_PERSON_ID]
Converting *(pointer+n) to pointer[n] [13] SCREEN[idx#14] = DIGIT[*print_person::$0] -- print_person::$3[OFFSET_STRUCT_PERSON_ID]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero print_person::$3 in [14] print_person::$0 = print_person::$3 + OFFSET_STRUCT_PERSON_ID
Simplifying expression containing zero print_person::$3 in [15] SCREEN[idx#14] = DIGIT[print_person::$3[OFFSET_STRUCT_PERSON_ID]]
Simplifying expression containing zero print_person::$3 in [12] print_person::$0 = print_person::$3 + OFFSET_STRUCT_PERSON_ID
Simplifying expression containing zero print_person::$3 in [13] SCREEN[idx#14] = DIGIT[print_person::$3[OFFSET_STRUCT_PERSON_ID]]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable print_person::$0 and assignment [7] print_person::$0 = print_person::$3
Eliminating unused constant OFFSET_STRUCT_PERSON_ID

View File

@ -1,10 +1,11 @@
Removing C-classic struct-unwound assignment main::p1 = struct-unwound {*(&main::p1)}
Removing C-classic struct-unwound assignment main::p1 = struct-unwound {*((byte*)&main::p1+OFFSET_STRUCT_POINT_X), *((byte*)&main::p1+OFFSET_STRUCT_POINT_Y)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::p1 = struct-unwound {*(&main::p1)}
main::$0 = 0 * SIZEOF_STRUCT_POINT
SCREEN[main::$0] = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
main::p2_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
@ -25,7 +26,6 @@ main: scope:[main] from __start
main::$8[OFFSET_STRUCT_POINT_Y] = main::p2_y#0
*((byte*)&main::p1+OFFSET_STRUCT_POINT_X) = main::p2_x#1
*((byte*)&main::p1+OFFSET_STRUCT_POINT_Y) = main::p2_y#0
main::p1 = struct-unwound {*((byte*)&main::p1+OFFSET_STRUCT_POINT_X), *((byte*)&main::p1+OFFSET_STRUCT_POINT_Y)}
main::$4 = 8 * SIZEOF_STRUCT_POINT
SCREEN[main::$4] = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
to:main::@return
@ -105,13 +105,11 @@ Inferred type updated to byte in main::$1 = 2 * SIZEOF_STRUCT_POINT
Inferred type updated to byte in main::$2 = 4 * SIZEOF_STRUCT_POINT
Inferred type updated to byte in main::$3 = 6 * SIZEOF_STRUCT_POINT
Inferred type updated to byte in main::$4 = 8 * SIZEOF_STRUCT_POINT
Removing C-classic struct-unwound assignment [1] main::p1 = struct-unwound {*(&main::p1)}
Removing C-classic struct-unwound assignment [22] main::p1 = struct-unwound {*((byte*)&main::p1+OFFSET_STRUCT_POINT_X), *((byte*)&main::p1+OFFSET_STRUCT_POINT_Y)}
Constant right-side identified [2] main::$0 = 0 * SIZEOF_STRUCT_POINT
Constant right-side identified [6] main::$1 = 2 * SIZEOF_STRUCT_POINT
Constant right-side identified [12] main::$2 = 4 * SIZEOF_STRUCT_POINT
Constant right-side identified [15] main::$3 = 6 * SIZEOF_STRUCT_POINT
Constant right-side identified [23] main::$4 = 8 * SIZEOF_STRUCT_POINT
Constant right-side identified [1] main::$0 = 0 * SIZEOF_STRUCT_POINT
Constant right-side identified [5] main::$1 = 2 * SIZEOF_STRUCT_POINT
Constant right-side identified [11] main::$2 = 4 * SIZEOF_STRUCT_POINT
Constant right-side identified [14] main::$3 = 6 * SIZEOF_STRUCT_POINT
Constant right-side identified [21] main::$4 = 8 * SIZEOF_STRUCT_POINT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$0 = 0*SIZEOF_STRUCT_POINT
Constant main::$1 = 2*SIZEOF_STRUCT_POINT
@ -122,12 +120,12 @@ Constant main::$4 = 8*SIZEOF_STRUCT_POINT
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero 0*SIZEOF_STRUCT_POINT in
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero SCREEN in [3] SCREEN[main::$0] = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)&main::p1 in [4] main::p2_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero main::$5 in [8] main::$5[OFFSET_STRUCT_POINT_X] = main::p2_x#0
Simplifying expression containing zero (byte*)&main::p1 in [11] *((byte*)&main::p1+OFFSET_STRUCT_POINT_X) = 3
Simplifying expression containing zero main::$7 in [17] main::$7[OFFSET_STRUCT_POINT_X] = main::p2_x#1
Simplifying expression containing zero (byte*)&main::p1 in [20] *((byte*)&main::p1+OFFSET_STRUCT_POINT_X) = main::p2_x#1
Simplifying expression containing zero SCREEN in [2] SCREEN[main::$0] = memcpy(*(&main::p1), struct Point, SIZEOF_STRUCT_POINT)
Simplifying expression containing zero (byte*)&main::p1 in [3] main::p2_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero main::$5 in [7] main::$5[OFFSET_STRUCT_POINT_X] = main::p2_x#0
Simplifying expression containing zero (byte*)&main::p1 in [10] *((byte*)&main::p1+OFFSET_STRUCT_POINT_X) = 3
Simplifying expression containing zero main::$7 in [16] main::$7[OFFSET_STRUCT_POINT_X] = main::p2_x#1
Simplifying expression containing zero (byte*)&main::p1 in [19] *((byte*)&main::p1+OFFSET_STRUCT_POINT_X) = main::p2_x#1
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::$0
Eliminating unused constant OFFSET_STRUCT_POINT_X

View File

@ -1,10 +1,10 @@
Removing C-classic struct-unwound assignment main::p1 = struct-unwound {*(&main::p1)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
main::p1 = struct-unwound {*(&main::p1)}
print1::p_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
print1::p_y#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_Y)
print1::idx#0 = 0
@ -133,7 +133,6 @@ Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::p1 = struct-unwound {*(&main::p1)}
Constant print1::idx#0 = 0
Constant print2::idx#0 = 2
Constant print1::p_x#1 = main::p2_x
@ -143,10 +142,10 @@ Constant print2::p_x#1 = main::p2_x
Constant print2::p_y#1 = main::p2_y
Constant print2::idx#1 = 6
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero (byte*)&main::p1 in [2] print1::p_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)&main::p1 in [6] print2::p_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)SCREEN in [21] ((byte*)SCREEN+OFFSET_STRUCT_POINT_X)[print1::$0] = print1::p_x#2
Simplifying expression containing zero (byte*)SCREEN in [26] ((byte*)SCREEN+OFFSET_STRUCT_POINT_X)[print2::$0] = print2::p_x#2
Simplifying expression containing zero (byte*)&main::p1 in [1] print1::p_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)&main::p1 in [5] print2::p_x#0 = *((byte*)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)SCREEN in [20] ((byte*)SCREEN+OFFSET_STRUCT_POINT_X)[print1::$0] = print1::p_x#2
Simplifying expression containing zero (byte*)SCREEN in [25] ((byte*)SCREEN+OFFSET_STRUCT_POINT_X)[print2::$0] = print2::p_x#2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars

View File

@ -8,19 +8,24 @@
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.const SIZEOF_STRUCT_COLS = 3
.const OFFSET_STRUCT_COLS_BG = 1
.const OFFSET_STRUCT_COLS_FG = 2
.const SIZEOF_STRUCT_COLS = 3
.label COLS = $d020
.segment Code
// fg_sum(struct Cols zp(3) a, struct Cols zp(6) b)
// fg_sum(byte zp(3) a_border, byte zp(4) a_bg, byte zp(5) a_fg, byte zp(6) b_border, byte zp(7) b_bg, byte zp(8) b_fg)
fg_sum: {
.label a = 3
.label b = 6
.label return = 2
.label a_border = 3
.label a_bg = 4
.label a_fg = 5
.label b_border = 6
.label b_bg = 7
.label b_fg = 8
// a.fg+b.fg
lda a+OFFSET_STRUCT_COLS_FG
lda.z a_fg
clc
adc b+OFFSET_STRUCT_COLS_FG
adc.z b_fg
// return a.fg+b.fg;
sta.z return
// }
@ -28,18 +33,18 @@ fg_sum: {
}
main: {
// fg_sum(a, b)
ldy #SIZEOF_STRUCT_COLS
!:
lda a-1,y
sta fg_sum.a-1,y
dey
bne !-
ldy #SIZEOF_STRUCT_COLS
!:
lda b-1,y
sta fg_sum.b-1,y
dey
bne !-
lda a
sta.z fg_sum.a_border
lda a+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.a_bg
lda a+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.a_fg
lda b
sta.z fg_sum.b_border
lda b+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.b_bg
lda b+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.b_fg
jsr fg_sum
// char sum1 = fg_sum(a, b)
lda.z fg_sum.return
@ -53,18 +58,18 @@ main: {
dey
bne !-
// fg_sum(c, d)
ldy #SIZEOF_STRUCT_COLS
!:
lda c-1,y
sta fg_sum.a-1,y
dey
bne !-
ldy #SIZEOF_STRUCT_COLS
!:
lda d-1,y
sta fg_sum.b-1,y
dey
bne !-
lda c
sta.z fg_sum.a_border
lda c+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.a_bg
lda c+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.a_fg
lda d
sta.z fg_sum.b_border
lda d+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.b_bg
lda d+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.b_fg
jsr fg_sum
// char sum2 = fg_sum(c, d)
lda.z fg_sum.return

View File

@ -1,7 +1,7 @@
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
fg_sum: scope:[fg_sum] from
[0] fg_sum::$0 = *((byte*)&fg_sum::a+OFFSET_STRUCT_COLS_FG) + *((byte*)&fg_sum::b+OFFSET_STRUCT_COLS_FG)
[0] fg_sum::$0 = fg_sum::a_fg + fg_sum::b_fg
[1] fg_sum::return = fg_sum::$0
to:fg_sum::@return
fg_sum::@return: scope:[fg_sum] from fg_sum
@ -10,18 +10,26 @@ fg_sum::@return: scope:[fg_sum] from fg_sum
void main()
main: scope:[main] from
[3] *(&fg_sum::a) = memcpy(*(&a), struct Cols, SIZEOF_STRUCT_COLS)
[4] *(&fg_sum::b) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
[5] callexecute fg_sum
[6] main::sum1#0 = fg_sum::return
[7] *COLS = main::sum1#0
[8] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
[9] *(&fg_sum::a) = memcpy(*(&c), struct Cols, SIZEOF_STRUCT_COLS)
[10] *(&fg_sum::b) = memcpy(*(&d), struct Cols, SIZEOF_STRUCT_COLS)
[11] callexecute fg_sum
[12] main::sum2#0 = fg_sum::return
[13] *COLS = main::sum2#0
[3] fg_sum::a_border = *((byte*)&a)
[4] fg_sum::a_bg = *((byte*)&a+OFFSET_STRUCT_COLS_BG)
[5] fg_sum::a_fg = *((byte*)&a+OFFSET_STRUCT_COLS_FG)
[6] fg_sum::b_border = *((byte*)&b)
[7] fg_sum::b_bg = *((byte*)&b+OFFSET_STRUCT_COLS_BG)
[8] fg_sum::b_fg = *((byte*)&b+OFFSET_STRUCT_COLS_FG)
[9] callexecute fg_sum
[10] main::sum1#0 = fg_sum::return
[11] *COLS = main::sum1#0
[12] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
[13] fg_sum::a_border = *((byte*)&c)
[14] fg_sum::a_bg = *((byte*)&c+OFFSET_STRUCT_COLS_BG)
[15] fg_sum::a_fg = *((byte*)&c+OFFSET_STRUCT_COLS_FG)
[16] fg_sum::b_border = *((byte*)&d)
[17] fg_sum::b_bg = *((byte*)&d+OFFSET_STRUCT_COLS_BG)
[18] fg_sum::b_fg = *((byte*)&d+OFFSET_STRUCT_COLS_FG)
[19] callexecute fg_sum
[20] main::sum2#0 = fg_sum::return
[21] *COLS = main::sum2#0
to:main::@return
main::@return: scope:[main] from main
[14] return
[22] return
to:@return

View File

@ -1,29 +1,35 @@
Converting parameter in __varcall procedure to load/store fg_sum::a
Converting parameter in __varcall procedure to load/store fg_sum::b
Converting return in __varcall procedure to load/store fg_sum::return
Calling convention __varcall adding prepare/execute/finalize for main::$0 = call fg_sum a b
Calling convention __varcall adding prepare/execute/finalize for main::$1 = call fg_sum c d
Eliminating unused variable with no statement fg_sum::a
Eliminating unused variable with no statement fg_sum::b
Calling convention __varcall adding prepare/execute/finalize for main::$0 = call fg_sum *((byte*)&a+OFFSET_STRUCT_COLS_BORDER) *((byte*)&a+OFFSET_STRUCT_COLS_BG) *((byte*)&a+OFFSET_STRUCT_COLS_FG) *((byte*)&b+OFFSET_STRUCT_COLS_BORDER) *((byte*)&b+OFFSET_STRUCT_COLS_BG) *((byte*)&b+OFFSET_STRUCT_COLS_FG)
Calling convention __varcall adding prepare/execute/finalize for main::$1 = call fg_sum *((byte*)&c+OFFSET_STRUCT_COLS_BORDER) *((byte*)&c+OFFSET_STRUCT_COLS_BG) *((byte*)&c+OFFSET_STRUCT_COLS_FG) *((byte*)&d+OFFSET_STRUCT_COLS_BORDER) *((byte*)&d+OFFSET_STRUCT_COLS_BG) *((byte*)&d+OFFSET_STRUCT_COLS_FG)
Calling convention VAR_CALL adding return value assignment main::$0 = fg_sum::return
Calling convention VAR_CALL adding return value assignment main::$1 = fg_sum::return
Removing C-classic struct-unwound assignment d = struct-unwound {*(&d)}
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&fg_sum::a) = memcpy(*(&a), struct Cols, SIZEOF_STRUCT_COLS)
fg_sum::a = struct-unwound {*(&fg_sum::a)}
*(&fg_sum::b) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
fg_sum::b = struct-unwound {*(&fg_sum::b)}
fg_sum::a_border = *((byte*)&a+OFFSET_STRUCT_COLS_BORDER)
fg_sum::a_bg = *((byte*)&a+OFFSET_STRUCT_COLS_BG)
fg_sum::a_fg = *((byte*)&a+OFFSET_STRUCT_COLS_FG)
fg_sum::b_border = *((byte*)&b+OFFSET_STRUCT_COLS_BORDER)
fg_sum::b_bg = *((byte*)&b+OFFSET_STRUCT_COLS_BG)
fg_sum::b_fg = *((byte*)&b+OFFSET_STRUCT_COLS_FG)
callexecute fg_sum
main::$0 = fg_sum::return
main::sum1#0 = main::$0
*COLS = main::sum1#0
*(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
d = struct-unwound {*(&d)}
*(&fg_sum::a) = memcpy(*(&c), struct Cols, SIZEOF_STRUCT_COLS)
fg_sum::a = struct-unwound {*(&fg_sum::a)}
*(&fg_sum::b) = memcpy(*(&d), struct Cols, SIZEOF_STRUCT_COLS)
fg_sum::b = struct-unwound {*(&fg_sum::b)}
fg_sum::a_border = *((byte*)&c+OFFSET_STRUCT_COLS_BORDER)
fg_sum::a_bg = *((byte*)&c+OFFSET_STRUCT_COLS_BG)
fg_sum::a_fg = *((byte*)&c+OFFSET_STRUCT_COLS_FG)
fg_sum::b_border = *((byte*)&d+OFFSET_STRUCT_COLS_BORDER)
fg_sum::b_bg = *((byte*)&d+OFFSET_STRUCT_COLS_BG)
fg_sum::b_fg = *((byte*)&d+OFFSET_STRUCT_COLS_FG)
callexecute fg_sum
main::$1 = fg_sum::return
main::sum2#0 = main::$1
@ -33,9 +39,9 @@ main::@return: scope:[main] from main
return
to:@return
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
fg_sum: scope:[fg_sum] from
fg_sum::$0 = *((byte*)&fg_sum::a+OFFSET_STRUCT_COLS_FG) + *((byte*)&fg_sum::b+OFFSET_STRUCT_COLS_FG)
fg_sum::$0 = fg_sum::a_fg + fg_sum::b_fg
fg_sum::return = fg_sum::$0
to:fg_sum::@return
fg_sum::@return: scope:[fg_sum] from fg_sum
@ -54,6 +60,8 @@ __start::@return: scope:[__start] from __start::@1
SYMBOL TABLE SSA
constant byte* const COLS = (byte*)$d020
constant byte OFFSET_STRUCT_COLS_BG = 1
constant byte OFFSET_STRUCT_COLS_BORDER = 0
constant byte OFFSET_STRUCT_COLS_FG = 2
constant byte SIZEOF_STRUCT_COLS = 3
void __start()
@ -61,10 +69,14 @@ struct Cols a loadstore = { border: 1, bg: 2, fg: 3 }
struct Cols b loadstore = { border: 3, bg: 4, fg: 6 }
struct Cols c loadstore = { border: 5, bg: 6, fg: 7 }
struct Cols d loadstore = {}
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
byte~ fg_sum::$0
struct Cols fg_sum::a loadstore
struct Cols fg_sum::b loadstore
byte fg_sum::a_bg loadstore
byte fg_sum::a_border loadstore
byte fg_sum::a_fg loadstore
byte fg_sum::b_bg loadstore
byte fg_sum::b_border loadstore
byte fg_sum::b_fg loadstore
byte fg_sum::return loadstore
void main()
byte~ main::$0
@ -81,11 +93,13 @@ Alias main::sum1#0 = main::$0
Alias main::sum2#0 = main::$1
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)fg_sum::return = fg_sum::$0
Removing C-classic struct-unwound assignment [1] fg_sum::a = struct-unwound {*(&fg_sum::a)}
Removing C-classic struct-unwound assignment [3] fg_sum::b = struct-unwound {*(&fg_sum::b)}
Removing C-classic struct-unwound assignment [8] d = struct-unwound {*(&d)}
Removing C-classic struct-unwound assignment [10] fg_sum::a = struct-unwound {*(&fg_sum::a)}
Removing C-classic struct-unwound assignment [12] fg_sum::b = struct-unwound {*(&fg_sum::b)}
Simplifying expression containing zero (byte*)&a in [0] fg_sum::a_border = *((byte*)&a+OFFSET_STRUCT_COLS_BORDER)
Simplifying expression containing zero (byte*)&b in [3] fg_sum::b_border = *((byte*)&b+OFFSET_STRUCT_COLS_BORDER)
Simplifying expression containing zero (byte*)&c in [10] fg_sum::a_border = *((byte*)&c+OFFSET_STRUCT_COLS_BORDER)
Simplifying expression containing zero (byte*)&d in [13] fg_sum::b_border = *((byte*)&d+OFFSET_STRUCT_COLS_BORDER)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_COLS_BORDER
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
@ -95,16 +109,16 @@ Alias candidate removed (volatile)fg_sum::return = fg_sum::$0
Alias candidate removed (volatile)fg_sum::return = fg_sum::$0
Alias candidate removed (volatile)fg_sum::return = fg_sum::$0
CALL GRAPH
Calls in [main] to fg_sum:5 fg_sum:11
Calls in [main] to fg_sum:9 fg_sum:19
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
FINAL CONTROL FLOW GRAPH
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
fg_sum: scope:[fg_sum] from
[0] fg_sum::$0 = *((byte*)&fg_sum::a+OFFSET_STRUCT_COLS_FG) + *((byte*)&fg_sum::b+OFFSET_STRUCT_COLS_FG)
[0] fg_sum::$0 = fg_sum::a_fg + fg_sum::b_fg
[1] fg_sum::return = fg_sum::$0
to:fg_sum::@return
fg_sum::@return: scope:[fg_sum] from fg_sum
@ -113,20 +127,28 @@ fg_sum::@return: scope:[fg_sum] from fg_sum
void main()
main: scope:[main] from
[3] *(&fg_sum::a) = memcpy(*(&a), struct Cols, SIZEOF_STRUCT_COLS)
[4] *(&fg_sum::b) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
[5] callexecute fg_sum
[6] main::sum1#0 = fg_sum::return
[7] *COLS = main::sum1#0
[8] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
[9] *(&fg_sum::a) = memcpy(*(&c), struct Cols, SIZEOF_STRUCT_COLS)
[10] *(&fg_sum::b) = memcpy(*(&d), struct Cols, SIZEOF_STRUCT_COLS)
[11] callexecute fg_sum
[12] main::sum2#0 = fg_sum::return
[13] *COLS = main::sum2#0
[3] fg_sum::a_border = *((byte*)&a)
[4] fg_sum::a_bg = *((byte*)&a+OFFSET_STRUCT_COLS_BG)
[5] fg_sum::a_fg = *((byte*)&a+OFFSET_STRUCT_COLS_FG)
[6] fg_sum::b_border = *((byte*)&b)
[7] fg_sum::b_bg = *((byte*)&b+OFFSET_STRUCT_COLS_BG)
[8] fg_sum::b_fg = *((byte*)&b+OFFSET_STRUCT_COLS_FG)
[9] callexecute fg_sum
[10] main::sum1#0 = fg_sum::return
[11] *COLS = main::sum1#0
[12] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS)
[13] fg_sum::a_border = *((byte*)&c)
[14] fg_sum::a_bg = *((byte*)&c+OFFSET_STRUCT_COLS_BG)
[15] fg_sum::a_fg = *((byte*)&c+OFFSET_STRUCT_COLS_FG)
[16] fg_sum::b_border = *((byte*)&d)
[17] fg_sum::b_bg = *((byte*)&d+OFFSET_STRUCT_COLS_BG)
[18] fg_sum::b_fg = *((byte*)&d+OFFSET_STRUCT_COLS_FG)
[19] callexecute fg_sum
[20] main::sum2#0 = fg_sum::return
[21] *COLS = main::sum2#0
to:main::@return
main::@return: scope:[main] from main
[14] return
[22] return
to:@return
@ -135,10 +157,14 @@ struct Cols a loadstore = { border: 1, bg: 2, fg: 3 }
struct Cols b loadstore = { border: 3, bg: 4, fg: 6 }
struct Cols c loadstore = { border: 5, bg: 6, fg: 7 }
struct Cols d loadstore = {}
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
byte~ fg_sum::$0 22.0
struct Cols fg_sum::a loadstore
struct Cols fg_sum::b loadstore
byte fg_sum::a_bg loadstore 40.0
byte fg_sum::a_border loadstore 40.0
byte fg_sum::a_fg loadstore 1.875
byte fg_sum::b_bg loadstore 40.0
byte fg_sum::b_border loadstore 40.0
byte fg_sum::b_fg loadstore 7.5
byte fg_sum::return loadstore 3.75
void main()
byte main::sum1
@ -149,68 +175,108 @@ byte main::sum2#0 4.0
Initial phi equivalence classes
Added variable fg_sum::$0 to live range equivalence class [ fg_sum::$0 ]
Added variable fg_sum::return to live range equivalence class [ fg_sum::return ]
Added variable fg_sum::a_border to live range equivalence class [ fg_sum::a_border ]
Added variable fg_sum::a_bg to live range equivalence class [ fg_sum::a_bg ]
Added variable fg_sum::a_fg to live range equivalence class [ fg_sum::a_fg ]
Added variable fg_sum::b_border to live range equivalence class [ fg_sum::b_border ]
Added variable fg_sum::b_bg to live range equivalence class [ fg_sum::b_bg ]
Added variable fg_sum::b_fg to live range equivalence class [ fg_sum::b_fg ]
Added variable main::sum1#0 to live range equivalence class [ main::sum1#0 ]
Added variable main::sum2#0 to live range equivalence class [ main::sum2#0 ]
Added variable a to live range equivalence class [ a ]
Added variable b to live range equivalence class [ b ]
Added variable c to live range equivalence class [ c ]
Added variable d to live range equivalence class [ d ]
Added variable fg_sum::a to live range equivalence class [ fg_sum::a ]
Added variable fg_sum::b to live range equivalence class [ fg_sum::b ]
Complete equivalence classes
[ fg_sum::$0 ]
[ fg_sum::return ]
[ fg_sum::a_border ]
[ fg_sum::a_bg ]
[ fg_sum::a_fg ]
[ fg_sum::b_border ]
[ fg_sum::b_bg ]
[ fg_sum::b_fg ]
[ main::sum1#0 ]
[ main::sum2#0 ]
[ a ]
[ b ]
[ c ]
[ d ]
[ fg_sum::a ]
[ fg_sum::b ]
Allocated zp[1]:2 [ fg_sum::$0 ]
Allocated zp[1]:3 [ fg_sum::return ]
Allocated zp[1]:4 [ main::sum1#0 ]
Allocated zp[1]:5 [ main::sum2#0 ]
Allocated zp[1]:4 [ fg_sum::a_border ]
Allocated zp[1]:5 [ fg_sum::a_bg ]
Allocated zp[1]:6 [ fg_sum::a_fg ]
Allocated zp[1]:7 [ fg_sum::b_border ]
Allocated zp[1]:8 [ fg_sum::b_bg ]
Allocated zp[1]:9 [ fg_sum::b_fg ]
Allocated zp[1]:10 [ main::sum1#0 ]
Allocated zp[1]:11 [ main::sum2#0 ]
Allocated mem[3] [ a ]
Allocated mem[3] [ b ]
Allocated mem[3] [ c ]
Allocated mem[3] [ d ]
Allocated zp[3]:6 [ fg_sum::a ]
Allocated zp[3]:9 [ fg_sum::b ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] fg_sum::$0 = *((byte*)&fg_sum::a+OFFSET_STRUCT_COLS_FG) + *((byte*)&fg_sum::b+OFFSET_STRUCT_COLS_FG) [ fg_sum::$0 fg_sum::a fg_sum::b ] ( fg_sum:5 [ b d c fg_sum::$0 fg_sum::a fg_sum::b ] { } fg_sum:11 [ fg_sum::$0 fg_sum::a fg_sum::b ] { } ) always clobbers reg byte a
Statement [3] *(&fg_sum::a) = memcpy(*(&a), struct Cols, SIZEOF_STRUCT_COLS) [ fg_sum::a fg_sum::b b d c ] ( [ fg_sum::a fg_sum::b b d c ] { } ) always clobbers reg byte a reg byte y
Statement [4] *(&fg_sum::b) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) [ fg_sum::a fg_sum::b b d c ] ( [ fg_sum::a fg_sum::b b d c ] { } ) always clobbers reg byte a reg byte y
Statement [8] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) [ fg_sum::a fg_sum::b d c ] ( [ fg_sum::a fg_sum::b d c ] { } ) always clobbers reg byte a reg byte y
Statement [9] *(&fg_sum::a) = memcpy(*(&c), struct Cols, SIZEOF_STRUCT_COLS) [ fg_sum::a fg_sum::b d ] ( [ fg_sum::a fg_sum::b d ] { } ) always clobbers reg byte a reg byte y
Statement [10] *(&fg_sum::b) = memcpy(*(&d), struct Cols, SIZEOF_STRUCT_COLS) [ fg_sum::a fg_sum::b ] ( [ fg_sum::a fg_sum::b ] { } ) always clobbers reg byte a reg byte y
Statement [0] fg_sum::$0 = fg_sum::a_fg + fg_sum::b_fg [ fg_sum::$0 ] ( fg_sum:9 [ b d c fg_sum::$0 ] { } fg_sum:19 [ fg_sum::$0 ] { } ) always clobbers reg byte a
Statement [3] fg_sum::a_border = *((byte*)&a) [ a b d c ] ( [ a b d c ] { } ) always clobbers reg byte a
Statement [4] fg_sum::a_bg = *((byte*)&a+OFFSET_STRUCT_COLS_BG) [ a b d c ] ( [ a b d c ] { } ) always clobbers reg byte a
Statement [5] fg_sum::a_fg = *((byte*)&a+OFFSET_STRUCT_COLS_FG) [ fg_sum::a_fg b d c ] ( [ fg_sum::a_fg b d c ] { } ) always clobbers reg byte a
Statement [6] fg_sum::b_border = *((byte*)&b) [ fg_sum::a_fg b d c ] ( [ fg_sum::a_fg b d c ] { } ) always clobbers reg byte a
Statement [7] fg_sum::b_bg = *((byte*)&b+OFFSET_STRUCT_COLS_BG) [ fg_sum::a_fg b d c ] ( [ fg_sum::a_fg b d c ] { } ) always clobbers reg byte a
Statement [8] fg_sum::b_fg = *((byte*)&b+OFFSET_STRUCT_COLS_FG) [ fg_sum::a_fg fg_sum::b_fg b d c ] ( [ fg_sum::a_fg fg_sum::b_fg b d c ] { } ) always clobbers reg byte a
Statement [12] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) [ d c ] ( [ d c ] { } ) always clobbers reg byte a reg byte y
Statement [13] fg_sum::a_border = *((byte*)&c) [ d c ] ( [ d c ] { } ) always clobbers reg byte a
Statement [14] fg_sum::a_bg = *((byte*)&c+OFFSET_STRUCT_COLS_BG) [ d c ] ( [ d c ] { } ) always clobbers reg byte a
Statement [15] fg_sum::a_fg = *((byte*)&c+OFFSET_STRUCT_COLS_FG) [ fg_sum::a_fg d ] ( [ fg_sum::a_fg d ] { } ) always clobbers reg byte a
Statement [16] fg_sum::b_border = *((byte*)&d) [ fg_sum::a_fg d ] ( [ fg_sum::a_fg d ] { } ) always clobbers reg byte a
Statement [17] fg_sum::b_bg = *((byte*)&d+OFFSET_STRUCT_COLS_BG) [ fg_sum::a_fg d ] ( [ fg_sum::a_fg d ] { } ) always clobbers reg byte a
Statement [18] fg_sum::b_fg = *((byte*)&d+OFFSET_STRUCT_COLS_FG) [ fg_sum::a_fg fg_sum::b_fg ] ( [ fg_sum::a_fg fg_sum::b_fg ] { } ) always clobbers reg byte a
Potential registers zp[1]:2 [ fg_sum::$0 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ fg_sum::return ] : zp[1]:3 ,
Potential registers zp[1]:4 [ main::sum1#0 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:5 [ main::sum2#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:4 [ fg_sum::a_border ] : zp[1]:4 ,
Potential registers zp[1]:5 [ fg_sum::a_bg ] : zp[1]:5 ,
Potential registers zp[1]:6 [ fg_sum::a_fg ] : zp[1]:6 ,
Potential registers zp[1]:7 [ fg_sum::b_border ] : zp[1]:7 ,
Potential registers zp[1]:8 [ fg_sum::b_bg ] : zp[1]:8 ,
Potential registers zp[1]:9 [ fg_sum::b_fg ] : zp[1]:9 ,
Potential registers zp[1]:10 [ main::sum1#0 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:11 [ main::sum2#0 ] : zp[1]:11 , reg byte a , reg byte x , reg byte y ,
Potential registers mem[3] [ a ] : mem[3] ,
Potential registers mem[3] [ b ] : mem[3] ,
Potential registers mem[3] [ c ] : mem[3] ,
Potential registers mem[3] [ d ] : mem[3] ,
Potential registers zp[3]:6 [ fg_sum::a ] : zp[3]:6 ,
Potential registers zp[3]:9 [ fg_sum::b ] : zp[3]:9 ,
REGISTER UPLIFT SCOPES
Uplift Scope [fg_sum] 22: zp[1]:2 [ fg_sum::$0 ] 3.75: zp[1]:3 [ fg_sum::return ] 0: zp[3]:6 [ fg_sum::a ] 0: zp[3]:9 [ fg_sum::b ]
Uplift Scope [main] 4: zp[1]:4 [ main::sum1#0 ] 4: zp[1]:5 [ main::sum2#0 ]
Uplift Scope [fg_sum] 40: zp[1]:4 [ fg_sum::a_border ] 40: zp[1]:5 [ fg_sum::a_bg ] 40: zp[1]:7 [ fg_sum::b_border ] 40: zp[1]:8 [ fg_sum::b_bg ] 22: zp[1]:2 [ fg_sum::$0 ] 7.5: zp[1]:9 [ fg_sum::b_fg ] 3.75: zp[1]:3 [ fg_sum::return ] 1.88: zp[1]:6 [ fg_sum::a_fg ]
Uplift Scope [main] 4: zp[1]:10 [ main::sum1#0 ] 4: zp[1]:11 [ main::sum2#0 ]
Uplift Scope [Cols]
Uplift Scope [] 0: mem[3] [ a ] 0: mem[3] [ b ] 0: mem[3] [ c ] 0: mem[3] [ d ]
Uplifting [fg_sum] best 149 combination reg byte a [ fg_sum::$0 ] zp[1]:3 [ fg_sum::return ] zp[3]:6 [ fg_sum::a ] zp[3]:9 [ fg_sum::b ]
Uplifting [main] best 137 combination reg byte a [ main::sum1#0 ] reg byte a [ main::sum2#0 ]
Uplifting [Cols] best 137 combination
Uplifting [] best 137 combination mem[3] [ a ] mem[3] [ b ] mem[3] [ c ] mem[3] [ d ]
Uplifting [fg_sum] best 167 combination zp[1]:4 [ fg_sum::a_border ] zp[1]:5 [ fg_sum::a_bg ] zp[1]:7 [ fg_sum::b_border ] zp[1]:8 [ fg_sum::b_bg ] reg byte a [ fg_sum::$0 ] zp[1]:9 [ fg_sum::b_fg ] zp[1]:3 [ fg_sum::return ] zp[1]:6 [ fg_sum::a_fg ]
Uplifting [main] best 155 combination reg byte a [ main::sum1#0 ] reg byte a [ main::sum2#0 ]
Uplifting [Cols] best 155 combination
Uplifting [] best 155 combination mem[3] [ a ] mem[3] [ b ] mem[3] [ c ] mem[3] [ d ]
Attempting to uplift remaining variables inzp[1]:4 [ fg_sum::a_border ]
Uplifting [fg_sum] best 155 combination zp[1]:4 [ fg_sum::a_border ]
Attempting to uplift remaining variables inzp[1]:5 [ fg_sum::a_bg ]
Uplifting [fg_sum] best 155 combination zp[1]:5 [ fg_sum::a_bg ]
Attempting to uplift remaining variables inzp[1]:7 [ fg_sum::b_border ]
Uplifting [fg_sum] best 155 combination zp[1]:7 [ fg_sum::b_border ]
Attempting to uplift remaining variables inzp[1]:8 [ fg_sum::b_bg ]
Uplifting [fg_sum] best 155 combination zp[1]:8 [ fg_sum::b_bg ]
Attempting to uplift remaining variables inzp[1]:9 [ fg_sum::b_fg ]
Uplifting [fg_sum] best 155 combination zp[1]:9 [ fg_sum::b_fg ]
Attempting to uplift remaining variables inzp[1]:3 [ fg_sum::return ]
Uplifting [fg_sum] best 137 combination zp[1]:3 [ fg_sum::return ]
Uplifting [fg_sum] best 155 combination zp[1]:3 [ fg_sum::return ]
Attempting to uplift remaining variables inzp[1]:6 [ fg_sum::a_fg ]
Uplifting [fg_sum] best 155 combination zp[1]:6 [ fg_sum::a_fg ]
Allocated (was zp[1]:3) zp[1]:2 [ fg_sum::return ]
Allocated (was zp[3]:6) zp[3]:3 [ fg_sum::a ]
Allocated (was zp[3]:9) zp[3]:6 [ fg_sum::b ]
Allocated (was zp[1]:4) zp[1]:3 [ fg_sum::a_border ]
Allocated (was zp[1]:5) zp[1]:4 [ fg_sum::a_bg ]
Allocated (was zp[1]:6) zp[1]:5 [ fg_sum::a_fg ]
Allocated (was zp[1]:7) zp[1]:6 [ fg_sum::b_border ]
Allocated (was zp[1]:8) zp[1]:7 [ fg_sum::b_bg ]
Allocated (was zp[1]:9) zp[1]:8 [ fg_sum::b_fg ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -226,20 +292,25 @@ ASSEMBLER BEFORE OPTIMIZATION
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.const SIZEOF_STRUCT_COLS = 3
.const OFFSET_STRUCT_COLS_BG = 1
.const OFFSET_STRUCT_COLS_FG = 2
.const SIZEOF_STRUCT_COLS = 3
.label COLS = $d020
.segment Code
// fg_sum
// fg_sum(struct Cols zp(3) a, struct Cols zp(6) b)
// fg_sum(byte zp(3) a_border, byte zp(4) a_bg, byte zp(5) a_fg, byte zp(6) b_border, byte zp(7) b_bg, byte zp(8) b_fg)
fg_sum: {
.label a = 3
.label b = 6
.label return = 2
// [0] fg_sum::$0 = *((byte*)&fg_sum::a+OFFSET_STRUCT_COLS_FG) + *((byte*)&fg_sum::b+OFFSET_STRUCT_COLS_FG) -- vbuaa=_deref_pbuc1_plus__deref_pbuc2
lda a+OFFSET_STRUCT_COLS_FG
.label a_border = 3
.label a_bg = 4
.label a_fg = 5
.label b_border = 6
.label b_bg = 7
.label b_fg = 8
// [0] fg_sum::$0 = fg_sum::a_fg + fg_sum::b_fg -- vbuaa=vbuz1_plus_vbuz2
lda.z a_fg
clc
adc b+OFFSET_STRUCT_COLS_FG
adc.z b_fg
// [1] fg_sum::return = fg_sum::$0 -- vbuz1=vbuaa
sta.z return
jmp __breturn
@ -250,57 +321,65 @@ fg_sum: {
}
// main
main: {
// [3] *(&fg_sum::a) = memcpy(*(&a), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda a-1,y
sta fg_sum.a-1,y
dey
bne !-
// [4] *(&fg_sum::b) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda b-1,y
sta fg_sum.b-1,y
dey
bne !-
// [5] callexecute fg_sum -- jsr
// [3] fg_sum::a_border = *((byte*)&a) -- vbuz1=_deref_pbuc1
lda a
sta.z fg_sum.a_border
// [4] fg_sum::a_bg = *((byte*)&a+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda a+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.a_bg
// [5] fg_sum::a_fg = *((byte*)&a+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda a+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.a_fg
// [6] fg_sum::b_border = *((byte*)&b) -- vbuz1=_deref_pbuc1
lda b
sta.z fg_sum.b_border
// [7] fg_sum::b_bg = *((byte*)&b+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda b+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.b_bg
// [8] fg_sum::b_fg = *((byte*)&b+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda b+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.b_fg
// [9] callexecute fg_sum -- jsr
jsr fg_sum
// [6] main::sum1#0 = fg_sum::return -- vbuaa=vbuz1
// [10] main::sum1#0 = fg_sum::return -- vbuaa=vbuz1
lda.z fg_sum.return
// [7] *COLS = main::sum1#0 -- _deref_pbuc1=vbuaa
// [11] *COLS = main::sum1#0 -- _deref_pbuc1=vbuaa
sta COLS
// [8] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
// [12] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda b-1,y
sta d-1,y
dey
bne !-
// [9] *(&fg_sum::a) = memcpy(*(&c), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda c-1,y
sta fg_sum.a-1,y
dey
bne !-
// [10] *(&fg_sum::b) = memcpy(*(&d), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda d-1,y
sta fg_sum.b-1,y
dey
bne !-
// [11] callexecute fg_sum -- jsr
// [13] fg_sum::a_border = *((byte*)&c) -- vbuz1=_deref_pbuc1
lda c
sta.z fg_sum.a_border
// [14] fg_sum::a_bg = *((byte*)&c+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda c+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.a_bg
// [15] fg_sum::a_fg = *((byte*)&c+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda c+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.a_fg
// [16] fg_sum::b_border = *((byte*)&d) -- vbuz1=_deref_pbuc1
lda d
sta.z fg_sum.b_border
// [17] fg_sum::b_bg = *((byte*)&d+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda d+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.b_bg
// [18] fg_sum::b_fg = *((byte*)&d+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda d+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.b_fg
// [19] callexecute fg_sum -- jsr
jsr fg_sum
// [12] main::sum2#0 = fg_sum::return -- vbuaa=vbuz1
// [20] main::sum2#0 = fg_sum::return -- vbuaa=vbuz1
lda.z fg_sum.return
// [13] *COLS = main::sum2#0 -- _deref_pbuc1=vbuaa
// [21] *COLS = main::sum2#0 -- _deref_pbuc1=vbuaa
sta COLS
jmp __breturn
// main::@return
__breturn:
// [14] return
// [22] return
rts
}
// File Data
@ -320,16 +399,21 @@ Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const COLS = (byte*) 53280
constant byte OFFSET_STRUCT_COLS_BG = 1
constant byte OFFSET_STRUCT_COLS_FG = 2
constant byte SIZEOF_STRUCT_COLS = 3
struct Cols a loadstore mem[3] = { border: 1, bg: 2, fg: 3 }
struct Cols b loadstore mem[3] = { border: 3, bg: 4, fg: 6 }
struct Cols c loadstore mem[3] = { border: 5, bg: 6, fg: 7 }
struct Cols d loadstore mem[3] = {}
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
byte~ fg_sum::$0 reg byte a 22.0
struct Cols fg_sum::a loadstore zp[3]:3
struct Cols fg_sum::b loadstore zp[3]:6
byte fg_sum::a_bg loadstore zp[1]:4 40.0
byte fg_sum::a_border loadstore zp[1]:3 40.0
byte fg_sum::a_fg loadstore zp[1]:5 1.875
byte fg_sum::b_bg loadstore zp[1]:7 40.0
byte fg_sum::b_border loadstore zp[1]:6 40.0
byte fg_sum::b_fg loadstore zp[1]:8 7.5
byte fg_sum::return loadstore zp[1]:2 3.75
void main()
byte main::sum1
@ -339,18 +423,22 @@ byte main::sum2#0 reg byte a 4.0
reg byte a [ fg_sum::$0 ]
zp[1]:2 [ fg_sum::return ]
zp[1]:3 [ fg_sum::a_border ]
zp[1]:4 [ fg_sum::a_bg ]
zp[1]:5 [ fg_sum::a_fg ]
zp[1]:6 [ fg_sum::b_border ]
zp[1]:7 [ fg_sum::b_bg ]
zp[1]:8 [ fg_sum::b_fg ]
reg byte a [ main::sum1#0 ]
reg byte a [ main::sum2#0 ]
mem[3] [ a ]
mem[3] [ b ]
mem[3] [ c ]
mem[3] [ d ]
zp[3]:3 [ fg_sum::a ]
zp[3]:6 [ fg_sum::b ]
FINAL ASSEMBLER
Score: 131
Score: 149
// File Comments
// Test __varcall calling convention
@ -365,21 +453,26 @@ Score: 131
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.const SIZEOF_STRUCT_COLS = 3
.const OFFSET_STRUCT_COLS_BG = 1
.const OFFSET_STRUCT_COLS_FG = 2
.const SIZEOF_STRUCT_COLS = 3
.label COLS = $d020
.segment Code
// fg_sum
// fg_sum(struct Cols zp(3) a, struct Cols zp(6) b)
// fg_sum(byte zp(3) a_border, byte zp(4) a_bg, byte zp(5) a_fg, byte zp(6) b_border, byte zp(7) b_bg, byte zp(8) b_fg)
fg_sum: {
.label a = 3
.label b = 6
.label return = 2
.label a_border = 3
.label a_bg = 4
.label a_fg = 5
.label b_border = 6
.label b_bg = 7
.label b_fg = 8
// a.fg+b.fg
// [0] fg_sum::$0 = *((byte*)&fg_sum::a+OFFSET_STRUCT_COLS_FG) + *((byte*)&fg_sum::b+OFFSET_STRUCT_COLS_FG) -- vbuaa=_deref_pbuc1_plus__deref_pbuc2
lda a+OFFSET_STRUCT_COLS_FG
// [0] fg_sum::$0 = fg_sum::a_fg + fg_sum::b_fg -- vbuaa=vbuz1_plus_vbuz2
lda.z a_fg
clc
adc b+OFFSET_STRUCT_COLS_FG
adc.z b_fg
// return a.fg+b.fg;
// [1] fg_sum::return = fg_sum::$0 -- vbuz1=vbuaa
sta.z return
@ -391,30 +484,34 @@ fg_sum: {
// main
main: {
// fg_sum(a, b)
// [3] *(&fg_sum::a) = memcpy(*(&a), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda a-1,y
sta fg_sum.a-1,y
dey
bne !-
// [4] *(&fg_sum::b) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda b-1,y
sta fg_sum.b-1,y
dey
bne !-
// [5] callexecute fg_sum -- jsr
// [3] fg_sum::a_border = *((byte*)&a) -- vbuz1=_deref_pbuc1
lda a
sta.z fg_sum.a_border
// [4] fg_sum::a_bg = *((byte*)&a+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda a+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.a_bg
// [5] fg_sum::a_fg = *((byte*)&a+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda a+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.a_fg
// [6] fg_sum::b_border = *((byte*)&b) -- vbuz1=_deref_pbuc1
lda b
sta.z fg_sum.b_border
// [7] fg_sum::b_bg = *((byte*)&b+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda b+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.b_bg
// [8] fg_sum::b_fg = *((byte*)&b+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda b+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.b_fg
// [9] callexecute fg_sum -- jsr
jsr fg_sum
// char sum1 = fg_sum(a, b)
// [6] main::sum1#0 = fg_sum::return -- vbuaa=vbuz1
// [10] main::sum1#0 = fg_sum::return -- vbuaa=vbuz1
lda.z fg_sum.return
// *COLS = sum1
// [7] *COLS = main::sum1#0 -- _deref_pbuc1=vbuaa
// [11] *COLS = main::sum1#0 -- _deref_pbuc1=vbuaa
sta COLS
// d = b
// [8] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
// [12] *(&d) = memcpy(*(&b), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda b-1,y
@ -422,31 +519,35 @@ main: {
dey
bne !-
// fg_sum(c, d)
// [9] *(&fg_sum::a) = memcpy(*(&c), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda c-1,y
sta fg_sum.a-1,y
dey
bne !-
// [10] *(&fg_sum::b) = memcpy(*(&d), struct Cols, SIZEOF_STRUCT_COLS) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
ldy #SIZEOF_STRUCT_COLS
!:
lda d-1,y
sta fg_sum.b-1,y
dey
bne !-
// [11] callexecute fg_sum -- jsr
// [13] fg_sum::a_border = *((byte*)&c) -- vbuz1=_deref_pbuc1
lda c
sta.z fg_sum.a_border
// [14] fg_sum::a_bg = *((byte*)&c+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda c+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.a_bg
// [15] fg_sum::a_fg = *((byte*)&c+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda c+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.a_fg
// [16] fg_sum::b_border = *((byte*)&d) -- vbuz1=_deref_pbuc1
lda d
sta.z fg_sum.b_border
// [17] fg_sum::b_bg = *((byte*)&d+OFFSET_STRUCT_COLS_BG) -- vbuz1=_deref_pbuc1
lda d+OFFSET_STRUCT_COLS_BG
sta.z fg_sum.b_bg
// [18] fg_sum::b_fg = *((byte*)&d+OFFSET_STRUCT_COLS_FG) -- vbuz1=_deref_pbuc1
lda d+OFFSET_STRUCT_COLS_FG
sta.z fg_sum.b_fg
// [19] callexecute fg_sum -- jsr
jsr fg_sum
// char sum2 = fg_sum(c, d)
// [12] main::sum2#0 = fg_sum::return -- vbuaa=vbuz1
// [20] main::sum2#0 = fg_sum::return -- vbuaa=vbuz1
lda.z fg_sum.return
// *COLS = sum2
// [13] *COLS = main::sum2#0 -- _deref_pbuc1=vbuaa
// [21] *COLS = main::sum2#0 -- _deref_pbuc1=vbuaa
sta COLS
// main::@return
// }
// [14] return
// [22] return
rts
}
// File Data

View File

@ -1,14 +1,19 @@
constant byte* const COLS = (byte*) 53280
constant byte OFFSET_STRUCT_COLS_BG = 1
constant byte OFFSET_STRUCT_COLS_FG = 2
constant byte SIZEOF_STRUCT_COLS = 3
struct Cols a loadstore mem[3] = { border: 1, bg: 2, fg: 3 }
struct Cols b loadstore mem[3] = { border: 3, bg: 4, fg: 6 }
struct Cols c loadstore mem[3] = { border: 5, bg: 6, fg: 7 }
struct Cols d loadstore mem[3] = {}
__varcall byte fg_sum(struct Cols fg_sum::a , struct Cols fg_sum::b)
__varcall byte fg_sum(byte fg_sum::a_border , byte fg_sum::a_bg , byte fg_sum::a_fg , byte fg_sum::b_border , byte fg_sum::b_bg , byte fg_sum::b_fg)
byte~ fg_sum::$0 reg byte a 22.0
struct Cols fg_sum::a loadstore zp[3]:3
struct Cols fg_sum::b loadstore zp[3]:6
byte fg_sum::a_bg loadstore zp[1]:4 40.0
byte fg_sum::a_border loadstore zp[1]:3 40.0
byte fg_sum::a_fg loadstore zp[1]:5 1.875
byte fg_sum::b_bg loadstore zp[1]:7 40.0
byte fg_sum::b_border loadstore zp[1]:6 40.0
byte fg_sum::b_fg loadstore zp[1]:8 7.5
byte fg_sum::return loadstore zp[1]:2 3.75
void main()
byte main::sum1
@ -18,11 +23,15 @@ byte main::sum2#0 reg byte a 4.0
reg byte a [ fg_sum::$0 ]
zp[1]:2 [ fg_sum::return ]
zp[1]:3 [ fg_sum::a_border ]
zp[1]:4 [ fg_sum::a_bg ]
zp[1]:5 [ fg_sum::a_fg ]
zp[1]:6 [ fg_sum::b_border ]
zp[1]:7 [ fg_sum::b_bg ]
zp[1]:8 [ fg_sum::b_fg ]
reg byte a [ main::sum1#0 ]
reg byte a [ main::sum2#0 ]
mem[3] [ a ]
mem[3] [ b ]
mem[3] [ c ]
mem[3] [ d ]
zp[3]:3 [ fg_sum::a ]
zp[3]:6 [ fg_sum::b ]

View File

@ -18,7 +18,8 @@
"mega65.h": "c",
"mega65-f018.h": "c",
"mega65-viciv.h": "c",
"6502.h": "c"
"6502.h": "c",
"atan2.h": "c"
},
"kickassembler.assemblerJar": "/Applications/KickAssembler/KickAss.jar"
}