1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-29 09:29:31 +00:00
kickc/src/test/ref/declared-memory-var-1.log

265 lines
8.2 KiB
Plaintext

Setting inferred volatile on symbol affected by address-of idx_p = &idx
Inlined call call __init
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start::@1
main::i#0 = 0
to:main::@1
main::@1: scope:[main] from main main::@1
main::i#2 = phi( main/main::i#0, main::@1/main::i#1 )
SCREEN[main::i#2] = *idx_p
*idx_p = *idx_p + main::i#2
main::i#1 = main::i#2 + rangenext(0,5)
main::$0 = main::i#1 != rangelast(0,5)
if(main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
void __start()
__start: scope:[__start] from
to:__start::__init1
__start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
__start::@return: scope:[__start] from __start::@2
return
to:@return
SYMBOL TABLE SSA
__constant char * const SCREEN = (char *)$400
void __start()
__loadstore volatile char idx = 0
__constant char *idx_p = &idx
void main()
bool main::$0
char main::i
char main::i#0
char main::i#1
char main::i#2
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition main::$0 [6] if(main::i#1!=rangelast(0,5)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [4] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [6] if(main::i#1!=rangelast(0,5)) goto main::@1 to 6
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding number conversion cast (unumber) 6 in [4] if(main::i#1!=6) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 6
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings main::i#0
Constant inlined main::i#0 = 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@2(between main::@1 and main::@1)
Adding NOP phi() at start of main
CALL GRAPH
Created 1 initial phi equivalence classes
Coalesced [7] main::i#3 = main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block label main::@2
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] phi()
to:main::@1
main::@1: scope:[main] from main main::@1
[1] main::i#2 = phi( main/0, main::@1/main::i#1 )
[2] SCREEN[main::i#2] = *idx_p
[3] *idx_p = *idx_p + main::i#2
[4] main::i#1 = ++ main::i#2
[5] if(main::i#1!=6) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
[6] return
to:@return
VARIABLE REGISTER WEIGHTS
__loadstore volatile char idx = 0
void main()
char main::i
char main::i#1 // 16.5
char main::i#2 // 14.666666666666666
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable idx to live range equivalence class [ idx ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ idx ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated mem[1] [ idx ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] SCREEN[main::i#2] = *idx_p [ main::i#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 [3] *idx_p = *idx_p + main::i#2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
Statement [2] SCREEN[main::i#2] = *idx_p [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
Statement [3] *idx_p = *idx_p + main::i#2 [ main::i#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 mem[1] [ idx ] : mem[1] ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 31.17: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 0: mem[1] [ idx ]
Uplifting [main] best 391 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 391 combination mem[1] [ idx ]
Attempting to uplift remaining variables inmem[1] [ idx ]
Uplifting [] best 391 combination mem[1] [ idx ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a pointer to a memory variable
// Upstart
// Commodore 64 PRG executable file
.file [name="declared-memory-var-1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.label SCREEN = $400
.label idx_p = idx
.segment Code
// main
main: {
// [1] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
jmp __b1
// [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
__b1_from___b1:
// [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy
jmp __b1
// main::@1
__b1:
// [2] SCREEN[main::i#2] = *idx_p -- pbuc1_derefidx_vbuxx=_deref_pbuc2
lda idx_p
sta SCREEN,x
// [3] *idx_p = *idx_p + main::i#2 -- _deref_pbuc1=_deref_pbuc1_plus_vbuxx
txa
clc
adc idx_p
sta idx_p
// [4] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
inx
// [5] if(main::i#1!=6) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #6
bne __b1_from___b1
jmp __breturn
// main::@return
__breturn:
// [6] return
rts
}
// File Data
.segment Data
idx: .byte 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
__loadstore volatile char idx = 0 // mem[1]
__constant char *idx_p = &idx
void main()
char main::i
char main::i#1 // reg byte x 16.5
char main::i#2 // reg byte x 14.666666666666666
reg byte x [ main::i#2 main::i#1 ]
mem[1] [ idx ]
FINAL ASSEMBLER
Score: 301
// File Comments
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a pointer to a memory variable
// Upstart
// Commodore 64 PRG executable file
.file [name="declared-memory-var-1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.label SCREEN = $400
.label idx_p = idx
.segment Code
// main
main: {
// [1] phi from main to main::@1 [phi:main->main::@1]
// [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
// [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
// [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy
// main::@1
__b1:
// SCREEN[i] = *idx_p
// [2] SCREEN[main::i#2] = *idx_p -- pbuc1_derefidx_vbuxx=_deref_pbuc2
lda idx_p
sta SCREEN,x
// *idx_p +=i
// [3] *idx_p = *idx_p + main::i#2 -- _deref_pbuc1=_deref_pbuc1_plus_vbuxx
txa
clc
adc idx_p
sta idx_p
// for( char i: 0..5 )
// [4] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
inx
// [5] if(main::i#1!=6) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #6
bne __b1
// main::@return
// }
// [6] return
rts
}
// File Data
.segment Data
idx: .byte 0