1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-09 21:37:31 +00:00

Changed struct-ptr-5 to use arrow operator and changed member sequence.

This commit is contained in:
jespergravgaard 2019-06-10 17:16:52 +02:00
parent c50cef4058
commit 5e0b33f2ca
10 changed files with 279 additions and 306 deletions

View File

@ -0,0 +1,8 @@
ldy #{c1}
lda ({z1}),y
pha
iny
lda ({z1}),y
sta {z1}+1
pla
sta {z1}

View File

@ -0,0 +1,2 @@
ldy #1
lda ({z1}),y

View File

@ -0,0 +1,2 @@
ldy #{c1}+1
lda ({z1}),y

View File

@ -0,0 +1,2 @@
ldy #0
lda ({z1}),y

View File

@ -0,0 +1,2 @@
ldy #{c1}
lda ({z1}),y

View File

@ -1,8 +1,8 @@
// Minimal struct - simple linked list implemented using pointers
struct Entry {
struct Entry* next;
byte value;
struct Entry* next;
};
struct Entry* ENTRIES= 0x1000;
@ -13,15 +13,12 @@ void main() {
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;
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;
@ -29,12 +26,11 @@ void main() {
struct Entry* entry = ENTRIES;
while(entry) {
SCREEN[idx++] = '0'+(*entry).value;
struct Entry* next = (*entry).next;
SCREEN[idx++] = <next;
SCREEN[idx++] = >next;
SCREEN[idx++] = '0'+entry->value;
SCREEN[idx++] = <entry->next;
SCREEN[idx++] = >entry->next;
SCREEN[idx++] = ' ';
entry = (*entry).next;
entry = entry->next;
}

View File

@ -3,32 +3,31 @@
:BasicUpstart(main)
.pc = $80d "Program"
.const SIZEOF_STRUCT_ENTRY = 3
.const OFFSET_STRUCT_ENTRY_VALUE = 2
.const OFFSET_STRUCT_ENTRY_NEXT = 1
.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
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT
lda #>entry2
sta ENTRIES+1
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT+1
lda #1
sta ENTRIES+OFFSET_STRUCT_ENTRY_VALUE
sta ENTRIES
lda #<entry1
sta entry2
sta entry2+OFFSET_STRUCT_ENTRY_NEXT
lda #>entry1
sta entry2+1
sta entry2+OFFSET_STRUCT_ENTRY_NEXT+1
lda #2
sta entry2+OFFSET_STRUCT_ENTRY_VALUE
sta entry2
lda #<0
sta entry1
sta entry1+1
sta entry1+OFFSET_STRUCT_ENTRY_NEXT
sta entry1+OFFSET_STRUCT_ENTRY_NEXT+1
lda #3
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
sta entry1
ldx #0
lda #<ENTRIES
sta entry
@ -44,27 +43,23 @@ main: {
rts
b2:
lda #'0'
ldy #OFFSET_STRUCT_ENTRY_VALUE
clc
ldy #0
adc (entry),y
sta SCREEN,x
inx
ldy #0
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
sta next
iny
lda (entry),y
sta next+1
lda next
sta SCREEN,x
inx
lda next+1
ldy #OFFSET_STRUCT_ENTRY_NEXT+1
lda (entry),y
sta SCREEN,x
inx
lda #' '
sta SCREEN,x
inx
ldy #0
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
pha
iny

View File

@ -8,12 +8,12 @@
@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
[4] *((struct Entry**)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0
[5] *((byte*)(const struct Entry*) ENTRIES#0) ← (byte) 1
[6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0
[7] *((byte*)(const struct Entry*) main::entry2#0) ← (byte) 2
[8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0
[9] *((byte*)(const struct Entry*) main::entry1#0) ← (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 )
@ -24,17 +24,16 @@ 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)
[13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2)
[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)
[16] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
[17] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3
[18] (byte) main::idx#2 ← ++ (byte) main::idx#1
[19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
[20] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4
[21] (byte) main::idx#3 ← ++ (byte) main::idx#2
[22] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' '
[23] (byte) main::idx#4 ← ++ (byte) main::idx#3
[24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
to:main::@1

View File

@ -10,6 +10,7 @@ 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
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
@ -51,8 +52,8 @@ main: scope:[main] from @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
(bool~) main::$17 ← (number) 0 != (struct Entry*) main::entry#2
if((bool~) main::$17) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
(byte) main::idx#5 ← phi( main::@1/(byte) main::idx#6 )
@ -62,17 +63,17 @@ main::@2: scope:[main] from main::@1
*((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::$3 ← < *((struct Entry**) main::$14)
*((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
(struct Entry**) main::$15 ← (struct Entry**)(struct Entry*) main::entry#3 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
(byte~) main::$4 ← > *((struct Entry**) main::$15)
*((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)
(struct Entry**) main::$16 ← (struct Entry**)(struct Entry*) main::entry#3 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
(struct Entry*) main::entry#1 ← *((struct Entry**) main::$16)
to:main::@1
main::@return: scope:[main] from main::@1
return
@ -93,8 +94,8 @@ SYMBOL TABLE SSA
(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) OFFSET_STRUCT_ENTRY_NEXT = (byte) 1
(const byte) OFFSET_STRUCT_ENTRY_VALUE = (byte) 0
(const byte) SIZEOF_STRUCT_ENTRY = (byte) 3
(void()) main()
(struct Entry*~) main::$0
@ -105,7 +106,8 @@ SYMBOL TABLE SSA
(byte*) main::$13
(struct Entry**) main::$14
(struct Entry**) main::$15
(bool~) main::$16
(struct Entry**) main::$16
(bool~) main::$17
(byte~) main::$2
(byte~) main::$3
(byte~) main::$4
@ -138,8 +140,6 @@ SYMBOL TABLE SSA
(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
@ -149,7 +149,7 @@ 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
Adding number conversion cast (unumber) 0 in (bool~) main::$17 ← (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
@ -185,7 +185,7 @@ 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
Simple Condition (bool~) main::$17 [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
@ -209,30 +209,30 @@ Converting *(pointer+n) to pointer[n] [15] *((byte*) main::$10) ← (byte) 2 --
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)
Converting *(pointer+n) to pointer[n] [32] (byte~) main::$3 ← < *((struct Entry**) main::$14) -- *((struct Entry**)main::entry#2 + OFFSET_STRUCT_ENTRY_NEXT)
Converting *(pointer+n) to pointer[n] [36] (byte~) main::$4 ← > *((struct Entry**) main::$15) -- *((struct Entry**)main::entry#2 + OFFSET_STRUCT_ENTRY_NEXT)
Converting *(pointer+n) to pointer[n] [42] (struct Entry*) main::entry#1 ← *((struct Entry**) main::$16) -- *((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)
Simplifying expression containing zero (byte*)main::entry0#0 in [10] (byte*) main::$8 ← (byte*)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
Simplifying expression containing zero (byte*)main::entry0#0 in [11] *((byte*)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1
Simplifying expression containing zero (byte*)main::entry2#0 in [14] (byte*) main::$10 ← (byte*)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
Simplifying expression containing zero (byte*)main::entry2#0 in [15] *((byte*)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 2
Simplifying expression containing zero (byte*)main::entry1#0 in [18] (byte*) main::$12 ← (byte*)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
Simplifying expression containing zero (byte*)main::entry1#0 in [19] *((byte*)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 3
Simplifying expression containing zero (byte*)main::entry#2 in [27] (byte*) main::$13 ← (byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE
Simplifying expression containing zero (byte*)main::entry#2 in [28] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_VALUE)
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
Eliminating unused variable (struct Entry**) main::$7 and assignment [2] (struct Entry**) main::$7 ← (struct Entry**)(const struct Entry*) main::entry0#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
Eliminating unused variable (byte*) main::$8 and assignment [4] (byte*) main::$8 ← (byte*)(const struct Entry*) main::entry0#0
Eliminating unused variable (struct Entry**) main::$9 and assignment [6] (struct Entry**) main::$9 ← (struct Entry**)(struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
Eliminating unused variable (byte*) main::$10 and assignment [8] (byte*) main::$10 ← (byte*)(struct Entry*) main::entry2#0
Eliminating unused variable (struct Entry**) main::$11 and assignment [10] (struct Entry**) main::$11 ← (struct Entry**)(struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
Eliminating unused variable (byte*) main::$12 and assignment [12] (byte*) main::$12 ← (byte*)(struct Entry*) main::entry1#0
Eliminating unused variable (byte*) main::$13 and assignment [16] (byte*) main::$13 ← (byte*)(struct Entry*) main::entry#2
Eliminating unused variable (struct Entry**) main::$14 and assignment [20] (struct Entry**) main::$14 ← (struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
Eliminating unused variable (struct Entry**) main::$15 and assignment [24] (struct Entry**) main::$15 ← (struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
Eliminating unused variable (struct Entry**) main::$16 and assignment [30] (struct Entry**) main::$16 ← (struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT
Eliminating unused constant (const byte) OFFSET_STRUCT_ENTRY_VALUE
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
@ -240,10 +240,10 @@ 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
Constant value identified (struct Entry**)main::entry2#0 in [4] *((struct Entry**)(const struct Entry*) main::entry2#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0
Constant value identified (byte*)main::entry2#0 in [5] *((byte*)(const struct Entry*) main::entry2#0) ← (byte) 2
Constant value identified (struct Entry**)main::entry1#0 in [6] *((struct Entry**)(const struct Entry*) main::entry1#0 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0
Constant value identified (byte*)main::entry1#0 in [7] *((byte*)(const struct Entry*) main::entry1#0) ← (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
@ -253,9 +253,9 @@ 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)
Consolidated array index constant in *((struct Entry**)ENTRIES#0+OFFSET_STRUCT_ENTRY_NEXT)
Consolidated array index constant in *((struct Entry**)main::entry2#0+OFFSET_STRUCT_ENTRY_NEXT)
Consolidated array index constant in *((struct Entry**)main::entry1#0+OFFSET_STRUCT_ENTRY_NEXT)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
@ -265,8 +265,8 @@ 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 [26] main::entry#4 ← main::entry#1
Coalesced [27] 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
@ -284,12 +284,12 @@ FINAL CONTROL FLOW GRAPH
@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
[4] *((struct Entry**)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0
[5] *((byte*)(const struct Entry*) ENTRIES#0) ← (byte) 1
[6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0
[7] *((byte*)(const struct Entry*) main::entry2#0) ← (byte) 2
[8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0
[9] *((byte*)(const struct Entry*) main::entry1#0) ← (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 )
@ -300,19 +300,18 @@ 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)
[13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2)
[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)
[16] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
[17] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3
[18] (byte) main::idx#2 ← ++ (byte) main::idx#1
[19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
[20] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4
[21] (byte) main::idx#3 ← ++ (byte) main::idx#2
[22] *((const byte*) main::SCREEN#0 + (byte) main::idx#3) ← (byte) ' '
[23] (byte) main::idx#4 ← ++ (byte) main::idx#3
[24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT)
to:main::@1
@ -327,25 +326,22 @@ VARIABLE REGISTER WEIGHTS
(byte*) main::SCREEN
(struct Entry*) main::entry
(struct Entry*) main::entry#1 22.0
(struct Entry*) main::entry#2 1.5714285714285714
(struct Entry*) main::entry#2 1.6923076923076923
(struct Entry*) main::entry0
(struct Entry*) main::entry1
(struct Entry*) main::entry2
(byte) main::idx
(byte) main::idx#1 8.25
(byte) main::idx#1 11.0
(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 ]
@ -355,7 +351,6 @@ Complete equivalence classes
[ main::idx#5 main::idx#4 ]
[ main::$2 ]
[ main::idx#1 ]
[ main::next#0 ]
[ main::$3 ]
[ main::idx#2 ]
[ main::$4 ]
@ -364,11 +359,10 @@ 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 ]
Allocated zp ZP_BYTE:7 [ main::$3 ]
Allocated zp ZP_BYTE:8 [ main::idx#2 ]
Allocated zp ZP_BYTE:9 [ main::$4 ]
Allocated zp ZP_BYTE:10 [ main::idx#3 ]
INITIAL ASM
//SEG0 File Comments
@ -379,7 +373,7 @@ INITIAL ASM
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_STRUCT_ENTRY = 3
.const OFFSET_STRUCT_ENTRY_VALUE = 2
.const OFFSET_STRUCT_ENTRY_NEXT = 1
.label ENTRIES = $1000
//SEG3 @begin
bbegin:
@ -402,39 +396,38 @@ main: {
.label entry1 = ENTRIES+1*SIZEOF_STRUCT_ENTRY
.label entry2 = ENTRIES+2*SIZEOF_STRUCT_ENTRY
.label _2 = 5
.label _3 = 9
.label _4 = $b
.label _3 = 7
.label _4 = 9
.label idx = 6
.label next = 7
.label idx_2 = $a
.label idx_3 = $c
.label idx_2 = 8
.label idx_3 = $a
.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
//SEG10 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0 -- _deref_pptc1=pssc2
lda #<entry2
sta ENTRIES
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT
lda #>entry2
sta ENTRIES+1
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 -- _deref_pbuc1=vbuc2
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0) ← (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
sta ENTRIES
//SEG12 [6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0 -- _deref_pptc1=pssc2
lda #<entry1
sta entry2
sta entry2+OFFSET_STRUCT_ENTRY_NEXT
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
sta entry2+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG13 [7] *((byte*)(const struct Entry*) main::entry2#0) ← (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
sta entry2
//SEG14 [8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0 -- _deref_pptc1=pssc2
lda #<0
sta entry1
sta entry1+OFFSET_STRUCT_ENTRY_NEXT
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
sta entry1+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG15 [9] *((byte*)(const struct Entry*) main::entry1#0) ← (byte) 3 -- _deref_pbuc1=vbuc2
lda #3
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
sta entry1
//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
@ -462,10 +455,10 @@ main: {
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
//SEG24 [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2) -- vbuz1=vbuc1_plus__deref_pbuz2
lda #'0'
ldy #OFFSET_STRUCT_ENTRY_VALUE
clc
ldy #0
adc (entry),y
sta _2
//SEG25 [14] *((const byte*) main::SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$2 -- pbuc1_derefidx_vbuz1=vbuz2
@ -476,45 +469,40 @@ main: {
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
//SEG27 [16] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- vbuz1=_lo_pptz2_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT
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
//SEG28 [17] *((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
//SEG29 [18] (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
//SEG30 [19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- vbuz1=_hi_pptz2_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT+1
lda (entry),y
sta _4
//SEG32 [21] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4 -- pbuc1_derefidx_vbuz1=vbuz2
//SEG31 [20] *((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
//SEG32 [21] (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
//SEG33 [22] *((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
//SEG34 [23] (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
//SEG35 [24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- pssz1=pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
pha
iny
@ -522,72 +510,69 @@ main: {
sta entry+1
pla
sta entry
//SEG37 [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG36 [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
//SEG37 [10] phi (byte) main::idx#5 = (byte) main::idx#4 [phi:main::@2->main::@1#0] -- register_copy
//SEG38 [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 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((byte*)(const struct Entry*) ENTRIES#0) ← (byte) 1 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((byte*)(const struct Entry*) main::entry2#0) ← (byte) 2 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((byte*)(const struct Entry*) main::entry1#0) ← (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
Statement [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2) [ 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
Statement [16] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) [ main::entry#2 main::idx#1 main::$3 ] ( main:2 [ main::entry#2 main::idx#1 main::$3 ] ) 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 [19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) [ main::entry#2 main::idx#2 main::$4 ] ( main:2 [ main::entry#2 main::idx#2 main::$4 ] ) always clobbers reg byte a reg byte y
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::idx#2 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:8 [ main::idx#2 ]
Statement [22] *((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:10 [ main::idx#3 ]
Statement [24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) [ 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 byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((byte*)(const struct Entry*) ENTRIES#0) ← (byte) 1 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((byte*)(const struct Entry*) main::entry2#0) ← (byte) 2 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((byte*)(const struct Entry*) main::entry1#0) ← (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
Statement [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2) [ 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] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) [ main::entry#2 main::idx#1 main::$3 ] ( main:2 [ main::entry#2 main::idx#1 main::$3 ] ) always clobbers reg byte a reg byte y
Statement [19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) [ main::entry#2 main::idx#2 main::$4 ] ( main:2 [ main::entry#2 main::idx#2 main::$4 ] ) always clobbers reg byte a reg byte y
Statement [22] *((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 [24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) [ 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 ,
Potential registers zp ZP_BYTE:7 [ main::$3 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:8 [ main::idx#2 ] : zp ZP_BYTE:8 , reg byte x ,
Potential registers zp ZP_BYTE:9 [ main::$4 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:10 [ main::idx#3 ] : zp ZP_BYTE:10 , 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 [main] 23.69: zp ZP_WORD:2 [ main::entry#2 main::entry#1 ] 22: zp ZP_BYTE:5 [ main::$2 ] 22: zp ZP_BYTE:7 [ main::$3 ] 22: zp ZP_BYTE:9 [ main::$4 ] 19.25: zp ZP_BYTE:4 [ main::idx#5 main::idx#4 ] 16.5: zp ZP_BYTE:10 [ main::idx#3 ] 11: zp ZP_BYTE:6 [ main::idx#1 ] 11: zp ZP_BYTE:8 [ main::idx#2 ]
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 ]
Uplifting [main] best 1547 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:10 [ main::idx#3 ] zp ZP_BYTE:6 [ main::idx#1 ] zp ZP_BYTE:8 [ main::idx#2 ]
Limited combination testing to 100 combinations of 1536 possible.
Uplifting [Entry] best 1547 combination
Uplifting [] best 1547 combination
Attempting to uplift remaining variables inzp ZP_BYTE:10 [ main::idx#3 ]
Uplifting [main] best 1457 combination reg byte x [ main::idx#3 ]
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 ]
Uplifting [main] best 1367 combination reg byte x [ main::idx#1 ]
Attempting to uplift remaining variables inzp ZP_BYTE:8 [ main::idx#2 ]
Uplifting [main] best 1277 combination reg byte x [ main::idx#2 ]
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
@ -598,7 +583,7 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_STRUCT_ENTRY = 3
.const OFFSET_STRUCT_ENTRY_VALUE = 2
.const OFFSET_STRUCT_ENTRY_NEXT = 1
.label ENTRIES = $1000
//SEG3 @begin
bbegin:
@ -620,32 +605,31 @@ main: {
.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
//SEG10 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0 -- _deref_pptc1=pssc2
lda #<entry2
sta ENTRIES
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT
lda #>entry2
sta ENTRIES+1
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 -- _deref_pbuc1=vbuc2
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0) ← (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
sta ENTRIES
//SEG12 [6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0 -- _deref_pptc1=pssc2
lda #<entry1
sta entry2
sta entry2+OFFSET_STRUCT_ENTRY_NEXT
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
sta entry2+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG13 [7] *((byte*)(const struct Entry*) main::entry2#0) ← (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
sta entry2
//SEG14 [8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (struct Entry*) 0 -- _deref_pptc1=pssc2
lda #<0
sta entry1
sta entry1+OFFSET_STRUCT_ENTRY_NEXT
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
sta entry1+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG15 [9] *((byte*)(const struct Entry*) main::entry1#0) ← (byte) 3 -- _deref_pbuc1=vbuc2
lda #3
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
sta entry1
//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
@ -672,41 +656,36 @@ main: {
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
//SEG24 [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2) -- vbuaa=vbuc1_plus__deref_pbuz1
lda #'0'
ldy #OFFSET_STRUCT_ENTRY_VALUE
clc
ldy #0
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
//SEG27 [16] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- vbuaa=_lo_pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
sta next
iny
//SEG28 [17] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN,x
//SEG29 [18] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx
inx
//SEG30 [19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- vbuaa=_hi_pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT+1
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
//SEG31 [20] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN,x
//SEG30 [19] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx
//SEG32 [21] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- 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
//SEG33 [22] *((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
//SEG34 [23] (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
//SEG35 [24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- pssz1=pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
pha
iny
@ -714,10 +693,10 @@ main: {
sta entry+1
pla
sta entry
//SEG37 [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG36 [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
//SEG37 [10] phi (byte) main::idx#5 = (byte) main::idx#4 [phi:main::@2->main::@1#0] -- register_copy
//SEG38 [10] phi (struct Entry*) main::entry#2 = (struct Entry*) main::entry#1 [phi:main::@2->main::@1#1] -- register_copy
jmp b1
}
@ -752,7 +731,7 @@ FINAL SYMBOL TABLE
(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) OFFSET_STRUCT_ENTRY_NEXT OFFSET_STRUCT_ENTRY_NEXT = (byte) 1
(const byte) SIZEOF_STRUCT_ENTRY SIZEOF_STRUCT_ENTRY = (byte) 3
(void()) main()
(byte~) main::$2 reg byte a 22.0
@ -765,26 +744,23 @@ FINAL SYMBOL TABLE
(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::entry#2 entry zp ZP_WORD:2 1.6923076923076923
(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#1 reg byte x 11.0
(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 ]
@ -792,7 +768,7 @@ reg byte x [ main::idx#3 ]
FINAL ASSEMBLER
Score: 1323
Score: 1203
//SEG0 File Comments
// Minimal struct - simple linked list implemented using pointers
@ -802,7 +778,7 @@ Score: 1323
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_STRUCT_ENTRY = 3
.const OFFSET_STRUCT_ENTRY_VALUE = 2
.const OFFSET_STRUCT_ENTRY_NEXT = 1
.label ENTRIES = $1000
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
@ -816,31 +792,30 @@ main: {
.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
//SEG10 [4] *((struct Entry**)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry2#0 -- _deref_pptc1=pssc2
lda #<entry2
sta ENTRIES
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT
lda #>entry2
sta ENTRIES+1
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0+(const byte) OFFSET_STRUCT_ENTRY_VALUE) ← (byte) 1 -- _deref_pbuc1=vbuc2
sta ENTRIES+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG11 [5] *((byte*)(const struct Entry*) ENTRIES#0) ← (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
sta ENTRIES
//SEG12 [6] *((struct Entry**)(const struct Entry*) main::entry2#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (const struct Entry*) main::entry1#0 -- _deref_pptc1=pssc2
lda #<entry1
sta entry2
sta entry2+OFFSET_STRUCT_ENTRY_NEXT
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
sta entry2+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG13 [7] *((byte*)(const struct Entry*) main::entry2#0) ← (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
sta entry2
//SEG14 [8] *((struct Entry**)(const struct Entry*) main::entry1#0+(const byte) OFFSET_STRUCT_ENTRY_NEXT) ← (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
sta entry1+OFFSET_STRUCT_ENTRY_NEXT
sta entry1+OFFSET_STRUCT_ENTRY_NEXT+1
//SEG15 [9] *((byte*)(const struct Entry*) main::entry1#0) ← (byte) 3 -- _deref_pbuc1=vbuc2
lda #3
sta entry1+OFFSET_STRUCT_ENTRY_VALUE
sta entry1
//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
@ -863,41 +838,36 @@ main: {
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
//SEG24 [13] (byte~) main::$2 ← (byte) '0' + *((byte*)(struct Entry*) main::entry#2) -- vbuaa=vbuc1_plus__deref_pbuz1
lda #'0'
ldy #OFFSET_STRUCT_ENTRY_VALUE
clc
ldy #0
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
//SEG27 [16] (byte~) main::$3 ← < *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- vbuaa=_lo_pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
sta next
iny
//SEG28 [17] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$3 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN,x
//SEG29 [18] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx
inx
//SEG30 [19] (byte~) main::$4 ← > *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- vbuaa=_hi_pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT+1
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
//SEG31 [20] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$4 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN,x
//SEG30 [19] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx
//SEG32 [21] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- 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
//SEG33 [22] *((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
//SEG34 [23] (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
//SEG35 [24] (struct Entry*) main::entry#1 ← *((struct Entry**)(struct Entry*) main::entry#2 + (const byte) OFFSET_STRUCT_ENTRY_NEXT) -- pssz1=pptz1_derefidx_vbuc1
ldy #OFFSET_STRUCT_ENTRY_NEXT
lda (entry),y
pha
iny
@ -905,9 +875,9 @@ main: {
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
//SEG36 [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG37 [10] phi (byte) main::idx#5 = (byte) main::idx#4 [phi:main::@2->main::@1#0] -- register_copy
//SEG38 [10] phi (struct Entry*) main::entry#2 = (struct Entry*) main::entry#1 [phi:main::@2->main::@1#1] -- register_copy
jmp b1
}

View File

@ -5,7 +5,7 @@
(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) OFFSET_STRUCT_ENTRY_NEXT OFFSET_STRUCT_ENTRY_NEXT = (byte) 1
(const byte) SIZEOF_STRUCT_ENTRY SIZEOF_STRUCT_ENTRY = (byte) 3
(void()) main()
(byte~) main::$2 reg byte a 22.0
@ -18,26 +18,23 @@
(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::entry#2 entry zp ZP_WORD:2 1.6923076923076923
(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#1 reg byte x 11.0
(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 ]