1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 02:54:41 +00:00

Added iteration through all parts of the symbol table to usage finding. Now array lenghts set to constant calculations also work.

This commit is contained in:
Jesper Gravgaard 2018-07-23 16:27:30 +09:00
parent 99085f1351
commit 112087b7bb
12 changed files with 116 additions and 144 deletions

View File

@ -50,7 +50,7 @@ public class ProgramValueIterator {
* @param symbolVariable The symbol variable
* @param programValueHandler The programValueHandler to execute
*/
private static void execute(SymbolVariable symbolVariable, ProgramValueHandler programValueHandler) {
public static void execute(SymbolVariable symbolVariable, ProgramValueHandler programValueHandler) {
if(symbolVariable.getType() instanceof SymbolTypeArray) {
execute(new ProgramValue.TypeArraySize((SymbolTypeArray) symbolVariable.getType()), programValueHandler, null, null, null);
}

View File

@ -5,8 +5,11 @@ import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.VariableReferenceInfos;
import dk.camelot64.kickc.model.iterator.ProgramValue;
import dk.camelot64.kickc.model.iterator.ProgramValueIterator;
import dk.camelot64.kickc.model.statements.*;
import dk.camelot64.kickc.model.symbols.ConstantVar;
import dk.camelot64.kickc.model.statements.Statement;
import dk.camelot64.kickc.model.statements.StatementAssignment;
import dk.camelot64.kickc.model.statements.StatementCall;
import dk.camelot64.kickc.model.statements.StatementPhiBlock;
import dk.camelot64.kickc.model.symbols.SymbolVariable;
import dk.camelot64.kickc.model.values.*;
import java.util.*;
@ -80,43 +83,49 @@ public class PassNVariableReferenceInfos extends Pass2Base {
blockReferencedVars.put(blockLabel, getReferencedVars(blockLabel, new ArrayList<>()));
blockUsedVars.put(blockLabel, getUsedVars(blockLabel, new ArrayList<>()));
for(Statement statement : block.getStatements()) {
Collection<SymbolVariableRef> referenced = getReferenced(statement);
Collection<VariableRef> defined = getDefinedVars(statement);
Collection<VariableRef> referencedVars = getReferencedVars(statement);
// Add variable definitions to the statement
stmtDefined.put(statement.getIndex(), defined);
// Add variable reference to the statement
stmtReferenced.put(statement.getIndex(), referencedVars);
// Identify statement defining variables
for(VariableRef variableRef : defined) {
symbolVarReferences.putIfAbsent(variableRef, new ArrayList<>());
Collection<VariableReferenceInfos.ReferenceToSymbolVar> references = symbolVarReferences.get(variableRef);
references.add(new VariableReferenceInfos.ReferenceInStatement(statement.getIndex(), VariableReferenceInfos.ReferenceToSymbolVar.ReferenceType.DEFINE, variableRef));
}
// Gather statements referencing variables
for(VariableRef variableRef : referencedVars) {
if(!defined.contains(variableRef)) {
symbolVarReferences.putIfAbsent(variableRef, new ArrayList<>());
Collection<VariableReferenceInfos.ReferenceToSymbolVar> references = symbolVarReferences.get(variableRef);
references.add(new VariableReferenceInfos.ReferenceInStatement(statement.getIndex(), VariableReferenceInfos.ReferenceToSymbolVar.ReferenceType.USE, variableRef));
// Gather statements referencing variables/constants
Collection<VariableRef> varRefs = new ArrayList<>();
for(SymbolVariableRef referencedVarRef : referenced) {
if(referencedVarRef instanceof VariableRef) {
varRefs.add((VariableRef) referencedVarRef);
}
if(!defined.contains(referencedVarRef)) {
symbolVarReferences.putIfAbsent(referencedVarRef, new ArrayList<>());
Collection<VariableReferenceInfos.ReferenceToSymbolVar> references = symbolVarReferences.get(referencedVarRef);
references.add(
new VariableReferenceInfos.ReferenceInStatement(
statement.getIndex(),
VariableReferenceInfos.ReferenceToSymbolVar.ReferenceType.USE,
referencedVarRef));
}
}
// Gather statements referencing constants
Collection<ConstantRef> referencedConsts = getReferencedConsts(statement);
for(ConstantRef constantRef : referencedConsts) {
symbolVarReferences.putIfAbsent(constantRef, new ArrayList<>());
Collection<VariableReferenceInfos.ReferenceToSymbolVar> references = symbolVarReferences.get(constantRef);
references.add(new VariableReferenceInfos.ReferenceInStatement(statement.getIndex(), VariableReferenceInfos.ReferenceToSymbolVar.ReferenceType.USE, constantRef));
}
// Add variable reference to the statement
stmtReferenced.put(statement.getIndex(), varRefs);
}
}
// Gather constants referencing other constants
for(ConstantVar constantVar : getSymbols().getAllConstants(true)) {
Collection<ConstantRef> referencedConsts = getReferencedConsts(constantVar.getValue());
for(ConstantRef constantRef : referencedConsts) {
symbolVarReferences.putIfAbsent(constantRef, new ArrayList<>());
Collection<VariableReferenceInfos.ReferenceToSymbolVar> references = symbolVarReferences.get(constantRef);
references.add(new VariableReferenceInfos.ReferenceInSymbol(constantVar.getRef(), VariableReferenceInfos.ReferenceToSymbolVar.ReferenceType.USE, constantRef));
}
// Gather symbols in the symbol table referencing other variables/constants
Collection<SymbolVariable> allSymbolVariables = getProgram().getScope().getAllSymbolVariables(true);
for(SymbolVariable referencingVar : allSymbolVariables) {
ProgramValueIterator.execute(referencingVar,
(programValue, currentStmt, stmtIt, currentBlock) -> {
RValue rValue = programValue.get();
if(rValue instanceof SymbolVariableRef) {
SymbolVariableRef referencedVar = (SymbolVariableRef) rValue;
symbolVarReferences.putIfAbsent(referencedVar, new ArrayList<>());
Collection<VariableReferenceInfos.ReferenceToSymbolVar> references = symbolVarReferences.get(referencedVar);
references.add(new VariableReferenceInfos.ReferenceInSymbol((SymbolVariableRef) referencingVar.getRef(), VariableReferenceInfos.ReferenceToSymbolVar.ReferenceType.USE, referencedVar));
}
});
}
getProgram().setVariableReferenceInfos(new VariableReferenceInfos(blockReferencedVars, blockUsedVars, stmtReferenced, stmtDefined, symbolVarReferences));
}
@ -236,30 +245,13 @@ public class PassNVariableReferenceInfos extends Pass2Base {
*/
private Collection<VariableRef> getReferencedVars(Statement statement) {
LinkedHashSet<VariableRef> referencedVars = new LinkedHashSet<>();
for(SymbolRef symbolRef : getReferenced(statement)) {
if(symbolRef instanceof VariableRef) {
referencedVars.add((VariableRef) symbolRef);
}
}
getReferenced(statement)
.stream()
.filter(symbolVariableRef -> symbolVariableRef instanceof VariableRef)
.forEach(symbolVariableRef -> referencedVars.add((VariableRef) symbolVariableRef));
return referencedVars;
}
/**
* Get the constants referenced (used or defined) in a statement
*
* @param statement The statement to examine
* @return The referenced constants
*/
private Collection<ConstantRef> getReferencedConsts(Statement statement) {
LinkedHashSet<ConstantRef> referencedConsts = new LinkedHashSet<>();
for(SymbolRef symbolRef : getReferenced(statement)) {
if(symbolRef instanceof ConstantRef) {
referencedConsts.add((ConstantRef) symbolRef);
}
}
return referencedConsts;
}
/**
* Get the variables / constants referenced (used or defined) in a statement
*
@ -268,41 +260,12 @@ public class PassNVariableReferenceInfos extends Pass2Base {
*/
private Collection<SymbolVariableRef> getReferenced(Statement statement) {
LinkedHashSet<SymbolVariableRef> referenced = new LinkedHashSet<>();
if(statement instanceof StatementPhiBlock) {
StatementPhiBlock phiBlock = (StatementPhiBlock) statement;
for(StatementPhiBlock.PhiVariable phiVariable : phiBlock.getPhiVariables()) {
referenced.add(phiVariable.getVariable());
for(StatementPhiBlock.PhiRValue phiRValue : phiVariable.getValues()) {
referenced.addAll(getReferenced(phiRValue.getrValue()));
ProgramValueIterator.execute(statement,
(programValue, currentStmt, stmtIt, currentBlock) -> {
if(programValue.get() instanceof SymbolVariableRef)
referenced.add((SymbolVariableRef) programValue.get());
}
}
} else if(statement instanceof StatementAssignment) {
StatementAssignment assignment = (StatementAssignment) statement;
referenced.addAll(getReferenced(assignment.getlValue()));
referenced.addAll(getReferenced(assignment.getrValue1()));
referenced.addAll(getReferenced(assignment.getrValue2()));
} else if(statement instanceof StatementConditionalJump) {
StatementConditionalJump conditionalJump = (StatementConditionalJump) statement;
referenced.addAll(getReferenced(conditionalJump.getrValue1()));
referenced.addAll(getReferenced(conditionalJump.getrValue2()));
} else if(statement instanceof StatementCall) {
StatementCall call = (StatementCall) statement;
referenced.addAll(getReferenced(call.getlValue()));
if(call.getParameters() != null) {
for(RValue param : call.getParameters()) {
referenced.addAll(getReferenced(param));
}
}
} else if(statement instanceof StatementReturn) {
StatementReturn statementReturn = (StatementReturn) statement;
referenced.addAll(getReferenced(statementReturn.getValue()));
} else if(statement instanceof StatementAsm) {
// No references in ASM atm.
} else if(statement instanceof StatementKickAsm) {
// No references in ASM atm.
} else {
throw new RuntimeException("Unknown statement type " + statement);
}
, null, null);
return referenced;
}

View File

@ -1,7 +1,7 @@
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const ITEM_COUNT = 2
.const ITEM_COUNT = 3
.const ITEM_SIZE = 5
jsr main
main: {
@ -37,4 +37,4 @@ main: {
bne b1
rts
}
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

View File

@ -11,7 +11,7 @@ main: scope:[main] from @1
[4] phi() [ ] ( main:2 [ ] )
to:main::@1
main::@1: scope:[main] from main main::@3
[5] (byte*) main::cur_item#4 ← phi( main/(const byte[$0]) items#0 main::@3/(byte*) main::cur_item#1 ) [ main::item#4 main::cur_item#4 ] ( main:2 [ main::item#4 main::cur_item#4 ] )
[5] (byte*) main::cur_item#4 ← phi( main/(const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 main::@3/(byte*) main::cur_item#1 ) [ main::item#4 main::cur_item#4 ] ( main:2 [ main::item#4 main::cur_item#4 ] )
[5] (byte) main::item#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@3/(byte) main::item#1 ) [ main::item#4 main::cur_item#4 ] ( main:2 [ main::item#4 main::cur_item#4 ] )
to:main::@2
main::@2: scope:[main] from main::@1 main::@2

View File

@ -1,10 +1,10 @@
PARSING src/test/java/dk/camelot64/kickc/test/kc/array-length-symbolic.kc
// Illustrates symbolic array lengths
byte ITEM_COUNT = 2;
byte ITEM_COUNT = 3;
byte ITEM_SIZE = 5;
byte[ITEM_COUNT*ITEM_SIZE] items = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte[ITEM_COUNT*ITEM_SIZE] items = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Fills the array item by item with $is, where i is the item# and s is the sub#
void main() {
@ -42,10 +42,10 @@ SYMBOLS
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) ITEM_COUNT ← (byte/signed byte/word/signed word/dword/signed dword) 2
(byte) ITEM_COUNT ← (byte/signed byte/word/signed word/dword/signed dword) 3
(byte) ITEM_SIZE ← (byte/signed byte/word/signed word/dword/signed dword) 5
(byte~) $0 ← (byte) ITEM_COUNT * (byte) ITEM_SIZE
(byte[$0]) items ← { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
(byte[$0]) items ← { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
to:@1
main: scope:[main] from
(byte*) main::cur_item ← (byte[$0]) items
@ -80,7 +80,6 @@ main::@return: scope:[main] from main::@4
to:@end
@end: scope:[] from @1
Eliminating unused variable (byte~) $0 and assignment [2] (byte~) $0 ← (byte) ITEM_COUNT * (byte) ITEM_SIZE
Removing empty block main::@4
PROCEDURE MODIFY VARIABLE ANALYSIS
@ -90,9 +89,10 @@ Completing Phi functions...
CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[] from
(byte) ITEM_COUNT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
(byte) ITEM_COUNT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 3
(byte) ITEM_SIZE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 5
(byte[$0]) items#0 ← { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
(byte~) $0 ← (byte) ITEM_COUNT#0 * (byte) ITEM_SIZE#0
(byte[$0]) items#0 ← { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
to:@1
main: scope:[main] from @1
(byte) ITEM_SIZE#3 ← phi( @1/(byte) ITEM_SIZE#5 )
@ -142,6 +142,7 @@ main::@return: scope:[main] from main::@3
@end: scope:[] from @2
SYMBOL TABLE SSA
(byte~) $0
(label) @1
(label) @2
(label) @begin
@ -215,13 +216,14 @@ Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) main::$4 if((byte) main::sub#1!=rangelast(0,main::$1)) goto main::@2
Simple Condition (bool~) main::$5 if((byte) main::item#1!=rangelast(0,main::$0)) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) ITEM_COUNT#0 = 2
Constant (const byte) ITEM_COUNT#0 = 3
Constant (const byte) ITEM_SIZE#0 = 5
Constant (const byte[$0]) items#0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
Constant (const byte[$0]) items#0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
Constant (const byte) main::item#0 = 0
Constant (const byte) main::sub#0 = 0
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte[$0]) main::cur_item#0 = items#0
Constant (const byte) $0 = ITEM_COUNT#0*ITEM_SIZE#0
Constant (const byte*) main::cur_item#0 = items#0
Constant (const byte/signed word/word/dword/signed dword) main::$0 = ITEM_COUNT#0-1
Succesful SSA optimization Pass2ConstantIdentification
Resolved ranged next value main::item#1 ← ++ main::item#4 to ++
@ -239,11 +241,12 @@ Inlining constant with var siblings (const byte) main::item#0
Inlining constant with var siblings (const byte) main::item#0
Inlining constant with var siblings (const byte) main::sub#0
Inlining constant with var siblings (const byte) main::sub#0
Inlining constant with var siblings (const byte[$0]) main::cur_item#0
Inlining constant with var siblings (const byte[$0]) main::cur_item#0
Inlining constant with var siblings (const byte*) main::cur_item#0
Inlining constant with var siblings (const byte*) main::cur_item#0
Constant inlined main::sub#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::$1 = (const byte) ITEM_SIZE#0-(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::cur_item#0 = (const byte[$0]) items#0
Constant inlined $0 = (const byte) ITEM_COUNT#0*(const byte) ITEM_SIZE#0
Constant inlined main::cur_item#0 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0
Constant inlined main::$0 = (const byte) ITEM_COUNT#0-(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::item#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Succesful SSA optimization Pass2ConstantInlining
@ -298,7 +301,7 @@ main: scope:[main] from @1
[4] phi() [ ] ( main:2 [ ] )
to:main::@1
main::@1: scope:[main] from main main::@3
[5] (byte*) main::cur_item#4 ← phi( main/(const byte[$0]) items#0 main::@3/(byte*) main::cur_item#1 ) [ main::item#4 main::cur_item#4 ] ( main:2 [ main::item#4 main::cur_item#4 ] )
[5] (byte*) main::cur_item#4 ← phi( main/(const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 main::@3/(byte*) main::cur_item#1 ) [ main::item#4 main::cur_item#4 ] ( main:2 [ main::item#4 main::cur_item#4 ] )
[5] (byte) main::item#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@3/(byte) main::item#1 ) [ main::item#4 main::cur_item#4 ] ( main:2 [ main::item#4 main::cur_item#4 ] )
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
@ -348,7 +351,7 @@ Loop head: main::@1 tails: main::@3 blocks: main::@3 main::@2 main::@1 depth: 1
VARIABLE REGISTER WEIGHTS
(byte) ITEM_COUNT
(byte) ITEM_SIZE
(byte[$0]) items
(byte[ITEM_COUNT#0*ITEM_SIZE#0]) items
(void()) main()
(byte~) main::$2 202.0
(byte~) main::$3 202.0
@ -386,7 +389,7 @@ INITIAL ASM
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const ITEM_COUNT = 2
.const ITEM_COUNT = 3
.const ITEM_SIZE = 5
//SEG2 @begin
bbegin:
@ -413,7 +416,7 @@ main: {
.label item = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
//SEG11 [5] phi (byte*) main::cur_item#4 = (const byte[$0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1
//SEG11 [5] phi (byte*) main::cur_item#4 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<items
sta cur_item
lda #>items
@ -485,7 +488,7 @@ main: {
//SEG32 [15] return [ ] ( main:2 [ ] )
rts
}
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] (byte~) main::$2 ← (byte) main::item#4 << (byte/signed byte/word/signed word/dword/signed dword) 4 [ main::item#4 main::cur_item#4 main::sub#2 main::$2 ] ( main:2 [ main::item#4 main::cur_item#4 main::sub#2 main::$2 ] ) always clobbers reg byte a
@ -515,7 +518,7 @@ ASSEMBLER BEFORE OPTIMIZATION
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const ITEM_COUNT = 2
.const ITEM_COUNT = 3
.const ITEM_SIZE = 5
//SEG2 @begin
bbegin:
@ -538,7 +541,7 @@ main: {
.label cur_item = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
//SEG11 [5] phi (byte*) main::cur_item#4 = (const byte[$0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1
//SEG11 [5] phi (byte*) main::cur_item#4 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<items
sta cur_item
lda #>items
@ -602,7 +605,7 @@ main: {
//SEG32 [15] return [ ] ( main:2 [ ] )
rts
}
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
@ -637,11 +640,11 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(byte) ITEM_COUNT
(const byte) ITEM_COUNT#0 ITEM_COUNT = (byte/signed byte/word/signed word/dword/signed dword) 2
(const byte) ITEM_COUNT#0 ITEM_COUNT = (byte/signed byte/word/signed word/dword/signed dword) 3
(byte) ITEM_SIZE
(const byte) ITEM_SIZE#0 ITEM_SIZE = (byte/signed byte/word/signed word/dword/signed dword) 5
(byte[$0]) items
(const byte[$0]) items#0 items = { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
(byte[ITEM_COUNT#0*ITEM_SIZE#0]) items
(const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 items = { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
(void()) main()
(byte~) main::$2 reg byte a 202.0
(byte~) main::$3 reg byte a 202.0
@ -674,7 +677,7 @@ Score: 3422
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const ITEM_COUNT = 2
.const ITEM_COUNT = 3
.const ITEM_SIZE = 5
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
@ -688,7 +691,7 @@ Score: 3422
main: {
.label cur_item = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte*) main::cur_item#4 = (const byte[$0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1
//SEG11 [5] phi (byte*) main::cur_item#4 = (const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<items
sta cur_item
lda #>items
@ -741,5 +744,5 @@ main: {
//SEG32 [15] return [ ] ( main:2 [ ] )
rts
}
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

View File

@ -2,11 +2,11 @@
(label) @begin
(label) @end
(byte) ITEM_COUNT
(const byte) ITEM_COUNT#0 ITEM_COUNT = (byte/signed byte/word/signed word/dword/signed dword) 2
(const byte) ITEM_COUNT#0 ITEM_COUNT = (byte/signed byte/word/signed word/dword/signed dword) 3
(byte) ITEM_SIZE
(const byte) ITEM_SIZE#0 ITEM_SIZE = (byte/signed byte/word/signed word/dword/signed dword) 5
(byte[$0]) items
(const byte[$0]) items#0 items = { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
(byte[ITEM_COUNT#0*ITEM_SIZE#0]) items
(const byte[ITEM_COUNT#0*ITEM_SIZE#0]) items#0 items = { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0 }
(void()) main()
(byte~) main::$2 reg byte a 202.0
(byte~) main::$3 reg byte a 202.0

View File

@ -14,7 +14,7 @@ main::@1: scope:[main] from main main::@2
[5] (byte) main::y#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte) main::x#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte*) main::cursor#3 ← phi( main/(const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte*) main::cursor#3 ← phi( main/(const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] )
[8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] )

View File

@ -125,7 +125,6 @@ main::@return: scope:[main] from main::@4
to:@end
@end: scope:[] from @1
Eliminating unused variable (word/signed word/dword/signed dword~) $0 and assignment [1] (word/signed word/dword/signed dword~) $0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 25
Removing empty block main::@4
PROCEDURE MODIFY VARIABLE ANALYSIS
@ -136,6 +135,7 @@ Completing Phi functions...
CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[] from
(byte) STAR#0 ← (byte/signed byte/word/signed word/dword/signed dword) 81
(word/signed word/dword/signed dword~) $0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 25
(byte[$0]) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
to:@1
main: scope:[main] from @1
@ -218,6 +218,7 @@ main::@return: scope:[main] from main::@2
@end: scope:[] from @2
SYMBOL TABLE SSA
(word/signed word/dword/signed dword~) $0
(label) @1
(label) @2
(label) @begin
@ -348,7 +349,8 @@ Simple Condition (bool~) main::$10 if((byte) main::xd#0>(byte) main::e#1) goto m
Simple Condition (bool~) main::$15 if((byte) main::x#1<(byte/signed word/word/dword/signed dword~) main::$14) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) STAR#0 = 81
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const word/signed word/dword/signed dword) $0 = 40*25
Constant (const byte[$0]) SCREEN#0 = ((byte*))1024
Constant (const byte) main::x#0 = 4
Constant (const byte) main::y#0 = 4
Constant (const byte) main::x1#0 = 39
@ -356,7 +358,7 @@ Constant (const byte) main::y1#0 = 24
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::xd#0 = main::x1#0-main::x#0
Constant (const byte) main::yd#0 = main::y1#0-main::y#0
Constant (const byte/word/signed word/dword/signed dword) main::$3 = main::y#0*40
Constant (const byte/signed word/word/dword/signed dword) main::$3 = main::y#0*40
Constant (const byte/signed word/word/dword/signed dword) main::$14 = main::x1#0+1
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::e#0 = main::yd#0/2
@ -378,12 +380,13 @@ Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::cursor#0
Constant inlined main::cursor#0 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined main::cursor#0 = (const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined main::$3 = (byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::$14 = (const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined main::$4 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::$4 = (const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::y#0 = (byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined $0 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 25
Constant inlined main::e#0 = (const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@return
@ -449,7 +452,7 @@ main::@1: scope:[main] from main main::@2
[5] (byte) main::y#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte) main::x#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte*) main::cursor#3 ← phi( main/(const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte*) main::cursor#3 ← phi( main/(const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
[7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] )
[8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] )
@ -494,7 +497,7 @@ Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 main::@3 depth: 1
VARIABLE REGISTER WEIGHTS
(byte[$0]) SCREEN
(byte[40*25]) SCREEN
(byte) STAR
(void()) main()
(byte*) main::cursor
@ -581,7 +584,7 @@ main: {
//SEG13 [5] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#2] -- vbuz1=vbuc1
lda #4
sta x
//SEG14 [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1
//SEG14 [5] phi (byte*) main::cursor#3 = (const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1
lda #<SCREEN+4*$28+4
sta cursor
lda #>SCREEN+4*$28+4
@ -729,7 +732,7 @@ main: {
//SEG13 [5] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#2] -- vbuz1=vbuc1
lda #4
sta x
//SEG14 [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1
//SEG14 [5] phi (byte*) main::cursor#3 = (const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1
lda #<SCREEN+4*$28+4
sta cursor
lda #>SCREEN+4*$28+4
@ -834,8 +837,8 @@ FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte[$0]) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte[40*25]) SCREEN
(const byte[40*25]) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) STAR
(const byte) STAR#0 STAR = (byte/signed byte/word/signed word/dword/signed dword) 81
(void()) main()
@ -912,7 +915,7 @@ main: {
ldx #yd/2
//SEG13 [5] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#2] -- vbuz1=vbuc1
sta x
//SEG14 [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1
//SEG14 [5] phi (byte*) main::cursor#3 = (const byte[40*25]) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40+(byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1
lda #<SCREEN+4*$28+4
sta cursor
lda #>SCREEN+4*$28+4

View File

@ -1,8 +1,8 @@
(label) @1
(label) @begin
(label) @end
(byte[$0]) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte[40*25]) SCREEN
(const byte[40*25]) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) STAR
(const byte) STAR#0 STAR = (byte/signed byte/word/signed word/dword/signed dword) 81
(void()) main()

View File

@ -15,7 +15,7 @@ main::@1: scope:[main] from main main::@2
[5] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@2/(byte) main::e#5 ) [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte) main::x#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@2/(byte) main::x#1 ) [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[5] (word) main::idx#3 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0+(byte/signed byte/word/signed word/dword/signed dword) 0*(byte/signed byte/word/signed word/dword/signed dword) 40 main::@2/(word) main::idx#5 ) [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::idx#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::idx#3 main::e#3 main::y#2 main::x#1 ] )
[8] (word) main::idx#1 ← (word) main::idx#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::idx#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::idx#1 ] )
[9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] )

View File

@ -123,7 +123,6 @@ main::@return: scope:[main] from main::@4
to:@end
@end: scope:[] from @1
Eliminating unused variable (word/signed word/dword/signed dword~) main::$0 and assignment [1] (word/signed word/dword/signed dword~) main::$0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 25
Removing empty block main::@4
PROCEDURE MODIFY VARIABLE ANALYSIS
@ -136,6 +135,7 @@ CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
to:@1
main: scope:[main] from @1
(byte) main::STAR#0 ← (byte/signed byte/word/signed word/dword/signed dword) 81
(word/signed word/dword/signed dword~) main::$0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 25
(byte[main::$0]) main::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
(byte) main::x0#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
(byte) main::y0#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
@ -218,6 +218,7 @@ SYMBOL TABLE SSA
(label) @begin
(label) @end
(void()) main()
(word/signed word/dword/signed dword~) main::$0
(byte~) main::$1
(bool~) main::$10
(byte/signed word/word/dword/signed dword~) main::$11
@ -335,7 +336,8 @@ Simple Condition (bool~) main::$10 if((byte) main::xd#0>=(byte) main::e#1) goto
Simple Condition (bool~) main::$15 if((byte) main::x#1<(byte/signed word/word/dword/signed dword~) main::$14) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::STAR#0 = 81
Constant (const byte*) main::screen#0 = ((byte*))1024
Constant (const word/signed word/dword/signed dword) main::$0 = 40*25
Constant (const byte[main::$0]) main::screen#0 = ((byte*))1024
Constant (const byte) main::x#0 = 0
Constant (const byte) main::y#0 = 0
Constant (const byte) main::x1#0 = 39
@ -364,6 +366,7 @@ Inlining constant with var siblings (const word) main::idx#0
Inlining constant with var siblings (const word) main::idx#0
Inlining constant with var siblings (const word) main::idx#0
Constant inlined main::idx#0 = (byte/signed byte/word/signed word/dword/signed dword) 0+(byte/signed byte/word/signed word/dword/signed dword) 0*(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::$0 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 25
Constant inlined main::$14 = (const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::$4 = (byte/signed byte/word/signed word/dword/signed dword) 0*(byte/signed byte/word/signed word/dword/signed dword) 40
@ -434,7 +437,7 @@ main::@1: scope:[main] from main main::@2
[5] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@2/(byte) main::e#5 ) [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[5] (byte) main::x#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@2/(byte) main::x#1 ) [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[5] (word) main::idx#3 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0+(byte/signed byte/word/signed word/dword/signed dword) 0*(byte/signed byte/word/signed word/dword/signed dword) 40 main::@2/(word) main::idx#5 ) [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] )
[7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::idx#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::idx#3 main::e#3 main::y#2 main::x#1 ] )
[8] (word) main::idx#1 ← (word) main::idx#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::idx#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::idx#1 ] )
[9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] )
@ -490,7 +493,7 @@ VARIABLE REGISTER WEIGHTS
(word) main::idx#2 11.0
(word) main::idx#3 11.0
(word) main::idx#5 16.5
(byte[main::$0]) main::screen
(byte[40*25]) main::screen
(byte) main::x
(byte) main::x#1 3.666666666666667
(byte) main::x#2 11.0
@ -580,7 +583,7 @@ main: {
jmp b1
//SEG20 main::@1
b1:
//SEG21 [6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) -- pbuc1_derefidx_vwuz1=vbuc2
//SEG21 [6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) -- pbuc1_derefidx_vwuz1=vbuc2
lda #<screen
clc
adc idx
@ -646,14 +649,14 @@ main: {
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a
Statement [6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::x#2 main::x#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Statement [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ) always clobbers reg byte a
Statement [12] (word) main::idx#2 ← (word) main::idx#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ) always clobbers reg byte a
Statement [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) always clobbers reg byte a
Statement [6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a
Statement [6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a
Statement [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ) always clobbers reg byte a
Statement [12] (word) main::idx#2 ← (word) main::idx#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ) always clobbers reg byte a
Statement [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) always clobbers reg byte a
@ -728,7 +731,7 @@ main: {
jmp b1
//SEG20 main::@1
b1:
//SEG21 [6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) -- pbuc1_derefidx_vwuz1=vbuc2
//SEG21 [6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) -- pbuc1_derefidx_vwuz1=vbuc2
lda #<screen
clc
adc idx
@ -842,8 +845,8 @@ FINAL SYMBOL TABLE
(word) main::idx#2 idx zp ZP_WORD:2 11.0
(word) main::idx#3 idx zp ZP_WORD:2 11.0
(word) main::idx#5 idx zp ZP_WORD:2 16.5
(byte[main::$0]) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
(byte[40*25]) main::screen
(const byte[40*25]) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) main::x
(byte) main::x#1 reg byte x 3.666666666666667
(byte) main::x#2 reg byte x 11.0
@ -914,7 +917,7 @@ main: {
//SEG19 [5] phi (word) main::idx#3 = (word) main::idx#5 [phi:main::@2->main::@1#3] -- register_copy
//SEG20 main::@1
b1:
//SEG21 [6] *((const byte*) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) -- pbuc1_derefidx_vwuz1=vbuc2
//SEG21 [6] *((const byte[40*25]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) -- pbuc1_derefidx_vwuz1=vbuc2
lda #<screen
clc
adc idx

View File

@ -18,8 +18,8 @@
(word) main::idx#2 idx zp ZP_WORD:2 11.0
(word) main::idx#3 idx zp ZP_WORD:2 11.0
(word) main::idx#5 idx zp ZP_WORD:2 16.5
(byte[main::$0]) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
(byte[40*25]) main::screen
(const byte[40*25]) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) main::x
(byte) main::x#1 reg byte x 3.666666666666667
(byte) main::x#2 reg byte x 11.0