mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-04-08 14:37:40 +00:00
Implemented simple linked list using pointers to structs.
This commit is contained in:
parent
7daf36a811
commit
59f6937835
4
src/main/fragment/_deref_pptc1=pssc2.asm
Normal file
4
src/main/fragment/_deref_pptc1=pssc2.asm
Normal file
@ -0,0 +1,4 @@
|
||||
lda #<{c2}
|
||||
sta {c1}
|
||||
lda #>{c2}
|
||||
sta {c1}+1
|
8
src/main/fragment/pssz1=_deref_pptz1.asm
Normal file
8
src/main/fragment/pssz1=_deref_pptz1.asm
Normal file
@ -0,0 +1,8 @@
|
||||
ldy #0
|
||||
lda ({z1}),y
|
||||
pha
|
||||
iny
|
||||
lda ({z1}),y
|
||||
sta {z1}+1
|
||||
pla
|
||||
sta {z1}
|
6
src/main/fragment/pssz1=_deref_pptz2.asm
Normal file
6
src/main/fragment/pssz1=_deref_pptz2.asm
Normal file
@ -0,0 +1,6 @@
|
||||
ldy #0
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
iny
|
||||
lda ({z2}),y
|
||||
sta {z1}+1
|
1
src/main/fragment/vbuaa=_hi_pssz1.asm
Normal file
1
src/main/fragment/vbuaa=_hi_pssz1.asm
Normal file
@ -0,0 +1 @@
|
||||
lda {z1}+1
|
1
src/main/fragment/vbuaa=_lo_pssz1.asm
Normal file
1
src/main/fragment/vbuaa=_lo_pssz1.asm
Normal file
@ -0,0 +1 @@
|
||||
lda {z1}
|
@ -164,6 +164,7 @@ public class Compiler {
|
||||
new Pass1Procedures(program).execute();
|
||||
new PassNTypeInference(program).execute();
|
||||
new PassNTypeIdSimplification(program).execute();
|
||||
new Pass1StructTypeSizeFix(program).execute();
|
||||
new Pass1AssertProcedureCallParameters(program).execute();
|
||||
new Pass1AssertReturn(program).execute();
|
||||
new Pass1AssertUsedVars(program).execute();
|
||||
|
@ -17,11 +17,7 @@ public class SymbolTypeStruct implements SymbolType {
|
||||
|
||||
public SymbolTypeStruct(StructDefinition structDefinition) {
|
||||
this.name = structDefinition.getLocalName();
|
||||
int sizeBytes = 0;
|
||||
for(Variable member : structDefinition.getAllVariables(false)) {
|
||||
sizeBytes += member.getType().getSizeBytes();
|
||||
}
|
||||
this.sizeBytes = sizeBytes;
|
||||
this.sizeBytes = calculateSizeBytes(structDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,6 +38,23 @@ public class SymbolTypeStruct implements SymbolType {
|
||||
return sizeBytes;
|
||||
}
|
||||
|
||||
public void setSizeBytes(int sizeBytes) {
|
||||
this.sizeBytes = sizeBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of bytes used by the struct by calculating bytes used by each member
|
||||
* @param structDefinition The struct definition (get using getStructDefinition)
|
||||
* @return The number of bytes a struct value require
|
||||
*/
|
||||
public int calculateSizeBytes(StructDefinition structDefinition) {
|
||||
int sizeBytes = 0;
|
||||
for(Variable member : structDefinition.getAllVariables(false)) {
|
||||
sizeBytes += member.getType().getSizeBytes();
|
||||
}
|
||||
return sizeBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
|
@ -0,0 +1,53 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.symbols.StructDefinition;
|
||||
import dk.camelot64.kickc.model.symbols.Variable;
|
||||
import dk.camelot64.kickc.model.types.SymbolType;
|
||||
import dk.camelot64.kickc.model.types.SymbolTypePointer;
|
||||
import dk.camelot64.kickc.model.types.SymbolTypeStruct;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Fixes byte-size of all struct types. (which may be a bit off if struct types are referenced before being parsed completely)
|
||||
*/
|
||||
public class Pass1StructTypeSizeFix extends Pass2SsaOptimization {
|
||||
|
||||
public Pass1StructTypeSizeFix(Program program) {
|
||||
super(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean step() {
|
||||
AtomicBoolean modified = new AtomicBoolean(false);
|
||||
for(Variable variable : getScope().getAllVariables(true)) {
|
||||
modified.set(fixStructSize(variable.getType()));
|
||||
}
|
||||
return modified.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix struct byte-sizes in the passed type (if any)
|
||||
* @param type The type to fix
|
||||
* @return true if anything was modified
|
||||
*/
|
||||
private boolean fixStructSize(SymbolType type) {
|
||||
if(type instanceof SymbolTypeStruct) {
|
||||
SymbolTypeStruct typeStruct = (SymbolTypeStruct) type;
|
||||
StructDefinition structDefinition = typeStruct.getStructDefinition(getScope());
|
||||
int sizeBytes = typeStruct.calculateSizeBytes(structDefinition);
|
||||
if(sizeBytes!=typeStruct.getSizeBytes()) {
|
||||
getLog().append("Fixing struct type size "+type.getTypeName() + " to "+sizeBytes);
|
||||
typeStruct.setSizeBytes(sizeBytes);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if(type instanceof SymbolTypePointer) {
|
||||
return fixStructSize(((SymbolTypePointer) type).getElementType());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -35,6 +35,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStructPtr5() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-ptr-5");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStructPtr4() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-ptr-4");
|
||||
|
41
src/test/kc/struct-ptr-5.kc
Normal file
41
src/test/kc/struct-ptr-5.kc
Normal file
@ -0,0 +1,41 @@
|
||||
// Minimal struct - simple linked list implemented using pointers
|
||||
|
||||
struct Entry {
|
||||
struct Entry* next;
|
||||
byte value;
|
||||
};
|
||||
|
||||
struct Entry* ENTRIES= 0x1000;
|
||||
|
||||
void main() {
|
||||
// Create a few (non-linear) linked entries
|
||||
struct Entry* entry0 = ENTRIES;
|
||||
struct Entry* entry1 = ENTRIES+1;
|
||||
struct Entry* entry2 = ENTRIES+2;
|
||||
|
||||
(*entry0).next = entry2;
|
||||
(*entry0).value = 1;
|
||||
|
||||
(*entry2).next = entry1;
|
||||
(*entry2).value = 2;
|
||||
|
||||
(*entry1).next = 0;
|
||||
(*entry1).value = 3;
|
||||
|
||||
|
||||
// Run through the linked list
|
||||
const byte* SCREEN = 0x0400;
|
||||
byte idx = 0;
|
||||
|
||||
struct Entry* entry = ENTRIES;
|
||||
while(entry) {
|
||||
SCREEN[idx++] = '0'+(*entry).value;
|
||||
struct Entry* next = (*entry).next;
|
||||
SCREEN[idx++] = <next;
|
||||
SCREEN[idx++] = >next;
|
||||
SCREEN[idx++] = ' ';
|
||||
entry = (*entry).next;
|
||||
}
|
||||
|
||||
|
||||
}
|
76
src/test/ref/struct-ptr-5.asm
Normal file
76
src/test/ref/struct-ptr-5.asm
Normal file
@ -0,0 +1,76 @@
|
||||
// Minimal struct - simple linked list implemented using pointers
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.const SIZEOF_STRUCT_ENTRY = 3
|
||||
.const OFFSET_STRUCT_ENTRY_VALUE = 2
|
||||
.label ENTRIES = $1000
|
||||
main: {
|
||||
// Run through the linked list
|
||||
.label SCREEN = $400
|
||||
.label entry1 = ENTRIES+1*SIZEOF_STRUCT_ENTRY
|
||||
.label entry2 = ENTRIES+2*SIZEOF_STRUCT_ENTRY
|
||||
.label next = 4
|
||||
.label entry = 2
|
||||
lda #<entry2
|
||||
sta ENTRIES
|
||||
lda #>entry2
|
||||
sta ENTRIES+1
|
||||
lda #1
|
||||
sta ENTRIES+OFFSET_STRUCT_ENTRY_VALUE
|
||||
lda #<entry1
|
||||
sta entry2
|
||||
lda #>entry1
|
||||
sta entry2+1
|
||||
lda #2
|
||||
sta entry2+OFFSET_STRUCT_ENTRY_VALUE
|
||||
lda #<0
|
||||
sta entry1
|
||||
sta entry1+1
|
||||
lda #3
|
||||
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
|
||||
ldx #0
|
||||
lda #<ENTRIES
|
||||
sta entry
|
||||
lda #>ENTRIES
|
||||
sta entry+1
|
||||
b1:
|
||||
lda entry+1
|
||||
cmp #>0
|
||||
bne b2
|
||||
lda entry
|
||||
cmp #<0
|
||||
bne b2
|
||||
rts
|
||||
b2:
|
||||
lda #'0'
|
||||
ldy #OFFSET_STRUCT_ENTRY_VALUE
|
||||
clc
|
||||
adc (entry),y
|
||||
sta SCREEN,x
|
||||
inx
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
sta next
|
||||
iny
|
||||
lda (entry),y
|
||||
sta next+1
|
||||
lda next
|
||||
sta SCREEN,x
|
||||
inx
|
||||
lda next+1
|
||||
sta SCREEN,x
|
||||
inx
|
||||
lda #' '
|
||||
sta SCREEN,x
|
||||
inx
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
pha
|
||||
iny
|
||||
lda (entry),y
|
||||
sta entry+1
|
||||
pla
|
||||
sta entry
|
||||
jmp b1
|
||||
}
|
40
src/test/ref/struct-ptr-5.cfg
Normal file
40
src/test/ref/struct-ptr-5.cfg
Normal file
@ -0,0 +1,40 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0
|
||||
[5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1
|
||||
[6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0
|
||||
[7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2
|
||||
[8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0
|
||||
[9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[10] (byte) main::idx#5 ← phi( main/(byte) 0 main::@2/(byte) main::idx#4 )
|
||||
[10] (struct Entry*) main::entry#2 ← phi( main/(const struct Entry*) ENTRIES#0 main::@2/(struct Entry*) main::entry#1 )
|
||||
[11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[12] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE)
|
||||
[14] *((const byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2
|
||||
[15] (byte) main::idx#1 ← ++ (byte) main::idx#5
|
||||
[16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2)
|
||||
[17] (byte~) main::$3 ← < (struct Entry*) main::next#0
|
||||
[18] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3
|
||||
[19] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[20] (byte~) main::$4 ← > (struct Entry*) main::next#0
|
||||
[21] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4
|
||||
[22] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' '
|
||||
[24] (byte) main::idx#4 ← ++ (byte) main::idx#3
|
||||
[25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2)
|
||||
to:main::@1
|
913
src/test/ref/struct-ptr-5.log
Normal file
913
src/test/ref/struct-ptr-5.log
Normal file
@ -0,0 +1,913 @@
|
||||
Fixing struct type size struct Entry to 3
|
||||
Fixing pointer addition (struct Entry*~) main::$0 ← (struct Entry*) ENTRIES + (number) 1
|
||||
Fixing pointer addition (struct Entry*~) main::$1 ← (struct Entry*) ENTRIES + (number) 2
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry0).next
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry0).value
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry2).next
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry2).value
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry1).next
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry1).value
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry).value
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry).next
|
||||
Rewriting struct pointer member access *((struct Entry*) main::entry).next
|
||||
Warning! Adding boolean cast to non-boolean condition (struct Entry*) main::entry
|
||||
Adding pointer type conversion cast (struct Entry*) ENTRIES in (struct Entry*) ENTRIES ← (number) $1000
|
||||
Adding pointer type conversion cast (struct Entry*) *(main::$11) in *((struct Entry**) main::$11) ← (number) 0
|
||||
Adding pointer type conversion cast (byte*) main::SCREEN in (byte*) main::SCREEN ← (number) $400
|
||||
Identified constant variable (struct Entry*) ENTRIES
|
||||
Culled Empty Block (label) main::@4
|
||||
Culled Empty Block (label) main::@3
|
||||
Culled Empty Block (label) main::@5
|
||||
Culled Empty Block (label) main::@6
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
(struct Entry*) ENTRIES#0 ← ((struct Entry*)) (number) $1000
|
||||
to:@1
|
||||
main: scope:[main] from @1
|
||||
(struct Entry*) main::entry0#0 ← (struct Entry*) ENTRIES#0
|
||||
(number~) main::$5 ← (number) 1 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
(struct Entry*~) main::$0 ← (struct Entry*) ENTRIES#0 + (number~) main::$5
|
||||
(struct Entry*) main::entry1#0 ← (struct Entry*~) main::$0
|
||||
(number~) main::$6 ← (number) 2 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
(struct Entry*~) main::$1 ← (struct Entry*) ENTRIES#0 + (number~) main::$6
|
||||
(struct Entry*) main::entry2#0 ← (struct Entry*~) main::$1
|
||||
(struct Entry**) main::$7 ← (struct Entry**)(struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
*((struct Entry**) main::$7) ← (struct Entry*) main::entry2#0
|
||||
(byte*) main::$8 ← (byte*)(struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
*((byte*) main::$8) ← (number) 1
|
||||
(struct Entry**) main::$9 ← (struct Entry**)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
*((struct Entry**) main::$9) ← (struct Entry*) main::entry1#0
|
||||
(byte*) main::$10 ← (byte*)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
*((byte*) main::$10) ← (number) 2
|
||||
(struct Entry**) main::$11 ← (struct Entry**)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
*((struct Entry**) main::$11) ← ((struct Entry*)) (number) 0
|
||||
(byte*) main::$12 ← (byte*)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
*((byte*) main::$12) ← (number) 3
|
||||
(byte*) main::SCREEN#0 ← ((byte*)) (number) $400
|
||||
(byte) main::idx#0 ← (number) 0
|
||||
(struct Entry*) main::entry#0 ← (struct Entry*) ENTRIES#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
(byte) main::idx#6 ← phi( main/(byte) main::idx#0 main::@2/(byte) main::idx#4 )
|
||||
(struct Entry*) main::entry#2 ← phi( main/(struct Entry*) main::entry#0 main::@2/(struct Entry*) main::entry#1 )
|
||||
(bool~) main::$16 ← (number) 0 != (struct Entry*) main::entry#2
|
||||
if((bool~) main::$16) goto main::@2
|
||||
to:main::@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
(byte) main::idx#5 ← phi( main::@1/(byte) main::idx#6 )
|
||||
(struct Entry*) main::entry#3 ← phi( main::@1/(struct Entry*) main::entry#2 )
|
||||
(byte*) main::$13 ← (byte*)(struct Entry*) main::entry#3 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
(byte~) main::$2 ← (byte) '0' + *((byte*) main::$13)
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2
|
||||
(byte) main::idx#1 ← ++ (byte) main::idx#5
|
||||
(struct Entry**) main::$14 ← (struct Entry**)(struct Entry*) main::entry#3 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
(struct Entry*) main::next#0 ← *((struct Entry**) main::$14)
|
||||
(byte~) main::$3 ← < (struct Entry*) main::next#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3
|
||||
(byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
(byte~) main::$4 ← > (struct Entry*) main::next#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4
|
||||
(byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' '
|
||||
(byte) main::idx#4 ← ++ (byte) main::idx#3
|
||||
(struct Entry**) main::$15 ← (struct Entry**)(struct Entry*) main::entry#3 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
(struct Entry*) main::entry#1 ← *((struct Entry**) main::$15)
|
||||
to:main::@1
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@1: scope:[] from @begin
|
||||
call main
|
||||
to:@2
|
||||
@2: scope:[] from @1
|
||||
to:@end
|
||||
@end: scope:[] from @2
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(label) @1
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(struct Entry*) ENTRIES
|
||||
(struct Entry*) ENTRIES#0
|
||||
(struct Entry*) Entry::next
|
||||
(byte) Entry::value
|
||||
(const byte) OFFSET_STRUCT_ENTRY_NEXT = (byte) 0
|
||||
(const byte) OFFSET_STRUCT_ENTRY_VALUE = (byte) 2
|
||||
(const byte) SIZEOF_STRUCT_ENTRY = (byte) 3
|
||||
(void()) main()
|
||||
(struct Entry*~) main::$0
|
||||
(struct Entry*~) main::$1
|
||||
(byte*) main::$10
|
||||
(struct Entry**) main::$11
|
||||
(byte*) main::$12
|
||||
(byte*) main::$13
|
||||
(struct Entry**) main::$14
|
||||
(struct Entry**) main::$15
|
||||
(bool~) main::$16
|
||||
(byte~) main::$2
|
||||
(byte~) main::$3
|
||||
(byte~) main::$4
|
||||
(number~) main::$5
|
||||
(number~) main::$6
|
||||
(struct Entry**) main::$7
|
||||
(byte*) main::$8
|
||||
(struct Entry**) main::$9
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(byte*) main::SCREEN#0
|
||||
(struct Entry*) main::entry
|
||||
(struct Entry*) main::entry#0
|
||||
(struct Entry*) main::entry#1
|
||||
(struct Entry*) main::entry#2
|
||||
(struct Entry*) main::entry#3
|
||||
(struct Entry*) main::entry0
|
||||
(struct Entry*) main::entry0#0
|
||||
(struct Entry*) main::entry1
|
||||
(struct Entry*) main::entry1#0
|
||||
(struct Entry*) main::entry2
|
||||
(struct Entry*) main::entry2#0
|
||||
(byte) main::idx
|
||||
(byte) main::idx#0
|
||||
(byte) main::idx#1
|
||||
(byte) main::idx#2
|
||||
(byte) main::idx#3
|
||||
(byte) main::idx#4
|
||||
(byte) main::idx#5
|
||||
(byte) main::idx#6
|
||||
(struct Entry*) main::next
|
||||
(struct Entry*) main::next#0
|
||||
|
||||
Adding number conversion cast (unumber) 1 in (number~) main::$5 ← (number) 1 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Adding number conversion cast (unumber) main::$5 in (number~) main::$5 ← (unumber)(number) 1 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Adding number conversion cast (unumber) 2 in (number~) main::$6 ← (number) 2 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (unumber)(number) 2 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Adding number conversion cast (unumber) 1 in *((byte*) main::$8) ← (number) 1
|
||||
Adding number conversion cast (unumber) 2 in *((byte*) main::$10) ← (number) 2
|
||||
Adding number conversion cast (unumber) 3 in *((byte*) main::$12) ← (number) 3
|
||||
Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
|
||||
Adding number conversion cast (unumber) 0 in (bool~) main::$16 ← (number) 0 != (struct Entry*) main::entry#2
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Inlining cast (struct Entry*) ENTRIES#0 ← (struct Entry*)(number) $1000
|
||||
Inlining cast *((byte*) main::$8) ← (unumber)(number) 1
|
||||
Inlining cast *((byte*) main::$10) ← (unumber)(number) 2
|
||||
Inlining cast *((struct Entry**) main::$11) ← (struct Entry*)(number) 0
|
||||
Inlining cast *((byte*) main::$12) ← (unumber)(number) 3
|
||||
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
|
||||
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (struct Entry*) 4096
|
||||
Simplifying constant integer cast 1
|
||||
Simplifying constant integer cast 2
|
||||
Simplifying constant integer cast 1
|
||||
Simplifying constant integer cast 2
|
||||
Simplifying constant pointer cast (struct Entry*) 0
|
||||
Simplifying constant integer cast 3
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant integer cast 0
|
||||
Simplifying constant integer cast 0
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) 1
|
||||
Finalized unsigned number type (byte) 2
|
||||
Finalized unsigned number type (byte) 1
|
||||
Finalized unsigned number type (byte) 2
|
||||
Finalized unsigned number type (byte) 3
|
||||
Finalized unsigned number type (byte) 0
|
||||
Finalized unsigned number type (byte) 0
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Inferred type updated to byte in (unumber~) main::$5 ← (byte) 1 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Inferred type updated to byte in (unumber~) main::$6 ← (byte) 2 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Alias (struct Entry*) main::entry1#0 = (struct Entry*~) main::$0
|
||||
Alias (struct Entry*) main::entry2#0 = (struct Entry*~) main::$1
|
||||
Alias (struct Entry*) main::entry#2 = (struct Entry*) main::entry#3
|
||||
Alias (byte) main::idx#5 = (byte) main::idx#6
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Simple Condition (bool~) main::$16 [25] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant right-side identified [2] (byte~) main::$5 ← (byte) 1 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Constant right-side identified [5] (byte~) main::$6 ← (byte) 2 * (const byte) SIZEOF_STRUCT_ENTRY
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const struct Entry*) ENTRIES#0 = (struct Entry*) 4096
|
||||
Constant (const byte) main::$5 = 1*SIZEOF_STRUCT_ENTRY
|
||||
Constant (const byte) main::$6 = 2*SIZEOF_STRUCT_ENTRY
|
||||
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
|
||||
Constant (const byte) main::idx#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant (const struct Entry*) main::entry0#0 = ENTRIES#0
|
||||
Constant (const struct Entry*) main::entry#0 = ENTRIES#0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant value identified (struct Entry**)main::entry0#0 in [8] (struct Entry**) main::$7 ← (struct Entry**)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Constant value identified (byte*)main::entry0#0 in [10] (byte*) main::$8 ← (byte*)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
Successful SSA optimization Pass2ConstantValues
|
||||
Converting *(pointer+n) to pointer[n] [9] *((struct Entry**) main::$7) ← (struct Entry*) main::entry2#0 -- *((struct Entry**)main::entry0#0 + OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Converting *(pointer+n) to pointer[n] [11] *((byte*) main::$8) ← (byte) 1 -- *((byte*)main::entry0#0 + OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Converting *(pointer+n) to pointer[n] [13] *((struct Entry**) main::$9) ← (struct Entry*) main::entry1#0 -- *((struct Entry**)main::entry2#0 + OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Converting *(pointer+n) to pointer[n] [15] *((byte*) main::$10) ← (byte) 2 -- *((byte*)main::entry2#0 + OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Converting *(pointer+n) to pointer[n] [17] *((struct Entry**) main::$11) ← (struct Entry*) 0 -- *((struct Entry**)main::entry1#0 + OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Converting *(pointer+n) to pointer[n] [19] *((byte*) main::$12) ← (byte) 3 -- *((byte*)main::entry1#0 + OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Converting *(pointer+n) to pointer[n] [28] (byte~) main::$2 ← (byte) '0' + *((byte*) main::$13) -- *((byte*)main::entry#2 + OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Converting *(pointer+n) to pointer[n] [32] (struct Entry*) main::next#0 ← *((struct Entry**) main::$14) -- *((struct Entry**)main::entry#2 + OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Converting *(pointer+n) to pointer[n] [42] (struct Entry*) main::entry#1 ← *((struct Entry**) main::$15) -- *((struct Entry**)main::entry#2 + OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Successful SSA optimization Pass2InlineDerefIdx
|
||||
Simplifying expression containing zero (struct Entry**)main::entry0#0 in [8] (struct Entry**) main::$7 ← (struct Entry**)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Simplifying expression containing zero (struct Entry**)main::entry0#0 in [9] *((struct Entry**)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) main::entry2#0
|
||||
Simplifying expression containing zero (struct Entry**)main::entry2#0 in [12] (struct Entry**) main::$9 ← (struct Entry**)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Simplifying expression containing zero (struct Entry**)main::entry2#0 in [13] *((struct Entry**)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) main::entry1#0
|
||||
Simplifying expression containing zero (struct Entry**)main::entry1#0 in [16] (struct Entry**) main::$11 ← (struct Entry**)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Simplifying expression containing zero (struct Entry**)main::entry1#0 in [17] *((struct Entry**)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0
|
||||
Simplifying expression containing zero (struct Entry**)main::entry#2 in [31] (struct Entry**) main::$14 ← (struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Simplifying expression containing zero (struct Entry**)main::entry#2 in [32] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Simplifying expression containing zero (struct Entry**)main::entry#2 in [41] (struct Entry**) main::$15 ← (struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Simplifying expression containing zero (struct Entry**)main::entry#2 in [42] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
|
||||
Successful SSA optimization PassNSimplifyExpressionWithZero
|
||||
Eliminating unused variable (struct Entry**) main::$7 and assignment [2] (struct Entry**) main::$7 ← (struct Entry**)(const struct Entry*) main::entry0#0
|
||||
Eliminating unused variable (byte*) main::$8 and assignment [4] (byte*) main::$8 ← (byte*)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
Eliminating unused variable (struct Entry**) main::$9 and assignment [6] (struct Entry**) main::$9 ← (struct Entry**)(struct Entry*) main::entry2#0
|
||||
Eliminating unused variable (byte*) main::$10 and assignment [8] (byte*) main::$10 ← (byte*)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
Eliminating unused variable (struct Entry**) main::$11 and assignment [10] (struct Entry**) main::$11 ← (struct Entry**)(struct Entry*) main::entry1#0
|
||||
Eliminating unused variable (byte*) main::$12 and assignment [12] (byte*) main::$12 ← (byte*)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
Eliminating unused variable (byte*) main::$13 and assignment [16] (byte*) main::$13 ← (byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
|
||||
Eliminating unused variable (struct Entry**) main::$14 and assignment [20] (struct Entry**) main::$14 ← (struct Entry**)(struct Entry*) main::entry#2
|
||||
Eliminating unused variable (struct Entry**) main::$15 and assignment [30] (struct Entry**) main::$15 ← (struct Entry**)(struct Entry*) main::entry#2
|
||||
Eliminating unused constant (const byte) OFFSET_STRUCT_ENTRY_NEXT
|
||||
Successful SSA optimization PassNEliminateUnusedVars
|
||||
Constant right-side identified [0] (struct Entry*) main::entry1#0 ← (const struct Entry*) ENTRIES#0 + (const byte) main::$5
|
||||
Constant right-side identified [1] (struct Entry*) main::entry2#0 ← (const struct Entry*) ENTRIES#0 + (const byte) main::$6
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const struct Entry*) main::entry1#0 = ENTRIES#0+main::$5
|
||||
Constant (const struct Entry*) main::entry2#0 = ENTRIES#0+main::$6
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant value identified (struct Entry**)main::entry2#0 in [4] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0
|
||||
Constant value identified (byte*)main::entry2#0 in [5] *((byte*)(const struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2
|
||||
Constant value identified (struct Entry**)main::entry1#0 in [6] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0
|
||||
Constant value identified (byte*)main::entry1#0 in [7] *((byte*)(const struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3
|
||||
Successful SSA optimization Pass2ConstantValues
|
||||
Inlining constant with var siblings (const byte) main::idx#0
|
||||
Inlining constant with var siblings (const struct Entry*) main::entry#0
|
||||
Constant inlined main::$5 = (byte) 1*(const byte) SIZEOF_STRUCT_ENTRY
|
||||
Constant inlined main::$6 = (byte) 2*(const byte) SIZEOF_STRUCT_ENTRY
|
||||
Constant inlined main::idx#0 = (byte) 0
|
||||
Constant inlined main::entry0#0 = (const struct Entry*) ENTRIES#0
|
||||
Constant inlined main::entry#0 = (const struct Entry*) ENTRIES#0
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Consolidated array index constant in *((byte*)ENTRIES#0+OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Consolidated array index constant in *((byte*)main::entry2#0+OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Consolidated array index constant in *((byte*)main::entry1#0+OFFSET_STRUCT_ENTRY_VALUE)
|
||||
Successful SSA optimization Pass2ConstantAdditionElimination
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @2
|
||||
Adding NOP phi() at start of @end
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 2 initial phi equivalence classes
|
||||
Coalesced [27] main::entry#4 ← main::entry#1
|
||||
Coalesced [28] main::idx#7 ← main::idx#4
|
||||
Coalesced down to 2 phi equivalence classes
|
||||
Culled Empty Block (label) @2
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0
|
||||
[5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1
|
||||
[6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0
|
||||
[7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2
|
||||
[8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0
|
||||
[9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[10] (byte) main::idx#5 ← phi( main/(byte) 0 main::@2/(byte) main::idx#4 )
|
||||
[10] (struct Entry*) main::entry#2 ← phi( main/(const struct Entry*) ENTRIES#0 main::@2/(struct Entry*) main::entry#1 )
|
||||
[11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[12] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE)
|
||||
[14] *((const byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2
|
||||
[15] (byte) main::idx#1 ← ++ (byte) main::idx#5
|
||||
[16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2)
|
||||
[17] (byte~) main::$3 ← < (struct Entry*) main::next#0
|
||||
[18] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3
|
||||
[19] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[20] (byte~) main::$4 ← > (struct Entry*) main::next#0
|
||||
[21] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4
|
||||
[22] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' '
|
||||
[24] (byte) main::idx#4 ← ++ (byte) main::idx#3
|
||||
[25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2)
|
||||
to:main::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(struct Entry*) ENTRIES
|
||||
(struct Entry*) Entry::next
|
||||
(byte) Entry::value
|
||||
(void()) main()
|
||||
(byte~) main::$2 22.0
|
||||
(byte~) main::$3 22.0
|
||||
(byte~) main::$4 22.0
|
||||
(byte*) main::SCREEN
|
||||
(struct Entry*) main::entry
|
||||
(struct Entry*) main::entry#1 22.0
|
||||
(struct Entry*) main::entry#2 1.5714285714285714
|
||||
(struct Entry*) main::entry0
|
||||
(struct Entry*) main::entry1
|
||||
(struct Entry*) main::entry2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 8.25
|
||||
(byte) main::idx#2 11.0
|
||||
(byte) main::idx#3 16.5
|
||||
(byte) main::idx#4 11.0
|
||||
(byte) main::idx#5 8.25
|
||||
(struct Entry*) main::next
|
||||
(struct Entry*) main::next#0 8.25
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::entry#2 main::entry#1 ]
|
||||
[ main::idx#5 main::idx#4 ]
|
||||
Added variable main::$2 to zero page equivalence class [ main::$2 ]
|
||||
Added variable main::idx#1 to zero page equivalence class [ main::idx#1 ]
|
||||
Added variable main::next#0 to zero page equivalence class [ main::next#0 ]
|
||||
Added variable main::$3 to zero page equivalence class [ main::$3 ]
|
||||
Added variable main::idx#2 to zero page equivalence class [ main::idx#2 ]
|
||||
Added variable main::$4 to zero page equivalence class [ main::$4 ]
|
||||
Added variable main::idx#3 to zero page equivalence class [ main::idx#3 ]
|
||||
Complete equivalence classes
|
||||
[ main::entry#2 main::entry#1 ]
|
||||
[ main::idx#5 main::idx#4 ]
|
||||
[ main::$2 ]
|
||||
[ main::idx#1 ]
|
||||
[ main::next#0 ]
|
||||
[ main::$3 ]
|
||||
[ main::idx#2 ]
|
||||
[ main::$4 ]
|
||||
[ main::idx#3 ]
|
||||
Allocated zp ZP_WORD:2 [ main::entry#2 main::entry#1 ]
|
||||
Allocated zp ZP_BYTE:4 [ main::idx#5 main::idx#4 ]
|
||||
Allocated zp ZP_BYTE:5 [ main::$2 ]
|
||||
Allocated zp ZP_BYTE:6 [ main::idx#1 ]
|
||||
Allocated zp ZP_WORD:7 [ main::next#0 ]
|
||||
Allocated zp ZP_BYTE:9 [ main::$3 ]
|
||||
Allocated zp ZP_BYTE:10 [ main::idx#2 ]
|
||||
Allocated zp ZP_BYTE:11 [ main::$4 ]
|
||||
Allocated zp ZP_BYTE:12 [ main::idx#3 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
// Minimal struct - simple linked list implemented using pointers
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
.const SIZEOF_STRUCT_ENTRY = 3
|
||||
.const OFFSET_STRUCT_ENTRY_VALUE = 2
|
||||
.label ENTRIES = $1000
|
||||
//SEG3 @begin
|
||||
bbegin:
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
b1_from_bbegin:
|
||||
jmp b1
|
||||
//SEG5 @1
|
||||
b1:
|
||||
//SEG6 [2] call main
|
||||
jsr main
|
||||
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG8 @end
|
||||
bend:
|
||||
//SEG9 main
|
||||
main: {
|
||||
// Run through the linked list
|
||||
.label SCREEN = $400
|
||||
.label entry1 = ENTRIES+1*SIZEOF_STRUCT_ENTRY
|
||||
.label entry2 = ENTRIES+2*SIZEOF_STRUCT_ENTRY
|
||||
.label _2 = 5
|
||||
.label _3 = 9
|
||||
.label _4 = $b
|
||||
.label idx = 6
|
||||
.label next = 7
|
||||
.label idx_2 = $a
|
||||
.label idx_3 = $c
|
||||
.label idx_4 = 4
|
||||
.label entry = 2
|
||||
.label idx_5 = 4
|
||||
//SEG10 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0 -- _deref_pptc1=pssc2
|
||||
lda #<entry2
|
||||
sta ENTRIES
|
||||
lda #>entry2
|
||||
sta ENTRIES+1
|
||||
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 -- _deref_pbuc1=vbuc2
|
||||
lda #1
|
||||
sta ENTRIES+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG12 [6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0 -- _deref_pptc1=pssc2
|
||||
lda #<entry1
|
||||
sta entry2
|
||||
lda #>entry1
|
||||
sta entry2+1
|
||||
//SEG13 [7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2 -- _deref_pbuc1=vbuc2
|
||||
lda #2
|
||||
sta entry2+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG14 [8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0 -- _deref_pptc1=pssc2
|
||||
lda #<0
|
||||
sta entry1
|
||||
lda #>0
|
||||
sta entry1+1
|
||||
//SEG15 [9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3 -- _deref_pbuc1=vbuc2
|
||||
lda #3
|
||||
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG16 [10] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG17 [10] phi (byte) main::idx#5 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx_5
|
||||
//SEG18 [10] phi (struct Entry*) main::entry#2 = (const struct Entry*) ENTRIES#0 [phi:main->main::@1#1] -- pssz1=pssc1
|
||||
lda #<ENTRIES
|
||||
sta entry
|
||||
lda #>ENTRIES
|
||||
sta entry+1
|
||||
jmp b1
|
||||
//SEG19 main::@1
|
||||
b1:
|
||||
//SEG20 [11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2 -- vwuc1_neq_pssz1_then_la1
|
||||
lda entry+1
|
||||
cmp #>0
|
||||
bne b2
|
||||
lda entry
|
||||
cmp #<0
|
||||
bne b2
|
||||
jmp breturn
|
||||
//SEG21 main::@return
|
||||
breturn:
|
||||
//SEG22 [12] return
|
||||
rts
|
||||
//SEG23 main::@2
|
||||
b2:
|
||||
//SEG24 [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) -- vbuz1=vbuc1_plus_pbuz2_derefidx_vbuc2
|
||||
lda #'0'
|
||||
ldy #OFFSET_STRUCT_ENTRY_VALUE
|
||||
clc
|
||||
adc (entry),y
|
||||
sta _2
|
||||
//SEG25 [14] *((const byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _2
|
||||
ldy idx_5
|
||||
sta SCREEN,y
|
||||
//SEG26 [15] (byte) main::idx#1 ← ++ (byte) main::idx#5 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_5
|
||||
iny
|
||||
sty idx
|
||||
//SEG27 [16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2) -- pssz1=_deref_pptz2
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
sta next
|
||||
iny
|
||||
lda (entry),y
|
||||
sta next+1
|
||||
//SEG28 [17] (byte~) main::$3 ← < (struct Entry*) main::next#0 -- vbuz1=_lo_pssz2
|
||||
lda next
|
||||
sta _3
|
||||
//SEG29 [18] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _3
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG30 [19] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuz1=_inc_vbuz2
|
||||
ldy idx
|
||||
iny
|
||||
sty idx_2
|
||||
//SEG31 [20] (byte~) main::$4 ← > (struct Entry*) main::next#0 -- vbuz1=_hi_pssz2
|
||||
lda next+1
|
||||
sta _4
|
||||
//SEG32 [21] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _4
|
||||
ldy idx_2
|
||||
sta SCREEN,y
|
||||
//SEG33 [22] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_2
|
||||
iny
|
||||
sty idx_3
|
||||
//SEG34 [23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2
|
||||
lda #' '
|
||||
ldy idx_3
|
||||
sta SCREEN,y
|
||||
//SEG35 [24] (byte) main::idx#4 ← ++ (byte) main::idx#3 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_3
|
||||
iny
|
||||
sty idx_4
|
||||
//SEG36 [25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2) -- pssz1=_deref_pptz1
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
pha
|
||||
iny
|
||||
lda (entry),y
|
||||
sta entry+1
|
||||
pla
|
||||
sta entry
|
||||
//SEG37 [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
b1_from_b2:
|
||||
//SEG38 [10] phi (byte) main::idx#5 = (byte) main::idx#4 [phi:main::@2->main::@1#0] -- register_copy
|
||||
//SEG39 [10] phi (struct Entry*) main::entry#2 = (struct Entry*) main::entry#1 [phi:main::@2->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2 [ main::entry#2 main::idx#5 ] ( main:2 [ main::entry#2 main::idx#5 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::idx#5 main::idx#4 ]
|
||||
Statement [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) [ main::entry#2 main::idx#5 main::$2 ] ( main:2 [ main::entry#2 main::idx#5 main::$2 ] ) always clobbers reg byte a reg byte y
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:4 [ main::idx#5 main::idx#4 ]
|
||||
Statement [16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2) [ main::entry#2 main::idx#1 main::next#0 ] ( main:2 [ main::entry#2 main::idx#1 main::next#0 ] ) always clobbers reg byte a reg byte y
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ main::idx#1 ]
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:6 [ main::idx#1 ]
|
||||
Statement [17] (byte~) main::$3 ← < (struct Entry*) main::next#0 [ main::entry#2 main::idx#1 main::next#0 main::$3 ] ( main:2 [ main::entry#2 main::idx#1 main::next#0 main::$3 ] ) always clobbers reg byte a
|
||||
Statement [20] (byte~) main::$4 ← > (struct Entry*) main::next#0 [ main::entry#2 main::idx#2 main::$4 ] ( main:2 [ main::entry#2 main::idx#2 main::$4 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:10 [ main::idx#2 ]
|
||||
Statement [23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' ' [ main::entry#2 main::idx#3 ] ( main:2 [ main::entry#2 main::idx#3 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:12 [ main::idx#3 ]
|
||||
Statement [25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2) [ main::entry#1 main::idx#4 ] ( main:2 [ main::entry#1 main::idx#4 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
||||
Statement [11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2 [ main::entry#2 main::idx#5 ] ( main:2 [ main::entry#2 main::idx#5 ] ) always clobbers reg byte a
|
||||
Statement [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) [ main::entry#2 main::idx#5 main::$2 ] ( main:2 [ main::entry#2 main::idx#5 main::$2 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2) [ main::entry#2 main::idx#1 main::next#0 ] ( main:2 [ main::entry#2 main::idx#1 main::next#0 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [17] (byte~) main::$3 ← < (struct Entry*) main::next#0 [ main::entry#2 main::idx#1 main::next#0 main::$3 ] ( main:2 [ main::entry#2 main::idx#1 main::next#0 main::$3 ] ) always clobbers reg byte a
|
||||
Statement [20] (byte~) main::$4 ← > (struct Entry*) main::next#0 [ main::entry#2 main::idx#2 main::$4 ] ( main:2 [ main::entry#2 main::idx#2 main::$4 ] ) always clobbers reg byte a
|
||||
Statement [23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' ' [ main::entry#2 main::idx#3 ] ( main:2 [ main::entry#2 main::idx#3 ] ) always clobbers reg byte a
|
||||
Statement [25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2) [ main::entry#1 main::idx#4 ] ( main:2 [ main::entry#1 main::idx#4 ] ) always clobbers reg byte a reg byte y
|
||||
Potential registers zp ZP_WORD:2 [ main::entry#2 main::entry#1 ] : zp ZP_WORD:2 ,
|
||||
Potential registers zp ZP_BYTE:4 [ main::idx#5 main::idx#4 ] : zp ZP_BYTE:4 , reg byte x ,
|
||||
Potential registers zp ZP_BYTE:5 [ main::$2 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:6 [ main::idx#1 ] : zp ZP_BYTE:6 , reg byte x ,
|
||||
Potential registers zp ZP_WORD:7 [ main::next#0 ] : zp ZP_WORD:7 ,
|
||||
Potential registers zp ZP_BYTE:9 [ main::$3 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:10 [ main::idx#2 ] : zp ZP_BYTE:10 , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:11 [ main::$4 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:12 [ main::idx#3 ] : zp ZP_BYTE:12 , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 23.57: zp ZP_WORD:2 [ main::entry#2 main::entry#1 ] 22: zp ZP_BYTE:5 [ main::$2 ] 22: zp ZP_BYTE:9 [ main::$3 ] 22: zp ZP_BYTE:11 [ main::$4 ] 19.25: zp ZP_BYTE:4 [ main::idx#5 main::idx#4 ] 16.5: zp ZP_BYTE:12 [ main::idx#3 ] 11: zp ZP_BYTE:10 [ main::idx#2 ] 8.25: zp ZP_BYTE:6 [ main::idx#1 ] 8.25: zp ZP_WORD:7 [ main::next#0 ]
|
||||
Uplift Scope [Entry]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 1667 combination zp ZP_WORD:2 [ main::entry#2 main::entry#1 ] reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte a [ main::$4 ] reg byte x [ main::idx#5 main::idx#4 ] zp ZP_BYTE:12 [ main::idx#3 ] zp ZP_BYTE:10 [ main::idx#2 ] zp ZP_BYTE:6 [ main::idx#1 ] zp ZP_WORD:7 [ main::next#0 ]
|
||||
Limited combination testing to 100 combinations of 2304 possible.
|
||||
Uplifting [Entry] best 1667 combination
|
||||
Uplifting [] best 1667 combination
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:12 [ main::idx#3 ]
|
||||
Uplifting [main] best 1577 combination reg byte x [ main::idx#3 ]
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:10 [ main::idx#2 ]
|
||||
Uplifting [main] best 1487 combination reg byte x [ main::idx#2 ]
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::idx#1 ]
|
||||
Uplifting [main] best 1397 combination reg byte x [ main::idx#1 ]
|
||||
Allocated (was zp ZP_WORD:7) zp ZP_WORD:4 [ main::next#0 ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
// Minimal struct - simple linked list implemented using pointers
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
.const SIZEOF_STRUCT_ENTRY = 3
|
||||
.const OFFSET_STRUCT_ENTRY_VALUE = 2
|
||||
.label ENTRIES = $1000
|
||||
//SEG3 @begin
|
||||
bbegin:
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
b1_from_bbegin:
|
||||
jmp b1
|
||||
//SEG5 @1
|
||||
b1:
|
||||
//SEG6 [2] call main
|
||||
jsr main
|
||||
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG8 @end
|
||||
bend:
|
||||
//SEG9 main
|
||||
main: {
|
||||
// Run through the linked list
|
||||
.label SCREEN = $400
|
||||
.label entry1 = ENTRIES+1*SIZEOF_STRUCT_ENTRY
|
||||
.label entry2 = ENTRIES+2*SIZEOF_STRUCT_ENTRY
|
||||
.label next = 4
|
||||
.label entry = 2
|
||||
//SEG10 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0 -- _deref_pptc1=pssc2
|
||||
lda #<entry2
|
||||
sta ENTRIES
|
||||
lda #>entry2
|
||||
sta ENTRIES+1
|
||||
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 -- _deref_pbuc1=vbuc2
|
||||
lda #1
|
||||
sta ENTRIES+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG12 [6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0 -- _deref_pptc1=pssc2
|
||||
lda #<entry1
|
||||
sta entry2
|
||||
lda #>entry1
|
||||
sta entry2+1
|
||||
//SEG13 [7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2 -- _deref_pbuc1=vbuc2
|
||||
lda #2
|
||||
sta entry2+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG14 [8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0 -- _deref_pptc1=pssc2
|
||||
lda #<0
|
||||
sta entry1
|
||||
lda #>0
|
||||
sta entry1+1
|
||||
//SEG15 [9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3 -- _deref_pbuc1=vbuc2
|
||||
lda #3
|
||||
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG16 [10] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG17 [10] phi (byte) main::idx#5 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
//SEG18 [10] phi (struct Entry*) main::entry#2 = (const struct Entry*) ENTRIES#0 [phi:main->main::@1#1] -- pssz1=pssc1
|
||||
lda #<ENTRIES
|
||||
sta entry
|
||||
lda #>ENTRIES
|
||||
sta entry+1
|
||||
jmp b1
|
||||
//SEG19 main::@1
|
||||
b1:
|
||||
//SEG20 [11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2 -- vwuc1_neq_pssz1_then_la1
|
||||
lda entry+1
|
||||
cmp #>0
|
||||
bne b2
|
||||
lda entry
|
||||
cmp #<0
|
||||
bne b2
|
||||
jmp breturn
|
||||
//SEG21 main::@return
|
||||
breturn:
|
||||
//SEG22 [12] return
|
||||
rts
|
||||
//SEG23 main::@2
|
||||
b2:
|
||||
//SEG24 [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) -- vbuaa=vbuc1_plus_pbuz1_derefidx_vbuc2
|
||||
lda #'0'
|
||||
ldy #OFFSET_STRUCT_ENTRY_VALUE
|
||||
clc
|
||||
adc (entry),y
|
||||
//SEG25 [14] *((const byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2 -- pbuc1_derefidx_vbuxx=vbuaa
|
||||
sta SCREEN,x
|
||||
//SEG26 [15] (byte) main::idx#1 ← ++ (byte) main::idx#5 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG27 [16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2) -- pssz1=_deref_pptz2
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
sta next
|
||||
iny
|
||||
lda (entry),y
|
||||
sta next+1
|
||||
//SEG28 [17] (byte~) main::$3 ← < (struct Entry*) main::next#0 -- vbuaa=_lo_pssz1
|
||||
lda next
|
||||
//SEG29 [18] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3 -- pbuc1_derefidx_vbuxx=vbuaa
|
||||
sta SCREEN,x
|
||||
//SEG30 [19] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG31 [20] (byte~) main::$4 ← > (struct Entry*) main::next#0 -- vbuaa=_hi_pssz1
|
||||
lda next+1
|
||||
//SEG32 [21] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4 -- pbuc1_derefidx_vbuxx=vbuaa
|
||||
sta SCREEN,x
|
||||
//SEG33 [22] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG34 [23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2
|
||||
lda #' '
|
||||
sta SCREEN,x
|
||||
//SEG35 [24] (byte) main::idx#4 ← ++ (byte) main::idx#3 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG36 [25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2) -- pssz1=_deref_pptz1
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
pha
|
||||
iny
|
||||
lda (entry),y
|
||||
sta entry+1
|
||||
pla
|
||||
sta entry
|
||||
//SEG37 [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
b1_from_b2:
|
||||
//SEG38 [10] phi (byte) main::idx#5 = (byte) main::idx#4 [phi:main::@2->main::@1#0] -- register_copy
|
||||
//SEG39 [10] phi (struct Entry*) main::entry#2 = (struct Entry*) main::entry#1 [phi:main::@2->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction lda #>0
|
||||
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_b2:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction bbegin:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(struct Entry*) ENTRIES
|
||||
(const struct Entry*) ENTRIES#0 ENTRIES = (struct Entry*) 4096
|
||||
(struct Entry*) Entry::next
|
||||
(byte) Entry::value
|
||||
(const byte) OFFSET_STRUCT_ENTRY_VALUE OFFSET_STRUCT_ENTRY_VALUE = (byte) 2
|
||||
(const byte) SIZEOF_STRUCT_ENTRY SIZEOF_STRUCT_ENTRY = (byte) 3
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 22.0
|
||||
(byte~) main::$3 reg byte a 22.0
|
||||
(byte~) main::$4 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = (byte*) 1024
|
||||
(struct Entry*) main::entry
|
||||
(struct Entry*) main::entry#1 entry zp ZP_WORD:2 22.0
|
||||
(struct Entry*) main::entry#2 entry zp ZP_WORD:2 1.5714285714285714
|
||||
(struct Entry*) main::entry0
|
||||
(struct Entry*) main::entry1
|
||||
(const struct Entry*) main::entry1#0 entry1 = (const struct Entry*) ENTRIES#0+(byte) 1*(const byte) SIZEOF_STRUCT_ENTRY
|
||||
(struct Entry*) main::entry2
|
||||
(const struct Entry*) main::entry2#0 entry2 = (const struct Entry*) ENTRIES#0+(byte) 2*(const byte) SIZEOF_STRUCT_ENTRY
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte x 8.25
|
||||
(byte) main::idx#2 reg byte x 11.0
|
||||
(byte) main::idx#3 reg byte x 16.5
|
||||
(byte) main::idx#4 reg byte x 11.0
|
||||
(byte) main::idx#5 reg byte x 8.25
|
||||
(struct Entry*) main::next
|
||||
(struct Entry*) main::next#0 next zp ZP_WORD:4 8.25
|
||||
|
||||
zp ZP_WORD:2 [ main::entry#2 main::entry#1 ]
|
||||
reg byte x [ main::idx#5 main::idx#4 ]
|
||||
reg byte a [ main::$2 ]
|
||||
reg byte x [ main::idx#1 ]
|
||||
zp ZP_WORD:4 [ main::next#0 ]
|
||||
reg byte a [ main::$3 ]
|
||||
reg byte x [ main::idx#2 ]
|
||||
reg byte a [ main::$4 ]
|
||||
reg byte x [ main::idx#3 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 1323
|
||||
|
||||
//SEG0 File Comments
|
||||
// Minimal struct - simple linked list implemented using pointers
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
.const SIZEOF_STRUCT_ENTRY = 3
|
||||
.const OFFSET_STRUCT_ENTRY_VALUE = 2
|
||||
.label ENTRIES = $1000
|
||||
//SEG3 @begin
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
//SEG5 @1
|
||||
//SEG6 [2] call main
|
||||
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
||||
//SEG8 @end
|
||||
//SEG9 main
|
||||
main: {
|
||||
// Run through the linked list
|
||||
.label SCREEN = $400
|
||||
.label entry1 = ENTRIES+1*SIZEOF_STRUCT_ENTRY
|
||||
.label entry2 = ENTRIES+2*SIZEOF_STRUCT_ENTRY
|
||||
.label next = 4
|
||||
.label entry = 2
|
||||
//SEG10 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0) ← (const struct Entry*) main::entry2#0 -- _deref_pptc1=pssc2
|
||||
lda #<entry2
|
||||
sta ENTRIES
|
||||
lda #>entry2
|
||||
sta ENTRIES+1
|
||||
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 -- _deref_pbuc1=vbuc2
|
||||
lda #1
|
||||
sta ENTRIES+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG12 [6] *((struct Entry**)(const struct Entry*) main::entry2#0) ← (const struct Entry*) main::entry1#0 -- _deref_pptc1=pssc2
|
||||
lda #<entry1
|
||||
sta entry2
|
||||
lda #>entry1
|
||||
sta entry2+1
|
||||
//SEG13 [7] *((byte*)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2 -- _deref_pbuc1=vbuc2
|
||||
lda #2
|
||||
sta entry2+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG14 [8] *((struct Entry**)(const struct Entry*) main::entry1#0) ← (struct Entry*) 0 -- _deref_pptc1=pssc2
|
||||
lda #<0
|
||||
sta entry1
|
||||
sta entry1+1
|
||||
//SEG15 [9] *((byte*)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3 -- _deref_pbuc1=vbuc2
|
||||
lda #3
|
||||
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
|
||||
//SEG16 [10] phi from main to main::@1 [phi:main->main::@1]
|
||||
//SEG17 [10] phi (byte) main::idx#5 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
//SEG18 [10] phi (struct Entry*) main::entry#2 = (const struct Entry*) ENTRIES#0 [phi:main->main::@1#1] -- pssz1=pssc1
|
||||
lda #<ENTRIES
|
||||
sta entry
|
||||
lda #>ENTRIES
|
||||
sta entry+1
|
||||
//SEG19 main::@1
|
||||
b1:
|
||||
//SEG20 [11] if((byte) 0!=(struct Entry*) main::entry#2) goto main::@2 -- vwuc1_neq_pssz1_then_la1
|
||||
lda entry+1
|
||||
cmp #>0
|
||||
bne b2
|
||||
lda entry
|
||||
cmp #<0
|
||||
bne b2
|
||||
//SEG21 main::@return
|
||||
//SEG22 [12] return
|
||||
rts
|
||||
//SEG23 main::@2
|
||||
b2:
|
||||
//SEG24 [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) -- vbuaa=vbuc1_plus_pbuz1_derefidx_vbuc2
|
||||
lda #'0'
|
||||
ldy #OFFSET_STRUCT_ENTRY_VALUE
|
||||
clc
|
||||
adc (entry),y
|
||||
//SEG25 [14] *((const byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2 -- pbuc1_derefidx_vbuxx=vbuaa
|
||||
sta SCREEN,x
|
||||
//SEG26 [15] (byte) main::idx#1 ← ++ (byte) main::idx#5 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG27 [16] (struct Entry*) main::next#0 ← *((struct Entry**)(struct Entry*) main::entry#2) -- pssz1=_deref_pptz2
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
sta next
|
||||
iny
|
||||
lda (entry),y
|
||||
sta next+1
|
||||
//SEG28 [17] (byte~) main::$3 ← < (struct Entry*) main::next#0 -- vbuaa=_lo_pssz1
|
||||
lda next
|
||||
//SEG29 [18] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3 -- pbuc1_derefidx_vbuxx=vbuaa
|
||||
sta SCREEN,x
|
||||
//SEG30 [19] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG31 [20] (byte~) main::$4 ← > (struct Entry*) main::next#0 -- vbuaa=_hi_pssz1
|
||||
lda next+1
|
||||
//SEG32 [21] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4 -- pbuc1_derefidx_vbuxx=vbuaa
|
||||
sta SCREEN,x
|
||||
//SEG33 [22] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG34 [23] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2
|
||||
lda #' '
|
||||
sta SCREEN,x
|
||||
//SEG35 [24] (byte) main::idx#4 ← ++ (byte) main::idx#3 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG36 [25] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2) -- pssz1=_deref_pptz1
|
||||
ldy #0
|
||||
lda (entry),y
|
||||
pha
|
||||
iny
|
||||
lda (entry),y
|
||||
sta entry+1
|
||||
pla
|
||||
sta entry
|
||||
//SEG37 [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
//SEG38 [10] phi (byte) main::idx#5 = (byte) main::idx#4 [phi:main::@2->main::@1#0] -- register_copy
|
||||
//SEG39 [10] phi (struct Entry*) main::entry#2 = (struct Entry*) main::entry#1 [phi:main::@2->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
1
src/test/ref/struct-ptr-5.sym
Normal file
1
src/test/ref/struct-ptr-5.sym
Normal file
@ -0,0 +1 @@
|
||||
program
|
Loading…
x
Reference in New Issue
Block a user