1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-16 21:07:56 +00:00
kickc/src/test/ref/zeropage-exhausted.log

304 lines
8.6 KiB
Plaintext
Raw Normal View History

CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
main::i#0 = 0
to:main::@1
main::@1: scope:[main] from main main::@2
main::i#2 = phi( main/main::i#0, main::@2/main::i#1 )
main::$0 = main::i#2 < $a
if(main::$0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
main::i#3 = phi( main::@1/main::i#2 )
main::$2 = (char)main::i#3
main::$1 = main::$2 * SIZEOF_INT
main::SCREEN[main::$1] = main::i#3
main::i#1 = ++ main::i#3
to:main::@1
main::@return: scope:[main] from main::@1
return
to:@return
void __start()
__start: scope:[__start] from
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
__start::@return: scope:[__start] from __start::@1
return
to:@return
SYMBOL TABLE SSA
__constant char SIZEOF_INT = 2
void __start()
void main()
bool main::$0
char main::$1
char main::$2
__constant int * const main::SCREEN = (int *)$400
int main::i
int main::i#0
int main::i#1
int main::i#2
int main::i#3
Adding number conversion cast (snumber) $a in main::$0 = main::i#2 < $a
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (int *) 1024
Simplifying constant integer cast $a
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed char) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::i#2 = main::i#3
Successful SSA optimization Pass2AliasElimination
Simple Condition main::$0 [3] if(main::i#2<$a) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Rewriting multiplication to use shift [3] main::$1 = main::$2 * SIZEOF_INT
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings main::i#0
Constant inlined main::i#0 = 0
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant SIZEOF_INT
Successful SSA optimization PassNEliminateUnusedVars
Adding NOP phi() at start of main
CALL GRAPH
Created 1 initial phi equivalence classes
Coalesced [8] main::i#4 = main::i#1
Coalesced down to 1 phi equivalence classes
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::@2
[1] main::i#2 = phi( main/0, main::@2/main::i#1 )
[2] if(main::i#2<$a) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[3] return
to:@return
main::@2: scope:[main] from main::@1
[4] main::$2 = (char)main::i#2
[5] main::$1 = main::$2 << 1
[6] main::SCREEN[main::$1] = main::i#2
[7] main::i#1 = ++ main::i#2
to:main::@1
VARIABLE REGISTER WEIGHTS
void main()
char main::$1 // 22.0
char main::$2 // 22.0
int main::i
int main::i#1 // 22.0
int main::i#2 // 8.8
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable main::$2 to live range equivalence class [ main::$2 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::$2 ]
[ main::$1 ]
Zero-page exhausted. Moving allocation to main memory main::i#2
Allocated mem[2] [ main::i#2 main::i#1 ]
Zero-page exhausted. Moving allocation to main memory main::$2
Allocated mem[1] [ main::$2 ]
Zero-page exhausted. Moving allocation to main memory main::$1
Allocated mem[1] [ main::$1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] if(main::i#2<$a) goto main::@2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
Statement [4] main::$2 = (char)main::i#2 [ main::i#2 main::$2 ] ( [ main::i#2 main::$2 ] { } ) always clobbers reg byte a
Statement [5] main::$1 = main::$2 << 1 [ main::i#2 main::$1 ] ( [ main::i#2 main::$1 ] { } ) always clobbers reg byte a
Statement [6] main::SCREEN[main::$1] = main::i#2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
Potential registers mem[2] [ main::i#2 main::i#1 ] : mem[2] ,
Potential registers mem[1] [ main::$2 ] : mem[1] , reg byte a , reg byte x , reg byte y ,
Potential registers mem[1] [ main::$1 ] : mem[1] , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 30.8: mem[2] [ main::i#2 main::i#1 ] 22: mem[1] [ main::$2 ] 22: mem[1] [ main::$1 ]
Uplift Scope []
Uplifting [main] best 841 combination mem[2] [ main::i#2 main::i#1 ] reg byte a [ main::$2 ] reg byte a [ main::$1 ]
Uplifting [] best 841 combination
Zero-page exhausted. Moving allocation to main memory main::i#2
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests warning when running out of zeropage-addresses for variables
// Upstart
// Commodore 64 PRG executable file
.file [name="zeropage-exhausted.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
.segment Code
// main
// And then allocate a 2-byte-variable
main: {
.label SCREEN = $400
// [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] -- vwsm1=vwsc1
lda #<0
sta i
lda #>0
sta i+1
jmp __b1
// main::@1
__b1:
// [2] if(main::i#2<$a) goto main::@2 -- vwsm1_lt_vwuc1_then_la1
lda i+1
bmi __b2
cmp #>$a
bcc __b2
bne !+
lda i
cmp #<$a
bcc __b2
!:
jmp __breturn
// main::@return
__breturn:
// [3] return
rts
// main::@2
__b2:
// [4] main::$2 = (char)main::i#2 -- vbuaa=_byte_vwsm1
lda i
// [5] main::$1 = main::$2 << 1 -- vbuaa=vbuaa_rol_1
asl
// [6] main::SCREEN[main::$1] = main::i#2 -- pwsc1_derefidx_vbuaa=vwsm1
tay
lda i
sta SCREEN,y
lda i+1
sta SCREEN+1,y
// [7] main::i#1 = ++ main::i#2 -- vwsm1=_inc_vwsm1
inc i
bne !+
inc i+1
!:
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [1] phi main::i#2 = main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
.segment Data
i: .word 0
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
void main()
char main::$1 // reg byte a 22.0
char main::$2 // reg byte a 22.0
__constant int * const main::SCREEN = (int *) 1024
int main::i
int main::i#1 // i mem[2] 22.0
int main::i#2 // i mem[2] 8.8
mem[2] [ main::i#2 main::i#1 ]
reg byte a [ main::$2 ]
reg byte a [ main::$1 ]
FINAL ASSEMBLER
Score: 761
// File Comments
// Tests warning when running out of zeropage-addresses for variables
// Upstart
// Commodore 64 PRG executable file
.file [name="zeropage-exhausted.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
.segment Code
// main
// And then allocate a 2-byte-variable
main: {
.label SCREEN = $400
// [1] phi from main to main::@1 [phi:main->main::@1]
// [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vwsm1=vwsc1
lda #<0
sta i
sta i+1
// main::@1
__b1:
// for(__zp int i=0;i<10;i++)
// [2] if(main::i#2<$a) goto main::@2 -- vwsm1_lt_vwuc1_then_la1
lda i+1
bmi __b2
cmp #>$a
bcc __b2
bne !+
lda i
cmp #<$a
bcc __b2
!:
// main::@return
// }
// [3] return
rts
// main::@2
__b2:
// SCREEN[(char)i] = i
// [4] main::$2 = (char)main::i#2 -- vbuaa=_byte_vwsm1
lda i
// [5] main::$1 = main::$2 << 1 -- vbuaa=vbuaa_rol_1
asl
// [6] main::SCREEN[main::$1] = main::i#2 -- pwsc1_derefidx_vbuaa=vwsm1
tay
lda i
sta SCREEN,y
lda i+1
sta SCREEN+1,y
// for(__zp int i=0;i<10;i++)
// [7] main::i#1 = ++ main::i#2 -- vwsm1=_inc_vwsm1
inc i
bne !+
inc i+1
!:
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [1] phi main::i#2 = main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
.segment Data
i: .word 0
}
// File Data