1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-29 03:56:15 +00:00
kickc/src/test/ref/modglobal.log

736 lines
23 KiB
Plaintext

CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte) cnt#0 ← (byte) 0
(byte) cnt2#0 ← (byte) 0
(byte) cnt3#0 ← (byte) 0
to:@1
(void()) main()
main: scope:[main] from @1
(byte) cnt3#13 ← phi( @1/(byte) cnt3#14 )
(byte) cnt2#13 ← phi( @1/(byte) cnt2#14 )
(byte) cnt#14 ← phi( @1/(byte) cnt#15 )
call inccnt
(byte) inccnt::return#0 ← (byte) inccnt::return#3
to:main::@1
main::@1: scope:[main] from main
(byte) cnt3#7 ← phi( main/(byte) cnt3#5 )
(byte) cnt2#7 ← phi( main/(byte) cnt2#5 )
(byte) cnt#8 ← phi( main/(byte) cnt#6 )
(byte) inccnt::return#4 ← phi( main/(byte) inccnt::return#0 )
(byte~) main::$0 ← (byte) inccnt::return#4
(byte) cnt#1 ← (byte) cnt#8
(byte) cnt2#1 ← (byte) cnt2#7
(byte) cnt3#1 ← (byte) cnt3#7
*((const byte*) SCREEN + (number) 0) ← (byte~) main::$0
(byte) cnt#2 ← ++ (byte) cnt#1
call inccnt
(byte) inccnt::return#1 ← (byte) inccnt::return#3
to:main::@2
main::@2: scope:[main] from main::@1
(byte) cnt3#8 ← phi( main::@1/(byte) cnt3#5 )
(byte) cnt2#8 ← phi( main::@1/(byte) cnt2#5 )
(byte) cnt#9 ← phi( main::@1/(byte) cnt#6 )
(byte) inccnt::return#5 ← phi( main::@1/(byte) inccnt::return#1 )
(byte~) main::$1 ← (byte) inccnt::return#5
(byte) cnt#3 ← (byte) cnt#9
(byte) cnt2#2 ← (byte) cnt2#8
(byte) cnt3#2 ← (byte) cnt3#8
*((const byte*) SCREEN + (number) 1) ← (byte~) main::$1
*((const byte*) SCREEN + (number) 2) ← (byte) cnt2#2
*((const byte*) SCREEN + (number) 3) ← (byte) cnt3#2
to:main::@return
main::@return: scope:[main] from main::@2
(byte) cnt3#9 ← phi( main::@2/(byte) cnt3#2 )
(byte) cnt2#9 ← phi( main::@2/(byte) cnt2#2 )
(byte) cnt#10 ← phi( main::@2/(byte) cnt#3 )
(byte) cnt#4 ← (byte) cnt#10
(byte) cnt2#3 ← (byte) cnt2#9
(byte) cnt3#3 ← (byte) cnt3#9
return
to:@return
(byte()) inccnt()
inccnt: scope:[inccnt] from main main::@1
(byte) cnt3#10 ← phi( main/(byte) cnt3#13 main::@1/(byte) cnt3#1 )
(byte) cnt2#10 ← phi( main/(byte) cnt2#13 main::@1/(byte) cnt2#1 )
(byte) cnt#11 ← phi( main/(byte) cnt#14 main::@1/(byte) cnt#2 )
(byte) cnt#5 ← ++ (byte) cnt#11
(byte) cnt2#4 ← ++ (byte) cnt2#10
(byte) cnt3#4 ← ++ (byte) cnt3#10
(byte) inccnt::return#2 ← (byte) cnt#5
to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt
(byte) cnt3#11 ← phi( inccnt/(byte) cnt3#4 )
(byte) cnt2#11 ← phi( inccnt/(byte) cnt2#4 )
(byte) cnt#12 ← phi( inccnt/(byte) cnt#5 )
(byte) inccnt::return#6 ← phi( inccnt/(byte) inccnt::return#2 )
(byte) inccnt::return#3 ← (byte) inccnt::return#6
(byte) cnt#6 ← (byte) cnt#12
(byte) cnt2#5 ← (byte) cnt2#11
(byte) cnt3#5 ← (byte) cnt3#11
return
to:@return
@1: scope:[] from @begin
(byte) cnt3#14 ← phi( @begin/(byte) cnt3#0 )
(byte) cnt2#14 ← phi( @begin/(byte) cnt2#0 )
(byte) cnt#15 ← phi( @begin/(byte) cnt#0 )
call main
to:@2
@2: scope:[] from @1
(byte) cnt3#12 ← phi( @1/(byte) cnt3#3 )
(byte) cnt2#12 ← phi( @1/(byte) cnt2#3 )
(byte) cnt#13 ← phi( @1/(byte) cnt#4 )
(byte) cnt#7 ← (byte) cnt#13
(byte) cnt2#6 ← (byte) cnt2#12
(byte) cnt3#6 ← (byte) cnt3#12
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) SCREEN[(number) $100] = (byte*)(number) $400
(byte) cnt
(byte) cnt#0
(byte) cnt#1
(byte) cnt#10
(byte) cnt#11
(byte) cnt#12
(byte) cnt#13
(byte) cnt#14
(byte) cnt#15
(byte) cnt#2
(byte) cnt#3
(byte) cnt#4
(byte) cnt#5
(byte) cnt#6
(byte) cnt#7
(byte) cnt#8
(byte) cnt#9
(byte) cnt2
(byte) cnt2#0
(byte) cnt2#1
(byte) cnt2#10
(byte) cnt2#11
(byte) cnt2#12
(byte) cnt2#13
(byte) cnt2#14
(byte) cnt2#2
(byte) cnt2#3
(byte) cnt2#4
(byte) cnt2#5
(byte) cnt2#6
(byte) cnt2#7
(byte) cnt2#8
(byte) cnt2#9
(byte) cnt3
(byte) cnt3#0
(byte) cnt3#1
(byte) cnt3#10
(byte) cnt3#11
(byte) cnt3#12
(byte) cnt3#13
(byte) cnt3#14
(byte) cnt3#2
(byte) cnt3#3
(byte) cnt3#4
(byte) cnt3#5
(byte) cnt3#6
(byte) cnt3#7
(byte) cnt3#8
(byte) cnt3#9
(byte()) inccnt()
(label) inccnt::@return
(byte) inccnt::return
(byte) inccnt::return#0
(byte) inccnt::return#1
(byte) inccnt::return#2
(byte) inccnt::return#3
(byte) inccnt::return#4
(byte) inccnt::return#5
(byte) inccnt::return#6
(void()) main()
(byte~) main::$0
(byte~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return
Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN + (number) 0) ← (byte~) main::$0
Adding number conversion cast (unumber) 1 in *((const byte*) SCREEN + (number) 1) ← (byte~) main::$1
Adding number conversion cast (unumber) 2 in *((const byte*) SCREEN + (number) 2) ← (byte) cnt2#2
Adding number conversion cast (unumber) 3 in *((const byte*) SCREEN + (number) 3) ← (byte) cnt3#2
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias inccnt::return#0 = inccnt::return#4
Alias cnt#1 = cnt#8
Alias cnt2#1 = cnt2#7
Alias cnt3#1 = cnt3#7
Alias inccnt::return#1 = inccnt::return#5
Alias cnt#10 = cnt#3 cnt#9 cnt#4
Alias cnt2#2 = cnt2#8 cnt2#9 cnt2#3
Alias cnt3#2 = cnt3#8 cnt3#9 cnt3#3
Alias inccnt::return#2 = inccnt::return#6 inccnt::return#3
Alias cnt#12 = cnt#5 cnt#6
Alias cnt2#11 = cnt2#4 cnt2#5
Alias cnt3#11 = cnt3#4 cnt3#5
Alias cnt#0 = cnt#15
Alias cnt2#0 = cnt2#14
Alias cnt3#0 = cnt3#14
Alias cnt#13 = cnt#7
Alias cnt2#12 = cnt2#6
Alias cnt3#12 = cnt3#6
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) cnt#14 (byte) cnt#0
Identical Phi Values (byte) cnt2#13 (byte) cnt2#0
Identical Phi Values (byte) cnt3#13 (byte) cnt3#0
Identical Phi Values (byte) cnt#1 (byte) cnt#12
Identical Phi Values (byte) cnt2#1 (byte) cnt2#11
Identical Phi Values (byte) cnt3#1 (byte) cnt3#11
Identical Phi Values (byte) cnt#10 (byte) cnt#12
Identical Phi Values (byte) cnt2#2 (byte) cnt2#11
Identical Phi Values (byte) cnt3#2 (byte) cnt3#11
Identical Phi Values (byte) cnt#13 (byte) cnt#10
Identical Phi Values (byte) cnt2#12 (byte) cnt2#2
Identical Phi Values (byte) cnt3#12 (byte) cnt3#2
Successful SSA optimization Pass2IdenticalPhiElimination
Constant (const byte) cnt#0 = 0
Constant (const byte) cnt2#0 = 0
Constant (const byte) cnt3#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN in [8] *((const byte*) SCREEN + (byte) 0) ← (byte~) main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Inlining constant with var siblings (const byte) cnt#0
Inlining constant with var siblings (const byte) cnt2#0
Inlining constant with var siblings (const byte) cnt3#0
Constant inlined cnt#0 = (byte) 0
Constant inlined cnt3#0 = (byte) 0
Constant inlined cnt2#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN+1)
Consolidated array index constant in *(SCREEN+2)
Consolidated array index constant in *(SCREEN+3)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
Calls in [main] to inccnt:6 inccnt:14
Created 3 initial phi equivalence classes
Coalesced [11] cnt#16 ← cnt#2
Coalesced [12] cnt2#15 ← cnt2#11
Coalesced [13] cnt3#15 ← cnt3#11
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
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()
(void()) main()
main: scope:[main] from @1
[4] phi()
[5] call inccnt
[6] (byte) inccnt::return#0 ← (byte) inccnt::return#2
to:main::@1
main::@1: scope:[main] from main
[7] (byte~) main::$0 ← (byte) inccnt::return#0
[8] *((const byte*) SCREEN) ← (byte~) main::$0
[9] (byte) cnt#2 ← ++ (byte) cnt#12
[10] call inccnt
[11] (byte) inccnt::return#1 ← (byte) inccnt::return#2
to:main::@2
main::@2: scope:[main] from main::@1
[12] (byte~) main::$1 ← (byte) inccnt::return#1
[13] *((const byte*) SCREEN+(byte) 1) ← (byte~) main::$1
[14] *((const byte*) SCREEN+(byte) 2) ← (byte) cnt2#11
[15] *((const byte*) SCREEN+(byte) 3) ← (byte) cnt3#11
to:main::@return
main::@return: scope:[main] from main::@2
[16] return
to:@return
(byte()) inccnt()
inccnt: scope:[inccnt] from main main::@1
[17] (byte) cnt3#10 ← phi( main/(byte) 0 main::@1/(byte) cnt3#11 )
[17] (byte) cnt2#10 ← phi( main/(byte) 0 main::@1/(byte) cnt2#11 )
[17] (byte) cnt#11 ← phi( main/(byte) 0 main::@1/(byte) cnt#2 )
[18] (byte) cnt#12 ← ++ (byte) cnt#11
[19] (byte) cnt2#11 ← ++ (byte) cnt2#10
[20] (byte) cnt3#11 ← ++ (byte) cnt3#10
[21] (byte) inccnt::return#2 ← (byte) cnt#12
to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt
[22] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte) cnt
(byte) cnt#11 112.0
(byte) cnt#12 23.666666666666664
(byte) cnt#2 22.0
(byte) cnt2
(byte) cnt2#10 56.0
(byte) cnt2#11 9.461538461538462
(byte) cnt3
(byte) cnt3#10 37.33333333333333
(byte) cnt3#11 9.461538461538462
(byte()) inccnt()
(byte) inccnt::return
(byte) inccnt::return#0 22.0
(byte) inccnt::return#1 22.0
(byte) inccnt::return#2 30.75
(void()) main()
(byte~) main::$0 22.0
(byte~) main::$1 22.0
Initial phi equivalence classes
[ cnt#11 cnt#2 ]
[ cnt2#10 cnt2#11 ]
[ cnt3#10 cnt3#11 ]
Added variable inccnt::return#0 to live range equivalence class [ inccnt::return#0 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable inccnt::return#1 to live range equivalence class [ inccnt::return#1 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Added variable cnt#12 to live range equivalence class [ cnt#12 ]
Added variable inccnt::return#2 to live range equivalence class [ inccnt::return#2 ]
Complete equivalence classes
[ cnt#11 cnt#2 ]
[ cnt2#10 cnt2#11 ]
[ cnt3#10 cnt3#11 ]
[ inccnt::return#0 ]
[ main::$0 ]
[ inccnt::return#1 ]
[ main::$1 ]
[ cnt#12 ]
[ inccnt::return#2 ]
Allocated zp[1]:2 [ cnt#11 cnt#2 ]
Allocated zp[1]:3 [ cnt2#10 cnt2#11 ]
Allocated zp[1]:4 [ cnt3#10 cnt3#11 ]
Allocated zp[1]:5 [ inccnt::return#0 ]
Allocated zp[1]:6 [ main::$0 ]
Allocated zp[1]:7 [ inccnt::return#1 ]
Allocated zp[1]:8 [ main::$1 ]
Allocated zp[1]:9 [ cnt#12 ]
Allocated zp[1]:10 [ inccnt::return#2 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
.label cnt = 2
.label cnt2 = 3
.label cnt3 = 4
.label cnt_1 = 9
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label __0 = 6
.label __1 = 8
// [5] call inccnt
// [17] phi from main to inccnt [phi:main->inccnt]
inccnt_from_main:
// [17] phi (byte) cnt3#10 = (byte) 0 [phi:main->inccnt#0] -- vbuz1=vbuc1
lda #0
sta.z cnt3
// [17] phi (byte) cnt2#10 = (byte) 0 [phi:main->inccnt#1] -- vbuz1=vbuc1
lda #0
sta.z cnt2
// [17] phi (byte) cnt#11 = (byte) 0 [phi:main->inccnt#2] -- vbuz1=vbuc1
lda #0
sta.z cnt
jsr inccnt
// [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2 -- vbuz1=vbuz2
lda.z inccnt.return_2
sta.z inccnt.return
jmp __b1
// main::@1
__b1:
// [7] (byte~) main::$0 ← (byte) inccnt::return#0 -- vbuz1=vbuz2
lda.z inccnt.return
sta.z __0
// [8] *((const byte*) SCREEN) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1
lda.z __0
sta SCREEN
// [9] (byte) cnt#2 ← ++ (byte) cnt#12 -- vbuz1=_inc_vbuz2
ldy.z cnt_1
iny
sty.z cnt
// [10] call inccnt
// [17] phi from main::@1 to inccnt [phi:main::@1->inccnt]
inccnt_from___b1:
// [17] phi (byte) cnt3#10 = (byte) cnt3#11 [phi:main::@1->inccnt#0] -- register_copy
// [17] phi (byte) cnt2#10 = (byte) cnt2#11 [phi:main::@1->inccnt#1] -- register_copy
// [17] phi (byte) cnt#11 = (byte) cnt#2 [phi:main::@1->inccnt#2] -- register_copy
jsr inccnt
// [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2 -- vbuz1=vbuz2
lda.z inccnt.return_2
sta.z inccnt.return_1
jmp __b2
// main::@2
__b2:
// [12] (byte~) main::$1 ← (byte) inccnt::return#1 -- vbuz1=vbuz2
lda.z inccnt.return_1
sta.z __1
// [13] *((const byte*) SCREEN+(byte) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuz1
lda.z __1
sta SCREEN+1
// [14] *((const byte*) SCREEN+(byte) 2) ← (byte) cnt2#11 -- _deref_pbuc1=vbuz1
lda.z cnt2
sta SCREEN+2
// [15] *((const byte*) SCREEN+(byte) 3) ← (byte) cnt3#11 -- _deref_pbuc1=vbuz1
lda.z cnt3
sta SCREEN+3
jmp __breturn
// main::@return
__breturn:
// [16] return
rts
}
// inccnt
inccnt: {
.label return = 5
.label return_1 = 7
.label return_2 = $a
// [18] (byte) cnt#12 ← ++ (byte) cnt#11 -- vbuz1=_inc_vbuz2
ldy.z cnt
iny
sty.z cnt_1
// [19] (byte) cnt2#11 ← ++ (byte) cnt2#10 -- vbuz1=_inc_vbuz1
inc.z cnt2
// [20] (byte) cnt3#11 ← ++ (byte) cnt3#10 -- vbuz1=_inc_vbuz1
inc.z cnt3
// [21] (byte) inccnt::return#2 ← (byte) cnt#12 -- vbuz1=vbuz2
lda.z cnt_1
sta.z return_2
jmp __breturn
// inccnt::@return
__breturn:
// [22] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ cnt#11 cnt#2 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ cnt2#10 cnt2#11 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:4 [ cnt3#10 cnt3#11 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:5 [ inccnt::return#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:6 [ main::$0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:7 [ inccnt::return#1 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:8 [ main::$1 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:9 [ cnt#12 ] : zp[1]:9 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:10 [ inccnt::return#2 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [] 134: zp[1]:2 [ cnt#11 cnt#2 ] 65.46: zp[1]:3 [ cnt2#10 cnt2#11 ] 46.79: zp[1]:4 [ cnt3#10 cnt3#11 ] 23.67: zp[1]:9 [ cnt#12 ]
Uplift Scope [inccnt] 30.75: zp[1]:10 [ inccnt::return#2 ] 22: zp[1]:5 [ inccnt::return#0 ] 22: zp[1]:7 [ inccnt::return#1 ]
Uplift Scope [main] 22: zp[1]:6 [ main::$0 ] 22: zp[1]:8 [ main::$1 ]
Uplifting [] best 124 combination reg byte a [ cnt#11 cnt#2 ] reg byte y [ cnt2#10 cnt2#11 ] reg byte x [ cnt3#10 cnt3#11 ] zp[1]:9 [ cnt#12 ]
Limited combination testing to 100 combinations of 256 possible.
Uplifting [inccnt] best 103 combination reg byte a [ inccnt::return#2 ] reg byte a [ inccnt::return#0 ] reg byte a [ inccnt::return#1 ]
Uplifting [main] best 91 combination reg byte a [ main::$0 ] reg byte a [ main::$1 ]
Attempting to uplift remaining variables inzp[1]:9 [ cnt#12 ]
Uplifting [] best 91 combination zp[1]:9 [ cnt#12 ]
Allocated (was zp[1]:9) zp[1]:2 [ cnt#12 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
.label cnt = 2
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
// [5] call inccnt
// [17] phi from main to inccnt [phi:main->inccnt]
inccnt_from_main:
// [17] phi (byte) cnt3#10 = (byte) 0 [phi:main->inccnt#0] -- vbuxx=vbuc1
ldx #0
// [17] phi (byte) cnt2#10 = (byte) 0 [phi:main->inccnt#1] -- vbuyy=vbuc1
ldy #0
// [17] phi (byte) cnt#11 = (byte) 0 [phi:main->inccnt#2] -- vbuaa=vbuc1
lda #0
jsr inccnt
// [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2
jmp __b1
// main::@1
__b1:
// [7] (byte~) main::$0 ← (byte) inccnt::return#0
// [8] *((const byte*) SCREEN) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa
sta SCREEN
// [9] (byte) cnt#2 ← ++ (byte) cnt#12 -- vbuaa=_inc_vbuz1
lda.z cnt
clc
adc #1
// [10] call inccnt
// [17] phi from main::@1 to inccnt [phi:main::@1->inccnt]
inccnt_from___b1:
// [17] phi (byte) cnt3#10 = (byte) cnt3#11 [phi:main::@1->inccnt#0] -- register_copy
// [17] phi (byte) cnt2#10 = (byte) cnt2#11 [phi:main::@1->inccnt#1] -- register_copy
// [17] phi (byte) cnt#11 = (byte) cnt#2 [phi:main::@1->inccnt#2] -- register_copy
jsr inccnt
// [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2
jmp __b2
// main::@2
__b2:
// [12] (byte~) main::$1 ← (byte) inccnt::return#1
// [13] *((const byte*) SCREEN+(byte) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuaa
sta SCREEN+1
// [14] *((const byte*) SCREEN+(byte) 2) ← (byte) cnt2#11 -- _deref_pbuc1=vbuyy
sty SCREEN+2
// [15] *((const byte*) SCREEN+(byte) 3) ← (byte) cnt3#11 -- _deref_pbuc1=vbuxx
stx SCREEN+3
jmp __breturn
// main::@return
__breturn:
// [16] return
rts
}
// inccnt
inccnt: {
// [18] (byte) cnt#12 ← ++ (byte) cnt#11 -- vbuz1=_inc_vbuaa
clc
adc #1
sta.z cnt
// [19] (byte) cnt2#11 ← ++ (byte) cnt2#10 -- vbuyy=_inc_vbuyy
iny
// [20] (byte) cnt3#11 ← ++ (byte) cnt3#10 -- vbuxx=_inc_vbuxx
inx
// [21] (byte) inccnt::return#2 ← (byte) cnt#12 -- vbuaa=vbuz1
lda.z cnt
jmp __breturn
// inccnt::@return
__breturn:
// [22] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction lda #0 with TXA
Removing instruction lda.z cnt
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b1_from___bbegin:
Removing instruction __b1:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bbegin:
Removing instruction __bend:
Removing instruction inccnt_from_main:
Removing instruction __b1:
Removing instruction inccnt_from___b1:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN[(number) $100] = (byte*) 1024
(byte) cnt
(byte) cnt#11 reg byte a 112.0
(byte) cnt#12 cnt zp[1]:2 23.666666666666664
(byte) cnt#2 reg byte a 22.0
(byte) cnt2
(byte) cnt2#10 reg byte y 56.0
(byte) cnt2#11 reg byte y 9.461538461538462
(byte) cnt3
(byte) cnt3#10 reg byte x 37.33333333333333
(byte) cnt3#11 reg byte x 9.461538461538462
(byte()) inccnt()
(label) inccnt::@return
(byte) inccnt::return
(byte) inccnt::return#0 reg byte a 22.0
(byte) inccnt::return#1 reg byte a 22.0
(byte) inccnt::return#2 reg byte a 30.75
(void()) main()
(byte~) main::$0 reg byte a 22.0
(byte~) main::$1 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@return
reg byte a [ cnt#11 cnt#2 ]
reg byte y [ cnt2#10 cnt2#11 ]
reg byte x [ cnt3#10 cnt3#11 ]
reg byte a [ inccnt::return#0 ]
reg byte a [ main::$0 ]
reg byte a [ inccnt::return#1 ]
reg byte a [ main::$1 ]
zp[1]:2 [ cnt#12 ]
reg byte a [ inccnt::return#2 ]
FINAL ASSEMBLER
Score: 64
// File Comments
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
.label cnt = 2
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// inccnt()
// [5] call inccnt
// [17] phi from main to inccnt [phi:main->inccnt]
// [17] phi (byte) cnt3#10 = (byte) 0 [phi:main->inccnt#0] -- vbuxx=vbuc1
ldx #0
// [17] phi (byte) cnt2#10 = (byte) 0 [phi:main->inccnt#1] -- vbuyy=vbuc1
ldy #0
// [17] phi (byte) cnt#11 = (byte) 0 [phi:main->inccnt#2] -- vbuaa=vbuc1
txa
jsr inccnt
// inccnt()
// [6] (byte) inccnt::return#0 ← (byte) inccnt::return#2
// main::@1
// [7] (byte~) main::$0 ← (byte) inccnt::return#0
// SCREEN[0]=inccnt()
// [8] *((const byte*) SCREEN) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa
sta SCREEN
// cnt++;
// [9] (byte) cnt#2 ← ++ (byte) cnt#12 -- vbuaa=_inc_vbuz1
lda.z cnt
clc
adc #1
// inccnt()
// [10] call inccnt
// [17] phi from main::@1 to inccnt [phi:main::@1->inccnt]
// [17] phi (byte) cnt3#10 = (byte) cnt3#11 [phi:main::@1->inccnt#0] -- register_copy
// [17] phi (byte) cnt2#10 = (byte) cnt2#11 [phi:main::@1->inccnt#1] -- register_copy
// [17] phi (byte) cnt#11 = (byte) cnt#2 [phi:main::@1->inccnt#2] -- register_copy
jsr inccnt
// inccnt()
// [11] (byte) inccnt::return#1 ← (byte) inccnt::return#2
// main::@2
// [12] (byte~) main::$1 ← (byte) inccnt::return#1
// SCREEN[1]=inccnt()
// [13] *((const byte*) SCREEN+(byte) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuaa
sta SCREEN+1
// SCREEN[2]=cnt2
// [14] *((const byte*) SCREEN+(byte) 2) ← (byte) cnt2#11 -- _deref_pbuc1=vbuyy
sty SCREEN+2
// SCREEN[3]=cnt3
// [15] *((const byte*) SCREEN+(byte) 3) ← (byte) cnt3#11 -- _deref_pbuc1=vbuxx
stx SCREEN+3
// main::@return
// }
// [16] return
rts
}
// inccnt
inccnt: {
// ++cnt;
// [18] (byte) cnt#12 ← ++ (byte) cnt#11 -- vbuz1=_inc_vbuaa
clc
adc #1
sta.z cnt
// ++cnt2;
// [19] (byte) cnt2#11 ← ++ (byte) cnt2#10 -- vbuyy=_inc_vbuyy
iny
// ++cnt3;
// [20] (byte) cnt3#11 ← ++ (byte) cnt3#10 -- vbuxx=_inc_vbuxx
inx
// return cnt;
// [21] (byte) inccnt::return#2 ← (byte) cnt#12 -- vbuaa=vbuz1
// inccnt::@return
// }
// [22] return
rts
}
// File Data