1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00
kickc/src/test/ref/function-pointer-noarg-2.log

441 lines
13 KiB
Plaintext

Resolved forward reference fn1 to (void()) fn1()
Resolved forward reference fn2 to (void()) fn2()
Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) @1
Culled Empty Block (label) @2
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@3
main: scope:[main] from @3
(byte) main::i#0 ← (byte) 0
to:main::@1
main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
(number~) main::$0 ← (byte) main::i#2 & (number) 1
(bool~) main::$1 ← (number~) main::$0 == (number) 0
if((bool~) main::$1) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@1
(byte) main::i#4 ← phi( main::@1/(byte) main::i#2 )
to:main::@3
main::@3: scope:[main] from main::@1 main::@4
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 main::@4/(byte) main::i#4 )
(byte) main::i#1 ← (byte) main::i#3 + rangenext(0,$64)
(bool~) main::$4 ← (byte) main::i#1 != rangelast(0,$64)
if((bool~) main::$4) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
fn1: scope:[fn1] from
(byte*) fn1::BORDERCOL#0 ← ((byte*)) (number) $d020
*((byte*) fn1::BORDERCOL#0) ← ++ *((byte*) fn1::BORDERCOL#0)
to:fn1::@return
fn1::@return: scope:[fn1] from fn1
return
to:@return
fn2: scope:[fn2] from
(byte*) fn2::BGCOL#0 ← ((byte*)) (number) $d021
*((byte*) fn2::BGCOL#0) ← ++ *((byte*) fn2::BGCOL#0)
to:fn2::@return
fn2::@return: scope:[fn2] from fn2
return
to:@return
@3: scope:[] from @begin
call main
to:@4
@4: scope:[] from @3
to:@end
@end: scope:[] from @4
SYMBOL TABLE SSA
(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()
(number~) main::$0
(bool~) main::$1
(bool~) main::$4
(label) main::@1
(label) main::@3
(label) main::@4
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::i#2 & (number) 1
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#2 & (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*) fn1::BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) fn2::BGCOL#0 ← (byte*)(number) $d021
Successful SSA optimization Pass2InlineCast
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) 1
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#2 & (byte) 1
Alias (byte) main::i#2 = (byte) main::i#4
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::i#2 = (byte) main::i#3
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [4] if((byte~) main::$0==(byte) 0) goto main::@3
Simple Condition (bool~) main::$4 [9] if((byte) main::i#1!=rangelast(0,$64)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Constant (const byte*) fn1::BORDERCOL#0 = (byte*) 53280
Constant (const byte*) fn2::BGCOL#0 = (byte*) 53281
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [7] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [9] if(main::i#1!=rangelast(0,$64)) goto main::@1 to (number) $65
Removing unused procedure fn1
Removing unused procedure block fn1
Removing unused procedure block fn1::@return
Removing unused procedure fn2
Removing unused procedure block fn2
Removing unused procedure block fn2::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding number conversion cast (unumber) $65 in if((byte) main::i#1!=(number) $65) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $65
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $65
Successful SSA optimization PassNFinalizeNumberTypeConversions
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::@7(between main::@3 and main::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @3
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@4
CALL GRAPH
Calls in [] to main:2
Created 1 initial phi equivalence classes
Coalesced [13] main::i#5 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) main::@7
Renumbering block @3 to @1
Renumbering block main::@3 to main::@2
Renumbering block main::@4 to main::@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::@3
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()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1
[7] if((byte~) main::$0==(byte) 0) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@1
[8] phi()
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[9] (byte) main::i#1 ← ++ (byte) main::i#2
[10] if((byte) main::i#1!=(byte) $65) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
[11] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$0 22.0
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 8.25
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::$0 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::$0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Tests creating and assigning pointers to non-args no-return functions
// Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @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 = 3
.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::@2 to main::@1 [phi:main::@2->main::@1]
b1_from_b2:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp b1
// main::@1
b1:
// [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1
lda #1
and.z i
sta.z _0
// [7] if((byte~) main::$0==(byte) 0) goto main::@2 -- vbuz1_eq_0_then_la1
lda.z _0
cmp #0
beq b2
// [8] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
b3_from_b1:
jmp b3
// main::@3
b3:
jmp b2
// main::@2
b2:
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [10] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$65
cmp.z i
bne b1_from_b2
jmp breturn
// main::@return
breturn:
// [11] return
rts
}
// File Data
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_BYTE:3 [ main::$0 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 24.75: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:3 [ main::$0 ]
Uplift Scope []
Uplifting [main] best 338 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$0 ]
Uplifting [] best 338 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests creating and assigning pointers to non-args no-return functions
// Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @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::@2 to main::@1 [phi:main::@2->main::@1]
b1_from_b2:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp b1
// main::@1
b1:
// [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1
txa
and #1
// [7] if((byte~) main::$0==(byte) 0) goto main::@2 -- vbuaa_eq_0_then_la1
cmp #0
beq b2
// [8] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
b3_from_b1:
jmp b3
// main::@3
b3:
jmp b2
// main::@2
b2:
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [10] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #$65
bne b1_from_b2
jmp breturn
// main::@return
breturn:
// [11] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b3
Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b2 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b2:
Removing instruction b3_from_b1:
Removing instruction b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Removing instruction beq b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Removing instruction b2:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(byte~) main::$0 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 8.25
reg byte x [ main::i#2 main::i#1 ]
reg byte a [ main::$0 ]
FINAL ASSEMBLER
Score: 151
// File Comments
// Tests creating and assigning pointers to non-args no-return functions
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
// @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::@2 to main::@1 [phi:main::@2->main::@1]
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
// main::@1
b1:
// i&1
// [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1
txa
and #1
// if((i&1)==0)
// [7] if((byte~) main::$0==(byte) 0) goto main::@2 -- vbuaa_eq_0_then_la1
cmp #0
// [8] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
// main::@3
// main::@2
// for ( byte i: 0..100)
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [10] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #$65
bne b1
// main::@return
// }
// [11] return
rts
}
// File Data