1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-10 10:29:36 +00:00
kickc/src/test/ref/assignment-chained.log
2019-04-20 22:12:56 +02:00

319 lines
12 KiB
Plaintext

Identified constant variable (byte*) main::screen
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
main: scope:[main] from @1
(byte*) main::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
(byte) main::a#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
(byte) main::a#1 ← (byte) 'c'
*((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte) main::a#1
*((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) $28) ← (byte) main::a#1
*((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'm'
(byte) main::a#2 ← *((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) 1)
*((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) $29) ← (byte) main::a#2
(byte) main::a#3 ← (byte) 'l'
(byte/signed word/word/dword/signed dword~) main::$0 ← (byte/signed byte/word/signed word/dword/signed dword) 1 + (byte) main::a#3
*((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/signed word/word/dword/signed dword~) main::$0
*((byte*) main::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) $2a) ← (byte) main::a#3
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(byte/signed word/word/dword/signed dword~) main::$0
(label) main::@return
(byte) main::a
(byte) main::a#0
(byte) main::a#1
(byte) main::a#2
(byte) main::a#3
(byte*) main::screen
(byte*) main::screen#0
Culled Empty Block (label) @2
Successful SSA optimization Pass2CullEmptyBlocks
Constant (const byte*) main::screen#0 = ((byte*))$400
Constant (const byte) main::a#0 = 0
Constant (const byte) main::a#1 = 'c'
Constant (const byte) main::a#3 = 'l'
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte/signed word/word/dword/signed dword) main::$0 = 1+main::a#3
Successful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(main::screen#0+0)
Consolidated array index constant in *(main::screen#0+$28)
Consolidated array index constant in *(main::screen#0+1)
Consolidated array index constant in *(main::screen#0+1)
Consolidated array index constant in *(main::screen#0+$29)
Consolidated array index constant in *(main::screen#0+2)
Consolidated array index constant in *(main::screen#0+$2a)
Successful SSA optimization Pass2ConstantAdditionElimination
Eliminating unused constant (const byte) main::a#0
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings (const byte) main::a#1
Inlining constant with var siblings (const byte) main::a#3
Constant inlined main::a#3 = (byte) 'l'
Constant inlined main::$0 = (byte/signed byte/word/signed word/dword/signed dword) 1+(byte) 'l'
Constant inlined main::a#1 = (byte) 'c'
Successful SSA optimization Pass2ConstantInlining
Simplifying constant plus zero main::screen#0+0
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) main::screen#0) ← (byte) 'c'
[5] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $28) ← (byte) 'c'
[6] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'm'
[7] (byte) main::a#2 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1)
[8] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $29) ← (byte) main::a#2
[9] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/signed byte/word/signed word/dword/signed dword) 1+(byte) 'l'
[10] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $2a) ← (byte) 'l'
to:main::@return
main::@return: scope:[main] from main
[11] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::a
(byte) main::a#2 4.0
(byte*) main::screen
Initial phi equivalence classes
Added variable main::a#2 to zero page equivalence class [ main::a#2 ]
Complete equivalence classes
[ main::a#2 ]
Allocated zp ZP_BYTE:2 [ main::a#2 ]
INITIAL ASM
//SEG0 File Comments
// Tests that chained assignments work as intended
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
.label screen = $400
.label a = 2
//SEG10 [4] *((const byte*) main::screen#0) ← (byte) 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta screen
//SEG11 [5] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $28) ← (byte) 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta screen+$28
//SEG12 [6] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'm' -- _deref_pbuc1=vbuc2
lda #'m'
sta screen+1
//SEG13 [7] (byte) main::a#2 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) -- vbuz1=_deref_pbuc1
lda screen+1
sta a
//SEG14 [8] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $29) ← (byte) main::a#2 -- _deref_pbuc1=vbuz1
lda a
sta screen+$29
//SEG15 [9] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/signed byte/word/signed word/dword/signed dword) 1+(byte) 'l' -- _deref_pbuc1=vbuc2
lda #1+'l'
sta screen+2
//SEG16 [10] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $2a) ← (byte) 'l' -- _deref_pbuc1=vbuc2
// Chained assignment with a modification of the result
lda #'l'
sta screen+$2a
jmp breturn
//SEG17 main::@return
breturn:
//SEG18 [11] return
rts
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) main::screen#0) ← (byte) 'c' [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $28) ← (byte) 'c' [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'm' [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/signed byte/word/signed word/dword/signed dword) 1+(byte) 'l' [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $2a) ← (byte) 'l' [ ] ( main:2 [ ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ main::a#2 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 4: zp ZP_BYTE:2 [ main::a#2 ]
Uplift Scope []
Uplifting [main] best 59 combination reg byte a [ main::a#2 ]
Uplifting [] best 59 combination
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests that chained assignments work as intended
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
.label screen = $400
//SEG10 [4] *((const byte*) main::screen#0) ← (byte) 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta screen
//SEG11 [5] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $28) ← (byte) 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta screen+$28
//SEG12 [6] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'm' -- _deref_pbuc1=vbuc2
lda #'m'
sta screen+1
//SEG13 [7] (byte) main::a#2 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) -- vbuaa=_deref_pbuc1
lda screen+1
//SEG14 [8] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $29) ← (byte) main::a#2 -- _deref_pbuc1=vbuaa
sta screen+$29
//SEG15 [9] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/signed byte/word/signed word/dword/signed dword) 1+(byte) 'l' -- _deref_pbuc1=vbuc2
lda #1+'l'
sta screen+2
//SEG16 [10] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $2a) ← (byte) 'l' -- _deref_pbuc1=vbuc2
// Chained assignment with a modification of the result
lda #'l'
sta screen+$2a
jmp breturn
//SEG17 main::@return
breturn:
//SEG18 [11] return
rts
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #'c'
Removing instruction lda screen+1
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(byte) main::a
(byte) main::a#2 reg byte a 4.0
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) $400
reg byte a [ main::a#2 ]
FINAL ASSEMBLER
Score: 38
//SEG0 File Comments
// Tests that chained assignments work as intended
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
.label screen = $400
//SEG10 [4] *((const byte*) main::screen#0) ← (byte) 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta screen
//SEG11 [5] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $28) ← (byte) 'c' -- _deref_pbuc1=vbuc2
sta screen+$28
//SEG12 [6] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'm' -- _deref_pbuc1=vbuc2
lda #'m'
sta screen+1
//SEG13 [7] (byte) main::a#2 ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) -- vbuaa=_deref_pbuc1
//SEG14 [8] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $29) ← (byte) main::a#2 -- _deref_pbuc1=vbuaa
sta screen+$29
//SEG15 [9] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte/signed byte/word/signed word/dword/signed dword) 1+(byte) 'l' -- _deref_pbuc1=vbuc2
lda #1+'l'
sta screen+2
//SEG16 [10] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) $2a) ← (byte) 'l' -- _deref_pbuc1=vbuc2
// Chained assignment with a modification of the result
lda #'l'
sta screen+$2a
//SEG17 main::@return
//SEG18 [11] return
rts
}