mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-09 08:54:40 +00:00
784 lines
25 KiB
Plaintext
784 lines
25 KiB
Plaintext
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@1
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
(byte) main::i#0 ← (byte) 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 )
|
|
*((const nomodify byte*) plots + (byte) main::i#2) ← (byte) main::i#2
|
|
*((const nomodify byte*) SCREEN + (byte) main::i#2) ← (number) 0
|
|
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$27)
|
|
(bool~) main::$0 ← (byte) main::i#1 != rangelast(0,$27)
|
|
if((bool~) main::$0) goto main::@1
|
|
to:main::@2
|
|
main::@2: scope:[main] from main::@1 main::@3
|
|
(byte) line::x0#0 ← (number) 0
|
|
(byte) line::x1#0 ← (number) $a
|
|
call line
|
|
to:main::@3
|
|
main::@3: scope:[main] from main::@2
|
|
if(true) goto main::@2
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@3
|
|
return
|
|
to:@return
|
|
|
|
(void()) line((byte) line::x0 , (byte) line::x1)
|
|
line: scope:[line] from main::@2
|
|
(byte) line::x1#1 ← phi( main::@2/(byte) line::x1#0 )
|
|
(byte) line::x0#1 ← phi( main::@2/(byte) line::x0#0 )
|
|
(bool~) line::$0 ← (byte) line::x0#1 < (byte) line::x1#1
|
|
if((bool~) line::$0) goto line::@1
|
|
to:line::@2
|
|
line::@1: scope:[line] from line
|
|
(byte) line::x1#3 ← phi( line/(byte) line::x1#1 )
|
|
(byte) line::x0#2 ← phi( line/(byte) line::x0#1 )
|
|
(byte) line::x#0 ← (byte) line::x0#2
|
|
to:line::@3
|
|
line::@2: scope:[line] from line
|
|
(byte) line::x0#3 ← phi( line/(byte) line::x0#1 )
|
|
(byte) plot::x#0 ← (byte) line::x0#3
|
|
call plot
|
|
to:line::@5
|
|
line::@5: scope:[line] from line::@2
|
|
to:line::@return
|
|
line::@3: scope:[line] from line::@1 line::@6
|
|
(byte) line::x1#2 ← phi( line::@1/(byte) line::x1#3 line::@6/(byte) line::x1#4 )
|
|
(byte) line::x#2 ← phi( line::@1/(byte) line::x#0 line::@6/(byte) line::x#1 )
|
|
(bool~) line::$2 ← (byte) line::x#2 <= (byte) line::x1#2
|
|
if((bool~) line::$2) goto line::@4
|
|
to:line::@return
|
|
line::@4: scope:[line] from line::@3
|
|
(byte) line::x1#5 ← phi( line::@3/(byte) line::x1#2 )
|
|
(byte) line::x#3 ← phi( line::@3/(byte) line::x#2 )
|
|
(byte) plot::x#1 ← (byte) line::x#3
|
|
call plot
|
|
to:line::@6
|
|
line::@6: scope:[line] from line::@4
|
|
(byte) line::x1#4 ← phi( line::@4/(byte) line::x1#5 )
|
|
(byte) line::x#4 ← phi( line::@4/(byte) line::x#3 )
|
|
(byte) line::x#1 ← ++ (byte) line::x#4
|
|
to:line::@3
|
|
line::@return: scope:[line] from line::@3 line::@5
|
|
return
|
|
to:@return
|
|
|
|
(void()) plot((byte) plot::x)
|
|
plot: scope:[plot] from line::@2 line::@4
|
|
(byte) plot::x#2 ← phi( line::@2/(byte) plot::x#0 line::@4/(byte) plot::x#1 )
|
|
(byte) plot::idx#0 ← *((const nomodify byte*) plots + (byte) plot::x#2)
|
|
(number~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (number) 1
|
|
*((const nomodify byte*) SCREEN + (byte) plot::idx#0) ← (number~) plot::$0
|
|
to:plot::@return
|
|
plot::@return: scope:[plot] from plot
|
|
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()) line((byte) line::x0 , (byte) line::x1)
|
|
(bool~) line::$0
|
|
(bool~) line::$2
|
|
(label) line::@1
|
|
(label) line::@2
|
|
(label) line::@3
|
|
(label) line::@4
|
|
(label) line::@5
|
|
(label) line::@6
|
|
(label) line::@return
|
|
(byte) line::x
|
|
(byte) line::x#0
|
|
(byte) line::x#1
|
|
(byte) line::x#2
|
|
(byte) line::x#3
|
|
(byte) line::x#4
|
|
(byte) line::x0
|
|
(byte) line::x0#0
|
|
(byte) line::x0#1
|
|
(byte) line::x0#2
|
|
(byte) line::x0#3
|
|
(byte) line::x1
|
|
(byte) line::x1#0
|
|
(byte) line::x1#1
|
|
(byte) line::x1#2
|
|
(byte) line::x1#3
|
|
(byte) line::x1#4
|
|
(byte) line::x1#5
|
|
(void()) main()
|
|
(bool~) main::$0
|
|
(label) main::@1
|
|
(label) main::@2
|
|
(label) main::@3
|
|
(label) main::@return
|
|
(byte) main::i
|
|
(byte) main::i#0
|
|
(byte) main::i#1
|
|
(byte) main::i#2
|
|
(void()) plot((byte) plot::x)
|
|
(number~) plot::$0
|
|
(label) plot::@return
|
|
(byte) plot::idx
|
|
(byte) plot::idx#0
|
|
(byte) plot::x
|
|
(byte) plot::x#0
|
|
(byte) plot::x#1
|
|
(byte) plot::x#2
|
|
(const nomodify byte*) plots = (byte*)(number) $1000
|
|
|
|
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (number) 0
|
|
Adding number conversion cast (unumber) 0 in (byte) line::x0#0 ← (number) 0
|
|
Adding number conversion cast (unumber) $a in (byte) line::x1#0 ← (number) $a
|
|
Adding number conversion cast (unumber) 1 in (number~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (number) 1
|
|
Adding number conversion cast (unumber) plot::$0 in (number~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (unumber)(number) 1
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (unumber)(number) 0
|
|
Inlining cast (byte) line::x0#0 ← (unumber)(number) 0
|
|
Inlining cast (byte) line::x1#0 ← (unumber)(number) $a
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant pointer cast (byte*) 4096
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast $a
|
|
Simplifying constant integer cast 1
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) $a
|
|
Finalized unsigned number type (byte) 1
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Inferred type updated to byte in (unumber~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (byte) 1
|
|
Alias line::x0#1 = line::x0#2 line::x#0 line::x0#3
|
|
Alias line::x1#1 = line::x1#3
|
|
Alias line::x#2 = line::x#3 line::x#4
|
|
Alias line::x1#2 = line::x1#5 line::x1#4
|
|
Successful SSA optimization Pass2AliasElimination
|
|
Identical Phi Values (byte) line::x0#1 (byte) line::x0#0
|
|
Identical Phi Values (byte) line::x1#1 (byte) line::x1#0
|
|
Identical Phi Values (byte) line::x1#2 (byte) line::x1#1
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
|
Simple Condition (bool~) main::$0 [6] if((byte) main::i#1!=rangelast(0,$27)) goto main::@1
|
|
Simple Condition (bool~) line::$0 [14] if((byte) line::x0#0<(byte) line::x1#0) goto line::@1
|
|
Simple Condition (bool~) line::$2 [19] if((byte) line::x#2<=(byte) line::x1#0) goto line::@4
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
|
Constant (const byte) main::i#0 = 0
|
|
Constant (const byte) line::x0#0 = 0
|
|
Constant (const byte) line::x1#0 = $a
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant (const byte) plot::x#0 = line::x0#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
if() condition always true - replacing block destination [10] if(true) goto main::@2
|
|
if() condition always true - replacing block destination [14] if((const byte) line::x0#0<(const byte) line::x1#0) goto line::@1
|
|
Successful SSA optimization Pass2ConstantIfs
|
|
Resolved ranged next value [4] main::i#1 ← ++ main::i#2 to ++
|
|
Resolved ranged comparison value [6] if(main::i#1!=rangelast(0,$27)) goto main::@1 to (number) $28
|
|
Rewriting conditional comparison [19] if((byte) line::x#2<=(const byte) line::x1#0) goto line::@4
|
|
Removing unused block main::@return
|
|
Removing PHI-reference to removed block (line::@2) in block plot
|
|
Removing unused block line::@2
|
|
Removing unused block line::@5
|
|
Successful SSA optimization Pass2EliminateUnusedBlocks
|
|
Adding number conversion cast (unumber) $28 in if((byte) main::i#1!=(number) $28) goto main::@1
|
|
Adding number conversion cast (unumber) line::x1#0+1 in if((byte) line::x#2<(const byte) line::x1#0+(number) 1) goto line::@4
|
|
Adding number conversion cast (unumber) 1 in if((byte) line::x#2<(unumber)(const byte) line::x1#0+(number) 1) goto line::@4
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant integer cast $28
|
|
Simplifying constant integer cast (const byte) line::x1#0+(unumber)(number) 1
|
|
Simplifying constant integer cast 1
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) $28
|
|
Finalized unsigned number type (byte) 1
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Identical Phi Values (byte) plot::x#2 (byte) plot::x#1
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
|
Eliminating unused constant (const byte) plot::x#0
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Inlining constant with var siblings (const byte) main::i#0
|
|
Constant inlined main::i#0 = (byte) 0
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Added new block during phi lifting main::@4(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 @2
|
|
Adding NOP phi() at start of @end
|
|
Adding NOP phi() at start of main
|
|
Adding NOP phi() at start of main::@2
|
|
Adding NOP phi() at start of main::@3
|
|
Adding NOP phi() at start of line
|
|
Adding NOP phi() at start of line::@1
|
|
CALL GRAPH
|
|
Calls in [] to main:2
|
|
Calls in [main] to line:12
|
|
Calls in [line] to plot:21
|
|
|
|
Created 2 initial phi equivalence classes
|
|
Coalesced [14] main::i#3 ← main::i#1
|
|
Coalesced [23] line::x#5 ← line::x#1
|
|
Coalesced down to 2 phi equivalence classes
|
|
Culled Empty Block (label) @2
|
|
Culled Empty Block (label) main::@3
|
|
Culled Empty Block (label) main::@4
|
|
Culled Empty Block (label) line::@1
|
|
Renumbering block line::@3 to line::@1
|
|
Renumbering block line::@4 to line::@2
|
|
Renumbering block line::@6 to line::@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
|
|
Adding NOP phi() at start of main::@2
|
|
Adding NOP phi() at start of line
|
|
|
|
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::@1
|
|
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
|
[6] *((const nomodify byte*) plots + (byte) main::i#2) ← (byte) main::i#2
|
|
[7] *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (byte) 0
|
|
[8] (byte) main::i#1 ← ++ (byte) main::i#2
|
|
[9] if((byte) main::i#1!=(byte) $28) goto main::@1
|
|
to:main::@2
|
|
main::@2: scope:[main] from main::@1 main::@2
|
|
[10] phi()
|
|
[11] call line
|
|
to:main::@2
|
|
|
|
(void()) line((byte) line::x0 , (byte) line::x1)
|
|
line: scope:[line] from main::@2
|
|
[12] phi()
|
|
to:line::@1
|
|
line::@1: scope:[line] from line line::@3
|
|
[13] (byte) line::x#2 ← phi( line/(const byte) line::x0#0 line::@3/(byte) line::x#1 )
|
|
[14] if((byte) line::x#2<(const byte) line::x1#0+(byte) 1) goto line::@2
|
|
to:line::@return
|
|
line::@return: scope:[line] from line::@1
|
|
[15] return
|
|
to:@return
|
|
line::@2: scope:[line] from line::@1
|
|
[16] (byte) plot::x#1 ← (byte) line::x#2
|
|
[17] call plot
|
|
to:line::@3
|
|
line::@3: scope:[line] from line::@2
|
|
[18] (byte) line::x#1 ← ++ (byte) line::x#2
|
|
to:line::@1
|
|
|
|
(void()) plot((byte) plot::x)
|
|
plot: scope:[plot] from line::@2
|
|
[19] (byte) plot::idx#0 ← *((const nomodify byte*) plots + (byte) plot::x#1)
|
|
[20] (byte~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (byte) 1
|
|
[21] *((const nomodify byte*) SCREEN + (byte) plot::idx#0) ← (byte~) plot::$0
|
|
to:plot::@return
|
|
plot::@return: scope:[plot] from plot
|
|
[22] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(void()) line((byte) line::x0 , (byte) line::x1)
|
|
(byte) line::x
|
|
(byte) line::x#1 200002.0
|
|
(byte) line::x#2 100001.0
|
|
(byte) line::x0
|
|
(byte) line::x1
|
|
(void()) main()
|
|
(byte) main::i
|
|
(byte) main::i#1 151.5
|
|
(byte) main::i#2 168.33333333333331
|
|
(void()) plot((byte) plot::x)
|
|
(byte~) plot::$0 2000002.0
|
|
(byte) plot::idx
|
|
(byte) plot::idx#0 1500001.5
|
|
(byte) plot::x
|
|
(byte) plot::x#1 1100002.0
|
|
|
|
Initial phi equivalence classes
|
|
[ main::i#2 main::i#1 ]
|
|
[ line::x#2 line::x#1 ]
|
|
Added variable plot::x#1 to live range equivalence class [ plot::x#1 ]
|
|
Added variable plot::idx#0 to live range equivalence class [ plot::idx#0 ]
|
|
Added variable plot::$0 to live range equivalence class [ plot::$0 ]
|
|
Complete equivalence classes
|
|
[ main::i#2 main::i#1 ]
|
|
[ line::x#2 line::x#1 ]
|
|
[ plot::x#1 ]
|
|
[ plot::idx#0 ]
|
|
[ plot::$0 ]
|
|
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
|
|
Allocated zp[1]:3 [ line::x#2 line::x#1 ]
|
|
Allocated zp[1]:4 [ plot::x#1 ]
|
|
Allocated zp[1]:5 [ plot::idx#0 ]
|
|
Allocated zp[1]:6 [ plot::$0 ]
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.label plots = $1000
|
|
.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 i = 2
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
|
__b1_from_main:
|
|
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
|
lda #0
|
|
sta.z i
|
|
jmp __b1
|
|
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
|
__b1_from___b1:
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
|
jmp __b1
|
|
// main::@1
|
|
__b1:
|
|
// [6] *((const nomodify byte*) plots + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1
|
|
ldy.z i
|
|
tya
|
|
sta plots,y
|
|
// [7] *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (byte) 0 -- pbuc1_derefidx_vbuz1=vbuc2
|
|
lda #0
|
|
ldy.z i
|
|
sta SCREEN,y
|
|
// [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
|
inc.z i
|
|
// [9] if((byte) main::i#1!=(byte) $28) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
|
lda #$28
|
|
cmp.z i
|
|
bne __b1_from___b1
|
|
// [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
|
|
__b2_from___b1:
|
|
__b2_from___b2:
|
|
jmp __b2
|
|
// main::@2
|
|
__b2:
|
|
// [11] call line
|
|
// [12] phi from main::@2 to line [phi:main::@2->line]
|
|
line_from___b2:
|
|
jsr line
|
|
jmp __b2_from___b2
|
|
}
|
|
// line
|
|
line: {
|
|
.const x0 = 0
|
|
.const x1 = $a
|
|
.label x = 3
|
|
// [13] phi from line to line::@1 [phi:line->line::@1]
|
|
__b1_from_line:
|
|
// [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@1#0] -- vbuz1=vbuc1
|
|
lda #x0
|
|
sta.z x
|
|
jmp __b1
|
|
// line::@1
|
|
__b1:
|
|
// [14] if((byte) line::x#2<(const byte) line::x1#0+(byte) 1) goto line::@2 -- vbuz1_lt_vbuc1_then_la1
|
|
lda.z x
|
|
cmp #x1+1
|
|
bcc __b2
|
|
jmp __breturn
|
|
// line::@return
|
|
__breturn:
|
|
// [15] return
|
|
rts
|
|
// line::@2
|
|
__b2:
|
|
// [16] (byte) plot::x#1 ← (byte) line::x#2 -- vbuz1=vbuz2
|
|
lda.z x
|
|
sta.z plot.x
|
|
// [17] call plot
|
|
jsr plot
|
|
jmp __b3
|
|
// line::@3
|
|
__b3:
|
|
// [18] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuz1=_inc_vbuz1
|
|
inc.z x
|
|
// [13] phi from line::@3 to line::@1 [phi:line::@3->line::@1]
|
|
__b1_from___b3:
|
|
// [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@3->line::@1#0] -- register_copy
|
|
jmp __b1
|
|
}
|
|
// plot
|
|
// plot(byte zp(4) x)
|
|
plot: {
|
|
.label __0 = 6
|
|
.label x = 4
|
|
.label idx = 5
|
|
// [19] (byte) plot::idx#0 ← *((const nomodify byte*) plots + (byte) plot::x#1) -- vbuz1=pbuc1_derefidx_vbuz2
|
|
ldy.z x
|
|
lda plots,y
|
|
sta.z idx
|
|
// [20] (byte~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (byte) 1 -- vbuz1=pbuc1_derefidx_vbuz2_plus_1
|
|
ldx.z idx
|
|
ldy SCREEN,x
|
|
iny
|
|
sty.z __0
|
|
// [21] *((const nomodify byte*) SCREEN + (byte) plot::idx#0) ← (byte~) plot::$0 -- pbuc1_derefidx_vbuz1=vbuz2
|
|
lda.z __0
|
|
ldy.z idx
|
|
sta SCREEN,y
|
|
jmp __breturn
|
|
// plot::@return
|
|
__breturn:
|
|
// [22] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [7] *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (byte) 0 [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
|
|
Statement [6] *((const nomodify byte*) plots + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
Statement [7] *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (byte) 0 [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
|
|
Potential registers zp[1]:3 [ line::x#2 line::x#1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
|
|
Potential registers zp[1]:4 [ plot::x#1 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y ,
|
|
Potential registers zp[1]:5 [ plot::idx#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y ,
|
|
Potential registers zp[1]:6 [ plot::$0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [plot] 2,000,002: zp[1]:6 [ plot::$0 ] 1,500,001.5: zp[1]:5 [ plot::idx#0 ] 1,100,002: zp[1]:4 [ plot::x#1 ]
|
|
Uplift Scope [line] 300,003: zp[1]:3 [ line::x#2 line::x#1 ]
|
|
Uplift Scope [main] 319.83: zp[1]:2 [ main::i#2 main::i#1 ]
|
|
Uplift Scope []
|
|
|
|
Uplifting [plot] best 4368 combination reg byte a [ plot::$0 ] reg byte y [ plot::idx#0 ] reg byte x [ plot::x#1 ]
|
|
Uplifting [line] best 3168 combination reg byte x [ line::x#2 line::x#1 ]
|
|
Uplifting [main] best 3018 combination reg byte x [ main::i#2 main::i#1 ]
|
|
Uplifting [] best 3018 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.label plots = $1000
|
|
.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: {
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
|
__b1_from_main:
|
|
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
|
ldx #0
|
|
jmp __b1
|
|
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
|
__b1_from___b1:
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
|
jmp __b1
|
|
// main::@1
|
|
__b1:
|
|
// [6] *((const nomodify byte*) plots + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx
|
|
txa
|
|
sta plots,x
|
|
// [7] *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2
|
|
lda #0
|
|
sta SCREEN,x
|
|
// [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
|
inx
|
|
// [9] if((byte) main::i#1!=(byte) $28) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
|
cpx #$28
|
|
bne __b1_from___b1
|
|
// [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
|
|
__b2_from___b1:
|
|
__b2_from___b2:
|
|
jmp __b2
|
|
// main::@2
|
|
__b2:
|
|
// [11] call line
|
|
// [12] phi from main::@2 to line [phi:main::@2->line]
|
|
line_from___b2:
|
|
jsr line
|
|
jmp __b2_from___b2
|
|
}
|
|
// line
|
|
line: {
|
|
.const x0 = 0
|
|
.const x1 = $a
|
|
// [13] phi from line to line::@1 [phi:line->line::@1]
|
|
__b1_from_line:
|
|
// [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@1#0] -- vbuxx=vbuc1
|
|
ldx #x0
|
|
jmp __b1
|
|
// line::@1
|
|
__b1:
|
|
// [14] if((byte) line::x#2<(const byte) line::x1#0+(byte) 1) goto line::@2 -- vbuxx_lt_vbuc1_then_la1
|
|
cpx #x1+1
|
|
bcc __b2
|
|
jmp __breturn
|
|
// line::@return
|
|
__breturn:
|
|
// [15] return
|
|
rts
|
|
// line::@2
|
|
__b2:
|
|
// [16] (byte) plot::x#1 ← (byte) line::x#2
|
|
// [17] call plot
|
|
jsr plot
|
|
jmp __b3
|
|
// line::@3
|
|
__b3:
|
|
// [18] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuxx=_inc_vbuxx
|
|
inx
|
|
// [13] phi from line::@3 to line::@1 [phi:line::@3->line::@1]
|
|
__b1_from___b3:
|
|
// [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@3->line::@1#0] -- register_copy
|
|
jmp __b1
|
|
}
|
|
// plot
|
|
// plot(byte register(X) x)
|
|
plot: {
|
|
// [19] (byte) plot::idx#0 ← *((const nomodify byte*) plots + (byte) plot::x#1) -- vbuyy=pbuc1_derefidx_vbuxx
|
|
ldy plots,x
|
|
// [20] (byte~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (byte) 1 -- vbuaa=pbuc1_derefidx_vbuyy_plus_1
|
|
lda SCREEN,y
|
|
clc
|
|
adc #1
|
|
// [21] *((const nomodify byte*) SCREEN + (byte) plot::idx#0) ← (byte~) plot::$0 -- pbuc1_derefidx_vbuyy=vbuaa
|
|
sta SCREEN,y
|
|
jmp __breturn
|
|
// plot::@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 __b1
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __b3
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Replacing label __b1_from___b1 with __b1
|
|
Replacing label __b2_from___b2 with __b2
|
|
Removing instruction __b1_from___bbegin:
|
|
Removing instruction __b1:
|
|
Removing instruction main_from___b1:
|
|
Removing instruction __bend_from___b1:
|
|
Removing instruction __b1_from___b1:
|
|
Removing instruction __b2_from___b1:
|
|
Removing instruction __b2_from___b2:
|
|
Removing instruction line_from___b2:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction __bbegin:
|
|
Removing instruction __bend:
|
|
Removing instruction __b1_from_main:
|
|
Removing instruction __b1_from_line:
|
|
Removing instruction __breturn:
|
|
Removing instruction __b3:
|
|
Removing instruction __b1_from___b3:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
Removing instruction jmp __b1
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(const nomodify byte*) SCREEN = (byte*) 1024
|
|
(void()) line((byte) line::x0 , (byte) line::x1)
|
|
(label) line::@1
|
|
(label) line::@2
|
|
(label) line::@3
|
|
(label) line::@return
|
|
(byte) line::x
|
|
(byte) line::x#1 reg byte x 200002.0
|
|
(byte) line::x#2 reg byte x 100001.0
|
|
(byte) line::x0
|
|
(const byte) line::x0#0 x0 = (byte) 0
|
|
(byte) line::x1
|
|
(const byte) line::x1#0 x1 = (byte) $a
|
|
(void()) main()
|
|
(label) main::@1
|
|
(label) main::@2
|
|
(byte) main::i
|
|
(byte) main::i#1 reg byte x 151.5
|
|
(byte) main::i#2 reg byte x 168.33333333333331
|
|
(void()) plot((byte) plot::x)
|
|
(byte~) plot::$0 reg byte a 2000002.0
|
|
(label) plot::@return
|
|
(byte) plot::idx
|
|
(byte) plot::idx#0 reg byte y 1500001.5
|
|
(byte) plot::x
|
|
(byte) plot::x#1 reg byte x 1100002.0
|
|
(const nomodify byte*) plots = (byte*) 4096
|
|
|
|
reg byte x [ main::i#2 main::i#1 ]
|
|
reg byte x [ line::x#2 line::x#1 ]
|
|
reg byte x [ plot::x#1 ]
|
|
reg byte y [ plot::idx#0 ]
|
|
reg byte a [ plot::$0 ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 2013
|
|
|
|
// File Comments
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.label plots = $1000
|
|
.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: {
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
|
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
|
ldx #0
|
|
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
|
// main::@1
|
|
__b1:
|
|
// plots[i] = i
|
|
// [6] *((const nomodify byte*) plots + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx
|
|
txa
|
|
sta plots,x
|
|
// SCREEN[i] = 0
|
|
// [7] *((const nomodify byte*) SCREEN + (byte) main::i#2) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2
|
|
lda #0
|
|
sta SCREEN,x
|
|
// for(byte i : 0..39)
|
|
// [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
|
inx
|
|
// [9] if((byte) main::i#1!=(byte) $28) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
|
cpx #$28
|
|
bne __b1
|
|
// [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
|
|
// main::@2
|
|
__b2:
|
|
// line(0, 10)
|
|
// [11] call line
|
|
// [12] phi from main::@2 to line [phi:main::@2->line]
|
|
jsr line
|
|
jmp __b2
|
|
}
|
|
// line
|
|
line: {
|
|
.const x0 = 0
|
|
.const x1 = $a
|
|
// [13] phi from line to line::@1 [phi:line->line::@1]
|
|
// [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@1#0] -- vbuxx=vbuc1
|
|
ldx #x0
|
|
// line::@1
|
|
__b1:
|
|
// for(byte x = x0; x<=x1; x++)
|
|
// [14] if((byte) line::x#2<(const byte) line::x1#0+(byte) 1) goto line::@2 -- vbuxx_lt_vbuc1_then_la1
|
|
cpx #x1+1
|
|
bcc __b2
|
|
// line::@return
|
|
// }
|
|
// [15] return
|
|
rts
|
|
// line::@2
|
|
__b2:
|
|
// plot(x)
|
|
// [16] (byte) plot::x#1 ← (byte) line::x#2
|
|
// [17] call plot
|
|
jsr plot
|
|
// line::@3
|
|
// for(byte x = x0; x<=x1; x++)
|
|
// [18] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuxx=_inc_vbuxx
|
|
inx
|
|
// [13] phi from line::@3 to line::@1 [phi:line::@3->line::@1]
|
|
// [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@3->line::@1#0] -- register_copy
|
|
jmp __b1
|
|
}
|
|
// plot
|
|
// plot(byte register(X) x)
|
|
plot: {
|
|
// idx = plots[x]
|
|
// [19] (byte) plot::idx#0 ← *((const nomodify byte*) plots + (byte) plot::x#1) -- vbuyy=pbuc1_derefidx_vbuxx
|
|
ldy plots,x
|
|
// SCREEN[idx]+1
|
|
// [20] (byte~) plot::$0 ← *((const nomodify byte*) SCREEN + (byte) plot::idx#0) + (byte) 1 -- vbuaa=pbuc1_derefidx_vbuyy_plus_1
|
|
lda SCREEN,y
|
|
clc
|
|
adc #1
|
|
// SCREEN[idx] = SCREEN[idx]+1
|
|
// [21] *((const nomodify byte*) SCREEN + (byte) plot::idx#0) ← (byte~) plot::$0 -- pbuc1_derefidx_vbuyy=vbuaa
|
|
sta SCREEN,y
|
|
// plot::@return
|
|
// }
|
|
// [22] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|