mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-29 03:56:15 +00:00
196 lines
5.9 KiB
Plaintext
196 lines
5.9 KiB
Plaintext
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
void main()
|
|
main: scope:[main] from __start
|
|
main::i#0 = 0
|
|
main::SCREEN[main::i#0] = *((byte*)&bar+OFFSET_STRUCT_FOO_THING1)
|
|
main::i#1 = ++ main::i#0
|
|
main::SCREEN[main::i#1] = *((byte*)&bar+OFFSET_STRUCT_FOO_THING2)
|
|
main::i#2 = ++ main::i#1
|
|
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 byte OFFSET_STRUCT_FOO_THING1 = 0
|
|
const byte OFFSET_STRUCT_FOO_THING2 = 1
|
|
void __start()
|
|
struct foo bar loadstore = { thing1: 'a', thing2: 'b' }
|
|
void main()
|
|
const nomodify byte* main::SCREEN = (byte*)$400
|
|
byte main::i
|
|
byte main::i#0
|
|
byte main::i#1
|
|
byte main::i#2
|
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Successful SSA optimization PassNCastSimplification
|
|
Constant main::i#0 = 0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Simplifying expression containing zero (byte*)&bar in [1] main::SCREEN[main::i#0] = *((byte*)&bar+OFFSET_STRUCT_FOO_THING1)
|
|
Simplifying expression containing zero main::SCREEN in [1] main::SCREEN[main::i#0] = *((byte*)&bar)
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused variable main::i#2 and assignment [3] main::i#2 = ++ main::i#1
|
|
Eliminating unused constant OFFSET_STRUCT_FOO_THING1
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
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 [1] main::i#1 = ++ main::i#0
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant main::i#1 = ++main::i#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Inlining constant with different constant siblings main::i#0
|
|
Inlining constant with different constant siblings main::i#1
|
|
Constant inlined main::i#0 = 0
|
|
Constant inlined main::i#1 = ++0
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Consolidated array index constant in *(main::SCREEN+++0)
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
|
Simplifying constant integer increment ++0
|
|
Successful SSA optimization Pass2ConstantSimplification
|
|
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] *main::SCREEN = *((byte*)&bar)
|
|
[1] *(main::SCREEN+1) = *((byte*)&bar+OFFSET_STRUCT_FOO_THING2)
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[2] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
struct foo bar loadstore = { thing1: 'a', thing2: 'b' }
|
|
void main()
|
|
byte main::i
|
|
|
|
Initial phi equivalence classes
|
|
Added variable bar to live range equivalence class [ bar ]
|
|
Complete equivalence classes
|
|
[ bar ]
|
|
Allocated mem[2] [ bar ]
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [0] *main::SCREEN = *((byte*)&bar) [ bar ] ( [ bar ] { } ) always clobbers reg byte a
|
|
Statement [1] *(main::SCREEN+1) = *((byte*)&bar+OFFSET_STRUCT_FOO_THING2) [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Potential registers mem[2] [ bar ] : mem[2] ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [foo]
|
|
Uplift Scope [main]
|
|
Uplift Scope [] 0: mem[2] [ bar ]
|
|
|
|
Uplifting [foo] best 25 combination
|
|
Uplifting [main] best 25 combination
|
|
Uplifting [] best 25 combination mem[2] [ bar ]
|
|
|
|
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 memory variable struct value
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="declared-memory-var-5.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
|
|
.const OFFSET_STRUCT_FOO_THING2 = 1
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
.label SCREEN = $400
|
|
// [0] *main::SCREEN = *((byte*)&bar) -- _deref_pbuc1=_deref_pbuc2
|
|
lda bar
|
|
sta SCREEN
|
|
// [1] *(main::SCREEN+1) = *((byte*)&bar+OFFSET_STRUCT_FOO_THING2) -- _deref_pbuc1=_deref_pbuc2
|
|
lda bar+OFFSET_STRUCT_FOO_THING2
|
|
sta SCREEN+1
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [2] return
|
|
rts
|
|
}
|
|
// File Data
|
|
.segment Data
|
|
bar: .byte 'a', 'b'
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
const byte OFFSET_STRUCT_FOO_THING2 = 1
|
|
struct foo bar loadstore mem[2] = { thing1: 'a', thing2: 'b' }
|
|
void main()
|
|
const nomodify byte* main::SCREEN = (byte*) 1024
|
|
byte main::i
|
|
|
|
mem[2] [ bar ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 22
|
|
|
|
// 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 memory variable struct value
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="declared-memory-var-5.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
|
|
.const OFFSET_STRUCT_FOO_THING2 = 1
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
.label SCREEN = $400
|
|
// SCREEN[i++] = bar.thing1
|
|
// [0] *main::SCREEN = *((byte*)&bar) -- _deref_pbuc1=_deref_pbuc2
|
|
lda bar
|
|
sta SCREEN
|
|
// SCREEN[i++] = bar.thing2
|
|
// [1] *(main::SCREEN+1) = *((byte*)&bar+OFFSET_STRUCT_FOO_THING2) -- _deref_pbuc1=_deref_pbuc2
|
|
lda bar+OFFSET_STRUCT_FOO_THING2
|
|
sta SCREEN+1
|
|
// main::@return
|
|
// }
|
|
// [2] return
|
|
rts
|
|
}
|
|
// File Data
|
|
.segment Data
|
|
bar: .byte 'a', 'b'
|
|
|