mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-29 09:29:31 +00:00
202 lines
5.7 KiB
Plaintext
202 lines
5.7 KiB
Plaintext
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
void main()
|
|
main: scope:[main] from __start
|
|
main::$0 = main::c1 * 2
|
|
main::c2#0 = main::$0
|
|
main::c2#1 = ++ main::c2#0
|
|
main::$1 = main::c1 * main::c2#1
|
|
main::c3#0 = main::$1
|
|
SCREEN[0] = main::c3#0
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
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
|
|
const nomodify byte* SCREEN = (byte*)$400
|
|
void __start()
|
|
void main()
|
|
number~ main::$0
|
|
byte~ main::$1
|
|
const byte main::c1 = 4
|
|
byte main::c2
|
|
byte main::c2#0
|
|
byte main::c2#1
|
|
byte main::c3
|
|
byte main::c3#0
|
|
|
|
Adding number conversion cast (unumber) 2 in main::$0 = main::c1 * 2
|
|
Adding number conversion cast (unumber) main::$0 in main::$0 = main::c1 * (unumber)2
|
|
Adding number conversion cast (unumber) 0 in SCREEN[0] = main::c3#0
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Simplifying constant integer cast 2
|
|
Simplifying constant integer cast 0
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 2
|
|
Finalized unsigned number type (byte) 0
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Inferred type updated to byte in main::$0 = main::c1 * 2
|
|
Alias main::c2#0 = main::$0
|
|
Alias main::c3#0 = main::$1
|
|
Successful SSA optimization Pass2AliasElimination
|
|
Constant right-side identified [0] main::c2#0 = main::c1 * 2
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant main::c2#0 = main::c1*2
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Simplifying expression containing zero SCREEN in [3] SCREEN[0] = main::c3#0
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
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
|
|
Constant right-side identified [0] main::c2#1 = ++ main::c2#0
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant main::c2#1 = ++main::c2#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant right-side identified [0] main::c3#0 = main::c1 * main::c2#1
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant main::c3#0 = main::c1*main::c2#1
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Inlining constant with different constant siblings main::c2#0
|
|
Inlining constant with different constant siblings main::c2#1
|
|
Constant inlined main::c2#0 = main::c1*2
|
|
Constant inlined main::c2#1 = ++main::c1*2
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Simplifying constant integer increment ++main::c1*2
|
|
Successful SSA optimization Pass2ConstantSimplification
|
|
Adding number conversion cast (unumber) main::c1*2+1 in
|
|
Adding number conversion cast (unumber) 1 in
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant integer cast main::c1*2+(unumber)1
|
|
Simplifying constant integer cast 1
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 1
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
CALL GRAPH
|
|
|
|
Created 0 initial phi equivalence classes
|
|
Coalesced down to 0 phi equivalence classes
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
void main()
|
|
main: scope:[main] from
|
|
[0] *SCREEN = main::c3#0
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[1] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
void main()
|
|
byte main::c2
|
|
byte main::c3
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [0] *SCREEN = main::c3#0 [ ] ( [ ] { } ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [main]
|
|
Uplift Scope []
|
|
|
|
Uplifting [main] best 15 combination
|
|
Uplifting [] best 15 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Test compile-time and run-time multiplication
|
|
// Compile-time multiplication
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="multiply-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
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
.const c1 = 4
|
|
.const c3 = c1*(c1*2+1)
|
|
// [0] *SCREEN = main::c3#0 -- _deref_pbuc1=vbuc2
|
|
lda #c3
|
|
sta SCREEN
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [1] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
const nomodify byte* SCREEN = (byte*) 1024
|
|
void main()
|
|
const byte main::c1 = 4
|
|
byte main::c2
|
|
byte main::c3
|
|
const byte main::c3#0 c3 = main::c1*main::c1*2+1
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 12
|
|
|
|
// File Comments
|
|
// Test compile-time and run-time multiplication
|
|
// Compile-time multiplication
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="multiply-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
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
.const c1 = 4
|
|
.const c3 = c1*(c1*2+1)
|
|
// SCREEN[0] = c3
|
|
// [0] *SCREEN = main::c3#0 -- _deref_pbuc1=vbuc2
|
|
lda #c3
|
|
sta SCREEN
|
|
// main::@return
|
|
// }
|
|
// [1] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|