1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-03 07:29:37 +00:00
kickc/src/test/ref/declared-memory-var-7.log
2023-04-23 11:54:47 +02:00

328 lines
9.6 KiB
Plaintext

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
idx = idx + 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
idx = 0
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 char 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
Adding number conversion cast (unumber) 6 in 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 __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of __start::@2
Adding NOP phi() at start of main
CALL GRAPH
Calls in [__start] to main:3
Created 1 initial phi equivalence classes
Coalesced [13] main::i#3 = main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label main::@2
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
void __start()
__start: scope:[__start] from
[0] phi()
to:__start::__init1
__start::__init1: scope:[__start] from __start
[1] idx = 0
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
to:@return
void main()
main: scope:[main] from __start::@1
[5] phi()
to:main::@1
main::@1: scope:[main] from main main::@1
[6] main::i#2 = phi( main/0, main::@1/main::i#1 )
[7] SCREEN[main::i#2] = idx
[8] idx = idx + main::i#2
[9] main::i#1 = ++ main::i#2
[10] if(main::i#1!=6) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
[11] return
to:@return
VARIABLE REGISTER WEIGHTS
void __start()
__loadstore char idx // 38.125
void main()
char main::i
char main::i#1 // 151.5
char main::i#2 // 134.66666666666666
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 zp[1]:3 [ idx ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] idx = 0 [ idx ] ( [ idx ] { } ) always clobbers reg byte a
Statement [7] SCREEN[main::i#2] = idx [ idx main::i#2 ] ( main:3 [ idx 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 [8] idx = idx + main::i#2 [ idx main::i#2 ] ( main:3 [ idx main::i#2 ] { } ) always clobbers reg byte a
Statement [1] idx = 0 [ idx ] ( [ idx ] { } ) always clobbers reg byte a
Statement [7] SCREEN[main::i#2] = idx [ idx main::i#2 ] ( main:3 [ idx main::i#2 ] { } ) always clobbers reg byte a
Statement [8] idx = idx + main::i#2 [ idx main::i#2 ] ( main:3 [ idx 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 [ idx ] : zp[1]:3 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 286.17: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 38.12: zp[1]:3 [ idx ]
Uplift Scope [__start]
Uplifting [main] best 414 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 414 combination zp[1]:3 [ idx ]
Uplifting [__start] best 414 combination
Attempting to uplift remaining variables inzp[1]:3 [ idx ]
Uplifting [] best 414 combination zp[1]:3 [ idx ]
Allocated (was zp[1]:3) zp[1]:2 [ 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 zeropage notregister variable
// Upstart
// Commodore 64 PRG executable file
.file [name="declared-memory-var-7.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(__start)
// Global Constants & labels
.label SCREEN = $400
.label idx = 2
.segment Code
// __start
__start: {
jmp __init1
// __start::__init1
__init1:
// [1] idx = 0 -- vbuz1=vbuc1
lda #0
sta.z idx
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
__b1_from___init1:
jmp __b1
// __start::@1
__b1:
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
main_from___b1:
jsr main
jmp __breturn
// __start::@return
__breturn:
// [4] return
rts
}
// main
main: {
// [6] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [6] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
jmp __b1
// [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
__b1_from___b1:
// [6] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy
jmp __b1
// main::@1
__b1:
// [7] SCREEN[main::i#2] = idx -- pbuc1_derefidx_vbuxx=vbuz1
lda.z idx
sta SCREEN,x
// [8] idx = idx + main::i#2 -- vbuz1=vbuz1_plus_vbuxx
txa
clc
adc.z idx
sta.z idx
// [9] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
inx
// [10] if(main::i#1!=6) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #6
bne __b1_from___b1
jmp __breturn
// main::@return
__breturn:
// [11] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __init1
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___init1:
Removing instruction main_from___b1:
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
Removing instruction __breturn:
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
void __start()
__loadstore char idx // zp[1]:2 38.125
void main()
char main::i
char main::i#1 // reg byte x 151.5
char main::i#2 // reg byte x 134.66666666666666
reg byte x [ main::i#2 main::i#1 ]
zp[1]:2 [ idx ]
FINAL ASSEMBLER
Score: 288
// 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 zeropage notregister variable
// Upstart
// Commodore 64 PRG executable file
.file [name="declared-memory-var-7.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(__start)
// Global Constants & labels
.label SCREEN = $400
.label idx = 2
.segment Code
// __start
__start: {
// __start::__init1
// __ma char idx
// [1] idx = 0 -- vbuz1=vbuc1
lda #0
sta.z idx
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
jsr main
// __start::@return
// [4] return
rts
}
// main
main: {
// [6] phi from main to main::@1 [phi:main->main::@1]
// [6] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
// [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
// [6] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy
// main::@1
__b1:
// SCREEN[i] = idx
// [7] SCREEN[main::i#2] = idx -- pbuc1_derefidx_vbuxx=vbuz1
lda.z idx
sta SCREEN,x
// idx +=i
// [8] idx = idx + main::i#2 -- vbuz1=vbuz1_plus_vbuxx
txa
clc
adc.z idx
sta.z idx
// for( char i: 0..5 )
// [9] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
inx
// [10] if(main::i#1!=6) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #6
bne __b1
// main::@return
// }
// [11] return
rts
}
// File Data