mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-02 20:29:38 +00:00
Added tests suitable for changing word-pointer behavior. Preparing for #139
This commit is contained in:
parent
d55a958c70
commit
7b157f9b44
7
src/main/fragment/vwuz1=_deref_pwuz1.asm
Normal file
7
src/main/fragment/vwuz1=_deref_pwuz1.asm
Normal file
@ -0,0 +1,7 @@
|
||||
ldy #0
|
||||
lda ({z1}),y
|
||||
tax
|
||||
iny
|
||||
lda ({z1}),y
|
||||
sta {z1}+1
|
||||
stx {z1}
|
6
src/main/fragment/vwuz1=_deref_pwuz2.asm
Normal file
6
src/main/fragment/vwuz1=_deref_pwuz2.asm
Normal file
@ -0,0 +1,6 @@
|
||||
ldy #0
|
||||
lda ({z2}),y
|
||||
sta {z1}
|
||||
iny
|
||||
lda ({z2}),y
|
||||
sta {z1}+1
|
@ -37,6 +37,26 @@ public class TestPrograms {
|
||||
// compileAndCompare("pointer-cast-3");
|
||||
//}
|
||||
|
||||
@Test
|
||||
public void testWordPointerMath() throws IOException, URISyntaxException {
|
||||
compileAndCompare("word-pointer-math");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWordPointerIteration() throws IOException, URISyntaxException {
|
||||
compileAndCompare("word-pointer-iteration");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWordPointerIteration0() throws IOException, URISyntaxException {
|
||||
compileAndCompare("word-pointer-iteration-0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWordArray() throws IOException, URISyntaxException {
|
||||
compileAndCompare("word-array");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeofExpression() throws IOException, URISyntaxException {
|
||||
compileAndCompare("sizeof-expr");
|
||||
|
14
src/test/kc/word-array.kc
Normal file
14
src/test/kc/word-array.kc
Normal file
@ -0,0 +1,14 @@
|
||||
// Tests a simple word array
|
||||
void main() {
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
word[] words = { $3130, $3332, $3534, $3736 };
|
||||
const byte* SCREEN = $400;
|
||||
byte idx = 0;
|
||||
for( byte i: 0..3) {
|
||||
word w = words[i];
|
||||
SCREEN[idx++] = <w;
|
||||
SCREEN[idx++] = >w;
|
||||
idx++;
|
||||
}
|
||||
|
||||
}
|
12
src/test/kc/word-pointer-iteration-0.kc
Normal file
12
src/test/kc/word-pointer-iteration-0.kc
Normal file
@ -0,0 +1,12 @@
|
||||
// Tests simple word pointer iteration
|
||||
void main() {
|
||||
const byte* SCREEN = $400+40*6;
|
||||
word* wp = $0400;
|
||||
wp++;
|
||||
SCREEN[0] = <*wp;
|
||||
SCREEN[1] = >*wp;
|
||||
wp++;
|
||||
SCREEN[2] = <*wp;
|
||||
SCREEN[3] = >*wp;
|
||||
|
||||
}
|
15
src/test/kc/word-pointer-iteration.kc
Normal file
15
src/test/kc/word-pointer-iteration.kc
Normal file
@ -0,0 +1,15 @@
|
||||
// Tests simple word pointer iteration
|
||||
void main() {
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
word[] words = { $3130, $3332, $3534, $3736};
|
||||
const byte* SCREEN = $400;
|
||||
byte idx = 0;
|
||||
word* wp = words;
|
||||
for( byte i: 0..3) {
|
||||
word w = *(wp++);
|
||||
SCREEN[idx++] = <w;
|
||||
SCREEN[idx++] = >w;
|
||||
idx++;
|
||||
}
|
||||
|
||||
}
|
14
src/test/kc/word-pointer-math.kc
Normal file
14
src/test/kc/word-pointer-math.kc
Normal file
@ -0,0 +1,14 @@
|
||||
// Tests simple word pointer math
|
||||
void main() {
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
word[] words = { $3130, $3332, $3534, $3736};
|
||||
const byte* SCREEN = $400;
|
||||
byte idx = 0;
|
||||
for( byte i: 0..3) {
|
||||
word w = *(words+i);
|
||||
SCREEN[idx++] = <w;
|
||||
SCREEN[idx++] = >w;
|
||||
idx++;
|
||||
}
|
||||
|
||||
}
|
30
src/test/ref/word-array.asm
Normal file
30
src/test/ref/word-array.asm
Normal file
@ -0,0 +1,30 @@
|
||||
// Tests a simple word array
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label w = 2
|
||||
ldy #0
|
||||
ldx #0
|
||||
b1:
|
||||
lda words,x
|
||||
sta w
|
||||
lda words+1,x
|
||||
sta w+1
|
||||
lda w
|
||||
sta SCREEN,y
|
||||
iny
|
||||
lda w+1
|
||||
sta SCREEN,y
|
||||
iny
|
||||
tya
|
||||
tay
|
||||
iny
|
||||
inx
|
||||
cpx #4
|
||||
bne b1
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
29
src/test/ref/word-array.cfg
Normal file
29
src/test/ref/word-array.cfg
Normal file
@ -0,0 +1,29 @@
|
||||
@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] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::idx#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::idx#3 )
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
|
||||
[6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2)
|
||||
[7] (byte~) main::$0 ← < (word) main::w#0
|
||||
[8] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0
|
||||
[9] (byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
[10] (byte~) main::$1 ← > (word) main::w#0
|
||||
[11] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
|
||||
[12] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[13] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[14] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[15] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[16] return
|
||||
to:@return
|
498
src/test/ref/word-array.log
Normal file
498
src/test/ref/word-array.log
Normal file
@ -0,0 +1,498 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
main: scope:[main] from @1
|
||||
(word[]) main::words#0 ← { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
(byte*) main::SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
|
||||
(byte) main::idx#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
(byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::idx#4 ← phi( main/(byte) main::idx#0 main::@1/(byte) main::idx#3 )
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(word) main::w#0 ← *((word[]) main::words#0 + (byte) main::i#2)
|
||||
(byte~) main::$0 ← < (word) main::w#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0
|
||||
(byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
(byte~) main::$1 ← > (word) main::w#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
|
||||
(byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
(byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,3)
|
||||
(bool~) main::$2 ← (byte) main::i#1 != rangelast(0,3)
|
||||
if((bool~) main::$2) goto main::@1
|
||||
to:main::@return
|
||||
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
|
||||
(void()) main()
|
||||
(byte~) main::$0
|
||||
(byte~) main::$1
|
||||
(bool~) main::$2
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(byte*) main::SCREEN#0
|
||||
(byte) main::i
|
||||
(byte) main::i#0
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#0
|
||||
(byte) main::idx#1
|
||||
(byte) main::idx#2
|
||||
(byte) main::idx#3
|
||||
(byte) main::idx#4
|
||||
(word) main::w
|
||||
(word) main::w#0
|
||||
(word[]) main::words
|
||||
(word[]) main::words#0
|
||||
|
||||
Culled Empty Block (label) @2
|
||||
Successful SSA optimization Pass2CullEmptyBlocks
|
||||
Simple Condition (bool~) main::$2 [15] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const word[]) main::words#0 = { $3130, $3332, $3534, $3736 }
|
||||
Constant (const byte*) main::SCREEN#0 = ((byte*))$400
|
||||
Constant (const byte) main::idx#0 = 0
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value main::i#1 ← ++ main::i#2 to ++
|
||||
Resolved ranged comparison value if(main::i#1!=rangelast(0,3)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 4
|
||||
Inlining constant with var siblings (const byte) main::idx#0
|
||||
Inlining constant with var siblings (const byte) main::i#0
|
||||
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
Constant inlined main::idx#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Added new block during phi lifting main::@3(between main::@1 and main::@1)
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 2 initial phi equivalence classes
|
||||
Coalesced [17] main::i#3 ← main::i#1
|
||||
Coalesced [18] main::idx#5 ← main::idx#3
|
||||
Coalesced down to 2 phi equivalence classes
|
||||
Culled Empty Block (label) main::@3
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
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] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::idx#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::idx#3 )
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
|
||||
[6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2)
|
||||
[7] (byte~) main::$0 ← < (word) main::w#0
|
||||
[8] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0
|
||||
[9] (byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
[10] (byte~) main::$1 ← > (word) main::w#0
|
||||
[11] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
|
||||
[12] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[13] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[14] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[15] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[16] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) main()
|
||||
(byte~) main::$0 22.0
|
||||
(byte~) main::$1 22.0
|
||||
(byte*) main::SCREEN
|
||||
(byte) main::i
|
||||
(byte) main::i#1 16.5
|
||||
(byte) main::i#2 3.666666666666667
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 11.0
|
||||
(byte) main::idx#2 22.0
|
||||
(byte) main::idx#3 7.333333333333333
|
||||
(byte) main::idx#4 8.25
|
||||
(word) main::w
|
||||
(word) main::w#0 8.25
|
||||
(word[]) main::words
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::idx#4 main::idx#3 ]
|
||||
Added variable main::w#0 to zero page equivalence class [ main::w#0 ]
|
||||
Added variable main::$0 to zero page equivalence class [ main::$0 ]
|
||||
Added variable main::idx#1 to zero page equivalence class [ main::idx#1 ]
|
||||
Added variable main::$1 to zero page equivalence class [ main::$1 ]
|
||||
Added variable main::idx#2 to zero page equivalence class [ main::idx#2 ]
|
||||
Complete equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::idx#4 main::idx#3 ]
|
||||
[ main::w#0 ]
|
||||
[ main::$0 ]
|
||||
[ main::idx#1 ]
|
||||
[ main::$1 ]
|
||||
[ main::idx#2 ]
|
||||
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Allocated zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Allocated zp ZP_WORD:4 [ main::w#0 ]
|
||||
Allocated zp ZP_BYTE:6 [ main::$0 ]
|
||||
Allocated zp ZP_BYTE:7 [ main::idx#1 ]
|
||||
Allocated zp ZP_BYTE:8 [ main::$1 ]
|
||||
Allocated zp ZP_BYTE:9 [ main::idx#2 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
// Tests a simple word array
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG9 @end
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label _0 = 6
|
||||
.label _1 = 8
|
||||
.label w = 4
|
||||
.label idx = 7
|
||||
.label idx_2 = 9
|
||||
.label idx_3 = 3
|
||||
.label i = 2
|
||||
.label idx_4 = 3
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG12 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx_4
|
||||
//SEG13 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta i
|
||||
jmp b1
|
||||
//SEG14 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
b1_from_b1:
|
||||
//SEG15 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
//SEG17 main::@1
|
||||
b1:
|
||||
//SEG18 [6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2) -- vwuz1=pwuc1_derefidx_vbuz2
|
||||
ldy i
|
||||
lda words,y
|
||||
sta w
|
||||
lda words+1,y
|
||||
sta w+1
|
||||
//SEG19 [7] (byte~) main::$0 ← < (word) main::w#0 -- vbuz1=_lo_vwuz2
|
||||
lda w
|
||||
sta _0
|
||||
//SEG20 [8] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _0
|
||||
ldy idx_4
|
||||
sta SCREEN,y
|
||||
//SEG21 [9] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_4
|
||||
iny
|
||||
sty idx
|
||||
//SEG22 [10] (byte~) main::$1 ← > (word) main::w#0 -- vbuz1=_hi_vwuz2
|
||||
lda w+1
|
||||
sta _1
|
||||
//SEG23 [11] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _1
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG24 [12] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuz1=_inc_vbuz2
|
||||
ldy idx
|
||||
iny
|
||||
sty idx_2
|
||||
//SEG25 [13] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_2
|
||||
iny
|
||||
sty idx_3
|
||||
//SEG26 [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc i
|
||||
//SEG27 [15] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
||||
lda #4
|
||||
cmp i
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG28 main::@return
|
||||
breturn:
|
||||
//SEG29 [16] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2) [ main::i#2 main::idx#4 main::w#0 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Statement [7] (byte~) main::$0 ← < (word) main::w#0 [ main::i#2 main::idx#4 main::w#0 main::$0 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 main::$0 ] ) always clobbers reg byte a
|
||||
Statement [10] (byte~) main::$1 ← > (word) main::w#0 [ main::i#2 main::idx#1 main::$1 ] ( main:2 [ main::i#2 main::idx#1 main::$1 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:7 [ main::idx#1 ]
|
||||
Statement [6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2) [ main::i#2 main::idx#4 main::w#0 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 ] ) always clobbers reg byte a
|
||||
Statement [7] (byte~) main::$0 ← < (word) main::w#0 [ main::i#2 main::idx#4 main::w#0 main::$0 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 main::$0 ] ) always clobbers reg byte a
|
||||
Statement [10] (byte~) main::$1 ← > (word) main::w#0 [ main::i#2 main::idx#1 main::$1 ] ( main:2 [ main::i#2 main::idx#1 main::$1 ] ) always clobbers reg byte a
|
||||
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ] : zp ZP_BYTE:3 , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_WORD:4 [ main::w#0 ] : zp ZP_WORD:4 ,
|
||||
Potential registers zp ZP_BYTE:6 [ main::$0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:7 [ main::idx#1 ] : zp ZP_BYTE:7 , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:8 [ main::$1 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:9 [ main::idx#2 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 22: zp ZP_BYTE:6 [ main::$0 ] 22: zp ZP_BYTE:8 [ main::$1 ] 22: zp ZP_BYTE:9 [ main::idx#2 ] 20.17: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 15.58: zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ] 11: zp ZP_BYTE:7 [ main::idx#1 ] 8.25: zp ZP_WORD:4 [ main::w#0 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 833 combination reg byte a [ main::$0 ] reg byte a [ main::$1 ] reg byte a [ main::idx#2 ] reg byte x [ main::i#2 main::i#1 ] zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ] zp ZP_BYTE:7 [ main::idx#1 ] zp ZP_WORD:4 [ main::w#0 ]
|
||||
Limited combination testing to 100 combinations of 1728 possible.
|
||||
Uplifting [] best 833 combination
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Uplifting [main] best 713 combination reg byte y [ main::idx#4 main::idx#3 ]
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:7 [ main::idx#1 ]
|
||||
Uplifting [main] best 623 combination reg byte y [ main::idx#1 ]
|
||||
Allocated (was zp ZP_WORD:4) zp ZP_WORD:2 [ main::w#0 ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
// Tests a simple word array
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG9 @end
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label w = 2
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG12 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
|
||||
ldy #0
|
||||
//SEG13 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
jmp b1
|
||||
//SEG14 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
b1_from_b1:
|
||||
//SEG15 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
//SEG17 main::@1
|
||||
b1:
|
||||
//SEG18 [6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2) -- vwuz1=pwuc1_derefidx_vbuxx
|
||||
lda words,x
|
||||
sta w
|
||||
lda words+1,x
|
||||
sta w+1
|
||||
//SEG19 [7] (byte~) main::$0 ← < (word) main::w#0 -- vbuaa=_lo_vwuz1
|
||||
lda w
|
||||
//SEG20 [8] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG21 [9] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuyy=_inc_vbuyy
|
||||
iny
|
||||
//SEG22 [10] (byte~) main::$1 ← > (word) main::w#0 -- vbuaa=_hi_vwuz1
|
||||
lda w+1
|
||||
//SEG23 [11] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG24 [12] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuaa=_inc_vbuyy
|
||||
iny
|
||||
tya
|
||||
//SEG25 [13] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuyy=_inc_vbuaa
|
||||
tay
|
||||
iny
|
||||
//SEG26 [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG27 [15] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
||||
cpx #4
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG28 main::@return
|
||||
breturn:
|
||||
//SEG29 [16] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction main_from_b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction bbegin:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(byte~) main::$0 reg byte a 22.0
|
||||
(byte~) main::$1 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 3.666666666666667
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte y 11.0
|
||||
(byte) main::idx#2 reg byte a 22.0
|
||||
(byte) main::idx#3 reg byte y 7.333333333333333
|
||||
(byte) main::idx#4 reg byte y 8.25
|
||||
(word) main::w
|
||||
(word) main::w#0 w zp ZP_WORD:2 8.25
|
||||
(word[]) main::words
|
||||
(const word[]) main::words#0 words = { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
reg byte y [ main::idx#4 main::idx#3 ]
|
||||
zp ZP_WORD:2 [ main::w#0 ]
|
||||
reg byte a [ main::$0 ]
|
||||
reg byte y [ main::idx#1 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte a [ main::idx#2 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 521
|
||||
|
||||
//SEG0 File Comments
|
||||
// Tests a simple word array
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//SEG3 @begin
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
//SEG5 @1
|
||||
//SEG6 [2] call main
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
//SEG9 @end
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label w = 2
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
//SEG12 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
|
||||
ldy #0
|
||||
//SEG13 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
//SEG14 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
//SEG15 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy
|
||||
//SEG17 main::@1
|
||||
b1:
|
||||
//SEG18 [6] (word) main::w#0 ← *((const word[]) main::words#0 + (byte) main::i#2) -- vwuz1=pwuc1_derefidx_vbuxx
|
||||
lda words,x
|
||||
sta w
|
||||
lda words+1,x
|
||||
sta w+1
|
||||
//SEG19 [7] (byte~) main::$0 ← < (word) main::w#0 -- vbuaa=_lo_vwuz1
|
||||
lda w
|
||||
//SEG20 [8] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG21 [9] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuyy=_inc_vbuyy
|
||||
iny
|
||||
//SEG22 [10] (byte~) main::$1 ← > (word) main::w#0 -- vbuaa=_hi_vwuz1
|
||||
lda w+1
|
||||
//SEG23 [11] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG24 [12] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuaa=_inc_vbuyy
|
||||
iny
|
||||
tya
|
||||
//SEG25 [13] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuyy=_inc_vbuaa
|
||||
tay
|
||||
iny
|
||||
//SEG26 [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG27 [15] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
||||
cpx #4
|
||||
bne b1
|
||||
//SEG28 main::@return
|
||||
//SEG29 [16] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
30
src/test/ref/word-array.sym
Normal file
30
src/test/ref/word-array.sym
Normal file
@ -0,0 +1,30 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(byte~) main::$0 reg byte a 22.0
|
||||
(byte~) main::$1 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 3.666666666666667
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte y 11.0
|
||||
(byte) main::idx#2 reg byte a 22.0
|
||||
(byte) main::idx#3 reg byte y 7.333333333333333
|
||||
(byte) main::idx#4 reg byte y 8.25
|
||||
(word) main::w
|
||||
(word) main::w#0 w zp ZP_WORD:2 8.25
|
||||
(word[]) main::words
|
||||
(const word[]) main::words#0 words = { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
reg byte y [ main::idx#4 main::idx#3 ]
|
||||
zp ZP_WORD:2 [ main::w#0 ]
|
||||
reg byte a [ main::$0 ]
|
||||
reg byte y [ main::idx#1 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte a [ main::idx#2 ]
|
16
src/test/ref/word-pointer-iteration-0.asm
Normal file
16
src/test/ref/word-pointer-iteration-0.asm
Normal file
@ -0,0 +1,16 @@
|
||||
// Tests simple word pointer iteration
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
.label SCREEN = $400+$28*6
|
||||
lda $400+1
|
||||
sta SCREEN
|
||||
lda $400+1+1
|
||||
sta SCREEN+1
|
||||
lda $400+1+1
|
||||
sta SCREEN+2
|
||||
lda $400+1+1+1
|
||||
sta SCREEN+3
|
||||
rts
|
||||
}
|
22
src/test/ref/word-pointer-iteration-0.cfg
Normal file
22
src/test/ref/word-pointer-iteration-0.cfg
Normal file
@ -0,0 +1,22 @@
|
||||
@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] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2
|
||||
[6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3
|
||||
[8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4
|
||||
[10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[12] return
|
||||
to:@return
|
337
src/test/ref/word-pointer-iteration-0.log
Normal file
337
src/test/ref/word-pointer-iteration-0.log
Normal file
@ -0,0 +1,337 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
main: scope:[main] from @1
|
||||
(byte/word/signed word/dword/signed dword~) main::$0 ← (byte/signed byte/word/signed word/dword/signed dword) $28 * (byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
(word/signed dword/dword/signed word~) main::$1 ← (word/signed word/dword/signed dword) $400 + (byte/word/signed word/dword/signed dword~) main::$0
|
||||
(byte*) main::SCREEN#0 ← ((byte*)) (word/signed dword/dword/signed word~) main::$1
|
||||
(word*) main::wp#0 ← ((word*)) (word/signed word/dword/signed dword) $400
|
||||
(word*) main::wp#1 ← ++ (word*) main::wp#0
|
||||
(byte~) main::$2 ← < *((word*) main::wp#1)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte~) main::$2
|
||||
(byte~) main::$3 ← > *((word*) main::wp#1)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3
|
||||
(word*) main::wp#2 ← ++ (word*) main::wp#1
|
||||
(byte~) main::$4 ← < *((word*) main::wp#2)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4
|
||||
(byte~) main::$5 ← > *((word*) main::wp#2)
|
||||
*((byte*) main::SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
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
|
||||
(void()) main()
|
||||
(byte/word/signed word/dword/signed dword~) main::$0
|
||||
(word/signed dword/dword/signed word~) main::$1
|
||||
(byte~) main::$2
|
||||
(byte~) main::$3
|
||||
(byte~) main::$4
|
||||
(byte~) main::$5
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(byte*) main::SCREEN#0
|
||||
(word*) main::wp
|
||||
(word*) main::wp#0
|
||||
(word*) main::wp#1
|
||||
(word*) main::wp#2
|
||||
|
||||
Culled Empty Block (label) @2
|
||||
Successful SSA optimization Pass2CullEmptyBlocks
|
||||
Constant (const byte/word/signed word/dword/signed dword) main::$0 = $28*6
|
||||
Constant (const word*) main::wp#0 = ((word*))$400
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant (const word/signed dword/dword/signed word) main::$1 = $400+main::$0
|
||||
Constant (const word*) main::wp#1 = ++main::wp#0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant (const byte*) main::SCREEN#0 = ((byte*))main::$1
|
||||
Constant (const word*) main::wp#2 = ++main::wp#1
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Consolidated array index constant in *(main::SCREEN#0+0)
|
||||
Consolidated array index constant in *(main::SCREEN#0+1)
|
||||
Consolidated array index constant in *(main::SCREEN#0+2)
|
||||
Consolidated array index constant in *(main::SCREEN#0+3)
|
||||
Successful SSA optimization Pass2ConstantAdditionElimination
|
||||
Inlining constant with different constant siblings (const word*) main::wp#0
|
||||
Inlining constant with different constant siblings (const word*) main::wp#1
|
||||
Inlining constant with different constant siblings (const word*) main::wp#2
|
||||
Constant inlined main::wp#0 = ((word*))(word/signed word/dword/signed dword) $400
|
||||
Constant inlined main::$1 = (word/signed word/dword/signed dword) $400+(byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
Constant inlined main::wp#1 = ++((word*))(word/signed word/dword/signed dword) $400
|
||||
Constant inlined main::$0 = (byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
Constant inlined main::wp#2 = ++++((word*))(word/signed word/dword/signed dword) $400
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Simplifying constant plus zero main::SCREEN#0+0
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 0 initial phi equivalence classes
|
||||
Coalesced down to 0 phi equivalence classes
|
||||
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] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2
|
||||
[6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3
|
||||
[8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4
|
||||
[10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400)
|
||||
[11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[12] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) main()
|
||||
(byte~) main::$2 4.0
|
||||
(byte~) main::$3 4.0
|
||||
(byte~) main::$4 4.0
|
||||
(byte~) main::$5 4.0
|
||||
(byte*) main::SCREEN
|
||||
(word*) main::wp
|
||||
|
||||
Initial phi equivalence classes
|
||||
Added variable main::$2 to zero page equivalence class [ main::$2 ]
|
||||
Added variable main::$3 to zero page equivalence class [ main::$3 ]
|
||||
Added variable main::$4 to zero page equivalence class [ main::$4 ]
|
||||
Added variable main::$5 to zero page equivalence class [ main::$5 ]
|
||||
Complete equivalence classes
|
||||
[ main::$2 ]
|
||||
[ main::$3 ]
|
||||
[ main::$4 ]
|
||||
[ main::$5 ]
|
||||
Allocated zp ZP_BYTE:2 [ main::$2 ]
|
||||
Allocated zp ZP_BYTE:3 [ main::$3 ]
|
||||
Allocated zp ZP_BYTE:4 [ main::$4 ]
|
||||
Allocated zp ZP_BYTE:5 [ main::$5 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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: {
|
||||
.label SCREEN = $400+$28*6
|
||||
.label _2 = 2
|
||||
.label _3 = 3
|
||||
.label _4 = 4
|
||||
.label _5 = 5
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+1
|
||||
sta _2
|
||||
//SEG11 [5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuz1
|
||||
lda _2
|
||||
sta SCREEN
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+1+1
|
||||
sta _3
|
||||
//SEG13 [7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3 -- _deref_pbuc1=vbuz1
|
||||
lda _3
|
||||
sta SCREEN+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_lo__deref_pwuc1
|
||||
lda $400+1+1
|
||||
sta _4
|
||||
//SEG15 [9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4 -- _deref_pbuc1=vbuz1
|
||||
lda _4
|
||||
sta SCREEN+2
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuz1=_hi__deref_pwuc1
|
||||
lda $400+1+1+1
|
||||
sta _5
|
||||
//SEG17 [11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5 -- _deref_pbuc1=vbuz1
|
||||
lda _5
|
||||
sta SCREEN+3
|
||||
jmp breturn
|
||||
//SEG18 main::@return
|
||||
breturn:
|
||||
//SEG19 [12] return
|
||||
rts
|
||||
}
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Potential registers zp ZP_BYTE:2 [ main::$2 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:3 [ main::$3 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:4 [ main::$4 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:5 [ main::$5 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 4: zp ZP_BYTE:2 [ main::$2 ] 4: zp ZP_BYTE:3 [ main::$3 ] 4: zp ZP_BYTE:4 [ main::$4 ] 4: zp ZP_BYTE:5 [ main::$5 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 53 combination reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte a [ main::$4 ] reg byte a [ main::$5 ]
|
||||
Limited combination testing to 100 combinations of 256 possible.
|
||||
Uplifting [] best 53 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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: {
|
||||
.label SCREEN = $400+$28*6
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1
|
||||
//SEG11 [5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG13 [7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG15 [9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+2
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1+1
|
||||
//SEG17 [11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+3
|
||||
jmp breturn
|
||||
//SEG18 main::@return
|
||||
breturn:
|
||||
//SEG19 [12] return
|
||||
rts
|
||||
}
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
Removing instruction breturn:
|
||||
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
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 4.0
|
||||
(byte~) main::$3 reg byte a 4.0
|
||||
(byte~) main::$4 reg byte a 4.0
|
||||
(byte~) main::$5 reg byte a 4.0
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400+(byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
(word*) main::wp
|
||||
|
||||
reg byte a [ main::$2 ]
|
||||
reg byte a [ main::$3 ]
|
||||
reg byte a [ main::$4 ]
|
||||
reg byte a [ main::$5 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 38
|
||||
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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: {
|
||||
.label SCREEN = $400+$28*6
|
||||
//SEG10 [4] (byte~) main::$2 ← < *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1
|
||||
//SEG11 [5] *((const byte*) main::SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN
|
||||
//SEG12 [6] (byte~) main::$3 ← > *(++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG13 [7] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$3 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+1
|
||||
//SEG14 [8] (byte~) main::$4 ← < *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_lo__deref_pwuc1
|
||||
lda $400+1+1
|
||||
//SEG15 [9] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$4 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+2
|
||||
//SEG16 [10] (byte~) main::$5 ← > *(++++((word*))(word/signed word/dword/signed dword) $400) -- vbuaa=_hi__deref_pwuc1
|
||||
lda $400+1+1+1
|
||||
//SEG17 [11] *((const byte*) main::SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 3) ← (byte~) main::$5 -- _deref_pbuc1=vbuaa
|
||||
sta SCREEN+3
|
||||
//SEG18 main::@return
|
||||
//SEG19 [12] return
|
||||
rts
|
||||
}
|
||||
|
17
src/test/ref/word-pointer-iteration-0.sym
Normal file
17
src/test/ref/word-pointer-iteration-0.sym
Normal file
@ -0,0 +1,17 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 4.0
|
||||
(byte~) main::$3 reg byte a 4.0
|
||||
(byte~) main::$4 reg byte a 4.0
|
||||
(byte~) main::$5 reg byte a 4.0
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400+(byte/signed byte/word/signed word/dword/signed dword) $28*(byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
(word*) main::wp
|
||||
|
||||
reg byte a [ main::$2 ]
|
||||
reg byte a [ main::$3 ]
|
||||
reg byte a [ main::$4 ]
|
||||
reg byte a [ main::$5 ]
|
45
src/test/ref/word-pointer-iteration.asm
Normal file
45
src/test/ref/word-pointer-iteration.asm
Normal file
@ -0,0 +1,45 @@
|
||||
// Tests simple word pointer iteration
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label w = 5
|
||||
.label wp = 2
|
||||
.label idx = 4
|
||||
ldx #0
|
||||
txa
|
||||
sta idx
|
||||
lda #<words
|
||||
sta wp
|
||||
lda #>words
|
||||
sta wp+1
|
||||
b1:
|
||||
ldy #0
|
||||
lda (wp),y
|
||||
sta w
|
||||
iny
|
||||
lda (wp),y
|
||||
sta w+1
|
||||
inc wp
|
||||
bne !+
|
||||
inc wp+1
|
||||
!:
|
||||
lda w
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
iny
|
||||
lda w+1
|
||||
sta SCREEN,y
|
||||
iny
|
||||
tya
|
||||
clc
|
||||
adc #1
|
||||
sta idx
|
||||
inx
|
||||
cpx #4
|
||||
bne b1
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
31
src/test/ref/word-pointer-iteration.cfg
Normal file
31
src/test/ref/word-pointer-iteration.cfg
Normal file
@ -0,0 +1,31 @@
|
||||
@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] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
|
||||
[5] (byte) main::idx#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::idx#3 )
|
||||
[5] (word*) main::wp#2 ← phi( main/(const word[]) main::words#0 main::@1/(word*) main::wp#1 )
|
||||
[6] (word) main::w#0 ← *((word*) main::wp#2)
|
||||
[7] (word*) main::wp#1 ← ++ (word*) main::wp#2
|
||||
[8] (byte~) main::$0 ← < (word) main::w#0
|
||||
[9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0
|
||||
[10] (byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
[11] (byte~) main::$1 ← > (word) main::w#0
|
||||
[12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
|
||||
[13] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[14] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[15] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[17] return
|
||||
to:@return
|
576
src/test/ref/word-pointer-iteration.log
Normal file
576
src/test/ref/word-pointer-iteration.log
Normal file
@ -0,0 +1,576 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
main: scope:[main] from @1
|
||||
(word[]) main::words#0 ← { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
(byte*) main::SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
|
||||
(byte) main::idx#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
(word*) main::wp#0 ← (word[]) main::words#0
|
||||
(byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte) main::idx#4 ← phi( main/(byte) main::idx#0 main::@1/(byte) main::idx#3 )
|
||||
(word*) main::wp#2 ← phi( main/(word*) main::wp#0 main::@1/(word*) main::wp#1 )
|
||||
(word) main::w#0 ← *((word*) main::wp#2)
|
||||
(word*) main::wp#1 ← ++ (word*) main::wp#2
|
||||
(byte~) main::$0 ← < (word) main::w#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0
|
||||
(byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
(byte~) main::$1 ← > (word) main::w#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
|
||||
(byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
(byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,3)
|
||||
(bool~) main::$2 ← (byte) main::i#1 != rangelast(0,3)
|
||||
if((bool~) main::$2) goto main::@1
|
||||
to:main::@return
|
||||
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
|
||||
(void()) main()
|
||||
(byte~) main::$0
|
||||
(byte~) main::$1
|
||||
(bool~) main::$2
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(byte*) main::SCREEN#0
|
||||
(byte) main::i
|
||||
(byte) main::i#0
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#0
|
||||
(byte) main::idx#1
|
||||
(byte) main::idx#2
|
||||
(byte) main::idx#3
|
||||
(byte) main::idx#4
|
||||
(word) main::w
|
||||
(word) main::w#0
|
||||
(word[]) main::words
|
||||
(word[]) main::words#0
|
||||
(word*) main::wp
|
||||
(word*) main::wp#0
|
||||
(word*) main::wp#1
|
||||
(word*) main::wp#2
|
||||
|
||||
Culled Empty Block (label) @2
|
||||
Successful SSA optimization Pass2CullEmptyBlocks
|
||||
Alias (word[]) main::words#0 = (word*) main::wp#0
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Simple Condition (bool~) main::$2 [17] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const word[]) main::words#0 = { $3130, $3332, $3534, $3736 }
|
||||
Constant (const byte*) main::SCREEN#0 = ((byte*))$400
|
||||
Constant (const byte) main::idx#0 = 0
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value main::i#1 ← ++ main::i#2 to ++
|
||||
Resolved ranged comparison value if(main::i#1!=rangelast(0,3)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 4
|
||||
Inlining constant with var siblings (const byte) main::idx#0
|
||||
Inlining constant with var siblings (const byte) main::i#0
|
||||
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
Constant inlined main::idx#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Added new block during phi lifting main::@3(between main::@1 and main::@1)
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 3 initial phi equivalence classes
|
||||
Coalesced [18] main::wp#3 ← main::wp#1
|
||||
Coalesced [19] main::idx#5 ← main::idx#3
|
||||
Coalesced [20] main::i#3 ← main::i#1
|
||||
Coalesced down to 3 phi equivalence classes
|
||||
Culled Empty Block (label) main::@3
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
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] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
|
||||
[5] (byte) main::idx#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::idx#3 )
|
||||
[5] (word*) main::wp#2 ← phi( main/(const word[]) main::words#0 main::@1/(word*) main::wp#1 )
|
||||
[6] (word) main::w#0 ← *((word*) main::wp#2)
|
||||
[7] (word*) main::wp#1 ← ++ (word*) main::wp#2
|
||||
[8] (byte~) main::$0 ← < (word) main::w#0
|
||||
[9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0
|
||||
[10] (byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
[11] (byte~) main::$1 ← > (word) main::w#0
|
||||
[12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
|
||||
[13] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[14] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[15] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[17] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) main()
|
||||
(byte~) main::$0 22.0
|
||||
(byte~) main::$1 22.0
|
||||
(byte*) main::SCREEN
|
||||
(byte) main::i
|
||||
(byte) main::i#1 16.5
|
||||
(byte) main::i#2 2.2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 11.0
|
||||
(byte) main::idx#2 22.0
|
||||
(byte) main::idx#3 7.333333333333333
|
||||
(byte) main::idx#4 6.6000000000000005
|
||||
(word) main::w
|
||||
(word) main::w#0 6.6000000000000005
|
||||
(word[]) main::words
|
||||
(word*) main::wp
|
||||
(word*) main::wp#1 2.2
|
||||
(word*) main::wp#2 16.5
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::wp#2 main::wp#1 ]
|
||||
[ main::idx#4 main::idx#3 ]
|
||||
[ main::i#2 main::i#1 ]
|
||||
Added variable main::w#0 to zero page equivalence class [ main::w#0 ]
|
||||
Added variable main::$0 to zero page equivalence class [ main::$0 ]
|
||||
Added variable main::idx#1 to zero page equivalence class [ main::idx#1 ]
|
||||
Added variable main::$1 to zero page equivalence class [ main::$1 ]
|
||||
Added variable main::idx#2 to zero page equivalence class [ main::idx#2 ]
|
||||
Complete equivalence classes
|
||||
[ main::wp#2 main::wp#1 ]
|
||||
[ main::idx#4 main::idx#3 ]
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::w#0 ]
|
||||
[ main::$0 ]
|
||||
[ main::idx#1 ]
|
||||
[ main::$1 ]
|
||||
[ main::idx#2 ]
|
||||
Allocated zp ZP_WORD:2 [ main::wp#2 main::wp#1 ]
|
||||
Allocated zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
Allocated zp ZP_BYTE:5 [ main::i#2 main::i#1 ]
|
||||
Allocated zp ZP_WORD:6 [ main::w#0 ]
|
||||
Allocated zp ZP_BYTE:8 [ main::$0 ]
|
||||
Allocated zp ZP_BYTE:9 [ main::idx#1 ]
|
||||
Allocated zp ZP_BYTE:10 [ main::$1 ]
|
||||
Allocated zp ZP_BYTE:11 [ main::idx#2 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG9 @end
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label _0 = 8
|
||||
.label _1 = $a
|
||||
.label w = 6
|
||||
.label wp = 2
|
||||
.label idx = 9
|
||||
.label idx_2 = $b
|
||||
.label idx_3 = 4
|
||||
.label i = 5
|
||||
.label idx_4 = 4
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta i
|
||||
//SEG13 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx_4
|
||||
//SEG14 [5] phi (word*) main::wp#2 = (const word[]) main::words#0 [phi:main->main::@1#2] -- pwuz1=pwuc1
|
||||
lda #<words
|
||||
sta wp
|
||||
lda #>words
|
||||
sta wp+1
|
||||
jmp b1
|
||||
//SEG15 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
b1_from_b1:
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG17 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#1] -- register_copy
|
||||
//SEG18 [5] phi (word*) main::wp#2 = (word*) main::wp#1 [phi:main::@1->main::@1#2] -- register_copy
|
||||
jmp b1
|
||||
//SEG19 main::@1
|
||||
b1:
|
||||
//SEG20 [6] (word) main::w#0 ← *((word*) main::wp#2) -- vwuz1=_deref_pwuz2
|
||||
ldy #0
|
||||
lda (wp),y
|
||||
sta w
|
||||
iny
|
||||
lda (wp),y
|
||||
sta w+1
|
||||
//SEG21 [7] (word*) main::wp#1 ← ++ (word*) main::wp#2 -- pwuz1=_inc_pwuz1
|
||||
inc wp
|
||||
bne !+
|
||||
inc wp+1
|
||||
!:
|
||||
//SEG22 [8] (byte~) main::$0 ← < (word) main::w#0 -- vbuz1=_lo_vwuz2
|
||||
lda w
|
||||
sta _0
|
||||
//SEG23 [9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _0
|
||||
ldy idx_4
|
||||
sta SCREEN,y
|
||||
//SEG24 [10] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_4
|
||||
iny
|
||||
sty idx
|
||||
//SEG25 [11] (byte~) main::$1 ← > (word) main::w#0 -- vbuz1=_hi_vwuz2
|
||||
lda w+1
|
||||
sta _1
|
||||
//SEG26 [12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _1
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG27 [13] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuz1=_inc_vbuz2
|
||||
ldy idx
|
||||
iny
|
||||
sty idx_2
|
||||
//SEG28 [14] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_2
|
||||
iny
|
||||
sty idx_3
|
||||
//SEG29 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc i
|
||||
//SEG30 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
||||
lda #4
|
||||
cmp i
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG31 main::@return
|
||||
breturn:
|
||||
//SEG32 [17] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [6] (word) main::w#0 ← *((word*) main::wp#2) [ main::wp#2 main::idx#4 main::i#2 main::w#0 ] ( main:2 [ main::wp#2 main::idx#4 main::i#2 main::w#0 ] ) always clobbers reg byte a reg byte y
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ main::i#2 main::i#1 ]
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:5 [ main::i#2 main::i#1 ]
|
||||
Statement [8] (byte~) main::$0 ← < (word) main::w#0 [ main::idx#4 main::i#2 main::wp#1 main::w#0 main::$0 ] ( main:2 [ main::idx#4 main::i#2 main::wp#1 main::w#0 main::$0 ] ) always clobbers reg byte a
|
||||
Statement [11] (byte~) main::$1 ← > (word) main::w#0 [ main::i#2 main::wp#1 main::idx#1 main::$1 ] ( main:2 [ main::i#2 main::wp#1 main::idx#1 main::$1 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ main::idx#1 ]
|
||||
Statement [6] (word) main::w#0 ← *((word*) main::wp#2) [ main::wp#2 main::idx#4 main::i#2 main::w#0 ] ( main:2 [ main::wp#2 main::idx#4 main::i#2 main::w#0 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [8] (byte~) main::$0 ← < (word) main::w#0 [ main::idx#4 main::i#2 main::wp#1 main::w#0 main::$0 ] ( main:2 [ main::idx#4 main::i#2 main::wp#1 main::w#0 main::$0 ] ) always clobbers reg byte a
|
||||
Statement [11] (byte~) main::$1 ← > (word) main::w#0 [ main::i#2 main::wp#1 main::idx#1 main::$1 ] ( main:2 [ main::i#2 main::wp#1 main::idx#1 main::$1 ] ) always clobbers reg byte a
|
||||
Potential registers zp ZP_WORD:2 [ main::wp#2 main::wp#1 ] : zp ZP_WORD:2 ,
|
||||
Potential registers zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ] : zp ZP_BYTE:4 , reg byte x ,
|
||||
Potential registers zp ZP_BYTE:5 [ main::i#2 main::i#1 ] : zp ZP_BYTE:5 , reg byte x ,
|
||||
Potential registers zp ZP_WORD:6 [ main::w#0 ] : zp ZP_WORD:6 ,
|
||||
Potential registers zp ZP_BYTE:8 [ main::$0 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:9 [ main::idx#1 ] : zp ZP_BYTE:9 , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:10 [ main::$1 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:11 [ main::idx#2 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 22: zp ZP_BYTE:8 [ main::$0 ] 22: zp ZP_BYTE:10 [ main::$1 ] 22: zp ZP_BYTE:11 [ main::idx#2 ] 18.7: zp ZP_WORD:2 [ main::wp#2 main::wp#1 ] 18.7: zp ZP_BYTE:5 [ main::i#2 main::i#1 ] 13.93: zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ] 11: zp ZP_BYTE:9 [ main::idx#1 ] 6.6: zp ZP_WORD:6 [ main::w#0 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 1118 combination reg byte a [ main::$0 ] reg byte a [ main::$1 ] reg byte a [ main::idx#2 ] zp ZP_WORD:2 [ main::wp#2 main::wp#1 ] reg byte x [ main::i#2 main::i#1 ] zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ] zp ZP_BYTE:9 [ main::idx#1 ] zp ZP_WORD:6 [ main::w#0 ]
|
||||
Limited combination testing to 100 combinations of 768 possible.
|
||||
Uplifting [] best 1118 combination
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
Uplifting [main] best 1118 combination zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:9 [ main::idx#1 ]
|
||||
Uplifting [main] best 1028 combination reg byte y [ main::idx#1 ]
|
||||
Allocated (was zp ZP_WORD:6) zp ZP_WORD:5 [ main::w#0 ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG9 @end
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label w = 5
|
||||
.label wp = 2
|
||||
.label idx = 4
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
//SEG13 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx
|
||||
//SEG14 [5] phi (word*) main::wp#2 = (const word[]) main::words#0 [phi:main->main::@1#2] -- pwuz1=pwuc1
|
||||
lda #<words
|
||||
sta wp
|
||||
lda #>words
|
||||
sta wp+1
|
||||
jmp b1
|
||||
//SEG15 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
b1_from_b1:
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG17 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#1] -- register_copy
|
||||
//SEG18 [5] phi (word*) main::wp#2 = (word*) main::wp#1 [phi:main::@1->main::@1#2] -- register_copy
|
||||
jmp b1
|
||||
//SEG19 main::@1
|
||||
b1:
|
||||
//SEG20 [6] (word) main::w#0 ← *((word*) main::wp#2) -- vwuz1=_deref_pwuz2
|
||||
ldy #0
|
||||
lda (wp),y
|
||||
sta w
|
||||
iny
|
||||
lda (wp),y
|
||||
sta w+1
|
||||
//SEG21 [7] (word*) main::wp#1 ← ++ (word*) main::wp#2 -- pwuz1=_inc_pwuz1
|
||||
inc wp
|
||||
bne !+
|
||||
inc wp+1
|
||||
!:
|
||||
//SEG22 [8] (byte~) main::$0 ← < (word) main::w#0 -- vbuaa=_lo_vwuz1
|
||||
lda w
|
||||
//SEG23 [9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuaa
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG24 [10] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuyy=_inc_vbuz1
|
||||
ldy idx
|
||||
iny
|
||||
//SEG25 [11] (byte~) main::$1 ← > (word) main::w#0 -- vbuaa=_hi_vwuz1
|
||||
lda w+1
|
||||
//SEG26 [12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG27 [13] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuaa=_inc_vbuyy
|
||||
iny
|
||||
tya
|
||||
//SEG28 [14] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuaa
|
||||
clc
|
||||
adc #1
|
||||
sta idx
|
||||
//SEG29 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG30 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
||||
cpx #4
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG31 main::@return
|
||||
breturn:
|
||||
//SEG32 [17] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing instruction lda #0 with TXA
|
||||
Removing instruction ldy idx
|
||||
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction main_from_b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction bbegin:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(byte~) main::$0 reg byte a 22.0
|
||||
(byte~) main::$1 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 2.2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte y 11.0
|
||||
(byte) main::idx#2 reg byte a 22.0
|
||||
(byte) main::idx#3 idx zp ZP_BYTE:4 7.333333333333333
|
||||
(byte) main::idx#4 idx zp ZP_BYTE:4 6.6000000000000005
|
||||
(word) main::w
|
||||
(word) main::w#0 w zp ZP_WORD:5 6.6000000000000005
|
||||
(word[]) main::words
|
||||
(const word[]) main::words#0 words = { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
(word*) main::wp
|
||||
(word*) main::wp#1 wp zp ZP_WORD:2 2.2
|
||||
(word*) main::wp#2 wp zp ZP_WORD:2 16.5
|
||||
|
||||
zp ZP_WORD:2 [ main::wp#2 main::wp#1 ]
|
||||
zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
zp ZP_WORD:5 [ main::w#0 ]
|
||||
reg byte a [ main::$0 ]
|
||||
reg byte y [ main::idx#1 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte a [ main::idx#2 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 896
|
||||
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer iteration
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//SEG3 @begin
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
//SEG5 @1
|
||||
//SEG6 [2] call main
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
//SEG9 @end
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label w = 5
|
||||
.label wp = 2
|
||||
.label idx = 4
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
//SEG13 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
|
||||
txa
|
||||
sta idx
|
||||
//SEG14 [5] phi (word*) main::wp#2 = (const word[]) main::words#0 [phi:main->main::@1#2] -- pwuz1=pwuc1
|
||||
lda #<words
|
||||
sta wp
|
||||
lda #>words
|
||||
sta wp+1
|
||||
//SEG15 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG17 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#1] -- register_copy
|
||||
//SEG18 [5] phi (word*) main::wp#2 = (word*) main::wp#1 [phi:main::@1->main::@1#2] -- register_copy
|
||||
//SEG19 main::@1
|
||||
b1:
|
||||
//SEG20 [6] (word) main::w#0 ← *((word*) main::wp#2) -- vwuz1=_deref_pwuz2
|
||||
ldy #0
|
||||
lda (wp),y
|
||||
sta w
|
||||
iny
|
||||
lda (wp),y
|
||||
sta w+1
|
||||
//SEG21 [7] (word*) main::wp#1 ← ++ (word*) main::wp#2 -- pwuz1=_inc_pwuz1
|
||||
inc wp
|
||||
bne !+
|
||||
inc wp+1
|
||||
!:
|
||||
//SEG22 [8] (byte~) main::$0 ← < (word) main::w#0 -- vbuaa=_lo_vwuz1
|
||||
lda w
|
||||
//SEG23 [9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuaa
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG24 [10] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuyy=_inc_vbuz1
|
||||
iny
|
||||
//SEG25 [11] (byte~) main::$1 ← > (word) main::w#0 -- vbuaa=_hi_vwuz1
|
||||
lda w+1
|
||||
//SEG26 [12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG27 [13] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuaa=_inc_vbuyy
|
||||
iny
|
||||
tya
|
||||
//SEG28 [14] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuaa
|
||||
clc
|
||||
adc #1
|
||||
sta idx
|
||||
//SEG29 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG30 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
||||
cpx #4
|
||||
bne b1
|
||||
//SEG31 main::@return
|
||||
//SEG32 [17] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
34
src/test/ref/word-pointer-iteration.sym
Normal file
34
src/test/ref/word-pointer-iteration.sym
Normal file
@ -0,0 +1,34 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(byte~) main::$0 reg byte a 22.0
|
||||
(byte~) main::$1 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 2.2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte y 11.0
|
||||
(byte) main::idx#2 reg byte a 22.0
|
||||
(byte) main::idx#3 idx zp ZP_BYTE:4 7.333333333333333
|
||||
(byte) main::idx#4 idx zp ZP_BYTE:4 6.6000000000000005
|
||||
(word) main::w
|
||||
(word) main::w#0 w zp ZP_WORD:5 6.6000000000000005
|
||||
(word[]) main::words
|
||||
(const word[]) main::words#0 words = { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
(word*) main::wp
|
||||
(word*) main::wp#1 wp zp ZP_WORD:2 2.2
|
||||
(word*) main::wp#2 wp zp ZP_WORD:2 16.5
|
||||
|
||||
zp ZP_WORD:2 [ main::wp#2 main::wp#1 ]
|
||||
zp ZP_BYTE:4 [ main::idx#4 main::idx#3 ]
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
zp ZP_WORD:5 [ main::w#0 ]
|
||||
reg byte a [ main::$0 ]
|
||||
reg byte y [ main::idx#1 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte a [ main::idx#2 ]
|
44
src/test/ref/word-pointer-math.asm
Normal file
44
src/test/ref/word-pointer-math.asm
Normal file
@ -0,0 +1,44 @@
|
||||
// Tests simple word pointer math
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label _0 = 3
|
||||
.label w = 5
|
||||
.label idx = 2
|
||||
lda #0
|
||||
sta idx
|
||||
tax
|
||||
b1:
|
||||
txa
|
||||
clc
|
||||
adc #<words
|
||||
sta _0
|
||||
lda #>words
|
||||
adc #0
|
||||
sta _0+1
|
||||
ldy #0
|
||||
lda (_0),y
|
||||
sta w
|
||||
iny
|
||||
lda (_0),y
|
||||
sta w+1
|
||||
lda w
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
iny
|
||||
lda w+1
|
||||
sta SCREEN,y
|
||||
iny
|
||||
tya
|
||||
clc
|
||||
adc #1
|
||||
sta idx
|
||||
inx
|
||||
cpx #4
|
||||
bne b1
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
30
src/test/ref/word-pointer-math.cfg
Normal file
30
src/test/ref/word-pointer-math.cfg
Normal file
@ -0,0 +1,30 @@
|
||||
@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] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::idx#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::idx#3 )
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
|
||||
[6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2
|
||||
[7] (word) main::w#0 ← *((word*~) main::$0)
|
||||
[8] (byte~) main::$1 ← < (word) main::w#0
|
||||
[9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$1
|
||||
[10] (byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
[11] (byte~) main::$2 ← > (word) main::w#0
|
||||
[12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$2
|
||||
[13] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[14] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[15] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[17] return
|
||||
to:@return
|
558
src/test/ref/word-pointer-math.log
Normal file
558
src/test/ref/word-pointer-math.log
Normal file
@ -0,0 +1,558 @@
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
main: scope:[main] from @1
|
||||
(word[]) main::words#0 ← { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
(byte*) main::SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
|
||||
(byte) main::idx#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
(byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::idx#4 ← phi( main/(byte) main::idx#0 main::@1/(byte) main::idx#3 )
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(word*~) main::$0 ← (word[]) main::words#0 + (byte) main::i#2
|
||||
(word) main::w#0 ← *((word*~) main::$0)
|
||||
(byte~) main::$1 ← < (word) main::w#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$1
|
||||
(byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
(byte~) main::$2 ← > (word) main::w#0
|
||||
*((byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$2
|
||||
(byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
(byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,3)
|
||||
(bool~) main::$3 ← (byte) main::i#1 != rangelast(0,3)
|
||||
if((bool~) main::$3) goto main::@1
|
||||
to:main::@return
|
||||
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
|
||||
(void()) main()
|
||||
(word*~) main::$0
|
||||
(byte~) main::$1
|
||||
(byte~) main::$2
|
||||
(bool~) main::$3
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(byte*) main::SCREEN#0
|
||||
(byte) main::i
|
||||
(byte) main::i#0
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
(byte) main::idx
|
||||
(byte) main::idx#0
|
||||
(byte) main::idx#1
|
||||
(byte) main::idx#2
|
||||
(byte) main::idx#3
|
||||
(byte) main::idx#4
|
||||
(word) main::w
|
||||
(word) main::w#0
|
||||
(word[]) main::words
|
||||
(word[]) main::words#0
|
||||
|
||||
Culled Empty Block (label) @2
|
||||
Successful SSA optimization Pass2CullEmptyBlocks
|
||||
Simple Condition (bool~) main::$3 [16] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const word[]) main::words#0 = { $3130, $3332, $3534, $3736 }
|
||||
Constant (const byte*) main::SCREEN#0 = ((byte*))$400
|
||||
Constant (const byte) main::idx#0 = 0
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value main::i#1 ← ++ main::i#2 to ++
|
||||
Resolved ranged comparison value if(main::i#1!=rangelast(0,3)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 4
|
||||
Inlining constant with var siblings (const byte) main::idx#0
|
||||
Inlining constant with var siblings (const byte) main::i#0
|
||||
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
Constant inlined main::idx#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Added new block during phi lifting main::@3(between main::@1 and main::@1)
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 2 initial phi equivalence classes
|
||||
Coalesced [18] main::i#3 ← main::i#1
|
||||
Coalesced [19] main::idx#5 ← main::idx#3
|
||||
Coalesced down to 2 phi equivalence classes
|
||||
Culled Empty Block (label) main::@3
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
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] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::idx#4 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::idx#3 )
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
|
||||
[6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2
|
||||
[7] (word) main::w#0 ← *((word*~) main::$0)
|
||||
[8] (byte~) main::$1 ← < (word) main::w#0
|
||||
[9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$1
|
||||
[10] (byte) main::idx#1 ← ++ (byte) main::idx#4
|
||||
[11] (byte~) main::$2 ← > (word) main::w#0
|
||||
[12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$2
|
||||
[13] (byte) main::idx#2 ← ++ (byte) main::idx#1
|
||||
[14] (byte) main::idx#3 ← ++ (byte) main::idx#2
|
||||
[15] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[17] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(void()) main()
|
||||
(word*~) main::$0 22.0
|
||||
(byte~) main::$1 22.0
|
||||
(byte~) main::$2 22.0
|
||||
(byte*) main::SCREEN
|
||||
(byte) main::i
|
||||
(byte) main::i#1 16.5
|
||||
(byte) main::i#2 3.3000000000000003
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 11.0
|
||||
(byte) main::idx#2 22.0
|
||||
(byte) main::idx#3 7.333333333333333
|
||||
(byte) main::idx#4 6.6000000000000005
|
||||
(word) main::w
|
||||
(word) main::w#0 8.25
|
||||
(word[]) main::words
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::idx#4 main::idx#3 ]
|
||||
Added variable main::$0 to zero page equivalence class [ main::$0 ]
|
||||
Added variable main::w#0 to zero page equivalence class [ main::w#0 ]
|
||||
Added variable main::$1 to zero page equivalence class [ main::$1 ]
|
||||
Added variable main::idx#1 to zero page equivalence class [ main::idx#1 ]
|
||||
Added variable main::$2 to zero page equivalence class [ main::$2 ]
|
||||
Added variable main::idx#2 to zero page equivalence class [ main::idx#2 ]
|
||||
Complete equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ main::idx#4 main::idx#3 ]
|
||||
[ main::$0 ]
|
||||
[ main::w#0 ]
|
||||
[ main::$1 ]
|
||||
[ main::idx#1 ]
|
||||
[ main::$2 ]
|
||||
[ main::idx#2 ]
|
||||
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Allocated zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Allocated zp ZP_WORD:4 [ main::$0 ]
|
||||
Allocated zp ZP_WORD:6 [ main::w#0 ]
|
||||
Allocated zp ZP_BYTE:8 [ main::$1 ]
|
||||
Allocated zp ZP_BYTE:9 [ main::idx#1 ]
|
||||
Allocated zp ZP_BYTE:10 [ main::$2 ]
|
||||
Allocated zp ZP_BYTE:11 [ main::idx#2 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer math
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG9 @end
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label _0 = 4
|
||||
.label _1 = 8
|
||||
.label _2 = $a
|
||||
.label w = 6
|
||||
.label idx = 9
|
||||
.label idx_2 = $b
|
||||
.label idx_3 = 3
|
||||
.label i = 2
|
||||
.label idx_4 = 3
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG12 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx_4
|
||||
//SEG13 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta i
|
||||
jmp b1
|
||||
//SEG14 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
b1_from_b1:
|
||||
//SEG15 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
//SEG17 main::@1
|
||||
b1:
|
||||
//SEG18 [6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2 -- pwuz1=pwuc1_plus_vbuz2
|
||||
lda i
|
||||
clc
|
||||
adc #<words
|
||||
sta _0
|
||||
lda #>words
|
||||
adc #0
|
||||
sta _0+1
|
||||
//SEG19 [7] (word) main::w#0 ← *((word*~) main::$0) -- vwuz1=_deref_pwuz2
|
||||
ldy #0
|
||||
lda (_0),y
|
||||
sta w
|
||||
iny
|
||||
lda (_0),y
|
||||
sta w+1
|
||||
//SEG20 [8] (byte~) main::$1 ← < (word) main::w#0 -- vbuz1=_lo_vwuz2
|
||||
lda w
|
||||
sta _1
|
||||
//SEG21 [9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$1 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _1
|
||||
ldy idx_4
|
||||
sta SCREEN,y
|
||||
//SEG22 [10] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_4
|
||||
iny
|
||||
sty idx
|
||||
//SEG23 [11] (byte~) main::$2 ← > (word) main::w#0 -- vbuz1=_hi_vwuz2
|
||||
lda w+1
|
||||
sta _2
|
||||
//SEG24 [12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$2 -- pbuc1_derefidx_vbuz1=vbuz2
|
||||
lda _2
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG25 [13] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuz1=_inc_vbuz2
|
||||
ldy idx
|
||||
iny
|
||||
sty idx_2
|
||||
//SEG26 [14] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz2
|
||||
ldy idx_2
|
||||
iny
|
||||
sty idx_3
|
||||
//SEG27 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc i
|
||||
//SEG28 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
||||
lda #4
|
||||
cmp i
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG29 main::@return
|
||||
breturn:
|
||||
//SEG30 [17] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2 [ main::i#2 main::idx#4 main::$0 ] ( main:2 [ main::i#2 main::idx#4 main::$0 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Statement [7] (word) main::w#0 ← *((word*~) main::$0) [ main::i#2 main::idx#4 main::w#0 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 ] ) always clobbers reg byte a reg byte y
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Statement [8] (byte~) main::$1 ← < (word) main::w#0 [ main::i#2 main::idx#4 main::w#0 main::$1 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 main::$1 ] ) always clobbers reg byte a
|
||||
Statement [11] (byte~) main::$2 ← > (word) main::w#0 [ main::i#2 main::idx#1 main::$2 ] ( main:2 [ main::i#2 main::idx#1 main::$2 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ main::idx#1 ]
|
||||
Statement [6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2 [ main::i#2 main::idx#4 main::$0 ] ( main:2 [ main::i#2 main::idx#4 main::$0 ] ) always clobbers reg byte a
|
||||
Statement [7] (word) main::w#0 ← *((word*~) main::$0) [ main::i#2 main::idx#4 main::w#0 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [8] (byte~) main::$1 ← < (word) main::w#0 [ main::i#2 main::idx#4 main::w#0 main::$1 ] ( main:2 [ main::i#2 main::idx#4 main::w#0 main::$1 ] ) always clobbers reg byte a
|
||||
Statement [11] (byte~) main::$2 ← > (word) main::w#0 [ main::i#2 main::idx#1 main::$2 ] ( main:2 [ main::i#2 main::idx#1 main::$2 ] ) always clobbers reg byte a
|
||||
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x ,
|
||||
Potential registers zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ] : zp ZP_BYTE:3 , reg byte x ,
|
||||
Potential registers zp ZP_WORD:4 [ main::$0 ] : zp ZP_WORD:4 ,
|
||||
Potential registers zp ZP_WORD:6 [ main::w#0 ] : zp ZP_WORD:6 ,
|
||||
Potential registers zp ZP_BYTE:8 [ main::$1 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:9 [ main::idx#1 ] : zp ZP_BYTE:9 , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:10 [ main::$2 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y ,
|
||||
Potential registers zp ZP_BYTE:11 [ main::idx#2 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 22: zp ZP_WORD:4 [ main::$0 ] 22: zp ZP_BYTE:8 [ main::$1 ] 22: zp ZP_BYTE:10 [ main::$2 ] 22: zp ZP_BYTE:11 [ main::idx#2 ] 19.8: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 13.93: zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ] 11: zp ZP_BYTE:9 [ main::idx#1 ] 8.25: zp ZP_WORD:6 [ main::w#0 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 1053 combination zp ZP_WORD:4 [ main::$0 ] reg byte a [ main::$1 ] reg byte a [ main::$2 ] reg byte a [ main::idx#2 ] reg byte x [ main::i#2 main::i#1 ] zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ] zp ZP_BYTE:9 [ main::idx#1 ] zp ZP_WORD:6 [ main::w#0 ]
|
||||
Limited combination testing to 100 combinations of 768 possible.
|
||||
Uplifting [] best 1053 combination
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Uplifting [main] best 1053 combination zp ZP_BYTE:3 [ main::idx#4 main::idx#3 ]
|
||||
Attempting to uplift remaining variables inzp ZP_BYTE:9 [ main::idx#1 ]
|
||||
Uplifting [main] best 963 combination reg byte y [ main::idx#1 ]
|
||||
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ main::idx#4 main::idx#3 ]
|
||||
Allocated (was zp ZP_WORD:4) zp ZP_WORD:3 [ main::$0 ]
|
||||
Allocated (was zp ZP_WORD:6) zp ZP_WORD:5 [ main::w#0 ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer math
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//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
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
//SEG9 @end
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label _0 = 3
|
||||
.label w = 5
|
||||
.label idx = 2
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG12 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx
|
||||
//SEG13 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
jmp b1
|
||||
//SEG14 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
b1_from_b1:
|
||||
//SEG15 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy
|
||||
jmp b1
|
||||
//SEG17 main::@1
|
||||
b1:
|
||||
//SEG18 [6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2 -- pwuz1=pwuc1_plus_vbuxx
|
||||
txa
|
||||
clc
|
||||
adc #<words
|
||||
sta _0
|
||||
lda #>words
|
||||
adc #0
|
||||
sta _0+1
|
||||
//SEG19 [7] (word) main::w#0 ← *((word*~) main::$0) -- vwuz1=_deref_pwuz2
|
||||
ldy #0
|
||||
lda (_0),y
|
||||
sta w
|
||||
iny
|
||||
lda (_0),y
|
||||
sta w+1
|
||||
//SEG20 [8] (byte~) main::$1 ← < (word) main::w#0 -- vbuaa=_lo_vwuz1
|
||||
lda w
|
||||
//SEG21 [9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$1 -- pbuc1_derefidx_vbuz1=vbuaa
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG22 [10] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuyy=_inc_vbuz1
|
||||
ldy idx
|
||||
iny
|
||||
//SEG23 [11] (byte~) main::$2 ← > (word) main::w#0 -- vbuaa=_hi_vwuz1
|
||||
lda w+1
|
||||
//SEG24 [12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$2 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG25 [13] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuaa=_inc_vbuyy
|
||||
iny
|
||||
tya
|
||||
//SEG26 [14] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuaa
|
||||
clc
|
||||
adc #1
|
||||
sta idx
|
||||
//SEG27 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG28 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
||||
cpx #4
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG29 main::@return
|
||||
breturn:
|
||||
//SEG30 [17] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing instruction ldx #0 with TAX
|
||||
Removing instruction ldy idx
|
||||
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction main_from_b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction bbegin:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(word*~) main::$0 $0 zp ZP_WORD:3 22.0
|
||||
(byte~) main::$1 reg byte a 22.0
|
||||
(byte~) main::$2 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 3.3000000000000003
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte y 11.0
|
||||
(byte) main::idx#2 reg byte a 22.0
|
||||
(byte) main::idx#3 idx zp ZP_BYTE:2 7.333333333333333
|
||||
(byte) main::idx#4 idx zp ZP_BYTE:2 6.6000000000000005
|
||||
(word) main::w
|
||||
(word) main::w#0 w zp ZP_WORD:5 8.25
|
||||
(word[]) main::words
|
||||
(const word[]) main::words#0 words = { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
zp ZP_BYTE:2 [ main::idx#4 main::idx#3 ]
|
||||
zp ZP_WORD:3 [ main::$0 ]
|
||||
zp ZP_WORD:5 [ main::w#0 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte y [ main::idx#1 ]
|
||||
reg byte a [ main::$2 ]
|
||||
reg byte a [ main::idx#2 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 831
|
||||
|
||||
//SEG0 File Comments
|
||||
// Tests simple word pointer math
|
||||
//SEG1 Basic Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
//SEG2 Global Constants & labels
|
||||
//SEG3 @begin
|
||||
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
//SEG5 @1
|
||||
//SEG6 [2] call main
|
||||
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
||||
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
||||
//SEG9 @end
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label _0 = 3
|
||||
.label w = 5
|
||||
.label idx = 2
|
||||
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
//SEG12 [5] phi (byte) main::idx#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta idx
|
||||
//SEG13 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
|
||||
tax
|
||||
//SEG14 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
//SEG15 [5] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@1->main::@1#0] -- register_copy
|
||||
//SEG16 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy
|
||||
//SEG17 main::@1
|
||||
b1:
|
||||
//SEG18 [6] (word*~) main::$0 ← (const word[]) main::words#0 + (byte) main::i#2 -- pwuz1=pwuc1_plus_vbuxx
|
||||
txa
|
||||
clc
|
||||
adc #<words
|
||||
sta _0
|
||||
lda #>words
|
||||
adc #0
|
||||
sta _0+1
|
||||
//SEG19 [7] (word) main::w#0 ← *((word*~) main::$0) -- vwuz1=_deref_pwuz2
|
||||
ldy #0
|
||||
lda (_0),y
|
||||
sta w
|
||||
iny
|
||||
lda (_0),y
|
||||
sta w+1
|
||||
//SEG20 [8] (byte~) main::$1 ← < (word) main::w#0 -- vbuaa=_lo_vwuz1
|
||||
lda w
|
||||
//SEG21 [9] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$1 -- pbuc1_derefidx_vbuz1=vbuaa
|
||||
ldy idx
|
||||
sta SCREEN,y
|
||||
//SEG22 [10] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuyy=_inc_vbuz1
|
||||
iny
|
||||
//SEG23 [11] (byte~) main::$2 ← > (word) main::w#0 -- vbuaa=_hi_vwuz1
|
||||
lda w+1
|
||||
//SEG24 [12] *((const byte*) main::SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$2 -- pbuc1_derefidx_vbuyy=vbuaa
|
||||
sta SCREEN,y
|
||||
//SEG25 [13] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuaa=_inc_vbuyy
|
||||
iny
|
||||
tya
|
||||
//SEG26 [14] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuaa
|
||||
clc
|
||||
adc #1
|
||||
sta idx
|
||||
//SEG27 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//SEG28 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
||||
cpx #4
|
||||
bne b1
|
||||
//SEG29 main::@return
|
||||
//SEG30 [17] return
|
||||
rts
|
||||
// Clever word array that represents C64 numbers 0-7
|
||||
words: .word $3130, $3332, $3534, $3736
|
||||
}
|
||||
|
32
src/test/ref/word-pointer-math.sym
Normal file
32
src/test/ref/word-pointer-math.sym
Normal file
@ -0,0 +1,32 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(word*~) main::$0 $0 zp ZP_WORD:3 22.0
|
||||
(byte~) main::$1 reg byte a 22.0
|
||||
(byte~) main::$2 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte*) main::SCREEN
|
||||
(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 3.3000000000000003
|
||||
(byte) main::idx
|
||||
(byte) main::idx#1 reg byte y 11.0
|
||||
(byte) main::idx#2 reg byte a 22.0
|
||||
(byte) main::idx#3 idx zp ZP_BYTE:2 7.333333333333333
|
||||
(byte) main::idx#4 idx zp ZP_BYTE:2 6.6000000000000005
|
||||
(word) main::w
|
||||
(word) main::w#0 w zp ZP_WORD:5 8.25
|
||||
(word[]) main::words
|
||||
(const word[]) main::words#0 words = { (word/signed word/dword/signed dword) $3130, (word/signed word/dword/signed dword) $3332, (word/signed word/dword/signed dword) $3534, (word/signed word/dword/signed dword) $3736 }
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
zp ZP_BYTE:2 [ main::idx#4 main::idx#3 ]
|
||||
zp ZP_WORD:3 [ main::$0 ]
|
||||
zp ZP_WORD:5 [ main::w#0 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte y [ main::idx#1 ]
|
||||
reg byte a [ main::$2 ]
|
||||
reg byte a [ main::idx#2 ]
|
Loading…
Reference in New Issue
Block a user