mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-02 20:29:38 +00:00
Working on pointer math and sizeof(element)
This commit is contained in:
parent
7b157f9b44
commit
85317a1c5e
@ -162,6 +162,7 @@ public class Compiler {
|
||||
|
||||
new Pass1FixLValuesLoHi(program).execute();
|
||||
new Pass1AssertNoLValueIntermediate(program).execute();
|
||||
new Pass1PointerSizeofFix(program).execute();
|
||||
new Pass1AddTypePromotions(program).execute();
|
||||
new Pass1EarlyConstantIdentification(program).execute();
|
||||
new PassNStatementIndices(program).step();
|
||||
|
@ -0,0 +1,63 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.model.ControlFlowBlock;
|
||||
import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.operators.OperatorSizeOf;
|
||||
import dk.camelot64.kickc.model.operators.Operators;
|
||||
import dk.camelot64.kickc.model.statements.Statement;
|
||||
import dk.camelot64.kickc.model.statements.StatementAssignment;
|
||||
import dk.camelot64.kickc.model.symbols.Variable;
|
||||
import dk.camelot64.kickc.model.types.SymbolTypePointer;
|
||||
import dk.camelot64.kickc.model.values.VariableRef;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Fixes pointer math to use sizeof(type)
|
||||
*/
|
||||
public class Pass1PointerSizeofFix extends Pass1Base {
|
||||
|
||||
public Pass1PointerSizeofFix(Program program) {
|
||||
super(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean step() {
|
||||
for(ControlFlowBlock block : getGraph().getAllBlocks()) {
|
||||
ListIterator<Statement> stmtIt = block.getStatements().listIterator();
|
||||
while(stmtIt.hasNext()) {
|
||||
Statement statement = stmtIt.next();
|
||||
if(statement instanceof StatementAssignment) {
|
||||
StatementAssignment assignment = (StatementAssignment) statement;
|
||||
if((assignment.getrValue1() == null) && (assignment.getOperator() != null) && (assignment.getrValue2() instanceof VariableRef)) {
|
||||
// Found assignment of unary operator
|
||||
VariableRef varRef = (VariableRef) assignment.getrValue2();
|
||||
Variable variable = getScope().getVariable(varRef);
|
||||
if(variable.getType() instanceof SymbolTypePointer) {
|
||||
SymbolTypePointer pointerType = (SymbolTypePointer) variable.getType();
|
||||
if(pointerType.getElementType().getSizeBytes() > 1) {
|
||||
// Unary operation on non-byte pointer type - sizeof()-handling is needed!
|
||||
if(Operators.INCREMENT.equals(assignment.getOperator())) {
|
||||
// Pointer increment - add sizeof(type) instead
|
||||
getLog().append("Fixing pointer increment " + statement.toString(getProgram(), false));
|
||||
assignment.setrValue1(assignment.getrValue2());
|
||||
assignment.setOperator(Operators.PLUS);
|
||||
assignment.setrValue2(OperatorSizeOf.getSizeOfConstantVar(getProgram().getScope(), pointerType.getElementType()));
|
||||
} else if(Operators.DECREMENT.equals(assignment.getOperator())) {
|
||||
// Pointer Decrement - add sizeof(type) instead
|
||||
getLog().append("Fixing pointer decrement " + statement.toString(getProgram(), false));
|
||||
assignment.setrValue1(assignment.getrValue2());
|
||||
assignment.setOperator(Operators.MINUS);
|
||||
assignment.setrValue2(OperatorSizeOf.getSizeOfConstantVar(getProgram().getScope(), pointerType.getElementType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -8,5 +8,8 @@ void main() {
|
||||
wp++;
|
||||
SCREEN[2] = <*wp;
|
||||
SCREEN[3] = >*wp;
|
||||
wp--;
|
||||
SCREEN[4] = <*wp;
|
||||
SCREEN[5] = >*wp;
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,20 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.const SIZEOF_WORD = 2
|
||||
main: {
|
||||
.label SCREEN = $400+$28*6
|
||||
lda $400+1
|
||||
lda $400+SIZEOF_WORD
|
||||
sta SCREEN
|
||||
lda $400+1+1
|
||||
lda $400+SIZEOF_WORD+1
|
||||
sta SCREEN+1
|
||||
lda $400+1+1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD
|
||||
sta SCREEN+2
|
||||
lda $400+1+1+1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD+1
|
||||
sta SCREEN+3
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD
|
||||
sta SCREEN+4
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD+1
|
||||
sta SCREEN+5
|
||||
rts
|
||||
}
|
||||
|
@ -8,15 +8,19 @@
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[4] (byte~) main::$2 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD)
|
||||
[5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2
|
||||
[6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[6] (byte~) main::$3 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD)
|
||||
[7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3
|
||||
[8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[8] (byte~) main::$4 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD)
|
||||
[9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4
|
||||
[10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[10] (byte~) main::$5 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD)
|
||||
[11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5
|
||||
[12] (byte~) main::$6 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD)
|
||||
[13] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4) ← (byte~) main::$6
|
||||
[14] (byte~) main::$7 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD)
|
||||
[15] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 5) ← (byte~) main::$7
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[12] return
|
||||
[16] return
|
||||
to:@return
|
||||
|
@ -1,3 +1,6 @@
|
||||
Fixing pointer increment (word*) main::wp ← ++ (word*) main::wp
|
||||
Fixing pointer increment (word*) main::wp ← ++ (word*) main::wp
|
||||
Fixing pointer decrement (word*) main::wp ← -- (word*) main::wp
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
@ -7,16 +10,21 @@ main: scope:[main] from @1
|
||||
(word/signed dword/dword/signed word~) main::$1 ← (word/signed word/dword/signed dword) $400 + (byte/word/signed word/dword/signed dword~) main::$0
|
||||
(byte*) main::SCREEN#0 ← ((byte*)) (word/signed dword/dword/signed word~) main::$1
|
||||
(word*) main::wp#0 ← ((word*)) (word/signed word/dword/signed dword) $400
|
||||
(word*) main::wp#1 ← ++ (word*) main::wp#0
|
||||
(word*) main::wp#1 ← (word*) main::wp#0 + (const byte) SIZEOF_WORD
|
||||
(byte~) main::$2 ← < *((word*) main::wp#1)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte~) main::$2
|
||||
(byte~) main::$3 ← > *((word*) main::wp#1)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3
|
||||
(word*) main::wp#2 ← ++ (word*) main::wp#1
|
||||
(word*) main::wp#2 ← (word*) main::wp#1 + (const byte) SIZEOF_WORD
|
||||
(byte~) main::$4 ← < *((word*) main::wp#2)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4
|
||||
(byte~) main::$5 ← > *((word*) main::wp#2)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5
|
||||
(word*) main::wp#3 ← (word*) main::wp#2 - (const byte) SIZEOF_WORD
|
||||
(byte~) main::$6 ← < *((word*) main::wp#3)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 4) ← (byte~) main::$6
|
||||
(byte~) main::$7 ← > *((word*) main::wp#3)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 5) ← (byte~) main::$7
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
return
|
||||
@ -33,6 +41,7 @@ SYMBOL TABLE SSA
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) SIZEOF_WORD = (byte/signed byte/word/signed word/dword/signed dword) 2
|
||||
(void()) main()
|
||||
(byte/word/signed word/dword/signed dword~) main::$0
|
||||
(word/signed dword/dword/signed word~) main::$1
|
||||
@ -40,6 +49,8 @@ SYMBOL TABLE SSA
|
||||
(byte~) main::$3
|
||||
(byte~) main::$4
|
||||
(byte~) main::$5
|
||||
(byte~) main::$6
|
||||
(byte~) main::$7
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(byte*) main::SCREEN#0
|
||||
@ -47,6 +58,7 @@ SYMBOL TABLE SSA
|
||||
(word*) main::wp#0
|
||||
(word*) main::wp#1
|
||||
(word*) main::wp#2
|
||||
(word*) main::wp#3
|
||||
|
||||
Culled Empty Block (label) @2
|
||||
Successful SSA optimization Pass2CullEmptyBlocks
|
||||
@ -54,24 +66,30 @@ Constant (const byte/word/signed word/dword/signed dword) main::$0 = $28*6
|
||||
Constant (const word*) main::wp#0 = ((word*))$400
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant (const word/signed dword/dword/signed word) main::$1 = $400+main::$0
|
||||
Constant (const word*) main::wp#1 = ++main::wp#0
|
||||
Constant (const word*) main::wp#1 = main::wp#0+SIZEOF_WORD
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant (const byte*) main::SCREEN#0 = ((byte*))main::$1
|
||||
Constant (const word*) main::wp#2 = ++main::wp#1
|
||||
Constant (const word*) main::wp#2 = main::wp#1+SIZEOF_WORD
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant (const word*) main::wp#3 = main::wp#2-SIZEOF_WORD
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Consolidated array index constant in *(main::SCREEN#0+0)
|
||||
Consolidated array index constant in *(main::SCREEN#0+1)
|
||||
Consolidated array index constant in *(main::SCREEN#0+2)
|
||||
Consolidated array index constant in *(main::SCREEN#0+3)
|
||||
Consolidated array index constant in *(main::SCREEN#0+4)
|
||||
Consolidated array index constant in *(main::SCREEN#0+5)
|
||||
Successful SSA optimization Pass2ConstantAdditionElimination
|
||||
Inlining constant with different constant siblings (const word*) main::wp#0
|
||||
Inlining constant with different constant siblings (const word*) main::wp#1
|
||||
Inlining constant with different constant siblings (const word*) main::wp#2
|
||||
Inlining constant with different constant siblings (const word*) main::wp#3
|
||||
Constant inlined main::wp#0 = ((word*))(word/signed word/dword/signed dword) $400
|
||||
Constant inlined main::$1 = (word/signed word/dword/signed dword) $400+(byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
Constant inlined main::wp#1 = ++((word*))(word/signed word/dword/signed dword) $400
|
||||
Constant inlined main::wp#3 = ((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD
|
||||
Constant inlined main::wp#1 = ((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD
|
||||
Constant inlined main::$0 = (byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
Constant inlined main::wp#2 = ++++((word*))(word/signed word/dword/signed dword) $400
|
||||
Constant inlined main::wp#2 = ((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Simplifying constant plus zero main::SCREEN#0+0
|
||||
Adding NOP phi() at start of @begin
|
||||
@ -97,17 +115,21 @@ FINAL CONTROL FLOW GRAPH
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[4] (byte~) main::$2 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD)
|
||||
[5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2
|
||||
[6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[6] (byte~) main::$3 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD)
|
||||
[7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3
|
||||
[8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[8] (byte~) main::$4 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD)
|
||||
[9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4
|
||||
[10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[10] (byte~) main::$5 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD)
|
||||
[11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5
|
||||
[12] (byte~) main::$6 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD)
|
||||
[13] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4) ← (byte~) main::$6
|
||||
[14] (byte~) main::$7 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD)
|
||||
[15] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 5) ← (byte~) main::$7
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[12] return
|
||||
[16] return
|
||||
to:@return
|
||||
|
||||
|
||||
@ -117,6 +139,8 @@ VARIABLE REGISTER WEIGHTS
|
||||
(byte~) main::$3 4.0
|
||||
(byte~) main::$4 4.0
|
||||
(byte~) main::$5 4.0
|
||||
(byte~) main::$6 4.0
|
||||
(byte~) main::$7 4.0
|
||||
(byte*) main::SCREEN
|
||||
(word*) main::wp
|
||||
|
||||
@ -125,15 +149,21 @@ Added variable main::$2 to zero page equivalence class [ main::$2 ]
|
||||
Added variable main::$3 to zero page equivalence class [ main::$3 ]
|
||||
Added variable main::$4 to zero page equivalence class [ main::$4 ]
|
||||
Added variable main::$5 to zero page equivalence class [ main::$5 ]
|
||||
Added variable main::$6 to zero page equivalence class [ main::$6 ]
|
||||
Added variable main::$7 to zero page equivalence class [ main::$7 ]
|
||||
Complete equivalence classes
|
||||
[ main::$2 ]
|
||||
[ main::$3 ]
|
||||
[ main::$4 ]
|
||||
[ main::$5 ]
|
||||
[ main::$6 ]
|
||||
[ main::$7 ]
|
||||
Allocated zp ZP_BYTE:2 [ main::$2 ]
|
||||
Allocated zp ZP_BYTE:3 [ main::$3 ]
|
||||
Allocated zp ZP_BYTE:4 [ main::$4 ]
|
||||
Allocated zp ZP_BYTE:5 [ main::$5 ]
|
||||
Allocated zp ZP_BYTE:6 [ main::$6 ]
|
||||
Allocated zp ZP_BYTE:7 [ main::$7 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
@ -143,6 +173,7 @@ INITIAL ASM
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
.const SIZEOF_WORD = 2
|
||||
//SEG3 @begin
|
||||
bbegin:
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
@ -164,34 +195,48 @@ main: {
|
||||
.label _3 = 3
|
||||
.label _4 = 4
|
||||
.label _5 = 5
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+1
|
||||
.label _6 = 6
|
||||
.label _7 = 7
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD
|
||||
sta _2
|
||||
//SEG11 [5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuz1
|
||||
lda _2
|
||||
sta SCREEN
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+1
|
||||
sta _3
|
||||
//SEG13 [7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3 -- _deref_pbuc1=vbuz1
|
||||
lda _3
|
||||
sta SCREEN+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD
|
||||
sta _4
|
||||
//SEG15 [9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4 -- _deref_pbuc1=vbuz1
|
||||
lda _4
|
||||
sta SCREEN+2
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+1+1+1
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD+1
|
||||
sta _5
|
||||
//SEG17 [11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5 -- _deref_pbuc1=vbuz1
|
||||
lda _5
|
||||
sta SCREEN+3
|
||||
//SEG18 [12] (byte~) main::$6 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD
|
||||
sta _6
|
||||
//SEG19 [13] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4) ← (byte~) main::$6 -- _deref_pbuc1=vbuz1
|
||||
lda _6
|
||||
sta SCREEN+4
|
||||
//SEG20 [14] (byte~) main::$7 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD+1
|
||||
sta _7
|
||||
//SEG21 [15] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 5) ← (byte~) main::$7 -- _deref_pbuc1=vbuz1
|
||||
lda _7
|
||||
sta SCREEN+5
|
||||
jmp breturn
|
||||
//SEG18 main::@return
|
||||
//SEG22 main::@return
|
||||
breturn:
|
||||
//SEG19 [12] return
|
||||
//SEG23 [16] return
|
||||
rts
|
||||
}
|
||||
|
||||
@ -200,14 +245,20 @@ Potential registers zp ZP_BYTE:2 [ main::$2 ] : zp ZP_BYTE:2 , reg byte a , reg
|
||||
Potential registers zp ZP_BYTE:3 [ main::$3 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:4 [ main::$4 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:5 [ main::$5 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:6 [ main::$6 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:7 [ main::$7 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 4: zp ZP_BYTE:2 [ main::$2 ] 4: zp ZP_BYTE:3 [ main::$3 ] 4: zp ZP_BYTE:4 [ main::$4 ] 4: zp ZP_BYTE:5 [ main::$5 ]
|
||||
Uplift Scope [main] 4: zp ZP_BYTE:2 [ main::$2 ] 4: zp ZP_BYTE:3 [ main::$3 ] 4: zp ZP_BYTE:4 [ main::$4 ] 4: zp ZP_BYTE:5 [ main::$5 ] 4: zp ZP_BYTE:6 [ main::$6 ] 4: zp ZP_BYTE:7 [ main::$7 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 53 combination reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte a [ main::$4 ] reg byte a [ main::$5 ]
|
||||
Limited combination testing to 100 combinations of 256 possible.
|
||||
Uplifting [] best 53 combination
|
||||
Uplifting [main] best 81 combination reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte a [ main::$4 ] reg byte a [ main::$5 ] zp ZP_BYTE:6 [ main::$6 ] zp ZP_BYTE:7 [ main::$7 ]
|
||||
Limited combination testing to 100 combinations of 4096 possible.
|
||||
Uplifting [] best 81 combination
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::$6 ]
|
||||
Uplifting [main] best 75 combination reg byte a [ main::$6 ]
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:7 [ main::$7 ]
|
||||
Uplifting [main] best 69 combination reg byte a [ main::$7 ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
@ -217,6 +268,7 @@ ASSEMBLER BEFORE OPTIMIZATION
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
.const SIZEOF_WORD = 2
|
||||
//SEG3 @begin
|
||||
bbegin:
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
@ -234,26 +286,34 @@ bend:
|
||||
//SEG9 main
|
||||
main: {
|
||||
.label SCREEN = $400+$28*6
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD
|
||||
//SEG11 [5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+1
|
||||
//SEG13 [7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD
|
||||
//SEG15 [9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+2
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1+1
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD+1
|
||||
//SEG17 [11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+3
|
||||
//SEG18 [12] (byte~) main::$6 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD
|
||||
//SEG19 [13] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4) ← (byte~) main::$6 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+4
|
||||
//SEG20 [14] (byte~) main::$7 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD+1
|
||||
//SEG21 [15] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 5) ← (byte~) main::$7 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+5
|
||||
jmp breturn
|
||||
//SEG18 main::@return
|
||||
//SEG22 main::@return
|
||||
breturn:
|
||||
//SEG19 [12] return
|
||||
//SEG23 [16] return
|
||||
rts
|
||||
}
|
||||
|
||||
@ -279,11 +339,14 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte/signed byte/word/signed word/dword/signed dword) 2
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 4.0
|
||||
(byte~) main::$3 reg byte a 4.0
|
||||
(byte~) main::$4 reg byte a 4.0
|
||||
(byte~) main::$5 reg byte a 4.0
|
||||
(byte~) main::$6 reg byte a 4.0
|
||||
(byte~) main::$7 reg byte a 4.0
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400+(byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
@ -293,10 +356,12 @@ reg byte a [ main::$2 ]
|
||||
reg byte a [ main::$3 ]
|
||||
reg byte a [ main::$4 ]
|
||||
reg byte a [ main::$5 ]
|
||||
reg byte a [ main::$6 ]
|
||||
reg byte a [ main::$7 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 38
|
||||
Score: 54
|
||||
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
@ -305,6 +370,7 @@ Score: 38
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
.const SIZEOF_WORD = 2
|
||||
//SEG3 @begin
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
//SEG5 @1
|
||||
@ -314,24 +380,32 @@ Score: 38
|
||||
//SEG9 main
|
||||
main: {
|
||||
.label SCREEN = $400+$28*6
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD
|
||||
//SEG11 [5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+1
|
||||
//SEG13 [7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD
|
||||
//SEG15 [9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+2
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1+1
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD+1
|
||||
//SEG17 [11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+3
|
||||
//SEG18 main::@return
|
||||
//SEG19 [12] return
|
||||
//SEG18 [12] (byte~) main::$6 ← < *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD
|
||||
//SEG19 [13] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4) ← (byte~) main::$6 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+4
|
||||
//SEG20 [14] (byte~) main::$7 ← > *(((word*))(word/signed word/dword/signed dword) $400+(const byte) SIZEOF_WORD+(const byte) SIZEOF_WORD-(const byte) SIZEOF_WORD) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+SIZEOF_WORD+SIZEOF_WORD-SIZEOF_WORD+1
|
||||
//SEG21 [15] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 5) ← (byte~) main::$7 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+5
|
||||
//SEG22 main::@return
|
||||
//SEG23 [16] return
|
||||
rts
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte/signed byte/word/signed word/dword/signed dword) 2
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 4.0
|
||||
(byte~) main::$3 reg byte a 4.0
|
||||
(byte~) main::$4 reg byte a 4.0
|
||||
(byte~) main::$5 reg byte a 4.0
|
||||
(byte~) main::$6 reg byte a 4.0
|
||||
(byte~) main::$7 reg byte a 4.0
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400+(byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
@ -15,3 +18,5 @@ reg byte a [ main::$2 ]
|
||||
reg byte a [ main::$3 ]
|
||||
reg byte a [ main::$4 ]
|
||||
reg byte a [ main::$5 ]
|
||||
reg byte a [ main::$6 ]
|
||||
reg byte a [ main::$7 ]
|
||||
|
Loading…
Reference in New Issue
Block a user