1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-20 02:32:36 +00:00
kickc/src/test/ref/encoding-literal-char.log

520 lines
18 KiB
Plaintext

CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte) cpm ← (byte) 'A'pm
(byte[]) spm ← (const string) $0
(byte) ccpu ← (byte) 'A'pu
(byte[]) spu ← (const string) $1
(byte) csm ← (byte) 'A'
(byte[]) ssm ← (const string) $2
(byte) csu ← (byte) 'A'su
(byte[]) ssu ← (const string) $3
(byte*) screen ← ((byte*)) (number) $400
to:@1
(void()) main()
main: scope:[main] from @1
(byte) main::idx#0 ← (number) 0
*((byte*) screen + (byte) main::idx#0) ← (byte) cpm
(byte) main::idx#1 ← ++ (byte) main::idx#0
*((byte*) screen + (byte) main::idx#1) ← (byte) ccpu
(byte) main::idx#2 ← ++ (byte) main::idx#1
*((byte*) screen + (byte) main::idx#2) ← (byte) csm
(byte) main::idx#3 ← ++ (byte) main::idx#2
*((byte*) screen + (byte) main::idx#3) ← (byte) csu
(byte) main::idx#4 ← ++ (byte) main::idx#3
(byte) main::idx#5 ← (number) $28
*((byte*) screen + (byte) main::idx#5) ← *((byte[]) spm + (number) 0)
(byte) main::idx#6 ← ++ (byte) main::idx#5
*((byte*) screen + (byte) main::idx#6) ← *((byte[]) spu + (number) 0)
(byte) main::idx#7 ← ++ (byte) main::idx#6
*((byte*) screen + (byte) main::idx#7) ← *((byte[]) ssm + (number) 0)
(byte) main::idx#8 ← ++ (byte) main::idx#7
*((byte*) screen + (byte) main::idx#8) ← *((byte[]) ssu + (number) 0)
(byte) main::idx#9 ← ++ (byte) main::idx#8
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
(const string) $0 = (string) "A"pm
(const string) $1 = (string) "A"pu
(const string) $2 = (string) "A"
(const string) $3 = (string) "A"su
(label) @1
(label) @2
(label) @begin
(label) @end
(byte) ccpu
(byte) cpm
(byte) csm
(byte) csu
(void()) main()
(label) main::@return
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
(byte) main::idx#5
(byte) main::idx#6
(byte) main::idx#7
(byte) main::idx#8
(byte) main::idx#9
(byte*) screen
(byte[]) spm
(byte[]) spu
(byte[]) ssm
(byte[]) ssu
Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
Adding number conversion cast (unumber) $28 in (byte) main::idx#5 ← (number) $28
Adding number conversion cast (unumber) 0 in *((byte*) screen + (byte) main::idx#5) ← *((byte[]) spm + (number) 0)
Adding number conversion cast (unumber) 0 in *((byte*) screen + (byte) main::idx#6) ← *((byte[]) spu + (number) 0)
Adding number conversion cast (unumber) 0 in *((byte*) screen + (byte) main::idx#7) ← *((byte[]) ssm + (number) 0)
Adding number conversion cast (unumber) 0 in *((byte*) screen + (byte) main::idx#8) ← *((byte[]) ssu + (number) 0)
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) screen ← (byte*)(number) $400
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
Inlining cast (byte) main::idx#5 ← (unumber)(number) $28
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant (const byte) cpm = 'A'pm
Constant (const byte[]) spm = $0
Constant (const byte) ccpu = 'A'pu
Constant (const byte[]) spu = $1
Constant (const byte) csm = 'A'
Constant (const byte[]) ssm = $2
Constant (const byte) csu = 'A'su
Constant (const byte[]) ssu = $3
Constant (const byte*) screen = (byte*) 1024
Constant (const byte) main::idx#0 = 0
Constant (const byte) main::idx#5 = $28
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero screen in [10] *((const byte*) screen + (const byte) main::idx#0) ← (const byte) cpm
Simplifying expression containing zero spm in [19] *((const byte*) screen + (const byte) main::idx#5) ← *((const byte[]) spm + (byte) 0)
Simplifying expression containing zero spu in [21] *((const byte*) screen + (byte) main::idx#6) ← *((const byte[]) spu + (byte) 0)
Simplifying expression containing zero ssm in [23] *((const byte*) screen + (byte) main::idx#7) ← *((const byte[]) ssm + (byte) 0)
Simplifying expression containing zero ssu in [25] *((const byte*) screen + (byte) main::idx#8) ← *((const byte[]) ssu + (byte) 0)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) main::idx#4 and assignment [7] (byte) main::idx#4 ← ++ (byte) main::idx#3
Eliminating unused variable (byte) main::idx#9 and assignment [15] (byte) main::idx#9 ← ++ (byte) main::idx#8
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [1] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [8] (byte) main::idx#6 ← ++ (const byte) main::idx#5
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#1 = ++main::idx#0
Constant (const byte) main::idx#6 = ++main::idx#5
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [2] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Constant right-side identified [8] (byte) main::idx#7 ← ++ (const byte) main::idx#6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#2 = ++main::idx#1
Constant (const byte) main::idx#7 = ++main::idx#6
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [3] (byte) main::idx#3 ← ++ (const byte) main::idx#2
Constant right-side identified [8] (byte) main::idx#8 ← ++ (const byte) main::idx#7
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#3 = ++main::idx#2
Constant (const byte) main::idx#8 = ++main::idx#7
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const byte) main::idx#0
Inlining constant with different constant siblings (const byte) main::idx#5
Inlining constant with different constant siblings (const byte) main::idx#1
Inlining constant with different constant siblings (const byte) main::idx#6
Inlining constant with different constant siblings (const byte) main::idx#2
Inlining constant with different constant siblings (const byte) main::idx#7
Inlining constant with different constant siblings (const byte) main::idx#3
Inlining constant with different constant siblings (const byte) main::idx#8
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::idx#1 = ++(byte) 0
Constant inlined main::idx#2 = ++++(byte) 0
Constant inlined main::idx#3 = ++++++(byte) 0
Constant inlined main::idx#5 = (byte) $28
Constant inlined main::idx#6 = ++(byte) $28
Constant inlined main::idx#7 = ++++(byte) $28
Constant inlined main::idx#8 = ++++++(byte) $28
Constant inlined $0 = (const byte[]) spm
Constant inlined $1 = (const byte[]) spu
Constant inlined $2 = (const byte[]) ssm
Constant inlined $3 = (const byte[]) ssu
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(screen+++0)
Consolidated array index constant in *(screen+++++0)
Consolidated array index constant in *(screen+++++++0)
Consolidated array index constant in *(screen+$28)
Consolidated array index constant in *(screen+++$28)
Consolidated array index constant in *(screen+++++$28)
Consolidated array index constant in *(screen+++++++$28)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++$28
Simplifying constant integer increment ++$28
Simplifying constant integer increment ++$29
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++$29
Simplifying constant integer increment ++$2a
Successful SSA optimization Pass2ConstantSimplification
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
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
Culled Empty Block (label) @2
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()
(void()) main()
main: scope:[main] from @1
[4] *((const byte*) screen) ← (const byte) cpm
[5] *((const byte*) screen+(byte) 1) ← (const byte) ccpu
[6] *((const byte*) screen+(byte) 2) ← (const byte) csm
[7] *((const byte*) screen+(byte) 3) ← (const byte) csu
[8] *((const byte*) screen+(byte) $28) ← *((const byte[]) spm)
[9] *((const byte*) screen+(byte) $29) ← *((const byte[]) spu)
[10] *((const byte*) screen+(byte) $2a) ← *((const byte[]) ssm)
[11] *((const byte*) screen+(byte) $2b) ← *((const byte[]) ssu)
to:main::@return
main::@return: scope:[main] from main
[12] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::idx
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Tests encoding of literal chars
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.encoding "petscii_mixed"
.const cpm = 'A'
.encoding "petscii_upper"
.const ccpu = 'A'
.encoding "screencode_mixed"
.const csm = 'A'
.encoding "screencode_upper"
.const csu = 'A'
.label screen = $400
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
// [4] *((const byte*) screen) ← (const byte) cpm -- _deref_pbuc1=vbuc2
lda #cpm
sta screen
// [5] *((const byte*) screen+(byte) 1) ← (const byte) ccpu -- _deref_pbuc1=vbuc2
lda #ccpu
sta screen+1
// [6] *((const byte*) screen+(byte) 2) ← (const byte) csm -- _deref_pbuc1=vbuc2
lda #csm
sta screen+2
// [7] *((const byte*) screen+(byte) 3) ← (const byte) csu -- _deref_pbuc1=vbuc2
lda #csu
sta screen+3
// [8] *((const byte*) screen+(byte) $28) ← *((const byte[]) spm) -- _deref_pbuc1=_deref_pbuc2
lda spm
sta screen+$28
// [9] *((const byte*) screen+(byte) $29) ← *((const byte[]) spu) -- _deref_pbuc1=_deref_pbuc2
lda spu
sta screen+$29
// [10] *((const byte*) screen+(byte) $2a) ← *((const byte[]) ssm) -- _deref_pbuc1=_deref_pbuc2
lda ssm
sta screen+$2a
// [11] *((const byte*) screen+(byte) $2b) ← *((const byte[]) ssu) -- _deref_pbuc1=_deref_pbuc2
lda ssu
sta screen+$2b
jmp __breturn
// main::@return
__breturn:
// [12] return
rts
}
// File Data
.encoding "petscii_mixed"
spm: .text "A"
.byte 0
.encoding "petscii_upper"
spu: .text "A"
.byte 0
.encoding "screencode_mixed"
ssm: .text "A"
.byte 0
.encoding "screencode_upper"
ssu: .text "A"
.byte 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) screen) ← (const byte) cpm [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) screen+(byte) 1) ← (const byte) ccpu [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) screen+(byte) 2) ← (const byte) csm [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) screen+(byte) 3) ← (const byte) csu [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) screen+(byte) $28) ← *((const byte[]) spm) [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) screen+(byte) $29) ← *((const byte[]) spu) [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] *((const byte*) screen+(byte) $2a) ← *((const byte[]) ssm) [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [11] *((const byte*) screen+(byte) $2b) ← *((const byte[]) ssu) [ ] ( main:2 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope []
Uplifting [main] best 77 combination
Uplifting [] best 77 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests encoding of literal chars
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.encoding "petscii_mixed"
.const cpm = 'A'
.encoding "petscii_upper"
.const ccpu = 'A'
.encoding "screencode_mixed"
.const csm = 'A'
.encoding "screencode_upper"
.const csu = 'A'
.label screen = $400
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
// [4] *((const byte*) screen) ← (const byte) cpm -- _deref_pbuc1=vbuc2
lda #cpm
sta screen
// [5] *((const byte*) screen+(byte) 1) ← (const byte) ccpu -- _deref_pbuc1=vbuc2
lda #ccpu
sta screen+1
// [6] *((const byte*) screen+(byte) 2) ← (const byte) csm -- _deref_pbuc1=vbuc2
lda #csm
sta screen+2
// [7] *((const byte*) screen+(byte) 3) ← (const byte) csu -- _deref_pbuc1=vbuc2
lda #csu
sta screen+3
// [8] *((const byte*) screen+(byte) $28) ← *((const byte[]) spm) -- _deref_pbuc1=_deref_pbuc2
lda spm
sta screen+$28
// [9] *((const byte*) screen+(byte) $29) ← *((const byte[]) spu) -- _deref_pbuc1=_deref_pbuc2
lda spu
sta screen+$29
// [10] *((const byte*) screen+(byte) $2a) ← *((const byte[]) ssm) -- _deref_pbuc1=_deref_pbuc2
lda ssm
sta screen+$2a
// [11] *((const byte*) screen+(byte) $2b) ← *((const byte[]) ssu) -- _deref_pbuc1=_deref_pbuc2
lda ssu
sta screen+$2b
jmp __breturn
// main::@return
__breturn:
// [12] return
rts
}
// File Data
.encoding "petscii_mixed"
spm: .text "A"
.byte 0
.encoding "petscii_upper"
spu: .text "A"
.byte 0
.encoding "screencode_mixed"
ssm: .text "A"
.byte 0
.encoding "screencode_upper"
ssu: .text "A"
.byte 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
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 __b1:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte) ccpu ccpu = (byte) 'A'pu
(const byte) cpm cpm = (byte) 'A'pm
(const byte) csm csm = (byte) 'A'
(const byte) csu csu = (byte) 'A'su
(void()) main()
(label) main::@return
(byte) main::idx
(const byte*) screen screen = (byte*) 1024
(const byte[]) spm spm = (string) "A"pm
(const byte[]) spu spu = (string) "A"pu
(const byte[]) ssm ssm = (string) "A"
(const byte[]) ssu ssu = (string) "A"su
FINAL ASSEMBLER
Score: 62
// File Comments
// Tests encoding of literal chars
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.encoding "petscii_mixed"
.const cpm = 'A'
.encoding "petscii_upper"
.const ccpu = 'A'
.encoding "screencode_mixed"
.const csm = 'A'
.encoding "screencode_upper"
.const csu = 'A'
.label screen = $400
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// screen[idx++] = cpm
// [4] *((const byte*) screen) ← (const byte) cpm -- _deref_pbuc1=vbuc2
lda #cpm
sta screen
// screen[idx++] = ccpu
// [5] *((const byte*) screen+(byte) 1) ← (const byte) ccpu -- _deref_pbuc1=vbuc2
lda #ccpu
sta screen+1
// screen[idx++] = csm
// [6] *((const byte*) screen+(byte) 2) ← (const byte) csm -- _deref_pbuc1=vbuc2
lda #csm
sta screen+2
// screen[idx++] = csu
// [7] *((const byte*) screen+(byte) 3) ← (const byte) csu -- _deref_pbuc1=vbuc2
lda #csu
sta screen+3
// screen[idx++] = spm[0]
// [8] *((const byte*) screen+(byte) $28) ← *((const byte[]) spm) -- _deref_pbuc1=_deref_pbuc2
lda spm
sta screen+$28
// screen[idx++] = spu[0]
// [9] *((const byte*) screen+(byte) $29) ← *((const byte[]) spu) -- _deref_pbuc1=_deref_pbuc2
lda spu
sta screen+$29
// screen[idx++] = ssm[0]
// [10] *((const byte*) screen+(byte) $2a) ← *((const byte[]) ssm) -- _deref_pbuc1=_deref_pbuc2
lda ssm
sta screen+$2a
// screen[idx++] = ssu[0]
// [11] *((const byte*) screen+(byte) $2b) ← *((const byte[]) ssu) -- _deref_pbuc1=_deref_pbuc2
lda ssu
sta screen+$2b
// main::@return
// }
// [12] return
rts
}
// File Data
.encoding "petscii_mixed"
spm: .text "A"
.byte 0
.encoding "petscii_upper"
spu: .text "A"
.byte 0
.encoding "screencode_mixed"
ssm: .text "A"
.byte 0
.encoding "screencode_upper"
ssu: .text "A"
.byte 0