1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-07-01 22:29:45 +00:00
kickc/src/test/ref/declared-memory-var-1.log

265 lines
8.2 KiB
Plaintext
Raw Normal View History

2020-10-05 20:58:02 +00:00
Setting inferred volatile on symbol affected by address-of idx_p = &idx
Inlined call call __init
2019-09-26 12:53:33 +00:00
CONTROL FLOW GRAPH SSA
2020-10-05 20:58:02 +00:00
void main()
main: scope:[main] from __start::@1
2020-10-05 20:58:02 +00:00
main::i#0 = 0
2019-09-26 12:53:33 +00:00
to:main::@1
main::@1: scope:[main] from main main::@1
2020-10-05 20:58:02 +00:00
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
2019-09-26 12:53:33 +00:00
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
2020-06-27 19:18:00 +00:00
2020-10-05 20:58:02 +00:00
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
2020-06-27 19:18:00 +00:00
return
to:@return
2019-09-26 12:53:33 +00:00
SYMBOL TABLE SSA
__constant char * const SCREEN = (char *)$400
2020-10-05 20:58:02 +00:00
void __start()
__loadstore volatile char idx = 0
__constant char *idx_p = &idx
2020-10-05 20:58:02 +00:00
void main()
bool main::$0
char main::i
char main::i#0
char main::i#1
char main::i#2
2019-09-26 12:53:33 +00:00
Simplifying constant pointer cast (char *) 1024
2019-09-26 12:53:33 +00:00
Successful SSA optimization PassNCastSimplification
2020-10-05 20:58:02 +00:00
Simple Condition main::$0 [6] if(main::i#1!=rangelast(0,5)) goto main::@1
2019-09-26 12:53:33 +00:00
Successful SSA optimization Pass2ConditionalJumpSimplification
2020-10-05 20:58:02 +00:00
Constant main::i#0 = 0
2019-09-26 12:53:33 +00:00
Successful SSA optimization Pass2ConstantIdentification
2020-10-05 20:58:02 +00:00
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
2020-06-27 19:18:00 +00:00
Successful SSA optimization PassNEliminateEmptyStart
2020-10-05 20:58:02 +00:00
Adding number conversion cast (unumber) 6 in [4] if(main::i#1!=6) goto main::@1
2019-09-26 12:53:33 +00:00
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 6
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 6
2019-09-26 12:53:33 +00:00
Successful SSA optimization PassNFinalizeNumberTypeConversions
2020-10-05 20:58:02 +00:00
Inlining constant with var siblings main::i#0
Constant inlined main::i#0 = 0
2019-09-26 12:53:33 +00:00
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@2(between main::@1 and main::@1)
2019-09-26 12:53:33 +00:00
Adding NOP phi() at start of main
CALL GRAPH
Created 1 initial phi equivalence classes
2020-10-05 20:58:02 +00:00
Coalesced [7] main::i#3 = main::i#1
2019-09-26 12:53:33 +00:00
Coalesced down to 1 phi equivalence classes
2020-10-05 20:58:02 +00:00
Culled Empty Block label main::@2
2019-09-26 12:53:33 +00:00
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
2020-10-05 20:58:02 +00:00
void main()
2020-06-27 19:18:00 +00:00
main: scope:[main] from
[0] phi()
2019-09-26 12:53:33 +00:00
to:main::@1
main::@1: scope:[main] from main main::@1
2020-10-05 20:58:02 +00:00
[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
2019-09-26 12:53:33 +00:00
to:main::@return
main::@return: scope:[main] from main::@1
2020-06-27 19:18:00 +00:00
[6] return
2019-09-26 12:53:33 +00:00
to:@return
VARIABLE REGISTER WEIGHTS
__loadstore volatile char idx = 0
2020-10-05 20:58:02 +00:00
void main()
char main::i
char main::i#1 // 16.5
char main::i#2 // 14.666666666666666
2019-09-26 12:53:33 +00:00
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
2019-12-08 15:04:35 +00:00
Added variable idx to live range equivalence class [ idx ]
2019-09-26 12:53:33 +00:00
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ idx ]
2019-10-12 09:40:36 +00:00
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated mem[1] [ idx ]
2019-09-26 12:53:33 +00:00
REGISTER UPLIFT POTENTIAL REGISTERS
2020-10-05 20:58:02 +00:00
Statement [2] SCREEN[main::i#2] = *idx_p [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
2019-10-12 09:40:36 +00:00
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
2020-10-05 20:58:02 +00:00
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
2019-10-12 09:40:36 +00:00
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] ,
2019-09-26 12:53:33 +00:00
REGISTER UPLIFT SCOPES
2020-06-27 19:18:00 +00:00
Uplift Scope [main] 31.17: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 0: mem[1] [ idx ]
2019-09-26 12:53:33 +00:00
2020-06-27 19:18:00 +00:00
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 ]
2020-06-27 19:18:00 +00:00
Uplifting [] best 391 combination mem[1] [ idx ]
2019-09-26 12:53:33 +00:00
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)
2019-09-26 13:05:50 +00:00
// Test a pointer to a memory variable
2019-09-26 12:53:33 +00:00
// 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)
2019-09-26 12:53:33 +00:00
// Global Constants & labels
.label SCREEN = $400
.label idx_p = idx
.segment Code
2019-09-26 12:53:33 +00:00
// main
main: {
2020-06-27 19:18:00 +00:00
// [1] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
2020-10-05 20:58:02 +00:00
// [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
2019-09-26 12:53:33 +00:00
ldx #0
jmp __b1
2020-06-27 19:18:00 +00:00
// [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
__b1_from___b1:
2020-10-05 20:58:02 +00:00
// [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy
jmp __b1
2019-09-26 12:53:33 +00:00
// main::@1
__b1:
2020-10-05 20:58:02 +00:00
// [2] SCREEN[main::i#2] = *idx_p -- pbuc1_derefidx_vbuxx=_deref_pbuc2
lda idx_p
2019-09-26 12:53:33 +00:00
sta SCREEN,x
2020-10-05 20:58:02 +00:00
// [3] *idx_p = *idx_p + main::i#2 -- _deref_pbuc1=_deref_pbuc1_plus_vbuxx
2019-09-26 12:53:33 +00:00
txa
clc
adc idx_p
sta idx_p
2020-10-05 20:58:02 +00:00
// [4] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
2019-09-26 12:53:33 +00:00
inx
2020-10-05 20:58:02 +00:00
// [5] if(main::i#1!=6) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
2019-09-26 12:53:33 +00:00
cpx #6
bne __b1_from___b1
jmp __breturn
2019-09-26 12:53:33 +00:00
// main::@return
__breturn:
2020-06-27 19:18:00 +00:00
// [6] return
2019-09-26 12:53:33 +00:00
rts
}
// File Data
.segment Data
2019-09-26 12:53:33 +00:00
idx: .byte 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
2019-09-26 12:53:33 +00:00
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___b1:
2019-09-26 12:53:33 +00:00
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
2019-09-26 12:53:33 +00:00
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
2019-09-26 12:53:33 +00:00
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
2020-10-05 20:58:02 +00:00
void main()
char main::i
char main::i#1 // reg byte x 16.5
char main::i#2 // reg byte x 14.666666666666666
2019-09-26 12:53:33 +00:00
reg byte x [ main::i#2 main::i#1 ]
mem[1] [ idx ]
2019-09-26 12:53:33 +00:00
FINAL ASSEMBLER
Score: 301
2019-09-26 12:53:33 +00:00
// File Comments
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
2019-09-26 13:05:50 +00:00
// Test a pointer to a memory variable
2019-09-26 12:53:33 +00:00
// 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)
2019-09-26 12:53:33 +00:00
// Global Constants & labels
.label SCREEN = $400
.label idx_p = idx
.segment Code
2019-09-26 12:53:33 +00:00
// main
main: {
2020-06-27 19:18:00 +00:00
// [1] phi from main to main::@1 [phi:main->main::@1]
2020-10-05 20:58:02 +00:00
// [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
2019-09-26 12:53:33 +00:00
ldx #0
2020-06-27 19:18:00 +00:00
// [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
2020-10-05 20:58:02 +00:00
// [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy
2019-09-26 12:53:33 +00:00
// main::@1
__b1:
2019-09-26 12:53:33 +00:00
// SCREEN[i] = *idx_p
2020-10-05 20:58:02 +00:00
// [2] SCREEN[main::i#2] = *idx_p -- pbuc1_derefidx_vbuxx=_deref_pbuc2
lda idx_p
2019-09-26 12:53:33 +00:00
sta SCREEN,x
// *idx_p +=i
2020-10-05 20:58:02 +00:00
// [3] *idx_p = *idx_p + main::i#2 -- _deref_pbuc1=_deref_pbuc1_plus_vbuxx
2019-09-26 12:53:33 +00:00
txa
clc
adc idx_p
sta idx_p
2019-09-26 12:53:33 +00:00
// for( char i: 0..5 )
2020-10-05 20:58:02 +00:00
// [4] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
2019-09-26 12:53:33 +00:00
inx
2020-10-05 20:58:02 +00:00
// [5] if(main::i#1!=6) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
2019-09-26 12:53:33 +00:00
cpx #6
bne __b1
2019-09-26 12:53:33 +00:00
// main::@return
// }
2020-06-27 19:18:00 +00:00
// [6] return
2019-09-26 12:53:33 +00:00
rts
}
// File Data
.segment Data
2019-09-26 12:53:33 +00:00
idx: .byte 0