mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-06 00:33:42 +00:00
Completed refactoring of Variable class to use StorageStrategy.
This commit is contained in:
parent
f09e4da4d4
commit
032f9d079e
@ -81,12 +81,12 @@ public class AsmFragmentTemplate {
|
||||
// Generate a dummy instance to find clobber & cycles
|
||||
ProgramScope scope = new ProgramScope();
|
||||
LinkedHashMap<String, Value> bindings = new LinkedHashMap<>();
|
||||
Variable v1 = new Variable("$tmp1", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION, true, false, false);
|
||||
Variable v2 = new Variable("$tmp2", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION, true, false, false);
|
||||
Variable v3 = new Variable("$tmp3", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION, true, false, false);
|
||||
Variable v4 = new Variable("$tmp4", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION, true, false, false);
|
||||
Variable v5 = new Variable("$tmp5", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION, true, false, false);
|
||||
Variable v6 = new Variable("$tmp6", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION, true, false, false);
|
||||
Variable v1 = new Variable("$tmp1", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION);
|
||||
Variable v2 = new Variable("$tmp2", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION);
|
||||
Variable v3 = new Variable("$tmp3", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION);
|
||||
Variable v4 = new Variable("$tmp4", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION);
|
||||
Variable v5 = new Variable("$tmp5", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION);
|
||||
Variable v6 = new Variable("$tmp6", scope, SymbolType.BYTE, null, SymbolVariable.StorageStrategy.PHI_VERSION);
|
||||
v1.setAllocation(new Registers.RegisterZpByte(2));
|
||||
v2.setAllocation(new Registers.RegisterZpByte(4));
|
||||
v3.setAllocation(new Registers.RegisterZpByte(6));
|
||||
|
@ -100,12 +100,12 @@ public abstract class Scope implements Symbol, Serializable {
|
||||
}
|
||||
|
||||
public Variable addVariablePhiMaster(String name, SymbolType type, String dataSegment) {
|
||||
return add(new Variable(name, this, type, dataSegment, SymbolVariable.StorageStrategy.PHI_MASTER, false, false, true));
|
||||
return add(new Variable(name, this, type, dataSegment, SymbolVariable.StorageStrategy.PHI_MASTER));
|
||||
}
|
||||
|
||||
public Variable addVariableIntermediate() {
|
||||
String name = allocateIntermediateVariableName();
|
||||
return add(new Variable(name, this, SymbolType.VAR, getSegmentData(), SymbolVariable.StorageStrategy.INTERMEDIATE, true, false, false));
|
||||
return add(new Variable(name, this, SymbolType.VAR, getSegmentData(), SymbolVariable.StorageStrategy.INTERMEDIATE));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,7 +118,7 @@ public abstract class Scope implements Symbol, Serializable {
|
||||
LinkedHashSet<Variable> versions = new LinkedHashSet<>();
|
||||
for(Symbol symbol : symbols.values()) {
|
||||
if(symbol instanceof Variable) {
|
||||
if(((Variable) symbol).isPhiVersion()) {
|
||||
if(((Variable) symbol).isStoragePhiVersion()) {
|
||||
if(((Variable) symbol).getVersionOf().equals(unversioned)) {
|
||||
versions.add((Variable) symbol);
|
||||
}
|
||||
|
@ -18,27 +18,15 @@ import java.util.Objects;
|
||||
* */
|
||||
public class Variable extends SymbolVariable {
|
||||
|
||||
/** true if the variable is intermediate. */
|
||||
private boolean isIntermediate;
|
||||
|
||||
/** true if the variable is a PHI master variable that is turned into versions. (the variable has storage strategy PHI)*/
|
||||
private boolean isPhiMaster;
|
||||
|
||||
/** The number of the next version (only used for PHI masters)*/
|
||||
private Integer nextPhiVersionNumber;
|
||||
|
||||
/* true if the variable is a PHI version. (the "master" variable has storage strategy PHI)*/
|
||||
private boolean isPhiVersion;
|
||||
|
||||
/** If the variable is assigned to a specific "register", this contains the register. If null the variable has no allocation (yet). Constants are never assigned to registers. */
|
||||
private Registers.Register allocation;
|
||||
|
||||
public Variable(String name, Scope scope, SymbolType type, String dataSegment, StorageStrategy storageStrategy, boolean isIntermediate, boolean isPhiVersion, boolean isPhiMaster) {
|
||||
public Variable(String name, Scope scope, SymbolType type, String dataSegment, StorageStrategy storageStrategy) {
|
||||
super(name, scope, type, storageStrategy, dataSegment);
|
||||
this.isIntermediate = isIntermediate;
|
||||
this.isPhiVersion = isPhiVersion;
|
||||
this.isPhiMaster = isPhiMaster;
|
||||
if(isPhiMaster)
|
||||
if(StorageStrategy.PHI_MASTER.equals(storageStrategy))
|
||||
this.nextPhiVersionNumber = 0;
|
||||
}
|
||||
|
||||
@ -59,9 +47,6 @@ public class Variable extends SymbolVariable {
|
||||
this.setInferedVolatile(phiMaster.isInferedVolatile());
|
||||
this.setInferredType(phiMaster.isInferredType());
|
||||
this.setComments(phiMaster.getComments());
|
||||
this.isPhiMaster = false;
|
||||
this.isPhiVersion = true;
|
||||
this.isIntermediate = false;
|
||||
}
|
||||
|
||||
public Registers.Register getAllocation() {
|
||||
@ -72,39 +57,23 @@ public class Variable extends SymbolVariable {
|
||||
this.allocation = allocation;
|
||||
}
|
||||
|
||||
public boolean isConstant() {
|
||||
public boolean isStorageConstant() {
|
||||
return StorageStrategy.CONSTANT.equals(getStorageStrategy());
|
||||
}
|
||||
|
||||
public boolean isPhiMaster() {
|
||||
public boolean isStoragePhiMaster() {
|
||||
return StorageStrategy.PHI_MASTER.equals(getStorageStrategy());
|
||||
}
|
||||
|
||||
public boolean isPhiMaster2() {
|
||||
if(isPhiMaster) {
|
||||
if(!StorageStrategy.PHI_MASTER.equals(getStorageStrategy())) {
|
||||
System.out.println("PHI master mismatch!");
|
||||
}
|
||||
}
|
||||
//return isPhiMaster;
|
||||
return StorageStrategy.PHI_MASTER.equals(getStorageStrategy());
|
||||
}
|
||||
|
||||
public boolean isPhiVersion() {
|
||||
if(isPhiVersion) {
|
||||
if(!StorageStrategy.PHI_VERSION.equals(getStorageStrategy())) {
|
||||
throw new InternalError("PHI version mismatch!");
|
||||
}
|
||||
}
|
||||
public boolean isStoragePhiVersion() {
|
||||
return StorageStrategy.PHI_VERSION.equals(getStorageStrategy());
|
||||
}
|
||||
|
||||
public boolean isIntermediate() {
|
||||
if(isIntermediate) {
|
||||
if(!StorageStrategy.INTERMEDIATE.equals(getStorageStrategy())) {
|
||||
throw new InternalError("IMMEDIATE mismatch!");
|
||||
}
|
||||
}
|
||||
public boolean isStorageMemory() {
|
||||
return StorageStrategy.MEMORY.equals(getStorageStrategy());
|
||||
}
|
||||
|
||||
public boolean isStorageIntermediate() {
|
||||
return StorageStrategy.INTERMEDIATE.equals(getStorageStrategy());
|
||||
}
|
||||
|
||||
@ -113,7 +82,7 @@ public class Variable extends SymbolVariable {
|
||||
* @return The new version of the PHI master
|
||||
*/
|
||||
public Variable createVersion() {
|
||||
if(!isPhiMaster)
|
||||
if(!isStoragePhiMaster())
|
||||
throw new InternalError("Cannot version non-PHI variable");
|
||||
Variable version = new Variable(this, nextPhiVersionNumber++);
|
||||
getScope().add(version);
|
||||
@ -125,7 +94,7 @@ public class Variable extends SymbolVariable {
|
||||
* @return The original variable. Null if this is not a version.
|
||||
*/
|
||||
public Variable getVersionOf() {
|
||||
if(isPhiVersion()) {
|
||||
if(isStoragePhiVersion()) {
|
||||
String name = getName();
|
||||
String versionOfName = name.substring(0, name.indexOf("#"));
|
||||
return getScope().getVariable(versionOfName);
|
||||
@ -144,13 +113,11 @@ public class Variable extends SymbolVariable {
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!super.equals(o)) return false;
|
||||
Variable variable = (Variable) o;
|
||||
return isIntermediate == variable.isIntermediate &&
|
||||
isPhiVersion == variable.isPhiVersion &&
|
||||
Objects.equals(allocation, variable.allocation);
|
||||
return Objects.equals(allocation, variable.allocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), isIntermediate, isPhiVersion, allocation);
|
||||
return Objects.hash(super.hashCode(), allocation);
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
|
||||
this.visitDeclTypes(ctx.declTypes());
|
||||
SymbolType type = declVarType;
|
||||
List<Directive> directives = declVarDirectives;
|
||||
Variable param = new Variable(ctx.NAME().getText(), getCurrentScope(), type, currentDataSegment, SymbolVariable.StorageStrategy.PHI_MASTER, false, false, true);
|
||||
Variable param = new Variable(ctx.NAME().getText(), getCurrentScope(), type, currentDataSegment, SymbolVariable.StorageStrategy.PHI_MASTER);
|
||||
// Add directives
|
||||
addDirectives(param, type, directives, new StatementSource(ctx));
|
||||
exitDeclTypes();
|
||||
|
@ -76,7 +76,7 @@ public class Pass1GenerateSingleStaticAssignmentForm extends Pass1Base {
|
||||
private void versionAssignment(VariableRef lValueRef, ProgramValue programLValue, StatementSource source) {
|
||||
Collection<VariableRef> earlyIdentifiedConstants = getProgram().getEarlyIdentifiedConstants();
|
||||
Variable assignedVar = getScope().getVariable(lValueRef);
|
||||
if(assignedVar.isPhiMaster2()) {
|
||||
if(assignedVar.isStoragePhiMaster()) {
|
||||
// Assignment to a non-versioned non-intermediary variable
|
||||
Variable assignedSymbol = assignedVar;
|
||||
Variable version;
|
||||
@ -155,7 +155,7 @@ public class Pass1GenerateSingleStaticAssignmentForm extends Pass1Base {
|
||||
private void updateBlockVersions(VariableRef lValue, Map<Variable, Variable> blockVersions) {
|
||||
VariableRef lValueRef = lValue;
|
||||
Variable variable = Pass1GenerateSingleStaticAssignmentForm.this.getScope().getVariable(lValueRef);
|
||||
if(variable.isPhiVersion()) {
|
||||
if(variable.isStoragePhiVersion()) {
|
||||
blockVersions.put(variable.getVersionOf(), variable);
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class Pass1GenerateSingleStaticAssignmentForm extends Pass1Base {
|
||||
Variable version = null;
|
||||
if(rValue instanceof VariableRef) {
|
||||
Variable rValueVar = getScope().getVariable((VariableRef) rValue);
|
||||
if(rValueVar.isPhiMaster2()) {
|
||||
if(rValueVar.isStoragePhiMaster()) {
|
||||
// rValue needs versioning - look for version in statements
|
||||
Variable rSymbol = rValueVar;
|
||||
if(rSymbol.isDeclaredConstant() || earlyIdentifiedConstants.contains(rSymbol.getRef())) {
|
||||
@ -260,7 +260,8 @@ public class Pass1GenerateSingleStaticAssignmentForm extends Pass1Base {
|
||||
if(blockNewPhis != null) {
|
||||
for(Variable symbol : blockNewPhis.keySet()) {
|
||||
StatementPhiBlock phiBlock = block.getPhiBlock();
|
||||
phiBlock.addPhiVariable(blockNewPhis.get(symbol).getRef());
|
||||
Variable variable = blockNewPhis.get(symbol);
|
||||
phiBlock.addPhiVariable(variable.getRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -318,7 +319,7 @@ public class Pass1GenerateSingleStaticAssignmentForm extends Pass1Base {
|
||||
private void addSymbolToMap(LValue lValue, ControlFlowBlock block, Map<LabelRef, Map<Variable, Variable>> symbolMap) {
|
||||
if(lValue instanceof VariableRef) {
|
||||
Variable lValueVar = getScope().getVariable((VariableRef) lValue);
|
||||
if(lValueVar.isPhiVersion()) {
|
||||
if(lValueVar.isStoragePhiVersion()) {
|
||||
Variable versioned = lValueVar;
|
||||
LabelRef label = block.getLabel();
|
||||
Variable unversioned = versioned.getVersionOf();
|
||||
|
@ -73,7 +73,7 @@ public class Pass1UnwindBlockScopes extends Pass1Base {
|
||||
}
|
||||
} else if(symbol instanceof Variable) {
|
||||
Variable variable = (Variable) symbol;
|
||||
if(variable.isPhiMaster() || variable.isConstant()) {
|
||||
if(variable.isStoragePhiMaster() || variable.isStorageConstant()) {
|
||||
String name = findLocalName(procedure, symbol);
|
||||
Variable var = (Variable) symbol;
|
||||
Variable unwound = procedure.addVariablePhiMaster(name, symbol.getType(), var.getDataSegment());
|
||||
@ -84,7 +84,7 @@ public class Pass1UnwindBlockScopes extends Pass1Base {
|
||||
unwound.setDeclaredRegister((var.getDeclaredRegister()));
|
||||
unwound.setDeclaredExport(var.isDeclaredExport());
|
||||
unwoundSymbols.put(symbol.getRef(), unwound.getRef());
|
||||
} else if(variable.isIntermediate()) {
|
||||
} else if(variable.isStorageIntermediate()) {
|
||||
Variable unwound = procedure.addVariableIntermediate();
|
||||
unwoundSymbols.put(symbol.getRef(), unwound.getRef());
|
||||
} else {
|
||||
|
@ -212,7 +212,7 @@ public class Pass1UnwindStructValues extends Pass1Base {
|
||||
for(Variable member : structDefinition.getAllVariables(false)) {
|
||||
Variable memberVariable;
|
||||
if(variable.getRef().isIntermediate()) {
|
||||
memberVariable = scope.add(new Variable(variable.getLocalName() + "_" + member.getLocalName(), scope, member.getType(), variable.getDataSegment(), SymbolVariable.StorageStrategy.INTERMEDIATE, true, false, false));
|
||||
memberVariable = scope.add(new Variable(variable.getLocalName() + "_" + member.getLocalName(), scope, member.getType(), variable.getDataSegment(), SymbolVariable.StorageStrategy.INTERMEDIATE));
|
||||
} else {
|
||||
memberVariable = scope.addVariablePhiMaster(variable.getLocalName() + "_" + member.getLocalName(), member.getType(), variable.getDataSegment());
|
||||
}
|
||||
|
@ -43,8 +43,9 @@ public class Pass2AssertSymbols extends Pass2SsaAssertion {
|
||||
Collection<Symbol> tableSymbols = getScope().getAllSymbols(true);
|
||||
|
||||
for(Symbol tableSymbol : tableSymbols) {
|
||||
if(tableSymbol instanceof Variable && ((Variable) tableSymbol).isPhiMaster2()) continue;
|
||||
if(tableSymbol instanceof Variable && ((Variable) tableSymbol).isConstant()) continue;
|
||||
if(tableSymbol instanceof Variable && ((Variable) tableSymbol).isStoragePhiMaster()) continue;
|
||||
if(tableSymbol instanceof Variable && ((Variable) tableSymbol).isStorageConstant()) continue;
|
||||
if(tableSymbol instanceof Variable && ((Variable) tableSymbol).isStorageMemory()) continue;
|
||||
if(tableSymbol instanceof ConstantVar) continue;
|
||||
if(tableSymbol instanceof StructDefinition) continue;
|
||||
if(tableSymbol instanceof EnumDefinition) continue;
|
||||
|
@ -33,10 +33,10 @@ public class Pass4LiveRangeEquivalenceClassesFinalize extends Pass2Base {
|
||||
|
||||
// Add all versions of volatile variables to the same equivalence class
|
||||
for(Variable variable : getSymbols().getAllVariables(true)) {
|
||||
if(variable.isPhiVersion() && variable.isVolatile()) {
|
||||
if(variable.isStoragePhiVersion() && variable.isVolatile()) {
|
||||
// Found a volatile non-versioned variable
|
||||
for(Variable otherVariable : variable.getScope().getAllVariables(false)) {
|
||||
if(otherVariable.isPhiVersion()) {
|
||||
if(otherVariable.isStoragePhiVersion()) {
|
||||
if((otherVariable).getVersionOf().equals((variable).getVersionOf())) {
|
||||
// They share the same main variable
|
||||
LiveRangeEquivalenceClass varEC = liveRangeEquivalenceClassSet.getOrCreateEquivalenceClass(variable.getRef());
|
||||
|
@ -33,7 +33,7 @@ public class PassNAssertConstantModification extends Pass2SsaOptimization {
|
||||
if(lValue instanceof VariableRef) {
|
||||
VariableRef variableRef = (VariableRef) lValue;
|
||||
Variable variable = getScope().getVariable(variableRef);
|
||||
if(variable.isConstant() || earlyIdentifiedConstants.contains(variableRef)) {
|
||||
if(variable.isStorageConstant() || earlyIdentifiedConstants.contains(variableRef)) {
|
||||
if(assigned.contains(variableRef)) {
|
||||
throw new CompileError("Error! Constants can not be modified", statement.getSource());
|
||||
} else {
|
||||
|
@ -35,7 +35,6 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void testDeclaredMemoryVar2() throws IOException, URISyntaxException {
|
||||
compileAndCompare("declared-memory-var-2");
|
||||
@ -50,7 +49,6 @@ public class TestPrograms {
|
||||
public void testDeclaredMemoryVar0() throws IOException, URISyntaxException {
|
||||
compileAndCompare("declared-memory-var-0");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
@Test
|
||||
|
@ -17,7 +17,7 @@ main: scope:[main] from @1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
||||
[7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr)
|
||||
[7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr)
|
||||
[8] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) + (byte) main::i#2
|
||||
[9] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[10] if((byte) main::i#1!=(byte) 6) goto main::@1
|
||||
|
@ -12,7 +12,7 @@ Updating memory variable reference *((const byte*) idx_ptr)
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
*((const byte*) idx_ptr) ← (byte) 0
|
||||
(byte*) SCREEN#0 ← ((byte*)) (number) $400
|
||||
(byte*) SCREEN ← ((byte*)) (number) $400
|
||||
to:@1
|
||||
|
||||
(void()) main()
|
||||
@ -21,7 +21,7 @@ main: scope:[main] from @1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
*((byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr)
|
||||
*((byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr)
|
||||
*((const byte*) idx_ptr) ← *((const byte*) idx_ptr) + (byte) main::i#2
|
||||
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,5)
|
||||
(bool~) main::$0 ← (byte) main::i#1 != rangelast(0,5)
|
||||
@ -45,7 +45,6 @@ SYMBOL TABLE SSA
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(byte*) SCREEN#0
|
||||
(byte) idx memory
|
||||
(const byte*) idx_ptr = &(byte) idx
|
||||
(void()) main()
|
||||
@ -57,13 +56,13 @@ SYMBOL TABLE SSA
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
|
||||
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
|
||||
Inlining cast (byte*) SCREEN ← (byte*)(number) $400
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Simple Condition (bool~) main::$0 [8] if((byte) main::i#1!=rangelast(0,5)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const byte*) SCREEN#0 = (byte*) 1024
|
||||
Constant (const byte*) SCREEN = (byte*) 1024
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value [6] main::i#1 ← ++ main::i#2 to ++
|
||||
@ -112,7 +111,7 @@ main: scope:[main] from @1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
||||
[7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr)
|
||||
[7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr)
|
||||
[8] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) + (byte) main::i#2
|
||||
[9] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[10] if((byte) main::i#1!=(byte) 6) goto main::@1
|
||||
@ -124,7 +123,6 @@ main::@return: scope:[main] from main::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte*) SCREEN
|
||||
(byte) idx memory
|
||||
(void()) main()
|
||||
(byte) main::i
|
||||
@ -188,7 +186,7 @@ main: {
|
||||
jmp b1
|
||||
// main::@1
|
||||
b1:
|
||||
// [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr) -- pbuc1_derefidx_vbuz1=_deref_pbuc2
|
||||
// [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr) -- pbuc1_derefidx_vbuz1=_deref_pbuc2
|
||||
lda idx_ptr
|
||||
ldy.z i
|
||||
sta SCREEN,y
|
||||
@ -218,13 +216,13 @@ main: {
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [0] *((const byte*) idx_ptr) ← (byte) 0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [3] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Statement [8] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) + (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [11] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [0] *((const byte*) idx_ptr) ← (byte) 0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [3] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [8] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) + (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [11] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
|
||||
@ -284,7 +282,7 @@ main: {
|
||||
jmp b1
|
||||
// main::@1
|
||||
b1:
|
||||
// [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr) -- pbuc1_derefidx_vbuxx=_deref_pbuc2
|
||||
// [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr) -- pbuc1_derefidx_vbuxx=_deref_pbuc2
|
||||
lda idx_ptr
|
||||
sta SCREEN,x
|
||||
// [8] *((const byte*) idx_ptr) ← *((const byte*) idx_ptr) + (byte) main::i#2 -- _deref_pbuc1=_deref_pbuc1_plus_vbuxx
|
||||
@ -343,8 +341,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(const byte*) SCREEN SCREEN = (byte*) 1024
|
||||
(byte) idx memory
|
||||
(const byte*) idx_ptr idx_ptr = &(byte) idx
|
||||
(void()) main()
|
||||
@ -395,7 +392,7 @@ main: {
|
||||
// main::@1
|
||||
b1:
|
||||
// SCREEN[i] = idx
|
||||
// [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte*) idx_ptr) -- pbuc1_derefidx_vbuxx=_deref_pbuc2
|
||||
// [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_ptr) -- pbuc1_derefidx_vbuxx=_deref_pbuc2
|
||||
lda idx_ptr
|
||||
sta SCREEN,x
|
||||
// idx +=i
|
||||
|
@ -2,8 +2,7 @@
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(const byte*) SCREEN SCREEN = (byte*) 1024
|
||||
(byte) idx memory
|
||||
(const byte*) idx_ptr idx_ptr = &(byte) idx
|
||||
(void()) main()
|
||||
|
@ -15,7 +15,7 @@ main: scope:[main] from @1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
||||
[7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0)
|
||||
[7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0)
|
||||
[8] *((byte*) idx_p#0) ← *((byte*) idx_p#0) + (byte) main::i#2
|
||||
[9] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[10] if((byte) main::i#1!=(byte) 6) goto main::@1
|
||||
|
@ -9,7 +9,7 @@ CONTROL FLOW GRAPH SSA
|
||||
*((const byte*) idx_ptr) ← (byte) 0
|
||||
(byte*~) $0 ← & *((const byte*) idx_ptr)
|
||||
(byte*) idx_p#0 ← (byte*~) $0
|
||||
(byte*) SCREEN#0 ← ((byte*)) (number) $400
|
||||
(byte*) SCREEN ← ((byte*)) (number) $400
|
||||
to:@1
|
||||
|
||||
(void()) main()
|
||||
@ -20,7 +20,7 @@ main: scope:[main] from @1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) idx_p#1 ← phi( main/(byte*) idx_p#2 main::@1/(byte*) idx_p#1 )
|
||||
*((byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#1)
|
||||
*((byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#1)
|
||||
*((byte*) idx_p#1) ← *((byte*) idx_p#1) + (byte) main::i#2
|
||||
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,5)
|
||||
(bool~) main::$0 ← (byte) main::i#1 != rangelast(0,5)
|
||||
@ -44,7 +44,6 @@ SYMBOL TABLE SSA
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(byte*) SCREEN#0
|
||||
(byte) idx memory
|
||||
(byte*) idx_p
|
||||
(byte*) idx_p#0
|
||||
@ -61,7 +60,7 @@ SYMBOL TABLE SSA
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
|
||||
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
|
||||
Inlining cast (byte*) SCREEN ← (byte*)(number) $400
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
@ -72,7 +71,7 @@ Identical Phi Values (byte*) idx_p#1 (byte*) idx_p#2
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Simple Condition (bool~) main::$0 [11] if((byte) main::i#1!=rangelast(0,5)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const byte*) SCREEN#0 = (byte*) 1024
|
||||
Constant (const byte*) SCREEN = (byte*) 1024
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value [9] main::i#1 ← ++ main::i#2 to ++
|
||||
@ -121,7 +120,7 @@ main: scope:[main] from @1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
||||
[7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0)
|
||||
[7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0)
|
||||
[8] *((byte*) idx_p#0) ← *((byte*) idx_p#0) + (byte) main::i#2
|
||||
[9] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[10] if((byte) main::i#1!=(byte) 6) goto main::@1
|
||||
@ -132,7 +131,6 @@ main::@return: scope:[main] from main::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte*) SCREEN
|
||||
(byte) idx memory
|
||||
(byte*) idx_p
|
||||
(byte*) idx_p#0 4.375
|
||||
@ -202,7 +200,7 @@ main: {
|
||||
jmp b1
|
||||
// main::@1
|
||||
b1:
|
||||
// [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0) -- pbuc1_derefidx_vbuz1=_deref_pbuz2
|
||||
// [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0) -- pbuc1_derefidx_vbuz1=_deref_pbuz2
|
||||
ldx.z i
|
||||
ldy #0
|
||||
lda (idx_p),y
|
||||
@ -232,13 +230,13 @@ main: {
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [0] *((const byte*) idx_ptr) ← (byte) 0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [1] (byte*) idx_p#0 ← & *((const byte*) idx_ptr) [ idx_p#0 ] ( [ idx_p#0 ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0) [ idx_p#0 main::i#2 ] ( main:3 [ idx_p#0 main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0) [ idx_p#0 main::i#2 ] ( main:3 [ idx_p#0 main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Statement [8] *((byte*) idx_p#0) ← *((byte*) idx_p#0) + (byte) main::i#2 [ idx_p#0 main::i#2 ] ( main:3 [ idx_p#0 main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [0] *((const byte*) idx_ptr) ← (byte) 0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [1] (byte*) idx_p#0 ← & *((const byte*) idx_ptr) [ idx_p#0 ] ( [ idx_p#0 ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0) [ idx_p#0 main::i#2 ] ( main:3 [ idx_p#0 main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0) [ idx_p#0 main::i#2 ] ( main:3 [ idx_p#0 main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [8] *((byte*) idx_p#0) ← *((byte*) idx_p#0) + (byte) main::i#2 [ idx_p#0 main::i#2 ] ( main:3 [ idx_p#0 main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x ,
|
||||
Potential registers zp ZP_WORD:3 [ idx_p#0 ] : zp ZP_WORD:3 ,
|
||||
@ -300,7 +298,7 @@ main: {
|
||||
jmp b1
|
||||
// main::@1
|
||||
b1:
|
||||
// [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0) -- pbuc1_derefidx_vbuxx=_deref_pbuz1
|
||||
// [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0) -- pbuc1_derefidx_vbuxx=_deref_pbuz1
|
||||
ldy #0
|
||||
lda (idx_p),y
|
||||
sta SCREEN,x
|
||||
@ -354,8 +352,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(const byte*) SCREEN SCREEN = (byte*) 1024
|
||||
(byte) idx memory
|
||||
(byte*) idx_p
|
||||
(byte*) idx_p#0 idx_p zp ZP_WORD:2 4.375
|
||||
@ -415,7 +412,7 @@ main: {
|
||||
// main::@1
|
||||
b1:
|
||||
// SCREEN[i] = *idx_p
|
||||
// [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((byte*) idx_p#0) -- pbuc1_derefidx_vbuxx=_deref_pbuz1
|
||||
// [7] *((const byte*) SCREEN + (byte) main::i#2) ← *((byte*) idx_p#0) -- pbuc1_derefidx_vbuxx=_deref_pbuz1
|
||||
ldy #0
|
||||
lda (idx_p),y
|
||||
sta SCREEN,x
|
||||
|
@ -1,8 +1,7 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(const byte*) SCREEN SCREEN = (byte*) 1024
|
||||
(byte) idx memory
|
||||
(byte*) idx_p
|
||||
(byte*) idx_p#0 idx_p zp ZP_WORD:2 4.375
|
||||
|
@ -1,5 +1,5 @@
|
||||
@begin: scope:[] from
|
||||
[0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0
|
||||
[0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
|
@ -11,8 +11,8 @@ Updating memory variable reference *((const byte**) cursor_ptr)
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← ((byte*)) (number) $400
|
||||
*((const byte**) cursor_ptr) ← (byte*) SCREEN#0
|
||||
(byte*) SCREEN ← ((byte*)) (number) $400
|
||||
*((const byte**) cursor_ptr) ← (byte*) SCREEN
|
||||
to:@1
|
||||
|
||||
(void()) main()
|
||||
@ -45,7 +45,6 @@ SYMBOL TABLE SSA
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(byte*) SCREEN#0
|
||||
(byte*) cursor memory
|
||||
(const byte**) cursor_ptr = &(byte*) cursor
|
||||
(void()) main()
|
||||
@ -59,7 +58,7 @@ SYMBOL TABLE SSA
|
||||
|
||||
Adding number conversion cast (unumber) $29 in *((const byte**) cursor_ptr) ← *((const byte**) cursor_ptr) + (number) $29
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
|
||||
Inlining cast (byte*) SCREEN ← (byte*)(number) $400
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant integer cast $29
|
||||
@ -68,7 +67,7 @@ Finalized unsigned number type (byte) $29
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Simple Condition (bool~) main::$0 [8] if((byte) main::i#1!=rangelast(0,$18)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const byte*) SCREEN#0 = (byte*) 1024
|
||||
Constant (const byte*) SCREEN = (byte*) 1024
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value [6] main::i#1 ← ++ main::i#2 to ++
|
||||
@ -99,7 +98,7 @@ Adding NOP phi() at start of main
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
[0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0
|
||||
[0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
@ -129,7 +128,6 @@ main::@return: scope:[main] from main::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte*) SCREEN
|
||||
(byte*) cursor memory
|
||||
(void()) main()
|
||||
(byte) main::i
|
||||
@ -156,7 +154,7 @@ Target platform is c64basic / MOS6502X
|
||||
.label SCREEN = $400
|
||||
// @begin
|
||||
bbegin:
|
||||
// [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0 -- _deref_pptc1=pbuc2
|
||||
// [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN -- _deref_pptc1=pbuc2
|
||||
lda #<SCREEN
|
||||
sta cursor_ptr
|
||||
lda #>SCREEN
|
||||
@ -227,12 +225,12 @@ main: {
|
||||
cursor: .word 0
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [7] *(*((const byte**) cursor_ptr)) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Statement [8] *((const byte**) cursor_ptr) ← *((const byte**) cursor_ptr) + (byte) $29 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [7] *(*((const byte**) cursor_ptr)) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [8] *((const byte**) cursor_ptr) ← *((const byte**) cursor_ptr) + (byte) $29 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x ,
|
||||
@ -257,7 +255,7 @@ ASSEMBLER BEFORE OPTIMIZATION
|
||||
.label SCREEN = $400
|
||||
// @begin
|
||||
bbegin:
|
||||
// [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0 -- _deref_pptc1=pbuc2
|
||||
// [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN -- _deref_pptc1=pbuc2
|
||||
lda #<SCREEN
|
||||
sta cursor_ptr
|
||||
lda #>SCREEN
|
||||
@ -353,8 +351,7 @@ FINAL SYMBOL TABLE
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(const byte*) SCREEN SCREEN = (byte*) 1024
|
||||
(byte*) cursor memory
|
||||
(const byte**) cursor_ptr cursor_ptr = &(byte*) cursor
|
||||
(void()) main()
|
||||
@ -383,7 +380,7 @@ Score: 575
|
||||
// @begin
|
||||
bbegin:
|
||||
// cursor = SCREEN
|
||||
// [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN#0 -- _deref_pptc1=pbuc2
|
||||
// [0] *((const byte**) cursor_ptr) ← (const byte*) SCREEN -- _deref_pptc1=pbuc2
|
||||
lda #<SCREEN
|
||||
sta cursor_ptr
|
||||
lda #>SCREEN
|
||||
|
@ -2,8 +2,7 @@
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(const byte*) SCREEN SCREEN = (byte*) 1024
|
||||
(byte*) cursor memory
|
||||
(const byte**) cursor_ptr cursor_ptr = &(byte*) cursor
|
||||
(void()) main()
|
||||
|
Loading…
Reference in New Issue
Block a user