2019-04-02 22:03:37 +00:00
|
|
|
Resolved forward reference fn1 to (void()) fn1()
|
|
|
|
Resolved forward reference fn2 to (void()) fn2()
|
2019-05-30 20:29:04 +00:00
|
|
|
Culled Empty Block (label) main::@6
|
|
|
|
Culled Empty Block (label) main::@3
|
|
|
|
Culled Empty Block (label) main::@7
|
|
|
|
Culled Empty Block (label) main::@9
|
|
|
|
Culled Empty Block (label) main::@10
|
|
|
|
Culled Empty Block (label) @2
|
2019-04-02 22:03:37 +00:00
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
@begin: scope:[] from
|
|
|
|
to:@1
|
|
|
|
main: scope:[main] from @3
|
|
|
|
(void()*) main::f#0 ← (void()*) 0
|
2019-05-30 20:29:04 +00:00
|
|
|
(byte) main::i#0 ← (number) 0
|
2019-04-02 22:03:37 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@5
|
|
|
|
(byte) main::i#3 ← phi( main/(byte) main::i#0 main::@5/(byte) main::i#4 )
|
|
|
|
if(true) goto main::@2
|
|
|
|
to:main::@return
|
|
|
|
main::@2: scope:[main] from main::@1
|
|
|
|
(byte) main::i#2 ← phi( main::@1/(byte) main::i#3 )
|
|
|
|
(byte) main::i#1 ← ++ (byte) main::i#2
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) main::$0 ← (byte) main::i#1 & (number) 1
|
|
|
|
(bool~) main::$1 ← (number~) main::$0 == (number) 0
|
2019-04-02 22:03:37 +00:00
|
|
|
if((bool~) main::$1) goto main::@4
|
|
|
|
to:main::@8
|
|
|
|
main::@4: scope:[main] from main::@2
|
|
|
|
(byte) main::i#5 ← phi( main::@2/(byte) main::i#1 )
|
|
|
|
(void()*~) main::$3 ← & (void()) fn1()
|
|
|
|
(void()*) main::f#1 ← (void()*~) main::$3
|
|
|
|
to:main::@5
|
|
|
|
main::@8: scope:[main] from main::@2
|
|
|
|
(byte) main::i#6 ← phi( main::@2/(byte) main::i#1 )
|
|
|
|
(void()*~) main::$2 ← & (void()) fn2()
|
|
|
|
(void()*) main::f#2 ← (void()*~) main::$2
|
|
|
|
to:main::@5
|
|
|
|
main::@5: scope:[main] from main::@4 main::@8
|
|
|
|
(byte) main::i#4 ← phi( main::@4/(byte) main::i#5 main::@8/(byte) main::i#6 )
|
|
|
|
(void()*) main::f#3 ← phi( main::@4/(void()*) main::f#1 main::@8/(void()*) main::f#2 )
|
|
|
|
kickasm( uses main::f#3) {{ jsr ff
|
|
|
|
}}
|
|
|
|
to:main::@1
|
|
|
|
main::@return: scope:[main] from main::@1
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
@1: scope:[] from @begin
|
|
|
|
kickasm() {{ ff:
|
|
|
|
jmp (main.f)
|
|
|
|
}}
|
|
|
|
to:@3
|
|
|
|
fn1: scope:[fn1] from
|
2019-05-30 20:29:04 +00:00
|
|
|
(byte*) fn1::BORDERCOL#0 ← ((byte*)) (number) $d020
|
2019-04-02 22:03:37 +00:00
|
|
|
*((byte*) fn1::BORDERCOL#0) ← ++ *((byte*) fn1::BORDERCOL#0)
|
|
|
|
to:fn1::@return
|
|
|
|
fn1::@return: scope:[fn1] from fn1
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
fn2: scope:[fn2] from
|
2019-05-30 20:29:04 +00:00
|
|
|
(byte*) fn2::BGCOL#0 ← ((byte*)) (number) $d021
|
2019-04-02 22:03:37 +00:00
|
|
|
*((byte*) fn2::BGCOL#0) ← ++ *((byte*) fn2::BGCOL#0)
|
|
|
|
to:fn2::@return
|
|
|
|
fn2::@return: scope:[fn2] from fn2
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
@3: scope:[] from @1
|
|
|
|
call main
|
|
|
|
to:@4
|
|
|
|
@4: scope:[] from @3
|
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @4
|
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
|
|
|
(label) @1
|
|
|
|
(label) @3
|
|
|
|
(label) @4
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(void()) fn1()
|
|
|
|
(label) fn1::@return
|
|
|
|
(byte*) fn1::BORDERCOL
|
|
|
|
(byte*) fn1::BORDERCOL#0
|
|
|
|
(void()) fn2()
|
|
|
|
(label) fn2::@return
|
|
|
|
(byte*) fn2::BGCOL
|
|
|
|
(byte*) fn2::BGCOL#0
|
|
|
|
(void()) main()
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) main::$0
|
2019-04-02 22:03:37 +00:00
|
|
|
(bool~) main::$1
|
|
|
|
(void()*~) main::$2
|
|
|
|
(void()*~) main::$3
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@4
|
|
|
|
(label) main::@5
|
|
|
|
(label) main::@8
|
|
|
|
(label) main::@return
|
|
|
|
(void()*) main::f
|
|
|
|
(void()*) main::f#0
|
|
|
|
(void()*) main::f#1
|
|
|
|
(void()*) main::f#2
|
|
|
|
(void()*) main::f#3
|
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#0
|
|
|
|
(byte) main::i#1
|
|
|
|
(byte) main::i#2
|
|
|
|
(byte) main::i#3
|
|
|
|
(byte) main::i#4
|
|
|
|
(byte) main::i#5
|
|
|
|
(byte) main::i#6
|
|
|
|
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
|
|
|
|
Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::i#1 & (number) 1
|
|
|
|
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#1 & (unumber)(number) 1
|
|
|
|
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (unumber~) main::$0 == (number) 0
|
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
|
|
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
|
|
|
|
Inlining cast (byte*) fn1::BORDERCOL#0 ← (byte*)(number) $d020
|
|
|
|
Inlining cast (byte*) fn2::BGCOL#0 ← (byte*)(number) $d021
|
|
|
|
Successful SSA optimization Pass2InlineCast
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Simplifying constant pointer cast (byte*) 53280
|
|
|
|
Simplifying constant pointer cast (byte*) 53281
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
|
|
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#1 & (byte) 1
|
2019-04-02 22:03:37 +00:00
|
|
|
Alias (byte) main::i#2 = (byte) main::i#3
|
|
|
|
Alias (byte) main::i#1 = (byte) main::i#5 (byte) main::i#6
|
|
|
|
Alias (void()*) main::f#1 = (void()*~) main::$3
|
|
|
|
Alias (void()*) main::f#2 = (void()*~) main::$2
|
|
|
|
Successful SSA optimization Pass2AliasElimination
|
|
|
|
Alias (byte) main::i#1 = (byte) main::i#4
|
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2019-05-30 20:29:04 +00:00
|
|
|
Simple Condition (bool~) main::$1 [8] if((byte~) main::$0==(byte) 0) goto main::@4
|
2019-04-02 22:03:37 +00:00
|
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant right-side identified [10] (void()*) main::f#1 ← & (void()) fn1()
|
|
|
|
Constant right-side identified [13] (void()*) main::f#2 ← & (void()) fn2()
|
|
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
|
|
Constant (const void()*) main::f#0 = (void()*) 0
|
2019-04-02 22:03:37 +00:00
|
|
|
Constant (const byte) main::i#0 = 0
|
|
|
|
Constant (const void()*) main::f#1 = &fn1
|
|
|
|
Constant (const void()*) main::f#2 = &fn2
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant (const byte*) fn1::BORDERCOL#0 = (byte*) 53280
|
|
|
|
Constant (const byte*) fn2::BGCOL#0 = (byte*) 53281
|
2019-04-02 22:03:37 +00:00
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
2019-05-30 20:29:04 +00:00
|
|
|
if() condition always true - replacing block destination [3] if(true) goto main::@2
|
2019-04-02 22:03:37 +00:00
|
|
|
Successful SSA optimization Pass2ConstantIfs
|
2019-04-20 20:12:56 +00:00
|
|
|
Eliminating unused constant (const void()*) main::f#0
|
2019-04-02 22:03:37 +00:00
|
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
|
|
Removing unused block main::@return
|
|
|
|
Successful SSA optimization Pass2EliminateUnusedBlocks
|
|
|
|
Inlining constant with var siblings (const byte) main::i#0
|
|
|
|
Inlining constant with var siblings (const void()*) main::f#1
|
|
|
|
Inlining constant with var siblings (const void()*) main::f#2
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant inlined main::i#0 = (byte) 0
|
2019-04-02 22:03:37 +00:00
|
|
|
Constant inlined main::f#2 = &(void()) fn2()
|
|
|
|
Constant inlined main::f#1 = &(void()) fn1()
|
|
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
|
|
Adding NOP phi() at start of @begin
|
|
|
|
Adding NOP phi() at start of @3
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding NOP phi() at start of @4
|
2019-04-02 22:03:37 +00:00
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
Adding NOP phi() at start of main
|
|
|
|
Adding NOP phi() at start of main::@8
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding NOP phi() at start of main::@4
|
2019-04-02 22:03:37 +00:00
|
|
|
CALL GRAPH
|
|
|
|
Calls in [] to main:3
|
|
|
|
|
|
|
|
Created 2 initial phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Coalesced [14] main::i#7 ← main::i#1
|
2019-04-02 22:03:37 +00:00
|
|
|
Coalesced down to 2 phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Culled Empty Block (label) @4
|
|
|
|
Culled Empty Block (label) main::@8
|
2019-04-02 22:03:37 +00:00
|
|
|
Renumbering block @3 to @2
|
2019-05-30 20:29:04 +00:00
|
|
|
Renumbering block main::@4 to main::@3
|
|
|
|
Renumbering block main::@5 to main::@4
|
2019-04-02 22:03:37 +00:00
|
|
|
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
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding NOP phi() at start of main::@3
|
2019-04-02 22:03:37 +00:00
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
@begin: scope:[] from
|
|
|
|
[0] phi()
|
|
|
|
to:@1
|
|
|
|
@1: scope:[] from @begin
|
|
|
|
kickasm() {{ ff:
|
|
|
|
jmp (main.f)
|
|
|
|
}}
|
|
|
|
to:@2
|
|
|
|
@2: scope:[] from @1
|
|
|
|
[2] phi()
|
|
|
|
[3] call main
|
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @2
|
|
|
|
[4] phi()
|
|
|
|
main: scope:[main] from @2
|
|
|
|
[5] phi()
|
|
|
|
to:main::@1
|
2019-05-30 20:29:04 +00:00
|
|
|
main::@1: scope:[main] from main main::@4
|
|
|
|
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
|
2019-04-02 22:03:37 +00:00
|
|
|
to:main::@2
|
|
|
|
main::@2: scope:[main] from main::@1
|
|
|
|
[7] (byte) main::i#1 ← ++ (byte) main::i#2
|
2019-05-30 20:29:04 +00:00
|
|
|
[8] (byte~) main::$0 ← (byte) main::i#1 & (byte) 1
|
|
|
|
[9] if((byte~) main::$0==(byte) 0) goto main::@3
|
2019-04-02 22:03:37 +00:00
|
|
|
to:main::@4
|
2019-05-30 20:29:04 +00:00
|
|
|
main::@3: scope:[main] from main::@2
|
2019-04-02 22:03:37 +00:00
|
|
|
[10] phi()
|
2019-05-30 20:29:04 +00:00
|
|
|
to:main::@4
|
|
|
|
main::@4: scope:[main] from main::@2 main::@3
|
|
|
|
[11] (void()*) main::f#3 ← phi( main::@3/&(void()) fn1() main::@2/&(void()) fn2() )
|
2019-04-02 22:03:37 +00:00
|
|
|
kickasm( uses main::f#3) {{ jsr ff
|
|
|
|
}}
|
|
|
|
to:main::@1
|
|
|
|
fn2: scope:[fn2] from
|
|
|
|
[13] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0)
|
|
|
|
to:fn2::@return
|
|
|
|
fn2::@return: scope:[fn2] from fn2
|
|
|
|
[14] return
|
|
|
|
to:@return
|
|
|
|
fn1: scope:[fn1] from
|
|
|
|
[15] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0)
|
|
|
|
to:fn1::@return
|
|
|
|
fn1::@return: scope:[fn1] from fn1
|
|
|
|
[16] return
|
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
|
|
(void()) fn1()
|
|
|
|
(byte*) fn1::BORDERCOL
|
|
|
|
(void()) fn2()
|
|
|
|
(byte*) fn2::BGCOL
|
|
|
|
(void()) main()
|
|
|
|
(byte~) main::$0 22.0
|
|
|
|
(void()*) main::f
|
|
|
|
(void()*) main::f#3
|
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#1 5.5
|
|
|
|
(byte) main::i#2 22.0
|
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
[ main::i#2 main::i#1 ]
|
|
|
|
[ main::f#3 ]
|
|
|
|
Added variable main::$0 to zero page equivalence class [ main::$0 ]
|
|
|
|
Complete equivalence classes
|
|
|
|
[ main::i#2 main::i#1 ]
|
|
|
|
[ main::f#3 ]
|
|
|
|
[ main::$0 ]
|
|
|
|
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
|
|
|
Allocated zp ZP_WORD:3 [ main::f#3 ]
|
|
|
|
Allocated zp ZP_BYTE:5 [ main::$0 ]
|
|
|
|
|
|
|
|
INITIAL ASM
|
2019-09-08 00:29:17 +00:00
|
|
|
Target platform is c64basic / MOS6502X
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-04-02 22:03:37 +00:00
|
|
|
// Tests creating and assigning pointers to non-args no-return functions - plus inline kickasm-based calling
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2019-04-02 22:03:37 +00:00
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(bbegin)
|
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
2019-04-02 22:03:37 +00:00
|
|
|
bbegin:
|
|
|
|
jmp b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// @1
|
2019-04-02 22:03:37 +00:00
|
|
|
b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// kickasm() {{ ff: jmp (main.f) }}
|
2019-04-02 22:03:37 +00:00
|
|
|
ff:
|
|
|
|
jmp (main.f)
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] phi from @1 to @2 [phi:@1->@2]
|
2019-04-02 22:03:37 +00:00
|
|
|
b2_from_b1:
|
|
|
|
jmp b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// @2
|
2019-04-02 22:03:37 +00:00
|
|
|
b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [3] call main
|
|
|
|
// [5] phi from @2 to main [phi:@2->main]
|
2019-04-02 22:03:37 +00:00
|
|
|
main_from_b2:
|
|
|
|
jsr main
|
2019-07-08 14:43:09 +00:00
|
|
|
// [4] phi from @2 to @end [phi:@2->@end]
|
2019-04-02 22:03:37 +00:00
|
|
|
bend_from_b2:
|
|
|
|
jmp bend
|
2019-07-08 14:43:09 +00:00
|
|
|
// @end
|
2019-04-02 22:03:37 +00:00
|
|
|
bend:
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2019-04-02 22:03:37 +00:00
|
|
|
main: {
|
|
|
|
.label _0 = 5
|
|
|
|
.label i = 2
|
|
|
|
.label f = 3
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main to main::@1 [phi:main->main::@1]
|
2019-04-02 22:03:37 +00:00
|
|
|
b1_from_main:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z i
|
2019-04-02 22:03:37 +00:00
|
|
|
jmp b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@1
|
2019-04-02 22:03:37 +00:00
|
|
|
b1:
|
|
|
|
jmp b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-04-02 22:03:37 +00:00
|
|
|
b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [8] (byte~) main::$0 ← (byte) main::i#1 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #1
|
2019-08-07 19:00:19 +00:00
|
|
|
and.z i
|
|
|
|
sta.z _0
|
2019-07-08 14:43:09 +00:00
|
|
|
// [9] if((byte~) main::$0==(byte) 0) goto main::@3 -- vbuz1_eq_0_then_la1
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z _0
|
2019-04-02 22:03:37 +00:00
|
|
|
cmp #0
|
|
|
|
beq b3_from_b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
|
2019-04-02 22:03:37 +00:00
|
|
|
b4_from_b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi (void()*) main::f#3 = &(void()) fn2() [phi:main::@2->main::@4#0] -- pprz1=pprc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #<fn2
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #>fn2
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f+1
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
2019-04-02 22:03:37 +00:00
|
|
|
b3_from_b2:
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-05-30 20:29:04 +00:00
|
|
|
b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
|
2019-05-30 20:29:04 +00:00
|
|
|
b4_from_b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi (void()*) main::f#3 = &(void()) fn1() [phi:main::@3->main::@4#0] -- pprz1=pprc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #<fn1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #>fn1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f+1
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@4
|
2019-05-30 20:29:04 +00:00
|
|
|
b4:
|
2019-07-08 14:43:09 +00:00
|
|
|
// kickasm( uses main::f#3) {{ jsr ff }}
|
2019-04-02 22:03:37 +00:00
|
|
|
jsr ff
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
|
2019-05-30 20:29:04 +00:00
|
|
|
b1_from_b4:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
|
2019-04-02 22:03:37 +00:00
|
|
|
jmp b1
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn2
|
2019-04-02 22:03:37 +00:00
|
|
|
fn2: {
|
|
|
|
.label BGCOL = $d021
|
2019-07-08 14:43:09 +00:00
|
|
|
// [13] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
inc BGCOL
|
|
|
|
jmp breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn2::@return
|
2019-04-02 22:03:37 +00:00
|
|
|
breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [14] return
|
2019-04-02 22:03:37 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn1
|
2019-04-02 22:03:37 +00:00
|
|
|
fn1: {
|
|
|
|
.label BORDERCOL = $d020
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
inc BORDERCOL
|
|
|
|
jmp breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn1::@return
|
2019-04-02 22:03:37 +00:00
|
|
|
breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [16] return
|
2019-04-02 22:03:37 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2019-04-02 22:03:37 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
|
|
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp ZP_WORD:3 [ main::f#3 ] : zp ZP_WORD:3 ,
|
|
|
|
Potential registers zp ZP_BYTE:5 [ main::$0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
|
|
Uplift Scope [main] 27.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:5 [ main::$0 ] 0: zp ZP_WORD:3 [ main::f#3 ]
|
|
|
|
Uplift Scope [fn1]
|
|
|
|
Uplift Scope [fn2]
|
|
|
|
Uplift Scope []
|
|
|
|
|
|
|
|
Uplifting [main] best 3393 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] zp ZP_WORD:3 [ main::f#3 ]
|
|
|
|
Uplifting [fn1] best 3393 combination
|
|
|
|
Uplifting [fn2] best 3393 combination
|
|
|
|
Uplifting [] best 3393 combination
|
|
|
|
Allocated (was zp ZP_WORD:3) zp ZP_WORD:2 [ main::f#3 ]
|
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-04-02 22:03:37 +00:00
|
|
|
// Tests creating and assigning pointers to non-args no-return functions - plus inline kickasm-based calling
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2019-04-02 22:03:37 +00:00
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(bbegin)
|
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
2019-04-02 22:03:37 +00:00
|
|
|
bbegin:
|
|
|
|
jmp b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// @1
|
2019-04-02 22:03:37 +00:00
|
|
|
b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// kickasm() {{ ff: jmp (main.f) }}
|
2019-04-02 22:03:37 +00:00
|
|
|
ff:
|
|
|
|
jmp (main.f)
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] phi from @1 to @2 [phi:@1->@2]
|
2019-04-02 22:03:37 +00:00
|
|
|
b2_from_b1:
|
|
|
|
jmp b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// @2
|
2019-04-02 22:03:37 +00:00
|
|
|
b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [3] call main
|
|
|
|
// [5] phi from @2 to main [phi:@2->main]
|
2019-04-02 22:03:37 +00:00
|
|
|
main_from_b2:
|
|
|
|
jsr main
|
2019-07-08 14:43:09 +00:00
|
|
|
// [4] phi from @2 to @end [phi:@2->@end]
|
2019-04-02 22:03:37 +00:00
|
|
|
bend_from_b2:
|
|
|
|
jmp bend
|
2019-07-08 14:43:09 +00:00
|
|
|
// @end
|
2019-04-02 22:03:37 +00:00
|
|
|
bend:
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2019-04-02 22:03:37 +00:00
|
|
|
main: {
|
|
|
|
.label f = 2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main to main::@1 [phi:main->main::@1]
|
2019-04-02 22:03:37 +00:00
|
|
|
b1_from_main:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
ldx #0
|
|
|
|
jmp b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@1
|
2019-04-02 22:03:37 +00:00
|
|
|
b1:
|
|
|
|
jmp b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-04-02 22:03:37 +00:00
|
|
|
b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
2019-04-02 22:03:37 +00:00
|
|
|
inx
|
2019-07-08 14:43:09 +00:00
|
|
|
// [8] (byte~) main::$0 ← (byte) main::i#1 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
txa
|
|
|
|
and #1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [9] if((byte~) main::$0==(byte) 0) goto main::@3 -- vbuaa_eq_0_then_la1
|
2019-04-02 22:03:37 +00:00
|
|
|
cmp #0
|
|
|
|
beq b3_from_b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
|
2019-04-02 22:03:37 +00:00
|
|
|
b4_from_b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi (void()*) main::f#3 = &(void()) fn2() [phi:main::@2->main::@4#0] -- pprz1=pprc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #<fn2
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #>fn2
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f+1
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
2019-04-02 22:03:37 +00:00
|
|
|
b3_from_b2:
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-05-30 20:29:04 +00:00
|
|
|
b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
|
2019-05-30 20:29:04 +00:00
|
|
|
b4_from_b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi (void()*) main::f#3 = &(void()) fn1() [phi:main::@3->main::@4#0] -- pprz1=pprc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #<fn1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #>fn1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f+1
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@4
|
2019-05-30 20:29:04 +00:00
|
|
|
b4:
|
2019-07-08 14:43:09 +00:00
|
|
|
// kickasm( uses main::f#3) {{ jsr ff }}
|
2019-04-02 22:03:37 +00:00
|
|
|
jsr ff
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
|
2019-05-30 20:29:04 +00:00
|
|
|
b1_from_b4:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
|
2019-04-02 22:03:37 +00:00
|
|
|
jmp b1
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn2
|
2019-04-02 22:03:37 +00:00
|
|
|
fn2: {
|
|
|
|
.label BGCOL = $d021
|
2019-07-08 14:43:09 +00:00
|
|
|
// [13] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
inc BGCOL
|
|
|
|
jmp breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn2::@return
|
2019-04-02 22:03:37 +00:00
|
|
|
breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [14] return
|
2019-04-02 22:03:37 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn1
|
2019-04-02 22:03:37 +00:00
|
|
|
fn1: {
|
|
|
|
.label BORDERCOL = $d020
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
inc BORDERCOL
|
|
|
|
jmp breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn1::@return
|
2019-04-02 22:03:37 +00:00
|
|
|
breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [16] return
|
2019-04-02 22:03:37 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2019-04-02 22:03:37 +00:00
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
|
|
Removing instruction jmp b1
|
|
|
|
Removing instruction jmp b2
|
|
|
|
Removing instruction jmp bend
|
|
|
|
Removing instruction jmp b1
|
|
|
|
Removing instruction jmp b2
|
|
|
|
Removing instruction jmp b3
|
2019-05-30 20:29:04 +00:00
|
|
|
Removing instruction jmp b4
|
2019-04-02 22:03:37 +00:00
|
|
|
Removing instruction jmp breturn
|
|
|
|
Removing instruction jmp breturn
|
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2019-05-30 20:29:04 +00:00
|
|
|
Replacing label b3_from_b2 with b3
|
2019-04-02 22:03:37 +00:00
|
|
|
Replacing label b1 with b2
|
|
|
|
Removing instruction b1:
|
|
|
|
Removing instruction b2_from_b1:
|
|
|
|
Removing instruction main_from_b2:
|
|
|
|
Removing instruction bend_from_b2:
|
|
|
|
Removing instruction b1:
|
2019-05-30 20:29:04 +00:00
|
|
|
Removing instruction b3_from_b2:
|
|
|
|
Removing instruction b4_from_b3:
|
2019-04-02 22:03:37 +00:00
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
|
|
Removing instruction b2:
|
|
|
|
Removing instruction bend:
|
|
|
|
Removing instruction b1_from_main:
|
2019-05-30 20:29:04 +00:00
|
|
|
Removing instruction b4_from_b2:
|
|
|
|
Removing instruction b1_from_b4:
|
2019-04-02 22:03:37 +00:00
|
|
|
Removing instruction breturn:
|
|
|
|
Removing instruction breturn:
|
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
Updating BasicUpstart to call main directly
|
|
|
|
Removing instruction jsr main
|
|
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
|
|
Removing instruction bbegin:
|
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
|
|
|
(label) @1
|
|
|
|
(label) @2
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(void()) fn1()
|
|
|
|
(label) fn1::@return
|
|
|
|
(byte*) fn1::BORDERCOL
|
2019-05-30 20:29:04 +00:00
|
|
|
(const byte*) fn1::BORDERCOL#0 BORDERCOL = (byte*) 53280
|
2019-04-02 22:03:37 +00:00
|
|
|
(void()) fn2()
|
|
|
|
(label) fn2::@return
|
|
|
|
(byte*) fn2::BGCOL
|
2019-05-30 20:29:04 +00:00
|
|
|
(const byte*) fn2::BGCOL#0 BGCOL = (byte*) 53281
|
2019-04-02 22:03:37 +00:00
|
|
|
(void()) main()
|
|
|
|
(byte~) main::$0 reg byte a 22.0
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@4
|
|
|
|
(void()*) main::f
|
|
|
|
(void()*) main::f#3 f zp ZP_WORD:2
|
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#1 reg byte x 5.5
|
|
|
|
(byte) main::i#2 reg byte x 22.0
|
|
|
|
|
|
|
|
reg byte x [ main::i#2 main::i#1 ]
|
|
|
|
zp ZP_WORD:2 [ main::f#3 ]
|
|
|
|
reg byte a [ main::$0 ]
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
|
|
Score: 3225
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-04-02 22:03:37 +00:00
|
|
|
// Tests creating and assigning pointers to non-args no-return functions - plus inline kickasm-based calling
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2019-04-02 22:03:37 +00:00
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
|
|
|
// @1
|
|
|
|
// kickasm
|
|
|
|
// kickasm() {{ ff: jmp (main.f) }}
|
2019-04-02 22:03:37 +00:00
|
|
|
ff:
|
|
|
|
jmp (main.f)
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] phi from @1 to @2 [phi:@1->@2]
|
|
|
|
// @2
|
|
|
|
// [3] call main
|
|
|
|
// [5] phi from @2 to main [phi:@2->main]
|
|
|
|
// [4] phi from @2 to @end [phi:@2->@end]
|
|
|
|
// @end
|
|
|
|
// main
|
2019-04-02 22:03:37 +00:00
|
|
|
main: {
|
|
|
|
.label f = 2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main to main::@1 [phi:main->main::@1]
|
|
|
|
// [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
ldx #0
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@1
|
|
|
|
// main::@2
|
2019-04-02 22:03:37 +00:00
|
|
|
b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// ++i;
|
|
|
|
// [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
2019-04-02 22:03:37 +00:00
|
|
|
inx
|
2019-07-08 14:43:09 +00:00
|
|
|
// i&1
|
|
|
|
// [8] (byte~) main::$0 ← (byte) main::i#1 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
txa
|
|
|
|
and #1
|
2019-07-08 14:43:09 +00:00
|
|
|
// if((i&1)==0)
|
|
|
|
// [9] if((byte~) main::$0==(byte) 0) goto main::@3 -- vbuaa_eq_0_then_la1
|
2019-04-02 22:03:37 +00:00
|
|
|
cmp #0
|
2019-05-30 20:29:04 +00:00
|
|
|
beq b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
|
|
|
|
// [11] phi (void()*) main::f#3 = &(void()) fn2() [phi:main::@2->main::@4#0] -- pprz1=pprc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #<fn2
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #>fn2
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f+1
|
2019-05-30 20:29:04 +00:00
|
|
|
jmp b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
|
|
|
// main::@3
|
2019-05-30 20:29:04 +00:00
|
|
|
b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
|
|
|
|
// [11] phi (void()*) main::f#3 = &(void()) fn1() [phi:main::@3->main::@4#0] -- pprz1=pprc1
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #<fn1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f
|
2019-04-02 22:03:37 +00:00
|
|
|
lda #>fn1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z f+1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@4
|
2019-05-30 20:29:04 +00:00
|
|
|
b4:
|
2019-07-08 14:43:09 +00:00
|
|
|
// kickasm
|
|
|
|
// kickasm( uses main::f#3) {{ jsr ff }}
|
2019-04-02 22:03:37 +00:00
|
|
|
jsr ff
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
|
|
|
|
// [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
|
2019-04-02 22:03:37 +00:00
|
|
|
jmp b2
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn2
|
2019-04-02 22:03:37 +00:00
|
|
|
fn2: {
|
|
|
|
.label BGCOL = $d021
|
2019-07-08 14:43:09 +00:00
|
|
|
// (*BGCOL)++;
|
|
|
|
// [13] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
inc BGCOL
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn2::@return
|
|
|
|
// }
|
|
|
|
// [14] return
|
2019-04-02 22:03:37 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn1
|
2019-04-02 22:03:37 +00:00
|
|
|
fn1: {
|
|
|
|
.label BORDERCOL = $d020
|
2019-07-08 14:43:09 +00:00
|
|
|
// (*BORDERCOL)++;
|
|
|
|
// [15] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1
|
2019-04-02 22:03:37 +00:00
|
|
|
inc BORDERCOL
|
2019-07-08 14:43:09 +00:00
|
|
|
// fn1::@return
|
|
|
|
// }
|
|
|
|
// [16] return
|
2019-04-02 22:03:37 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2019-04-02 22:03:37 +00:00
|
|
|
|