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

522 lines
17 KiB
Plaintext

Fixing struct type size struct printf_buffer_number to 12
Fixing struct type size struct printf_buffer_number to 12
Fixing struct type size struct printf_buffer_number to 12
Fixing struct type SIZE_OF struct printf_buffer_number to 12
Fixing struct type SIZE_OF struct printf_buffer_number to 12
Inlined call vicSelectGfxBank::$0 = call toDd00(vicSelectGfxBank::gfx)
Inlined call call __init
Eliminating unused variable with no statement gotoxy::$4
Eliminating unused variable with no statement printf_buffer
CONTROL FLOW GRAPH SSA
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
gotoxy::x#3 = phi( conio_c64_init::@1/gotoxy::x#1 )
gotoxy::y#2 = phi( conio_c64_init::@1/gotoxy::y#1 )
gotoxy::$0 = gotoxy::y#2 > $19
gotoxy::$1 = ! gotoxy::$0
if(gotoxy::$1) goto gotoxy::@1
to:gotoxy::@2
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@2
gotoxy::x#2 = phi( gotoxy/gotoxy::x#3, gotoxy::@2/gotoxy::x#4 )
gotoxy::$2 = gotoxy::x#2 >= $28
gotoxy::$3 = ! gotoxy::$2
if(gotoxy::$3) goto gotoxy::@return
to:gotoxy::@3
gotoxy::@2: scope:[gotoxy] from gotoxy
gotoxy::x#4 = phi( gotoxy/gotoxy::x#3 )
gotoxy::y#0 = 0
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy::@1
gotoxy::x#0 = 0
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@1 gotoxy::@3
return
to:@return
void conio_c64_init()
conio_c64_init: scope:[conio_c64_init] from __start::__init1
conio_c64_init::line#0 = *conio_c64_init::BASIC_CURSOR_LINE
conio_c64_init::$0 = conio_c64_init::line#0 >= $19
conio_c64_init::$1 = ! conio_c64_init::$0
if(conio_c64_init::$1) goto conio_c64_init::@1
to:conio_c64_init::@2
conio_c64_init::@1: scope:[conio_c64_init] from conio_c64_init conio_c64_init::@2
conio_c64_init::line#2 = phi( conio_c64_init/conio_c64_init::line#0, conio_c64_init::@2/conio_c64_init::line#1 )
gotoxy::x#1 = 0
gotoxy::y#1 = conio_c64_init::line#2
call gotoxy
to:conio_c64_init::@3
conio_c64_init::@3: scope:[conio_c64_init] from conio_c64_init::@1
to:conio_c64_init::@return
conio_c64_init::@2: scope:[conio_c64_init] from conio_c64_init
conio_c64_init::line#1 = $19-1
to:conio_c64_init::@1
conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@3
return
to:@return
void chrout(volatile char petscii)
chrout: scope:[chrout] from main main::@1 main::@2 main::@3 main::@4
asm { jsr$ffd2 }
to:chrout::@return
chrout::@return: scope:[chrout] from chrout
return
to:@return
void main()
main: scope:[main] from __start::@1
chrout::petscii = $95
call chrout
to:main::@1
main::@1: scope:[main] from main
chrout::petscii = points[0]
call chrout
to:main::@2
main::@2: scope:[main] from main::@1
chrout::petscii = points[1]
call chrout
to:main::@3
main::@3: scope:[main] from main::@2
chrout::petscii = points[2]
call chrout
to:main::@4
main::@4: scope:[main] from main::@3
chrout::petscii = points[3]
call chrout
to:main::@5
main::@5: scope:[main] from main::@4
to:main::@return
main::@return: scope:[main] from main::@5
return
to:@return
void __start()
__start: scope:[__start] from
to:__start::__init1
__start::__init1: scope:[__start] from __start
call conio_c64_init
to:__start::@2
__start::@2: scope:[__start] from __start::__init1
to:__start::@1
__start::@1: scope:[__start] from __start::@2
call main
to:__start::@3
__start::@3: scope:[__start] from __start::@1
to:__start::@return
__start::@return: scope:[__start] from __start::@3
return
to:@return
SYMBOL TABLE SSA
__constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
void __start()
void chrout(volatile char petscii)
__loadstore volatile char chrout::petscii
void conio_c64_init()
bool conio_c64_init::$0
bool conio_c64_init::$1
__constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *)$d6
char conio_c64_init::line
char conio_c64_init::line#0
char conio_c64_init::line#1
char conio_c64_init::line#2
void gotoxy(char x , char y)
bool gotoxy::$0
bool gotoxy::$1
bool gotoxy::$2
bool gotoxy::$3
char gotoxy::x
char gotoxy::x#0
char gotoxy::x#1
char gotoxy::x#2
char gotoxy::x#3
char gotoxy::x#4
char gotoxy::y
char gotoxy::y#0
char gotoxy::y#1
char gotoxy::y#2
void main()
__constant char points[] = { 1, 2, 3, 4 }
Adding number conversion cast (unumber) $19 in gotoxy::$0 = gotoxy::y#2 > $19
Adding number conversion cast (unumber) $28 in gotoxy::$2 = gotoxy::x#2 >= $28
Adding number conversion cast (unumber) 0 in gotoxy::y#0 = 0
Adding number conversion cast (unumber) 0 in gotoxy::x#0 = 0
Adding number conversion cast (unumber) $19 in conio_c64_init::$0 = conio_c64_init::line#0 >= $19
Adding number conversion cast (unumber) 0 in gotoxy::x#1 = 0
Adding number conversion cast (unumber) $19-1 in conio_c64_init::line#1 = $19-1
Adding number conversion cast (unumber) $95 in chrout::petscii = $95
Adding number conversion cast (unumber) 0 in chrout::petscii = points[0]
Adding number conversion cast (unumber) 1 in chrout::petscii = points[1]
Adding number conversion cast (unumber) 2 in chrout::petscii = points[2]
Adding number conversion cast (unumber) 3 in chrout::petscii = points[3]
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast gotoxy::y#0 = (unumber)0
Inlining cast gotoxy::x#0 = (unumber)0
Inlining cast gotoxy::x#1 = (unumber)0
Inlining cast conio_c64_init::line#1 = (unumber)$19-1
Inlining cast chrout::petscii = (unumber)$95
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 214
Simplifying constant integer cast $19
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $19
Simplifying constant integer cast 0
Simplifying constant integer cast $95
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $19
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $19
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $95
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [2] gotoxy::$1 = gotoxy::y#2 <= $19 from [1] gotoxy::$0 = gotoxy::y#2 > $19
Inversing boolean not [6] gotoxy::$3 = gotoxy::x#2 < $28 from [5] gotoxy::$2 = gotoxy::x#2 >= $28
Inversing boolean not [14] conio_c64_init::$1 = conio_c64_init::line#0 < $19 from [13] conio_c64_init::$0 = conio_c64_init::line#0 >= $19
Successful SSA optimization Pass2UnaryNotSimplification
Alias gotoxy::x#3 = gotoxy::x#4
Successful SSA optimization Pass2AliasElimination
Alias gotoxy::x#2 = gotoxy::x#3
Successful SSA optimization Pass2AliasElimination
Identical Phi Values gotoxy::y#2 gotoxy::y#1
Identical Phi Values gotoxy::x#2 gotoxy::x#1
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition gotoxy::$1 [2] if(gotoxy::y#1<=$19) goto gotoxy::@1
Simple Condition gotoxy::$3 [4] if(gotoxy::x#1<$28) goto gotoxy::@return
Simple Condition conio_c64_init::$1 [10] if(conio_c64_init::line#0<$19) goto conio_c64_init::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [15] conio_c64_init::line#1 = (unumber)$19-1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant gotoxy::y#0 = 0
Constant gotoxy::x#0 = 0
Constant gotoxy::x#1 = 0
Constant conio_c64_init::line#1 = (unumber)$19-1
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [4] if(gotoxy::x#1<$28) goto gotoxy::@return
Successful SSA optimization Pass2ConstantIfs
Rewriting conditional comparison [2] if(gotoxy::y#1<=$19) goto gotoxy::@1
Simplifying expression containing zero points in [21] chrout::petscii = points[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Removing call to empty/unused procedure [30] call conio_c64_init
Successful SSA optimization PassNEliminateUnusedConstructors
Eliminating variable conio_c64_init::line#0 from unused block conio_c64_init
Eliminating variable conio_c64_init::line#2 from unused block conio_c64_init::@1
Eliminating variable gotoxy::y#1 from unused block conio_c64_init::@1
Removing unused procedure gotoxy
Removing unused procedure block gotoxy
Removing unused procedure block gotoxy::@1
Removing unused procedure block gotoxy::@2
Removing unused procedure block gotoxy::@3
Removing unused procedure block gotoxy::@return
Removing unused procedure conio_c64_init
Removing unused procedure block conio_c64_init
Removing PHI-reference to removed block (conio_c64_init) in block conio_c64_init::@1
Removing unused procedure block conio_c64_init::@1
Removing unused procedure block conio_c64_init::@3
Removing unused procedure block conio_c64_init::@2
Removing unused procedure block conio_c64_init::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@1
Removing unused procedure block __start::@3
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Consolidated array index constant in *(points+1)
Consolidated array index constant in *(points+2)
Consolidated array index constant in *(points+3)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 8
Finalized unsigned number type (char) $a
Finalized unsigned number type (char) $10
Finalized unsigned number type (char) $b
Finalized unsigned number type (char) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main::@5
CALL GRAPH
Calls in [main] to chrout:1 chrout:3 chrout:5 chrout:7 chrout:9
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::@5
FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] chrout::petscii = $95
[1] call chrout
to:main::@1
main::@1: scope:[main] from main
[2] chrout::petscii = *points
[3] call chrout
to:main::@2
main::@2: scope:[main] from main::@1
[4] chrout::petscii = *(points+1)
[5] call chrout
to:main::@3
main::@3: scope:[main] from main::@2
[6] chrout::petscii = *(points+2)
[7] call chrout
to:main::@4
main::@4: scope:[main] from main::@3
[8] chrout::petscii = *(points+3)
[9] call chrout
to:main::@return
main::@return: scope:[main] from main::@4
[10] return
to:@return
void chrout(volatile char petscii)
chrout: scope:[chrout] from main main::@1 main::@2 main::@3 main::@4
asm { jsr$ffd2 }
to:chrout::@return
chrout::@return: scope:[chrout] from chrout
[12] return
to:@return
VARIABLE REGISTER WEIGHTS
void chrout(volatile char petscii)
__loadstore volatile char chrout::petscii // 100.0
void main()
Initial phi equivalence classes
Added variable chrout::petscii to live range equivalence class [ chrout::petscii ]
Complete equivalence classes
[ chrout::petscii ]
Allocated zp[1]:2 [ chrout::petscii ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] chrout::petscii = $95 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [2] chrout::petscii = *points [ ] ( [ ] { } ) always clobbers reg byte a
Statement [4] chrout::petscii = *(points+1) [ ] ( [ ] { } ) always clobbers reg byte a
Statement [6] chrout::petscii = *(points+2) [ ] ( [ ] { } ) always clobbers reg byte a
Statement [8] chrout::petscii = *(points+3) [ ] ( [ ] { } ) always clobbers reg byte a
Statement asm { jsr$ffd2 } always clobbers reg byte a reg byte x reg byte y
Potential registers zp[1]:2 [ chrout::petscii ] : zp[1]:2 ,
REGISTER UPLIFT SCOPES
Uplift Scope [chrout] 100: zp[1]:2 [ chrout::petscii ]
Uplift Scope [RADIX]
Uplift Scope [MOS6526_CIA]
Uplift Scope [MOS6569_VICII]
Uplift Scope [MOS6581_SID]
Uplift Scope [printf_format_number]
Uplift Scope [printf_buffer_number]
Uplift Scope [printf_format_string]
Uplift Scope [main]
Uplift Scope []
Uplifting [chrout] best 99 combination zp[1]:2 [ chrout::petscii ]
Uplifting [RADIX] best 99 combination
Uplifting [MOS6526_CIA] best 99 combination
Uplifting [MOS6569_VICII] best 99 combination
Uplifting [MOS6581_SID] best 99 combination
Uplifting [printf_format_number] best 99 combination
Uplifting [printf_buffer_number] best 99 combination
Uplifting [printf_format_string] best 99 combination
Uplifting [main] best 99 combination
Uplifting [] best 99 combination
Attempting to uplift remaining variables inzp[1]:2 [ chrout::petscii ]
Uplifting [chrout] best 99 combination zp[1]:2 [ chrout::petscii ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
/// @file
/// Functions for performing input and output.
// Upstart
// Commodore 64 PRG executable file
.file [name="ducks-array.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
main: {
// [0] chrout::petscii = $95 -- vbuz1=vbuc1
lda #$95
sta.z chrout.petscii
// [1] call chrout
jsr chrout
jmp __b1
// main::@1
__b1:
// [2] chrout::petscii = *points -- vbuz1=_deref_pbuc1
lda points
sta.z chrout.petscii
// [3] call chrout
jsr chrout
jmp __b2
// main::@2
__b2:
// [4] chrout::petscii = *(points+1) -- vbuz1=_deref_pbuc1
lda points+1
sta.z chrout.petscii
// [5] call chrout
jsr chrout
jmp __b3
// main::@3
__b3:
// [6] chrout::petscii = *(points+2) -- vbuz1=_deref_pbuc1
lda points+2
sta.z chrout.petscii
// [7] call chrout
jsr chrout
jmp __b4
// main::@4
__b4:
// [8] chrout::petscii = *(points+3) -- vbuz1=_deref_pbuc1
lda points+3
sta.z chrout.petscii
// [9] call chrout
jsr chrout
jmp __breturn
// main::@return
__breturn:
// [10] return
rts
}
// chrout
// void chrout(__zp(2) volatile char petscii)
chrout: {
.label petscii = 2
// asm { jsr$ffd2 }
jsr $ffd2
jmp __breturn
// chrout::@return
__breturn:
// [12] return
rts
}
// File Data
.segment Data
points: .byte 1, 2, 3, 4
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __b3:
Removing instruction __b4:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
__constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
void chrout(volatile char petscii)
__loadstore volatile char chrout::petscii // zp[1]:2 100.0
void main()
__constant char points[] = { 1, 2, 3, 4 }
zp[1]:2 [ chrout::petscii ]
FINAL ASSEMBLER
Score: 81
// File Comments
/// @file
/// Functions for performing input and output.
// Upstart
// Commodore 64 PRG executable file
.file [name="ducks-array.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
main: {
// chrout(149)
// [0] chrout::petscii = $95 -- vbuz1=vbuc1
lda #$95
sta.z chrout.petscii
// [1] call chrout
jsr chrout
// main::@1
// chrout(points[0])
// [2] chrout::petscii = *points -- vbuz1=_deref_pbuc1
lda points
sta.z chrout.petscii
// [3] call chrout
jsr chrout
// main::@2
// chrout(points[1])
// [4] chrout::petscii = *(points+1) -- vbuz1=_deref_pbuc1
lda points+1
sta.z chrout.petscii
// [5] call chrout
jsr chrout
// main::@3
// chrout(points[2])
// [6] chrout::petscii = *(points+2) -- vbuz1=_deref_pbuc1
lda points+2
sta.z chrout.petscii
// [7] call chrout
jsr chrout
// main::@4
// chrout(points[3])
// [8] chrout::petscii = *(points+3) -- vbuz1=_deref_pbuc1
lda points+3
sta.z chrout.petscii
// [9] call chrout
jsr chrout
// main::@return
// }
// [10] return
rts
}
// chrout
// void chrout(__zp(2) volatile char petscii)
chrout: {
.label petscii = 2
// asm
// asm { jsr$ffd2 }
jsr $ffd2
// chrout::@return
// }
// [12] return
rts
}
// File Data
.segment Data
points: .byte 1, 2, 3, 4