mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-16 21:07:56 +00:00
381 lines
12 KiB
Plaintext
381 lines
12 KiB
Plaintext
Resolved forward reference fn1 to (void()) fn1()
|
|
Resolved forward reference fn2 to (void()) fn2()
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
(void()) main()
|
|
main: scope:[main] from __start
|
|
(void()*) main::f#0 ← (void()*) 0
|
|
(void()*) main::f#1 ← &(void()) fn1()
|
|
(byte~) main::$0 ← < (word)(void()*) main::f#1
|
|
*((const nomodify byte*) main::SCREEN + (number) 0) ← (byte~) main::$0
|
|
(byte~) main::$1 ← > (word)(void()*) main::f#1
|
|
*((const nomodify byte*) main::SCREEN + (number) 1) ← (byte~) main::$1
|
|
(void()*) main::f#2 ← &(void()) fn2()
|
|
(byte~) main::$2 ← < (word)(void()*) main::f#2
|
|
*((const nomodify byte*) main::SCREEN + (number) 2) ← (byte~) main::$2
|
|
(byte~) main::$3 ← > (word)(void()*) main::f#2
|
|
*((const nomodify byte*) main::SCREEN + (number) 3) ← (byte~) main::$3
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
return
|
|
to:@return
|
|
|
|
(void()) fn1()
|
|
fn1: scope:[fn1] from
|
|
*((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
|
|
to:fn1::@return
|
|
fn1::@return: scope:[fn1] from fn1
|
|
return
|
|
to:@return
|
|
|
|
(void()) fn2()
|
|
fn2: scope:[fn2] from
|
|
*((const nomodify byte*) fn2::BG_COLOR) ← ++ *((const nomodify byte*) fn2::BG_COLOR)
|
|
to:fn2::@return
|
|
fn2::@return: scope:[fn2] from fn2
|
|
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
|
|
(void()) __start()
|
|
(label) __start::@1
|
|
(label) __start::@return
|
|
(void()) fn1()
|
|
(label) fn1::@return
|
|
(const nomodify byte*) fn1::BORDER_COLOR = (byte*)(number) $d020
|
|
(void()) fn2()
|
|
(label) fn2::@return
|
|
(const nomodify byte*) fn2::BG_COLOR = (byte*)(number) $d021
|
|
(void()) main()
|
|
(byte~) main::$0
|
|
(byte~) main::$1
|
|
(byte~) main::$2
|
|
(byte~) main::$3
|
|
(label) main::@return
|
|
(const nomodify byte*) main::SCREEN = (byte*)(number) $400
|
|
(void()*) main::f
|
|
(void()*) main::f#0
|
|
(void()*) main::f#1
|
|
(void()*) main::f#2
|
|
|
|
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) main::SCREEN + (number) 0) ← (byte~) main::$0
|
|
Adding number conversion cast (unumber) 1 in *((const nomodify byte*) main::SCREEN + (number) 1) ← (byte~) main::$1
|
|
Adding number conversion cast (unumber) 2 in *((const nomodify byte*) main::SCREEN + (number) 2) ← (byte~) main::$2
|
|
Adding number conversion cast (unumber) 3 in *((const nomodify byte*) main::SCREEN + (number) 3) ← (byte~) main::$3
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Simplifying constant pointer cast (byte*) 53280
|
|
Simplifying constant pointer cast (byte*) 53281
|
|
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 (byte) 0
|
|
Finalized unsigned number type (byte) 1
|
|
Finalized unsigned number type (byte) 2
|
|
Finalized unsigned number type (byte) 3
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Constant (const void()*) main::f#0 = (void()*) 0
|
|
Constant (const void()*) main::f#1 = &fn1
|
|
Constant (const void()*) main::f#2 = &fn2
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant value identified (word)main::f#1 in [2] (byte~) main::$0 ← < (word)(const void()*) main::f#1
|
|
Constant value identified (word)main::f#1 in [4] (byte~) main::$1 ← > (word)(const void()*) main::f#1
|
|
Constant value identified (word)main::f#2 in [7] (byte~) main::$2 ← < (word)(const void()*) main::f#2
|
|
Constant value identified (word)main::f#2 in [9] (byte~) main::$3 ← > (word)(const void()*) main::f#2
|
|
Successful SSA optimization Pass2ConstantValues
|
|
Simplifying expression containing zero main::SCREEN in [3] *((const nomodify byte*) main::SCREEN + (byte) 0) ← (byte~) main::$0
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused constant (const void()*) main::f#0
|
|
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 [0] (byte~) main::$0 ← < (word)(const void()*) main::f#1
|
|
Constant right-side identified [2] (byte~) main::$1 ← > (word)(const void()*) main::f#1
|
|
Constant right-side identified [4] (byte~) main::$2 ← < (word)(const void()*) main::f#2
|
|
Constant right-side identified [6] (byte~) main::$3 ← > (word)(const void()*) main::f#2
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant (const byte) main::$0 = <(word)main::f#1
|
|
Constant (const byte) main::$1 = >(word)main::f#1
|
|
Constant (const byte) main::$2 = <(word)main::f#2
|
|
Constant (const byte) main::$3 = >(word)main::f#2
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Inlining constant with different constant siblings (const void()*) main::f#1
|
|
Inlining constant with different constant siblings (const void()*) main::f#2
|
|
Constant inlined main::f#2 = &(void()) fn2()
|
|
Constant inlined main::$3 = >(word)&(void()) fn2()
|
|
Constant inlined main::$1 = >(word)&(void()) fn1()
|
|
Constant inlined main::$2 = <(word)&(void()) fn2()
|
|
Constant inlined main::f#1 = &(void()) fn1()
|
|
Constant inlined main::$0 = <(word)&(void()) fn1()
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Consolidated array index constant in *(main::SCREEN+1)
|
|
Consolidated array index constant in *(main::SCREEN+2)
|
|
Consolidated array index constant in *(main::SCREEN+3)
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
|
CALL GRAPH
|
|
|
|
Created 0 initial phi equivalence classes
|
|
Coalesced down to 0 phi equivalence classes
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
(void()) fn2()
|
|
fn2: scope:[fn2] from
|
|
[0] *((const nomodify byte*) fn2::BG_COLOR) ← ++ *((const nomodify byte*) fn2::BG_COLOR)
|
|
to:fn2::@return
|
|
fn2::@return: scope:[fn2] from fn2
|
|
[1] return
|
|
to:@return
|
|
|
|
(void()) fn1()
|
|
fn1: scope:[fn1] from
|
|
[2] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR)
|
|
to:fn1::@return
|
|
fn1::@return: scope:[fn1] from fn1
|
|
[3] return
|
|
to:@return
|
|
|
|
(void()) main()
|
|
main: scope:[main] from
|
|
[4] *((const nomodify byte*) main::SCREEN) ← <(word)&(void()) fn1()
|
|
[5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← >(word)&(void()) fn1()
|
|
[6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← <(word)&(void()) fn2()
|
|
[7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← >(word)&(void()) fn2()
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[8] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(void()) fn1()
|
|
(void()) fn2()
|
|
(void()) main()
|
|
(void()*) main::f
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// Tests creating pointers to non-args no-return functions
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
// fn2
|
|
fn2: {
|
|
.label BG_COLOR = $d021
|
|
// [0] *((const nomodify byte*) fn2::BG_COLOR) ← ++ *((const nomodify byte*) fn2::BG_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc BG_COLOR
|
|
jmp __breturn
|
|
// fn2::@return
|
|
__breturn:
|
|
// [1] return
|
|
rts
|
|
}
|
|
// fn1
|
|
fn1: {
|
|
.label BORDER_COLOR = $d020
|
|
// [2] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc BORDER_COLOR
|
|
jmp __breturn
|
|
// fn1::@return
|
|
__breturn:
|
|
// [3] return
|
|
rts
|
|
}
|
|
// main
|
|
main: {
|
|
.label SCREEN = $400
|
|
// [4] *((const nomodify byte*) main::SCREEN) ← <(word)&(void()) fn1() -- _deref_pbuc1=vbuc2
|
|
lda #<fn1
|
|
sta SCREEN
|
|
// [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← >(word)&(void()) fn1() -- _deref_pbuc1=vbuc2
|
|
lda #>fn1
|
|
sta SCREEN+1
|
|
// [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← <(word)&(void()) fn2() -- _deref_pbuc1=vbuc2
|
|
lda #<fn2
|
|
sta SCREEN+2
|
|
// [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← >(word)&(void()) fn2() -- _deref_pbuc1=vbuc2
|
|
lda #>fn2
|
|
sta SCREEN+3
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [8] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] *((const nomodify byte*) main::SCREEN) ← <(word)&(void()) fn1() [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← >(word)&(void()) fn1() [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← <(word)&(void()) fn2() [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← >(word)&(void()) fn2() [ ] ( [ ] { } ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [main]
|
|
Uplift Scope [fn1]
|
|
Uplift Scope [fn2]
|
|
Uplift Scope []
|
|
|
|
Uplifting [main] best 63 combination
|
|
Uplifting [fn1] best 63 combination
|
|
Uplifting [fn2] best 63 combination
|
|
Uplifting [] best 63 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Tests creating pointers to non-args no-return functions
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
// fn2
|
|
fn2: {
|
|
.label BG_COLOR = $d021
|
|
// [0] *((const nomodify byte*) fn2::BG_COLOR) ← ++ *((const nomodify byte*) fn2::BG_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc BG_COLOR
|
|
jmp __breturn
|
|
// fn2::@return
|
|
__breturn:
|
|
// [1] return
|
|
rts
|
|
}
|
|
// fn1
|
|
fn1: {
|
|
.label BORDER_COLOR = $d020
|
|
// [2] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc BORDER_COLOR
|
|
jmp __breturn
|
|
// fn1::@return
|
|
__breturn:
|
|
// [3] return
|
|
rts
|
|
}
|
|
// main
|
|
main: {
|
|
.label SCREEN = $400
|
|
// [4] *((const nomodify byte*) main::SCREEN) ← <(word)&(void()) fn1() -- _deref_pbuc1=vbuc2
|
|
lda #<fn1
|
|
sta SCREEN
|
|
// [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← >(word)&(void()) fn1() -- _deref_pbuc1=vbuc2
|
|
lda #>fn1
|
|
sta SCREEN+1
|
|
// [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← <(word)&(void()) fn2() -- _deref_pbuc1=vbuc2
|
|
lda #<fn2
|
|
sta SCREEN+2
|
|
// [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← >(word)&(void()) fn2() -- _deref_pbuc1=vbuc2
|
|
lda #>fn2
|
|
sta SCREEN+3
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [8] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
(void()) fn1()
|
|
(label) fn1::@return
|
|
(const nomodify byte*) fn1::BORDER_COLOR = (byte*) 53280
|
|
(void()) fn2()
|
|
(label) fn2::@return
|
|
(const nomodify byte*) fn2::BG_COLOR = (byte*) 53281
|
|
(void()) main()
|
|
(label) main::@return
|
|
(const nomodify byte*) main::SCREEN = (byte*) 1024
|
|
(void()*) main::f
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 54
|
|
|
|
// File Comments
|
|
// Tests creating pointers to non-args no-return functions
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
// fn2
|
|
fn2: {
|
|
.label BG_COLOR = $d021
|
|
// (*BG_COLOR)++;
|
|
// [0] *((const nomodify byte*) fn2::BG_COLOR) ← ++ *((const nomodify byte*) fn2::BG_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc BG_COLOR
|
|
// fn2::@return
|
|
// }
|
|
// [1] return
|
|
rts
|
|
}
|
|
// fn1
|
|
fn1: {
|
|
.label BORDER_COLOR = $d020
|
|
// (*BORDER_COLOR)++;
|
|
// [2] *((const nomodify byte*) fn1::BORDER_COLOR) ← ++ *((const nomodify byte*) fn1::BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc BORDER_COLOR
|
|
// fn1::@return
|
|
// }
|
|
// [3] return
|
|
rts
|
|
}
|
|
// main
|
|
main: {
|
|
.label SCREEN = $400
|
|
// SCREEN[0] = <(word)f
|
|
// [4] *((const nomodify byte*) main::SCREEN) ← <(word)&(void()) fn1() -- _deref_pbuc1=vbuc2
|
|
lda #<fn1
|
|
sta SCREEN
|
|
// SCREEN[1] = >(word)f
|
|
// [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← >(word)&(void()) fn1() -- _deref_pbuc1=vbuc2
|
|
lda #>fn1
|
|
sta SCREEN+1
|
|
// SCREEN[2] = <(word)f
|
|
// [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← <(word)&(void()) fn2() -- _deref_pbuc1=vbuc2
|
|
lda #<fn2
|
|
sta SCREEN+2
|
|
// SCREEN[3] = >(word)f
|
|
// [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← >(word)&(void()) fn2() -- _deref_pbuc1=vbuc2
|
|
lda #>fn2
|
|
sta SCREEN+3
|
|
// main::@return
|
|
// }
|
|
// [8] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|