1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-20 02:32:36 +00:00
kickc/src/test/ref/summin.log

702 lines
29 KiB
Plaintext

CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
to:@2
main: scope:[main] from @2
(byte*) screen#4 ← phi( @2/(byte*) screen#5 )
(byte) sum::a#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
(byte) sum::b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
call sum
(byte) sum::return#0 ← (byte) sum::return#4
to:main::@1
main::@1: scope:[main] from main
(byte*) screen#3 ← phi( main/(byte*) screen#4 )
(byte) sum::return#5 ← phi( main/(byte) sum::return#0 )
(byte~) main::$0 ← (byte) sum::return#5
(byte) main::s1#0 ← (byte~) main::$0
(byte) sum::a#1 ← (byte/signed byte/word/signed word/dword/signed dword) 3
(byte) sum::b#1 ← (byte/signed byte/word/signed word/dword/signed dword) 4
call sum
(byte) sum::return#1 ← (byte) sum::return#4
to:main::@2
main::@2: scope:[main] from main::@1
(byte*) screen#2 ← phi( main::@1/(byte*) screen#3 )
(byte) main::s1#2 ← phi( main::@1/(byte) main::s1#0 )
(byte) sum::return#6 ← phi( main::@1/(byte) sum::return#1 )
(byte~) main::$1 ← (byte) sum::return#6
(byte) main::s2#0 ← (byte~) main::$1
(byte) sum::a#2 ← (byte/signed byte/word/signed word/dword/signed dword) 9
(byte) sum::b#2 ← (byte/signed byte/word/signed word/dword/signed dword) 13
call sum
(byte) sum::return#2 ← (byte) sum::return#4
to:main::@3
main::@3: scope:[main] from main::@2
(byte*) screen#1 ← phi( main::@2/(byte*) screen#2 )
(byte) main::s2#1 ← phi( main::@2/(byte) main::s2#0 )
(byte) main::s1#1 ← phi( main::@2/(byte) main::s1#2 )
(byte) sum::return#7 ← phi( main::@2/(byte) sum::return#2 )
(byte~) main::$2 ← (byte) sum::return#7
(byte) main::s3#0 ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::s1#1 + (byte) main::s2#1
(byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3#0
(byte) main::s4#0 ← (byte~) main::$4
*((byte*) screen#1) ← (byte) main::s4#0
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
sum: scope:[sum] from main main::@1 main::@2
(byte) sum::b#3 ← phi( main/(byte) sum::b#0 main::@1/(byte) sum::b#1 main::@2/(byte) sum::b#2 )
(byte) sum::a#3 ← phi( main/(byte) sum::a#0 main::@1/(byte) sum::a#1 main::@2/(byte) sum::a#2 )
(byte~) sum::$0 ← (byte) sum::a#3 + (byte) sum::b#3
(byte) sum::return#3 ← (byte~) sum::$0
to:sum::@return
sum::@return: scope:[sum] from sum
(byte) sum::return#8 ← phi( sum/(byte) sum::return#3 )
(byte) sum::return#4 ← (byte) sum::return#8
return
to:@return
@2: scope:[] from @begin
(byte*) screen#5 ← phi( @begin/(byte*) screen#0 )
call main
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) main()
(byte~) main::$0
(byte~) main::$1
(byte~) main::$2
(byte~) main::$3
(byte~) main::$4
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::s1
(byte) main::s1#0
(byte) main::s1#1
(byte) main::s1#2
(byte) main::s2
(byte) main::s2#0
(byte) main::s2#1
(byte) main::s3
(byte) main::s3#0
(byte) main::s4
(byte) main::s4#0
(byte*) screen
(byte*) screen#0
(byte*) screen#1
(byte*) screen#2
(byte*) screen#3
(byte*) screen#4
(byte*) screen#5
(byte()) sum((byte) sum::a , (byte) sum::b)
(byte~) sum::$0
(label) sum::@return
(byte) sum::a
(byte) sum::a#0
(byte) sum::a#1
(byte) sum::a#2
(byte) sum::a#3
(byte) sum::b
(byte) sum::b#0
(byte) sum::b#1
(byte) sum::b#2
(byte) sum::b#3
(byte) sum::return
(byte) sum::return#0
(byte) sum::return#1
(byte) sum::return#2
(byte) sum::return#3
(byte) sum::return#4
(byte) sum::return#5
(byte) sum::return#6
(byte) sum::return#7
(byte) sum::return#8
Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte) sum::return#0 = (byte) sum::return#5
Alias (byte*) screen#1 = (byte*) screen#3 (byte*) screen#4 (byte*) screen#2
Alias (byte) main::s1#0 = (byte~) main::$0 (byte) main::s1#2 (byte) main::s1#1
Alias (byte) sum::return#1 = (byte) sum::return#6
Alias (byte) main::s2#0 = (byte~) main::$1 (byte) main::s2#1
Alias (byte) sum::return#2 = (byte) sum::return#7
Alias (byte) main::s3#0 = (byte~) main::$2
Alias (byte) main::s4#0 = (byte~) main::$4
Alias (byte) sum::return#3 = (byte~) sum::$0 (byte) sum::return#8 (byte) sum::return#4
Alias (byte*) screen#0 = (byte*) screen#5
Successful SSA optimization Pass2AliasElimination
Redundant Phi (byte*) screen#1 (byte*) screen#0
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte*) screen#0 = ((byte*))1024
Constant (const byte) sum::a#0 = 1
Constant (const byte) sum::b#0 = 2
Constant (const byte) sum::a#1 = 3
Constant (const byte) sum::b#1 = 4
Constant (const byte) sum::a#2 = 9
Constant (const byte) sum::b#2 = 13
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) sum::a#0
Inlining constant with var siblings (const byte) sum::b#0
Inlining constant with var siblings (const byte) sum::a#1
Inlining constant with var siblings (const byte) sum::b#1
Inlining constant with var siblings (const byte) sum::a#2
Inlining constant with var siblings (const byte) sum::b#2
Constant inlined sum::b#1 = (byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined sum::a#2 = (byte/signed byte/word/signed word/dword/signed dword) 9
Constant inlined sum::b#0 = (byte/signed byte/word/signed word/dword/signed dword) 2
Constant inlined sum::a#1 = (byte/signed byte/word/signed word/dword/signed dword) 3
Constant inlined sum::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 13
Constant inlined sum::a#0 = (byte/signed byte/word/signed word/dword/signed dword) 1
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
Calls in [main] to sum:5 sum:8 sum:11
Created 2 initial phi equivalence classes
Coalesced down to 2 phi equivalence classes
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi() [ ] ( )
to:@2
@2: scope:[] from @begin
[1] phi() [ ] ( )
[2] call main [ ] ( )
to:@end
@end: scope:[] from @2
[3] phi() [ ] ( )
main: scope:[main] from @2
[4] phi() [ ] ( main:2 [ ] )
[5] call sum [ sum::return#3 ] ( main:2 [ sum::return#3 ] )
[6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] )
to:main::@1
main::@1: scope:[main] from main
[7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] )
[8] call sum [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] )
[9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] )
to:main::@2
main::@2: scope:[main] from main::@1
[10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] )
[11] call sum [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] )
[12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] )
to:main::@3
main::@3: scope:[main] from main::@2
[13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] )
[14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] )
[15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] )
[16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] )
to:main::@return
main::@return: scope:[main] from main::@3
[17] return [ ] ( main:2 [ ] )
to:@return
sum: scope:[sum] from main main::@1 main::@2
[18] (byte) sum::b#3 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@1/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte/signed byte/word/signed word/dword/signed dword) 13 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] )
[18] (byte) sum::a#3 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 1 main::@1/(byte/signed byte/word/signed word/dword/signed dword) 3 main::@2/(byte/signed byte/word/signed word/dword/signed dword) 9 ) [ sum::a#3 sum::b#3 ] ( main:2::sum:5 [ sum::a#3 sum::b#3 ] main:2::sum:8 [ main::s1#0 sum::a#3 sum::b#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::a#3 sum::b#3 ] )
[19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] )
to:sum::@return
sum::@return: scope:[sum] from sum
[20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] )
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$3 4.0
(byte) main::s1
(byte) main::s1#0 0.5714285714285714
(byte) main::s2
(byte) main::s2#0 1.0
(byte) main::s3
(byte) main::s3#0 2.0
(byte) main::s4
(byte) main::s4#0 4.0
(byte*) screen
(byte()) sum((byte) sum::a , (byte) sum::b)
(byte) sum::a
(byte) sum::a#3 2.0
(byte) sum::b
(byte) sum::b#3 2.0
(byte) sum::return
(byte) sum::return#0 4.0
(byte) sum::return#1 4.0
(byte) sum::return#2 4.0
(byte) sum::return#3 1.6
Initial phi equivalence classes
[ sum::a#3 ]
[ sum::b#3 ]
Added variable sum::return#0 to zero page equivalence class [ sum::return#0 ]
Added variable main::s1#0 to zero page equivalence class [ main::s1#0 ]
Added variable sum::return#1 to zero page equivalence class [ sum::return#1 ]
Added variable main::s2#0 to zero page equivalence class [ main::s2#0 ]
Added variable sum::return#2 to zero page equivalence class [ sum::return#2 ]
Added variable main::s3#0 to zero page equivalence class [ main::s3#0 ]
Added variable main::$3 to zero page equivalence class [ main::$3 ]
Added variable main::s4#0 to zero page equivalence class [ main::s4#0 ]
Added variable sum::return#3 to zero page equivalence class [ sum::return#3 ]
Complete equivalence classes
[ sum::a#3 ]
[ sum::b#3 ]
[ sum::return#0 ]
[ main::s1#0 ]
[ sum::return#1 ]
[ main::s2#0 ]
[ sum::return#2 ]
[ main::s3#0 ]
[ main::$3 ]
[ main::s4#0 ]
[ sum::return#3 ]
Allocated zp ZP_BYTE:2 [ sum::a#3 ]
Allocated zp ZP_BYTE:3 [ sum::b#3 ]
Allocated zp ZP_BYTE:4 [ sum::return#0 ]
Allocated zp ZP_BYTE:5 [ main::s1#0 ]
Allocated zp ZP_BYTE:6 [ sum::return#1 ]
Allocated zp ZP_BYTE:7 [ main::s2#0 ]
Allocated zp ZP_BYTE:8 [ sum::return#2 ]
Allocated zp ZP_BYTE:9 [ main::s3#0 ]
Allocated zp ZP_BYTE:10 [ main::$3 ]
Allocated zp ZP_BYTE:11 [ main::s4#0 ]
Allocated zp ZP_BYTE:12 [ sum::return#3 ]
INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.label screen = $400
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
jmp b2
//SEG4 @2
b2:
//SEG5 [2] call main [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
.label _3 = $a
.label s1 = 5
.label s2 = 7
.label s3 = 9
.label s4 = $b
//SEG10 [5] call sum [ sum::return#3 ] ( main:2 [ sum::return#3 ] )
//SEG11 [18] phi from main to sum [phi:main->sum]
sum_from_main:
//SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->sum#0] -- vbuz1=vbuc1
lda #2
sta sum.b
//SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 1 [phi:main->sum#1] -- vbuz1=vbuc1
lda #1
sta sum.a
jsr sum
//SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] ) -- vbuz1=vbuz2
lda sum.return_3
sta sum.return
jmp b1
//SEG15 main::@1
b1:
//SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- vbuz1=vbuz2
lda sum.return
sta s1
//SEG17 [8] call sum [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] )
//SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum]
sum_from_b1:
//SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main::@1->sum#0] -- vbuz1=vbuc1
lda #4
sta sum.b
//SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 3 [phi:main::@1->sum#1] -- vbuz1=vbuc1
lda #3
sta sum.a
jsr sum
//SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] ) -- vbuz1=vbuz2
lda sum.return_3
sta sum.return_1
jmp b2
//SEG22 main::@2
b2:
//SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- vbuz1=vbuz2
lda sum.return_1
sta s2
//SEG24 [11] call sum [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] )
//SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum]
sum_from_b2:
//SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 13 [phi:main::@2->sum#0] -- vbuz1=vbuc1
lda #$d
sta sum.b
//SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 9 [phi:main::@2->sum#1] -- vbuz1=vbuc1
lda #9
sta sum.a
jsr sum
//SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] ) -- vbuz1=vbuz2
lda sum.return_3
sta sum.return_2
jmp b3
//SEG29 main::@3
b3:
//SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- vbuz1=vbuz2
lda sum.return_2
sta s3
//SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- vbuz1=vbuz2_plus_vbuz3
lda s1
clc
adc s2
sta _3
//SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- vbuz1=vbuz2_plus_vbuz3
lda _3
clc
adc s3
sta s4
//SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuz1
lda s4
sta screen
jmp breturn
//SEG34 main::@return
breturn:
//SEG35 [17] return [ ] ( main:2 [ ] )
rts
}
//SEG36 sum
sum: {
.label return = 4
.label return_1 = 6
.label return_2 = 8
.label return_3 = $c
.label a = 2
.label b = 3
//SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- vbuz1=vbuz2_plus_vbuz3
lda a
clc
adc b
sta return_3
jmp breturn
//SEG38 sum::@return
breturn:
//SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] )
rts
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ main::s3#0 ]
Statement [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) always clobbers reg byte a
Statement [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ main::s1#0 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:7 [ main::s2#0 ]
Statement [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) always clobbers reg byte a
Statement [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) always clobbers reg byte a
Statement [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ sum::a#3 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:3 [ sum::b#3 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:4 [ sum::return#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:5 [ main::s1#0 ] : zp ZP_BYTE:5 , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:6 [ sum::return#1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:7 [ main::s2#0 ] : zp ZP_BYTE:7 , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:8 [ sum::return#2 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:9 [ main::s3#0 ] : zp ZP_BYTE:9 , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:10 [ main::$3 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:11 [ main::s4#0 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:12 [ sum::return#3 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [sum] 4: zp ZP_BYTE:4 [ sum::return#0 ] 4: zp ZP_BYTE:6 [ sum::return#1 ] 4: zp ZP_BYTE:8 [ sum::return#2 ] 2: zp ZP_BYTE:2 [ sum::a#3 ] 2: zp ZP_BYTE:3 [ sum::b#3 ] 1.6: zp ZP_BYTE:12 [ sum::return#3 ]
Uplift Scope [main] 4: zp ZP_BYTE:10 [ main::$3 ] 4: zp ZP_BYTE:11 [ main::s4#0 ] 2: zp ZP_BYTE:9 [ main::s3#0 ] 1: zp ZP_BYTE:7 [ main::s2#0 ] 0.57: zp ZP_BYTE:5 [ main::s1#0 ]
Uplift Scope []
Uplifting [sum] best 145 combination reg byte a [ sum::return#0 ] reg byte a [ sum::return#1 ] reg byte a [ sum::return#2 ] zp ZP_BYTE:2 [ sum::a#3 ] zp ZP_BYTE:3 [ sum::b#3 ] zp ZP_BYTE:12 [ sum::return#3 ]
Limited combination testing to 100 combinations of 4096 possible.
Uplifting [main] best 131 combination reg byte a [ main::$3 ] reg byte a [ main::s4#0 ] zp ZP_BYTE:9 [ main::s3#0 ] reg byte x [ main::s2#0 ] zp ZP_BYTE:5 [ main::s1#0 ]
Limited combination testing to 100 combinations of 432 possible.
Uplifting [] best 131 combination
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ sum::a#3 ]
Uplifting [sum] best 121 combination reg byte y [ sum::a#3 ]
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ sum::b#3 ]
Uplifting [sum] best 113 combination reg byte a [ sum::b#3 ]
Attempting to uplift remaining variables inzp ZP_BYTE:9 [ main::s3#0 ]
Uplifting [main] best 113 combination zp ZP_BYTE:9 [ main::s3#0 ]
Attempting to uplift remaining variables inzp ZP_BYTE:12 [ sum::return#3 ]
Uplifting [sum] best 101 combination reg byte a [ sum::return#3 ]
Attempting to uplift remaining variables inzp ZP_BYTE:5 [ main::s1#0 ]
Uplifting [main] best 101 combination zp ZP_BYTE:5 [ main::s1#0 ]
Allocated (was zp ZP_BYTE:5) zp ZP_BYTE:2 [ main::s1#0 ]
Allocated (was zp ZP_BYTE:9) zp ZP_BYTE:3 [ main::s3#0 ]
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.label screen = $400
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
jmp b2
//SEG4 @2
b2:
//SEG5 [2] call main [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
.label s1 = 2
.label s3 = 3
//SEG10 [5] call sum [ sum::return#3 ] ( main:2 [ sum::return#3 ] )
//SEG11 [18] phi from main to sum [phi:main->sum]
sum_from_main:
//SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->sum#0] -- vbuaa=vbuc1
lda #2
//SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 1 [phi:main->sum#1] -- vbuyy=vbuc1
ldy #1
jsr sum
//SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] )
// (byte) sum::return#0 = (byte) sum::return#3 // register copy reg byte a
jmp b1
//SEG15 main::@1
b1:
//SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- vbuz1=vbuaa
sta s1
//SEG17 [8] call sum [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] )
//SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum]
sum_from_b1:
//SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main::@1->sum#0] -- vbuaa=vbuc1
lda #4
//SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 3 [phi:main::@1->sum#1] -- vbuyy=vbuc1
ldy #3
jsr sum
//SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] )
// (byte) sum::return#1 = (byte) sum::return#3 // register copy reg byte a
jmp b2
//SEG22 main::@2
b2:
//SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- vbuxx=vbuaa
tax
//SEG24 [11] call sum [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] )
//SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum]
sum_from_b2:
//SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 13 [phi:main::@2->sum#0] -- vbuaa=vbuc1
lda #$d
//SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 9 [phi:main::@2->sum#1] -- vbuyy=vbuc1
ldy #9
jsr sum
//SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] )
// (byte) sum::return#2 = (byte) sum::return#3 // register copy reg byte a
jmp b3
//SEG29 main::@3
b3:
//SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- vbuz1=vbuaa
sta s3
//SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- vbuaa=vbuz1_plus_vbuxx
txa
clc
adc s1
//SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- vbuaa=vbuaa_plus_vbuz1
clc
adc s3
//SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuaa
sta screen
jmp breturn
//SEG34 main::@return
breturn:
//SEG35 [17] return [ ] ( main:2 [ ] )
rts
}
//SEG36 sum
sum: {
//SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- vbuaa=vbuyy_plus_vbuaa
sty $ff
clc
adc $ff
jmp breturn
//SEG38 sum::@return
breturn:
//SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] )
rts
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Removing instruction b2_from_bbegin:
Removing instruction main_from_b2:
Removing instruction bend_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b2:
Removing instruction bend:
Removing instruction sum_from_main:
Removing instruction b1:
Removing instruction sum_from_b1:
Removing instruction b2:
Removing instruction sum_from_b2:
Removing instruction b3:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(void()) main()
(byte~) main::$3 reg byte a 4.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::s1
(byte) main::s1#0 s1 zp ZP_BYTE:2 0.5714285714285714
(byte) main::s2
(byte) main::s2#0 reg byte x 1.0
(byte) main::s3
(byte) main::s3#0 s3 zp ZP_BYTE:3 2.0
(byte) main::s4
(byte) main::s4#0 reg byte a 4.0
(byte*) screen
(const byte*) screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
(byte()) sum((byte) sum::a , (byte) sum::b)
(label) sum::@return
(byte) sum::a
(byte) sum::a#3 reg byte y 2.0
(byte) sum::b
(byte) sum::b#3 reg byte a 2.0
(byte) sum::return
(byte) sum::return#0 reg byte a 4.0
(byte) sum::return#1 reg byte a 4.0
(byte) sum::return#2 reg byte a 4.0
(byte) sum::return#3 reg byte a 1.6
reg byte y [ sum::a#3 ]
reg byte a [ sum::b#3 ]
reg byte a [ sum::return#0 ]
zp ZP_BYTE:2 [ main::s1#0 ]
reg byte a [ sum::return#1 ]
reg byte x [ main::s2#0 ]
reg byte a [ sum::return#2 ]
zp ZP_BYTE:3 [ main::s3#0 ]
reg byte a [ main::$3 ]
reg byte a [ main::s4#0 ]
reg byte a [ sum::return#3 ]
FINAL ASSEMBLER
Score: 80
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.label screen = $400
//SEG2 @begin
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG4 @2
//SEG5 [2] call main [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
.label s1 = 2
.label s3 = 3
//SEG10 [5] call sum [ sum::return#3 ] ( main:2 [ sum::return#3 ] )
//SEG11 [18] phi from main to sum [phi:main->sum]
//SEG12 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->sum#0] -- vbuaa=vbuc1
lda #2
//SEG13 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 1 [phi:main->sum#1] -- vbuyy=vbuc1
ldy #1
jsr sum
//SEG14 [6] (byte) sum::return#0 ← (byte) sum::return#3 [ sum::return#0 ] ( main:2 [ sum::return#0 ] )
// (byte) sum::return#0 = (byte) sum::return#3 // register copy reg byte a
//SEG15 main::@1
//SEG16 [7] (byte) main::s1#0 ← (byte) sum::return#0 [ main::s1#0 ] ( main:2 [ main::s1#0 ] ) -- vbuz1=vbuaa
sta s1
//SEG17 [8] call sum [ sum::return#3 main::s1#0 ] ( main:2 [ sum::return#3 main::s1#0 ] )
//SEG18 [18] phi from main::@1 to sum [phi:main::@1->sum]
//SEG19 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main::@1->sum#0] -- vbuaa=vbuc1
lda #4
//SEG20 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 3 [phi:main::@1->sum#1] -- vbuyy=vbuc1
ldy #3
jsr sum
//SEG21 [9] (byte) sum::return#1 ← (byte) sum::return#3 [ main::s1#0 sum::return#1 ] ( main:2 [ main::s1#0 sum::return#1 ] )
// (byte) sum::return#1 = (byte) sum::return#3 // register copy reg byte a
//SEG22 main::@2
//SEG23 [10] (byte) main::s2#0 ← (byte) sum::return#1 [ main::s1#0 main::s2#0 ] ( main:2 [ main::s1#0 main::s2#0 ] ) -- vbuxx=vbuaa
tax
//SEG24 [11] call sum [ sum::return#3 main::s1#0 main::s2#0 ] ( main:2 [ sum::return#3 main::s1#0 main::s2#0 ] )
//SEG25 [18] phi from main::@2 to sum [phi:main::@2->sum]
//SEG26 [18] phi (byte) sum::b#3 = (byte/signed byte/word/signed word/dword/signed dword) 13 [phi:main::@2->sum#0] -- vbuaa=vbuc1
lda #$d
//SEG27 [18] phi (byte) sum::a#3 = (byte/signed byte/word/signed word/dword/signed dword) 9 [phi:main::@2->sum#1] -- vbuyy=vbuc1
ldy #9
jsr sum
//SEG28 [12] (byte) sum::return#2 ← (byte) sum::return#3 [ main::s1#0 main::s2#0 sum::return#2 ] ( main:2 [ main::s1#0 main::s2#0 sum::return#2 ] )
// (byte) sum::return#2 = (byte) sum::return#3 // register copy reg byte a
//SEG29 main::@3
//SEG30 [13] (byte) main::s3#0 ← (byte) sum::return#2 [ main::s1#0 main::s2#0 main::s3#0 ] ( main:2 [ main::s1#0 main::s2#0 main::s3#0 ] ) -- vbuz1=vbuaa
sta s3
//SEG31 [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) -- vbuaa=vbuz1_plus_vbuxx
txa
clc
adc s1
//SEG32 [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) -- vbuaa=vbuaa_plus_vbuz1
clc
adc s3
//SEG33 [16] *((const byte*) screen#0) ← (byte) main::s4#0 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuaa
sta screen
//SEG34 main::@return
//SEG35 [17] return [ ] ( main:2 [ ] )
rts
}
//SEG36 sum
sum: {
//SEG37 [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) -- vbuaa=vbuyy_plus_vbuaa
sty $ff
clc
adc $ff
//SEG38 sum::@return
//SEG39 [20] return [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] )
rts
}