1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-21 17:24:39 +00:00
kickc/src/test/ref/function-pointer-noarg-2.log

431 lines
12 KiB
Plaintext

Resolved forward reference fn1 to (void()) fn1()
Resolved forward reference fn2 to (void()) fn2()
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::@2
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(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::@2
to:main::@3
main::@3: scope:[main] from main::@1
(byte) main::i#4 ← phi( main::@1/(byte) main::i#2 )
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 main::@3/(byte) main::i#4 )
(byte) main::i#1 ← (byte) main::i#3 + rangenext(0,$64)
(bool~) main::$2 ← (byte) main::i#1 != rangelast(0,$64)
if((bool~) main::$2) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
(void()) fn1()
fn1: scope:[fn1] from
*((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
to:fn1::@return
fn1::@return: scope:[fn1] from fn1
return
to:@return
(void()) fn2()
fn2: scope:[fn2] from
*((const nomodify byte*) fn2::BG_COLOR) ← ++ *((const nomodify byte*) fn2::BG_COLOR)
to:fn2::@return
fn2::@return: scope:[fn2] from fn2
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
(void()) fn1()
(label) fn1::@return
(const nomodify byte*) fn1::BORDER_COLOR = (byte*)(number) $d020
(void()) fn2()
(label) fn2::@return
(const nomodify byte*) fn2::BG_COLOR = (byte*)(number) $d021
(void()) main()
(number~) main::$0
(bool~) main::$1
(bool~) main::$2
(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
(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
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53281
Simplifying constant integer cast 1
Simplifying constant integer cast 0
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 main::i#2 = main::i#4
Successful SSA optimization Pass2AliasElimination
Alias main::i#2 = main::i#3
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [4] if((byte~) main::$0==(byte) 0) goto main::@2
Simple Condition (bool~) main::$2 [7] if((byte) main::i#1!=rangelast(0,$64)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [5] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [7] 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::@4(between main::@2 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::@3
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) @2
Culled Empty Block (label) main::@4
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()
(void()) main()
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 202.0
(byte) main::i
(byte) main::i#1 151.5
(byte) main::i#2 75.75
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::$0 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]: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(main)
.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[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ main::$0 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 227.25: zp[1]:2 [ main::i#2 main::i#1 ] 202: zp[1]: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(main)
.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 __bbegin:
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp __b1
Removing instruction beq __b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b2:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(byte~) main::$0 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 151.5
(byte) main::i#2 reg byte x 75.75
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