1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-16 21:07:56 +00:00
kickc/src/test/ref/liverange-4.log

840 lines
27 KiB
Plaintext
Raw Normal View History

CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
(void()) main()
main: scope:[main] from @1
(byte) main::a#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@5
(byte) main::a#7 ← phi( main/(byte) main::a#0 main::@5/(byte) main::a#1 )
(byte) main::b#0 ← (byte) 0
to:main::@2
main::@2: scope:[main] from main::@1 main::@4
(byte) main::b#4 ← phi( main::@1/(byte) main::b#0 main::@4/(byte) main::b#1 )
(byte) main::a#4 ← phi( main::@1/(byte) main::a#7 main::@4/(byte) main::a#6 )
(byte) main::c#0 ← (byte) 0
to:main::@3
main::@3: scope:[main] from main::@2 main::@6
(byte) main::b#2 ← phi( main::@2/(byte) main::b#4 main::@6/(byte) main::b#5 )
(byte) main::a#2 ← phi( main::@2/(byte) main::a#4 main::@6/(byte) main::a#5 )
(byte) main::c#2 ← phi( main::@2/(byte) main::c#0 main::@6/(byte) main::c#1 )
(byte~) main::$0 ← (byte) main::c#2 + (byte) main::a#2
(byte) main::ca#0 ← (byte~) main::$0
(byte) print::b#0 ← (byte) main::b#2
(byte) print::ca#0 ← (byte) main::ca#0
call print
to:main::@6
main::@6: scope:[main] from main::@3
(byte) main::b#5 ← phi( main::@3/(byte) main::b#2 )
(byte) main::a#5 ← phi( main::@3/(byte) main::a#2 )
(byte) main::c#3 ← phi( main::@3/(byte) main::c#2 )
(byte) main::c#1 ← (byte) main::c#3 + rangenext(0,$64)
(bool~) main::$2 ← (byte) main::c#1 != rangelast(0,$64)
if((bool~) main::$2) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@6
(byte) main::a#6 ← phi( main::@6/(byte) main::a#5 )
(byte) main::b#3 ← phi( main::@6/(byte) main::b#5 )
(byte) main::b#1 ← (byte) main::b#3 + rangenext(0,$64)
(bool~) main::$3 ← (byte) main::b#1 != rangelast(0,$64)
if((bool~) main::$3) goto main::@2
to:main::@5
main::@5: scope:[main] from main::@4
(byte) main::a#3 ← phi( main::@4/(byte) main::a#6 )
(byte) main::a#1 ← (byte) main::a#3 + rangenext(0,$64)
(bool~) main::$4 ← (byte) main::a#1 != rangelast(0,$64)
if((bool~) main::$4) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@5
return
to:@return
(void()) print((byte) print::b , (byte) print::ca)
print: scope:[print] from main::@3
(byte) print::ca#1 ← phi( main::@3/(byte) print::ca#0 )
(byte) print::b#1 ← phi( main::@3/(byte) print::b#0 )
(byte) out::b#0 ← (byte) print::b#1
(byte) out::ca#0 ← (byte) print::ca#1
call out
to:print::@1
print::@1: scope:[print] from print
to:print::@return
print::@return: scope:[print] from print::@1
return
to:@return
(void()) out((byte) out::b , (byte) out::ca)
out: scope:[out] from print
(byte) out::b#1 ← phi( print/(byte) out::b#0 )
(byte) out::ca#1 ← phi( print/(byte) out::ca#0 )
*((const nomodify byte*) SCREEN + (byte) out::b#1) ← (byte) out::ca#1
to:out::@return
out::@return: scope:[out] from out
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
(const nomodify byte*) SCREEN = (byte*)(number) $400
(void()) main()
(byte~) main::$0
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte) main::a
(byte) main::a#0
(byte) main::a#1
(byte) main::a#2
(byte) main::a#3
(byte) main::a#4
(byte) main::a#5
(byte) main::a#6
(byte) main::a#7
(byte) main::b
(byte) main::b#0
(byte) main::b#1
(byte) main::b#2
(byte) main::b#3
(byte) main::b#4
(byte) main::b#5
(byte) main::c
(byte) main::c#0
(byte) main::c#1
(byte) main::c#2
(byte) main::c#3
(byte) main::ca
(byte) main::ca#0
(void()) out((byte) out::b , (byte) out::ca)
(label) out::@return
(byte) out::b
(byte) out::b#0
(byte) out::b#1
(byte) out::ca
(byte) out::ca#0
(byte) out::ca#1
(void()) print((byte) print::b , (byte) print::ca)
(label) print::@1
(label) print::@return
(byte) print::b
(byte) print::b#0
(byte) print::b#1
(byte) print::ca
(byte) print::ca#0
(byte) print::ca#1
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Alias main::ca#0 = main::$0
Alias main::c#2 = main::c#3
Alias main::a#2 = main::a#5 main::a#6 main::a#3
Alias main::b#2 = main::b#5 main::b#3
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::a#2 (byte) main::a#4
Identical Phi Values (byte) main::b#2 (byte) main::b#4
Identical Phi Values (byte) print::b#1 (byte) print::b#0
Identical Phi Values (byte) print::ca#1 (byte) print::ca#0
Identical Phi Values (byte) out::ca#1 (byte) out::ca#0
Identical Phi Values (byte) out::b#1 (byte) out::b#0
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values (byte) main::a#4 (byte) main::a#7
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$2 [12] if((byte) main::c#1!=rangelast(0,$64)) goto main::@3
Simple Condition (bool~) main::$3 [15] if((byte) main::b#1!=rangelast(0,$64)) goto main::@2
Simple Condition (bool~) main::$4 [18] if((byte) main::a#1!=rangelast(0,$64)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::a#0 = 0
Constant (const byte) main::b#0 = 0
Constant (const byte) main::c#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [10] main::c#1 ← ++ main::c#2 to ++
Resolved ranged comparison value [12] if(main::c#1!=rangelast(0,$64)) goto main::@3 to (number) $65
Resolved ranged next value [13] main::b#1 ← ++ main::b#4 to ++
Resolved ranged comparison value [15] if(main::b#1!=rangelast(0,$64)) goto main::@2 to (number) $65
Resolved ranged next value [16] main::a#1 ← ++ main::a#7 to ++
Resolved ranged comparison value [18] if(main::a#1!=rangelast(0,$64)) goto main::@1 to (number) $65
Adding number conversion cast (unumber) $65 in if((byte) main::c#1!=(number) $65) goto main::@3
Adding number conversion cast (unumber) $65 in if((byte) main::b#1!=(number) $65) goto main::@2
Adding number conversion cast (unumber) $65 in if((byte) main::a#1!=(number) $65) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $65
Simplifying constant integer cast $65
Simplifying constant integer cast $65
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $65
Finalized unsigned number type (byte) $65
Finalized unsigned number type (byte) $65
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const byte) main::a#0
Inlining constant with var siblings (const byte) main::b#0
Inlining constant with var siblings (const byte) main::c#0
Constant inlined main::a#0 = (byte) 0
Constant inlined main::c#0 = (byte) 0
Constant inlined main::b#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@7(between main::@5 and main::@1)
Added new block during phi lifting main::@8(between main::@4 and main::@2)
Added new block during phi lifting main::@9(between main::@6 and main::@3)
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
Adding NOP phi() at start of print::@1
CALL GRAPH
Calls in [] to main:2
Calls in [main] to print:12
Calls in [print] to out:25
Created 3 initial phi equivalence classes
Coalesced [20] main::a#8 ← main::a#1
Coalesced [21] main::b#6 ← main::b#1
Coalesced [22] main::c#4 ← main::c#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
Culled Empty Block (label) main::@9
Culled Empty Block (label) print::@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
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()
to:main::@1
main::@1: scope:[main] from main main::@5
[5] (byte) main::a#7 ← phi( main/(byte) 0 main::@5/(byte) main::a#1 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@4
[6] (byte) main::b#4 ← phi( main::@1/(byte) 0 main::@4/(byte) main::b#1 )
to:main::@3
main::@3: scope:[main] from main::@2 main::@6
[7] (byte) main::c#2 ← phi( main::@2/(byte) 0 main::@6/(byte) main::c#1 )
[8] (byte) main::ca#0 ← (byte) main::c#2 + (byte) main::a#7
[9] (byte) print::b#0 ← (byte) main::b#4
[10] (byte) print::ca#0 ← (byte) main::ca#0
[11] call print
to:main::@6
main::@6: scope:[main] from main::@3
[12] (byte) main::c#1 ← ++ (byte) main::c#2
[13] if((byte) main::c#1!=(byte) $65) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@6
[14] (byte) main::b#1 ← ++ (byte) main::b#4
[15] if((byte) main::b#1!=(byte) $65) goto main::@2
to:main::@5
main::@5: scope:[main] from main::@4
[16] (byte) main::a#1 ← ++ (byte) main::a#7
[17] if((byte) main::a#1!=(byte) $65) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@5
[18] return
to:@return
(void()) print((byte) print::b , (byte) print::ca)
print: scope:[print] from main::@3
[19] (byte) out::b#0 ← (byte) print::b#0
[20] (byte) out::ca#0 ← (byte) print::ca#0
[21] call out
to:print::@return
print::@return: scope:[print] from print
[22] return
to:@return
(void()) out((byte) out::b , (byte) out::ca)
out: scope:[out] from print
[23] *((const nomodify byte*) SCREEN + (byte) out::b#0) ← (byte) out::ca#0
to:out::@return
out::@return: scope:[out] from out
[24] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::a
(byte) main::a#1 151.5
(byte) main::a#7 927.5454545454544
(byte) main::b
(byte) main::b#1 1501.5
(byte) main::b#4 1500.375
(byte) main::c
(byte) main::c#1 15001.5
(byte) main::c#2 6000.6
(byte) main::ca
(byte) main::ca#0 10001.0
(void()) out((byte) out::b , (byte) out::ca)
(byte) out::b
(byte) out::b#0 550001.0
(byte) out::ca
(byte) out::ca#0 1100002.0
(void()) print((byte) print::b , (byte) print::ca)
(byte) print::b
(byte) print::b#0 55001.0
(byte) print::ca
(byte) print::ca#0 55001.0
Initial phi equivalence classes
[ main::a#7 main::a#1 ]
[ main::b#4 main::b#1 ]
[ main::c#2 main::c#1 ]
Added variable main::ca#0 to live range equivalence class [ main::ca#0 ]
Added variable print::b#0 to live range equivalence class [ print::b#0 ]
Added variable print::ca#0 to live range equivalence class [ print::ca#0 ]
Added variable out::b#0 to live range equivalence class [ out::b#0 ]
Added variable out::ca#0 to live range equivalence class [ out::ca#0 ]
Complete equivalence classes
[ main::a#7 main::a#1 ]
[ main::b#4 main::b#1 ]
[ main::c#2 main::c#1 ]
[ main::ca#0 ]
[ print::b#0 ]
[ print::ca#0 ]
[ out::b#0 ]
[ out::ca#0 ]
Allocated zp[1]:2 [ main::a#7 main::a#1 ]
Allocated zp[1]:3 [ main::b#4 main::b#1 ]
Allocated zp[1]:4 [ main::c#2 main::c#1 ]
Allocated zp[1]:5 [ main::ca#0 ]
Allocated zp[1]:6 [ print::b#0 ]
Allocated zp[1]:7 [ print::ca#0 ]
Allocated zp[1]:8 [ out::b#0 ]
Allocated zp[1]:9 [ out::ca#0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test effective live range and register allocation
// Here out::b, print::b and main::b can have the same allocation
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @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 ca = 5
.label c = 4
.label b = 3
.label a = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte) main::a#7 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #0
sta.z a
jmp __b1
// [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
__b1_from___b5:
// [5] phi (byte) main::a#7 = (byte) main::a#1 [phi:main::@5->main::@1#0] -- register_copy
jmp __b1
// main::@1
__b1:
// [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
__b2_from___b1:
// [6] phi (byte) main::b#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1
lda #0
sta.z b
jmp __b2
// [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
__b2_from___b4:
// [6] phi (byte) main::b#4 = (byte) main::b#1 [phi:main::@4->main::@2#0] -- register_copy
jmp __b2
// main::@2
__b2:
// [7] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
__b3_from___b2:
// [7] phi (byte) main::c#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuz1=vbuc1
lda #0
sta.z c
jmp __b3
// [7] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
__b3_from___b6:
// [7] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@6->main::@3#0] -- register_copy
jmp __b3
// main::@3
__b3:
// [8] (byte) main::ca#0 ← (byte) main::c#2 + (byte) main::a#7 -- vbuz1=vbuz2_plus_vbuz3
lda.z c
clc
adc.z a
sta.z ca
// [9] (byte) print::b#0 ← (byte) main::b#4 -- vbuz1=vbuz2
lda.z b
sta.z print.b
// [10] (byte) print::ca#0 ← (byte) main::ca#0 -- vbuz1=vbuz2
lda.z ca
sta.z print.ca
// [11] call print
jsr print
jmp __b6
// main::@6
__b6:
// [12] (byte) main::c#1 ← ++ (byte) main::c#2 -- vbuz1=_inc_vbuz1
inc.z c
// [13] if((byte) main::c#1!=(byte) $65) goto main::@3 -- vbuz1_neq_vbuc1_then_la1
lda #$65
cmp.z c
bne __b3_from___b6
jmp __b4
// main::@4
__b4:
// [14] (byte) main::b#1 ← ++ (byte) main::b#4 -- vbuz1=_inc_vbuz1
inc.z b
// [15] if((byte) main::b#1!=(byte) $65) goto main::@2 -- vbuz1_neq_vbuc1_then_la1
lda #$65
cmp.z b
bne __b2_from___b4
jmp __b5
// main::@5
__b5:
// [16] (byte) main::a#1 ← ++ (byte) main::a#7 -- vbuz1=_inc_vbuz1
inc.z a
// [17] if((byte) main::a#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$65
cmp.z a
bne __b1_from___b5
jmp __breturn
// main::@return
__breturn:
// [18] return
rts
}
// print
// print(byte zp(6) b, byte zp(7) ca)
print: {
.label b = 6
.label ca = 7
// [19] (byte) out::b#0 ← (byte) print::b#0 -- vbuz1=vbuz2
lda.z b
sta.z out.b
// [20] (byte) out::ca#0 ← (byte) print::ca#0 -- vbuz1=vbuz2
lda.z ca
sta.z out.ca
// [21] call out
jsr out
jmp __breturn
// print::@return
__breturn:
// [22] return
rts
}
// out
// out(byte zp(8) b, byte zp(9) ca)
out: {
.label b = 8
.label ca = 9
// [23] *((const nomodify byte*) SCREEN + (byte) out::b#0) ← (byte) out::ca#0 -- pbuc1_derefidx_vbuz1=vbuz2
lda.z ca
ldy.z b
sta SCREEN,y
jmp __breturn
// out::@return
__breturn:
// [24] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [8] (byte) main::ca#0 ← (byte) main::c#2 + (byte) main::a#7 [ main::a#7 main::b#4 main::c#2 main::ca#0 ] ( main:2 [ main::a#7 main::b#4 main::c#2 main::ca#0 ] { { print::b#0 = main::b#4 } { print::ca#0 = main::ca#0 } } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::a#7 main::a#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::b#4 main::b#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::c#2 main::c#1 ]
Statement [8] (byte) main::ca#0 ← (byte) main::c#2 + (byte) main::a#7 [ main::a#7 main::b#4 main::c#2 main::ca#0 ] ( main:2 [ main::a#7 main::b#4 main::c#2 main::ca#0 ] { { print::b#0 = main::b#4 } { print::ca#0 = main::ca#0 } } ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::a#7 main::a#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ main::b#4 main::b#1 ] : zp[1]:3 , reg byte x , reg byte y ,
Potential registers zp[1]:4 [ main::c#2 main::c#1 ] : zp[1]:4 , reg byte x , reg byte y ,
Potential registers zp[1]:5 [ main::ca#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:6 [ print::b#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:7 [ print::ca#0 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:8 [ out::b#0 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:9 [ out::ca#0 ] : zp[1]:9 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [out] 1,100,002: zp[1]:9 [ out::ca#0 ] 550,001: zp[1]:8 [ out::b#0 ]
Uplift Scope [print] 55,001: zp[1]:6 [ print::b#0 ] 55,001: zp[1]:7 [ print::ca#0 ]
Uplift Scope [main] 21,002.1: zp[1]:4 [ main::c#2 main::c#1 ] 10,001: zp[1]:5 [ main::ca#0 ] 3,001.88: zp[1]:3 [ main::b#4 main::b#1 ] 1,079.05: zp[1]:2 [ main::a#7 main::a#1 ]
Uplift Scope []
Uplifting [out] best 61468 combination reg byte a [ out::ca#0 ] reg byte x [ out::b#0 ]
Uplifting [print] best 55462 combination reg byte x [ print::b#0 ] reg byte a [ print::ca#0 ]
Uplifting [main] best 35562 combination reg byte y [ main::c#2 main::c#1 ] reg byte a [ main::ca#0 ] reg byte x [ main::b#4 main::b#1 ] zp[1]:2 [ main::a#7 main::a#1 ]
Limited combination testing to 100 combinations of 108 possible.
Uplifting [] best 35562 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::a#7 main::a#1 ]
Uplifting [main] best 35562 combination zp[1]:2 [ main::a#7 main::a#1 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test effective live range and register allocation
// Here out::b, print::b and main::b can have the same allocation
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @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 a = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte) main::a#7 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #0
sta.z a
jmp __b1
// [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
__b1_from___b5:
// [5] phi (byte) main::a#7 = (byte) main::a#1 [phi:main::@5->main::@1#0] -- register_copy
jmp __b1
// main::@1
__b1:
// [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
__b2_from___b1:
// [6] phi (byte) main::b#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1
ldx #0
jmp __b2
// [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
__b2_from___b4:
// [6] phi (byte) main::b#4 = (byte) main::b#1 [phi:main::@4->main::@2#0] -- register_copy
jmp __b2
// main::@2
__b2:
// [7] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
__b3_from___b2:
// [7] phi (byte) main::c#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuyy=vbuc1
ldy #0
jmp __b3
// [7] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
__b3_from___b6:
// [7] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@6->main::@3#0] -- register_copy
jmp __b3
// main::@3
__b3:
// [8] (byte) main::ca#0 ← (byte) main::c#2 + (byte) main::a#7 -- vbuaa=vbuyy_plus_vbuz1
tya
clc
adc.z a
// [9] (byte) print::b#0 ← (byte) main::b#4
// [10] (byte) print::ca#0 ← (byte) main::ca#0
// [11] call print
jsr print
jmp __b6
// main::@6
__b6:
// [12] (byte) main::c#1 ← ++ (byte) main::c#2 -- vbuyy=_inc_vbuyy
iny
// [13] if((byte) main::c#1!=(byte) $65) goto main::@3 -- vbuyy_neq_vbuc1_then_la1
cpy #$65
bne __b3_from___b6
jmp __b4
// main::@4
__b4:
// [14] (byte) main::b#1 ← ++ (byte) main::b#4 -- vbuxx=_inc_vbuxx
inx
// [15] if((byte) main::b#1!=(byte) $65) goto main::@2 -- vbuxx_neq_vbuc1_then_la1
cpx #$65
bne __b2_from___b4
jmp __b5
// main::@5
__b5:
// [16] (byte) main::a#1 ← ++ (byte) main::a#7 -- vbuz1=_inc_vbuz1
inc.z a
// [17] if((byte) main::a#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$65
cmp.z a
bne __b1_from___b5
jmp __breturn
// main::@return
__breturn:
// [18] return
rts
}
// print
// print(byte register(X) b, byte register(A) ca)
print: {
// [19] (byte) out::b#0 ← (byte) print::b#0
// [20] (byte) out::ca#0 ← (byte) print::ca#0
// [21] call out
jsr out
jmp __breturn
// print::@return
__breturn:
// [22] return
rts
}
// out
// out(byte register(X) b, byte register(A) ca)
out: {
// [23] *((const nomodify byte*) SCREEN + (byte) out::b#0) ← (byte) out::ca#0 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN,x
jmp __breturn
// out::@return
__breturn:
// [24] 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 __b3
Removing instruction jmp __b6
Removing instruction jmp __b4
Removing instruction jmp __b5
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b3_from___b6 with __b3
Replacing label __b2_from___b4 with __b2
Replacing label __b1_from___b5 with __b1
Removing instruction __b1_from___bbegin:
Removing instruction __b1:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b5:
Removing instruction __b2_from___b1:
Removing instruction __b2_from___b4:
Removing instruction __b3_from___b2:
Removing instruction __b3_from___b6:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bbegin:
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b6:
Removing instruction __b4:
Removing instruction __b5:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const nomodify byte*) SCREEN = (byte*) 1024
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte) main::a
(byte) main::a#1 a zp[1]:2 151.5
(byte) main::a#7 a zp[1]:2 927.5454545454544
(byte) main::b
(byte) main::b#1 reg byte x 1501.5
(byte) main::b#4 reg byte x 1500.375
(byte) main::c
(byte) main::c#1 reg byte y 15001.5
(byte) main::c#2 reg byte y 6000.6
(byte) main::ca
(byte) main::ca#0 reg byte a 10001.0
(void()) out((byte) out::b , (byte) out::ca)
(label) out::@return
(byte) out::b
(byte) out::b#0 reg byte x 550001.0
(byte) out::ca
(byte) out::ca#0 reg byte a 1100002.0
(void()) print((byte) print::b , (byte) print::ca)
(label) print::@return
(byte) print::b
(byte) print::b#0 reg byte x 55001.0
(byte) print::ca
(byte) print::ca#0 reg byte a 55001.0
zp[1]:2 [ main::a#7 main::a#1 ]
reg byte x [ main::b#4 main::b#1 ]
reg byte y [ main::c#2 main::c#1 ]
reg byte a [ main::ca#0 ]
reg byte x [ print::b#0 ]
reg byte a [ print::ca#0 ]
reg byte x [ out::b#0 ]
reg byte a [ out::ca#0 ]
FINAL ASSEMBLER
Score: 22554
// File Comments
// Test effective live range and register allocation
// Here out::b, print::b and main::b can have the same allocation
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @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: {
.label a = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (byte) main::a#7 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #0
sta.z a
// [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
// [5] phi (byte) main::a#7 = (byte) main::a#1 [phi:main::@5->main::@1#0] -- register_copy
// main::@1
__b1:
// [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
// [6] phi (byte) main::b#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1
ldx #0
// [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
// [6] phi (byte) main::b#4 = (byte) main::b#1 [phi:main::@4->main::@2#0] -- register_copy
// main::@2
__b2:
// [7] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
// [7] phi (byte) main::c#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuyy=vbuc1
ldy #0
// [7] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
// [7] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@6->main::@3#0] -- register_copy
// main::@3
__b3:
// ca = c+a
// [8] (byte) main::ca#0 ← (byte) main::c#2 + (byte) main::a#7 -- vbuaa=vbuyy_plus_vbuz1
tya
clc
adc.z a
// print(b, ca)
// [9] (byte) print::b#0 ← (byte) main::b#4
// [10] (byte) print::ca#0 ← (byte) main::ca#0
// [11] call print
jsr print
// main::@6
// for( char c: 0..100 )
// [12] (byte) main::c#1 ← ++ (byte) main::c#2 -- vbuyy=_inc_vbuyy
iny
// [13] if((byte) main::c#1!=(byte) $65) goto main::@3 -- vbuyy_neq_vbuc1_then_la1
cpy #$65
bne __b3
// main::@4
// for( char b: 0..100 )
// [14] (byte) main::b#1 ← ++ (byte) main::b#4 -- vbuxx=_inc_vbuxx
inx
// [15] if((byte) main::b#1!=(byte) $65) goto main::@2 -- vbuxx_neq_vbuc1_then_la1
cpx #$65
bne __b2
// main::@5
// for(char a: 0..100 )
// [16] (byte) main::a#1 ← ++ (byte) main::a#7 -- vbuz1=_inc_vbuz1
inc.z a
// [17] if((byte) main::a#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$65
cmp.z a
bne __b1
// main::@return
// }
// [18] return
rts
}
// print
// print(byte register(X) b, byte register(A) ca)
print: {
// out(b, ca)
// [19] (byte) out::b#0 ← (byte) print::b#0
// [20] (byte) out::ca#0 ← (byte) print::ca#0
// [21] call out
jsr out
// print::@return
// }
// [22] return
rts
}
// out
// out(byte register(X) b, byte register(A) ca)
out: {
// SCREEN[b] = ca
// [23] *((const nomodify byte*) SCREEN + (byte) out::b#0) ← (byte) out::ca#0 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN,x
// out::@return
// }
// [24] return
rts
}
// File Data