1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-18 04:08:58 +00:00
kickc/src/test/ref/operator-byte1.log

543 lines
19 KiB
Plaintext
Raw Normal View History

CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
main::bu = 7
main::bs = 7
main::wu = $4e20
main::ws = -$b1
main::du = $1e8480
main::ds = -$39a4f1
main::ptr = (byte*)0
main::i#0 = 0
main::SCREEN[main::i#0] = >$11
main::i#1 = ++ main::i#0
main::SCREEN[main::i#1] = >$179
main::i#2 = ++ main::i#1
main::$0 = > main::bu
main::SCREEN[main::i#2] = main::$0
main::i#3 = ++ main::i#2
main::$1 = > main::bs
main::SCREEN[main::i#3] = main::$1
main::i#4 = ++ main::i#3
main::$2 = > main::wu
main::SCREEN[main::i#4] = main::$2
main::i#5 = ++ main::i#4
main::$3 = > main::ws
main::SCREEN[main::i#5] = main::$3
main::i#6 = ++ main::i#5
main::$4 = > main::du
main::SCREEN[main::i#6] = main::$4
main::i#7 = ++ main::i#6
main::$5 = > main::ds
main::SCREEN[main::i#7] = main::$5
main::i#8 = ++ main::i#7
main::$6 = > main::ptr
main::SCREEN[main::i#8] = main::$6
main::i#9 = ++ main::i#8
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
void __start()
void main()
byte~ main::$0
byte~ main::$1
byte~ main::$2
byte~ main::$3
byte~ main::$4
byte~ main::$5
byte~ main::$6
constant byte* const main::SCREEN = (byte*)$400
volatile signed byte main::bs loadstore
volatile byte main::bu loadstore
volatile signed dword main::ds loadstore
volatile dword main::du loadstore
byte main::i
byte main::i#0
byte main::i#1
byte main::i#2
byte main::i#3
byte main::i#4
byte main::i#5
byte main::i#6
byte main::i#7
byte main::i#8
byte main::i#9
byte* volatile main::ptr loadstore
volatile signed word main::ws loadstore
volatile word main::wu loadstore
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 0
Successful SSA optimization PassNCastSimplification
Constant right-side identified [12] main::$0 = > main::bu
Constant right-side identified [15] main::$1 = > main::bs
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#0 = 0
Constant main::$0 = 0
Constant main::$1 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero >$11 in [8] main::SCREEN[main::i#0] = >$11
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::SCREEN in [8] main::SCREEN[main::i#0] = 0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::bu and assignment [0] main::bu = 7
Eliminating unused variable main::bs and assignment [1] main::bs = 7
Eliminating unused variable main::i#9 and assignment [29] main::i#9 = ++ main::i#8
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 [6] main::i#1 = ++ main::i#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#1 = ++main::i#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [7] main::i#2 = ++ main::i#1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#2 = ++main::i#1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [8] main::i#3 = ++ main::i#2
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#3 = ++main::i#2
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [9] main::i#4 = ++ main::i#3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#4 = ++main::i#3
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [11] main::i#5 = ++ main::i#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#5 = ++main::i#4
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [13] main::i#6 = ++ main::i#5
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#6 = ++main::i#5
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [15] main::i#7 = ++ main::i#6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#7 = ++main::i#6
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [17] main::i#8 = ++ main::i#7
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#8 = ++main::i#7
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings main::i#0
Inlining constant with different constant siblings main::i#1
Inlining constant with different constant siblings main::i#2
Inlining constant with different constant siblings main::i#3
Inlining constant with different constant siblings main::i#4
Inlining constant with different constant siblings main::i#5
Inlining constant with different constant siblings main::i#6
Inlining constant with different constant siblings main::i#7
Inlining constant with different constant siblings main::i#8
Constant inlined main::i#8 = ++++++++++++++++0
Constant inlined main::i#7 = ++++++++++++++0
Constant inlined main::$1 = 0
Constant inlined main::i#4 = ++++++++0
Constant inlined main::i#3 = ++++++0
Constant inlined main::i#6 = ++++++++++++0
Constant inlined main::$0 = 0
Constant inlined main::i#5 = ++++++++++0
Constant inlined main::i#0 = 0
Constant inlined main::i#2 = ++++0
Constant inlined main::i#1 = ++0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN+++0)
Consolidated array index constant in *(main::SCREEN+++++0)
Consolidated array index constant in *(main::SCREEN+++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++++++++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Simplifying constant integer increment ++7
Successful SSA optimization Pass2ConstantSimplification
Finalized unsigned number type (word) $179
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] main::wu = $4e20
[1] main::ws = -$b1
[2] main::du = $1e8480
[3] main::ds = -$39a4f1
[4] main::ptr = (byte*) 0
[5] *main::SCREEN = 0
[6] *(main::SCREEN+1) = >$179
[7] *(main::SCREEN+2) = 0
[8] *(main::SCREEN+3) = 0
[9] main::$2 = > main::wu
[10] *(main::SCREEN+4) = main::$2
[11] main::$3 = > main::ws
[12] *(main::SCREEN+5) = main::$3
[13] main::$4 = > main::du
[14] *(main::SCREEN+6) = main::$4
[15] main::$5 = > main::ds
[16] *(main::SCREEN+7) = main::$5
[17] main::$6 = > main::ptr
[18] *(main::SCREEN+8) = main::$6
to:main::@return
main::@return: scope:[main] from main
[19] return
to:@return
VARIABLE REGISTER WEIGHTS
void main()
byte~ main::$2 4.0
byte~ main::$3 4.0
byte~ main::$4 4.0
byte~ main::$5 4.0
byte~ main::$6 4.0
volatile signed dword main::ds loadstore 0.3333333333333333
volatile dword main::du loadstore 0.36363636363636365
byte main::i
byte* volatile main::ptr loadstore 0.3076923076923077
volatile signed word main::ws loadstore 0.4
volatile word main::wu loadstore 0.4444444444444444
Initial phi equivalence classes
Added variable main::wu to live range equivalence class [ main::wu ]
Added variable main::ws to live range equivalence class [ main::ws ]
Added variable main::du to live range equivalence class [ main::du ]
Added variable main::ds to live range equivalence class [ main::ds ]
Added variable main::ptr to live range equivalence class [ main::ptr ]
Added variable main::$2 to live range equivalence class [ main::$2 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Added variable main::$4 to live range equivalence class [ main::$4 ]
Added variable main::$5 to live range equivalence class [ main::$5 ]
Added variable main::$6 to live range equivalence class [ main::$6 ]
Complete equivalence classes
[ main::wu ]
[ main::ws ]
[ main::du ]
[ main::ds ]
[ main::ptr ]
[ main::$2 ]
[ main::$3 ]
[ main::$4 ]
[ main::$5 ]
[ main::$6 ]
Allocated zp[2]:2 [ main::wu ]
Allocated zp[2]:4 [ main::ws ]
Allocated zp[4]:6 [ main::du ]
Allocated zp[4]:10 [ main::ds ]
Allocated zp[2]:14 [ main::ptr ]
Allocated zp[1]:16 [ main::$2 ]
Allocated zp[1]:17 [ main::$3 ]
Allocated zp[1]:18 [ main::$4 ]
Allocated zp[1]:19 [ main::$5 ]
Allocated zp[1]:20 [ main::$6 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] main::wu = $4e20 [ main::wu ] ( [ main::wu ] { } ) always clobbers reg byte a
Statement [1] main::ws = -$b1 [ main::wu main::ws ] ( [ main::wu main::ws ] { } ) always clobbers reg byte a
Statement [2] main::du = $1e8480 [ main::wu main::ws main::du ] ( [ main::wu main::ws main::du ] { } ) always clobbers reg byte a
Statement [3] main::ds = -$39a4f1 [ main::wu main::ws main::du main::ds ] ( [ main::wu main::ws main::du main::ds ] { } ) always clobbers reg byte a
Statement [4] main::ptr = (byte*) 0 [ main::wu main::ws main::du main::ds main::ptr ] ( [ main::wu main::ws main::du main::ds main::ptr ] { } ) always clobbers reg byte a
Statement [5] *main::SCREEN = 0 [ main::wu main::ws main::du main::ds main::ptr ] ( [ main::wu main::ws main::du main::ds main::ptr ] { } ) always clobbers reg byte a
Statement [6] *(main::SCREEN+1) = >$179 [ main::wu main::ws main::du main::ds main::ptr ] ( [ main::wu main::ws main::du main::ds main::ptr ] { } ) always clobbers reg byte a
Statement [7] *(main::SCREEN+2) = 0 [ main::wu main::ws main::du main::ds main::ptr ] ( [ main::wu main::ws main::du main::ds main::ptr ] { } ) always clobbers reg byte a
Statement [8] *(main::SCREEN+3) = 0 [ main::wu main::ws main::du main::ds main::ptr ] ( [ main::wu main::ws main::du main::ds main::ptr ] { } ) always clobbers reg byte a
Potential registers zp[2]:2 [ main::wu ] : zp[2]:2 ,
Potential registers zp[2]:4 [ main::ws ] : zp[2]:4 ,
Potential registers zp[4]:6 [ main::du ] : zp[4]:6 ,
Potential registers zp[4]:10 [ main::ds ] : zp[4]:10 ,
Potential registers zp[2]:14 [ main::ptr ] : zp[2]:14 ,
Potential registers zp[1]:16 [ main::$2 ] : zp[1]:16 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:17 [ main::$3 ] : zp[1]:17 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:18 [ main::$4 ] : zp[1]:18 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:19 [ main::$5 ] : zp[1]:19 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:20 [ main::$6 ] : zp[1]:20 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 4: zp[1]:16 [ main::$2 ] 4: zp[1]:17 [ main::$3 ] 4: zp[1]:18 [ main::$4 ] 4: zp[1]:19 [ main::$5 ] 4: zp[1]:20 [ main::$6 ] 0.44: zp[2]:2 [ main::wu ] 0.4: zp[2]:4 [ main::ws ] 0.36: zp[4]:6 [ main::du ] 0.33: zp[4]:10 [ main::ds ] 0.31: zp[2]:14 [ main::ptr ]
Uplift Scope []
Uplifting [main] best 144 combination reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte a [ main::$4 ] reg byte a [ main::$5 ] zp[1]:20 [ main::$6 ] zp[2]:2 [ main::wu ] zp[2]:4 [ main::ws ] zp[4]:6 [ main::du ] zp[4]:10 [ main::ds ] zp[2]:14 [ main::ptr ]
Limited combination testing to 100 combinations of 1024 possible.
Uplifting [] best 144 combination
Attempting to uplift remaining variables inzp[1]:20 [ main::$6 ]
Uplifting [main] best 138 combination reg byte a [ main::$6 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test operator BYTE1()
// Upstart
// Commodore 64 PRG executable file
.file [name="operator-byte1.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: {
.label SCREEN = $400
.label wu = 2
.label ws = 4
.label du = 6
.label ds = $a
.label ptr = $e
// [0] main::wu = $4e20 -- vwuz1=vwuc1
lda #<$4e20
sta.z wu
lda #>$4e20
sta.z wu+1
// [1] main::ws = -$b1 -- vwsz1=vwsc1
lda #<-$b1
sta.z ws
lda #>-$b1
sta.z ws+1
// [2] main::du = $1e8480 -- vduz1=vduc1
lda #<$1e8480
sta.z du
lda #>$1e8480
sta.z du+1
lda #<$1e8480>>$10
sta.z du+2
lda #>$1e8480>>$10
sta.z du+3
// [3] main::ds = -$39a4f1 -- vdsz1=vdsc1
lda #<-$39a4f1
sta.z ds
lda #>-$39a4f1
sta.z ds+1
lda #<-$39a4f1>>$10
sta.z ds+2
lda #>-$39a4f1>>$10
sta.z ds+3
// [4] main::ptr = (byte*) 0 -- pbuz1=pbuc1
lda #<0
sta.z ptr
lda #>0
sta.z ptr+1
// [5] *main::SCREEN = 0 -- _deref_pbuc1=vbuc2
lda #0
sta SCREEN
// [6] *(main::SCREEN+1) = >$179 -- _deref_pbuc1=vbuc2
lda #>($179)
sta SCREEN+1
// [7] *(main::SCREEN+2) = 0 -- _deref_pbuc1=vbuc2
lda #0
sta SCREEN+2
// [8] *(main::SCREEN+3) = 0 -- _deref_pbuc1=vbuc2
lda #0
sta SCREEN+3
// [9] main::$2 = > main::wu -- vbuaa=_byte1_vwuz1
lda.z wu+1
// [10] *(main::SCREEN+4) = main::$2 -- _deref_pbuc1=vbuaa
sta SCREEN+4
// [11] main::$3 = > main::ws -- vbuaa=_byte1_vwsz1
lda.z ws+1
// [12] *(main::SCREEN+5) = main::$3 -- _deref_pbuc1=vbuaa
sta SCREEN+5
// [13] main::$4 = > main::du -- vbuaa=_byte1_vduz1
lda.z du+1
// [14] *(main::SCREEN+6) = main::$4 -- _deref_pbuc1=vbuaa
sta SCREEN+6
// [15] main::$5 = > main::ds -- vbuaa=_byte1_vdsz1
lda.z ds+1
// [16] *(main::SCREEN+7) = main::$5 -- _deref_pbuc1=vbuaa
sta SCREEN+7
// [17] main::$6 = > main::ptr -- vbuaa=_byte1_pbuz1
lda.z ptr+1
// [18] *(main::SCREEN+8) = main::$6 -- _deref_pbuc1=vbuaa
sta SCREEN+8
jmp __breturn
// main::@return
__breturn:
// [19] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Removing instruction lda #0
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
void main()
byte~ main::$2 reg byte a 4.0
byte~ main::$3 reg byte a 4.0
byte~ main::$4 reg byte a 4.0
byte~ main::$5 reg byte a 4.0
byte~ main::$6 reg byte a 4.0
constant byte* const main::SCREEN = (byte*) 1024
volatile signed dword main::ds loadstore zp[4]:10 0.3333333333333333
volatile dword main::du loadstore zp[4]:6 0.36363636363636365
byte main::i
byte* volatile main::ptr loadstore zp[2]:14 0.3076923076923077
volatile signed word main::ws loadstore zp[2]:4 0.4
volatile word main::wu loadstore zp[2]:2 0.4444444444444444
zp[2]:2 [ main::wu ]
zp[2]:4 [ main::ws ]
zp[4]:6 [ main::du ]
zp[4]:10 [ main::ds ]
zp[2]:14 [ main::ptr ]
reg byte a [ main::$2 ]
reg byte a [ main::$3 ]
reg byte a [ main::$4 ]
reg byte a [ main::$5 ]
reg byte a [ main::$6 ]
FINAL ASSEMBLER
Score: 129
// File Comments
// Test operator BYTE1()
// Upstart
// Commodore 64 PRG executable file
.file [name="operator-byte1.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: {
.label SCREEN = $400
.label wu = 2
.label ws = 4
.label du = 6
.label ds = $a
.label ptr = $e
// volatile unsigned int wu = 20000
// [0] main::wu = $4e20 -- vwuz1=vwuc1
lda #<$4e20
sta.z wu
lda #>$4e20
sta.z wu+1
// volatile signed int ws = -177
// [1] main::ws = -$b1 -- vwsz1=vwsc1
lda #<-$b1
sta.z ws
lda #>-$b1
sta.z ws+1
// volatile unsigned long du = 2000000
// [2] main::du = $1e8480 -- vduz1=vduc1
lda #<$1e8480
sta.z du
lda #>$1e8480
sta.z du+1
lda #<$1e8480>>$10
sta.z du+2
lda #>$1e8480>>$10
sta.z du+3
// volatile signed long ds = -3777777
// [3] main::ds = -$39a4f1 -- vdsz1=vdsc1
lda #<-$39a4f1
sta.z ds
lda #>-$39a4f1
sta.z ds+1
lda #<-$39a4f1>>$10
sta.z ds+2
lda #>-$39a4f1>>$10
sta.z ds+3
// char * volatile ptr = (char*)0x0000
// [4] main::ptr = (byte*) 0 -- pbuz1=pbuc1
lda #<0
sta.z ptr
sta.z ptr+1
// SCREEN[i++] = BYTE1(17)
// [5] *main::SCREEN = 0 -- _deref_pbuc1=vbuc2
sta SCREEN
// SCREEN[i++] = BYTE1(377)
// [6] *(main::SCREEN+1) = >$179 -- _deref_pbuc1=vbuc2
lda #>($179)
sta SCREEN+1
// SCREEN[i++] = BYTE1(bu)
// [7] *(main::SCREEN+2) = 0 -- _deref_pbuc1=vbuc2
lda #0
sta SCREEN+2
// SCREEN[i++] = BYTE1(bs)
// [8] *(main::SCREEN+3) = 0 -- _deref_pbuc1=vbuc2
sta SCREEN+3
// BYTE1(wu)
// [9] main::$2 = > main::wu -- vbuaa=_byte1_vwuz1
lda.z wu+1
// SCREEN[i++] = BYTE1(wu)
// [10] *(main::SCREEN+4) = main::$2 -- _deref_pbuc1=vbuaa
sta SCREEN+4
// BYTE1(ws)
// [11] main::$3 = > main::ws -- vbuaa=_byte1_vwsz1
lda.z ws+1
// SCREEN[i++] = BYTE1(ws)
// [12] *(main::SCREEN+5) = main::$3 -- _deref_pbuc1=vbuaa
sta SCREEN+5
// BYTE1(du)
// [13] main::$4 = > main::du -- vbuaa=_byte1_vduz1
lda.z du+1
// SCREEN[i++] = BYTE1(du)
// [14] *(main::SCREEN+6) = main::$4 -- _deref_pbuc1=vbuaa
sta SCREEN+6
// BYTE1(ds)
// [15] main::$5 = > main::ds -- vbuaa=_byte1_vdsz1
lda.z ds+1
// SCREEN[i++] = BYTE1(ds)
// [16] *(main::SCREEN+7) = main::$5 -- _deref_pbuc1=vbuaa
sta SCREEN+7
// BYTE1(ptr)
// [17] main::$6 = > main::ptr -- vbuaa=_byte1_pbuz1
lda.z ptr+1
// SCREEN[i++] = BYTE1(ptr)
// [18] *(main::SCREEN+8) = main::$6 -- _deref_pbuc1=vbuaa
sta SCREEN+8
// main::@return
// }
// [19] return
rts
}
// File Data