1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-02 22:56:11 +00:00
kickc/src/test/ref/fragment-synth.log

662 lines
22 KiB
Plaintext

Identified constant variable (byte*) main::screen
Culled Empty Block (label) @1
Culled Empty Block (label) fct::@1
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@2
(void()) main()
main: scope:[main] from @2
(byte*) main::screen ← ((byte*)) (number) $400
(byte*) main::z#0 ← ((byte*)) (number) $450
*((byte*) main::z#0 + (number) 2) ← (number) $f0
*((byte*) main::z#0 + (number) 3) ← (number) $f
(byte) main::x#0 ← (number) $aa
(byte) fct::x#0 ← (byte) main::x#0
(byte*) fct::z#0 ← (byte*) main::z#0
call fct
(byte) fct::return#0 ← (byte) fct::return#3
to:main::@1
main::@1: scope:[main] from main
(byte*) main::z#2 ← phi( main/(byte*) main::z#0 )
(byte) fct::return#4 ← phi( main/(byte) fct::return#0 )
(byte~) main::$0 ← (byte) fct::return#4
(byte) main::a1#0 ← (byte~) main::$0
*((byte*) main::screen + (number) 0) ← (byte) main::a1#0
(byte*) main::z#1 ← ++ (byte*) main::z#2
(byte) main::x#1 ← (number) $55
(byte) fct::x#1 ← (byte) main::x#1
(byte*) fct::z#1 ← (byte*) main::z#1
call fct
(byte) fct::return#1 ← (byte) fct::return#3
to:main::@2
main::@2: scope:[main] from main::@1
(byte) fct::return#5 ← phi( main::@1/(byte) fct::return#1 )
(byte~) main::$1 ← (byte) fct::return#5
(byte) main::a2#0 ← (byte~) main::$1
*((byte*) main::screen + (number) 1) ← (byte) main::a2#0
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
(byte()) fct((byte) fct::x , (byte*) fct::z)
fct: scope:[fct] from main main::@1
(byte*) fct::z#2 ← phi( main/(byte*) fct::z#0 main::@1/(byte*) fct::z#1 )
(byte) fct::x#2 ← phi( main/(byte) fct::x#0 main::@1/(byte) fct::x#1 )
(byte~) fct::$0 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (number) 2)
(byte) fct::a#0 ← (byte~) fct::$0
(byte) fct::return#2 ← (byte) fct::a#0
to:fct::@return
fct::@return: scope:[fct] from fct
(byte) fct::return#6 ← phi( fct/(byte) fct::return#2 )
(byte) fct::return#3 ← (byte) fct::return#6
return
to:@return
@2: scope:[] from @begin
call main
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(byte()) fct((byte) fct::x , (byte*) fct::z)
(byte~) fct::$0
(label) fct::@return
(byte) fct::a !reg byte a
(byte) fct::a#0 !reg byte a
(byte) fct::return
(byte) fct::return#0
(byte) fct::return#1
(byte) fct::return#2
(byte) fct::return#3
(byte) fct::return#4
(byte) fct::return#5
(byte) fct::return#6
(byte) fct::x !reg byte x
(byte) fct::x#0 !reg byte x
(byte) fct::x#1 !reg byte x
(byte) fct::x#2 !reg byte x
(byte*) fct::z
(byte*) fct::z#0
(byte*) fct::z#1
(byte*) fct::z#2
(void()) main()
(byte~) main::$0
(byte~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::a1
(byte) main::a1#0
(byte) main::a2
(byte) main::a2#0
(byte*) main::screen
(byte) main::x
(byte) main::x#0
(byte) main::x#1
(byte*) main::z
(byte*) main::z#0
(byte*) main::z#1
(byte*) main::z#2
Adding number conversion cast (unumber) $f0 in *((byte*) main::z#0 + (number) 2) ← (number) $f0
Adding number conversion cast (unumber) 2 in *((byte*) main::z#0 + (number) 2) ← ((unumber)) (number) $f0
Adding number conversion cast (unumber) $f in *((byte*) main::z#0 + (number) 3) ← (number) $f
Adding number conversion cast (unumber) 3 in *((byte*) main::z#0 + (number) 3) ← ((unumber)) (number) $f
Adding number conversion cast (unumber) $aa in (byte) main::x#0 ← (number) $aa
Adding number conversion cast (unumber) 0 in *((byte*) main::screen + (number) 0) ← (byte) main::a1#0
Adding number conversion cast (unumber) $55 in (byte) main::x#1 ← (number) $55
Adding number conversion cast (unumber) 1 in *((byte*) main::screen + (number) 1) ← (byte) main::a2#0
Adding number conversion cast (unumber) 2 in (byte~) fct::$0 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (number) 2)
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::screen ← (byte*)(number) $400
Inlining cast (byte*) main::z#0 ← (byte*)(number) $450
Inlining cast *((byte*) main::z#0 + (unumber)(number) 2) ← (unumber)(number) $f0
Inlining cast *((byte*) main::z#0 + (unumber)(number) 3) ← (unumber)(number) $f
Inlining cast (byte) main::x#0 ← (unumber)(number) $aa
Inlining cast (byte) main::x#1 ← (unumber)(number) $55
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 1104
Simplifying constant integer cast $f0
Simplifying constant integer cast 2
Simplifying constant integer cast $f
Simplifying constant integer cast 3
Simplifying constant integer cast $aa
Simplifying constant integer cast 0
Simplifying constant integer cast $55
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $f0
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) $f
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) $aa
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $55
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) fct::return#0 = (byte) fct::return#4
Alias (byte*) main::z#0 = (byte*) main::z#2
Alias (byte) main::a1#0 = (byte~) main::$0
Alias (byte) fct::return#1 = (byte) fct::return#5
Alias (byte) main::a2#0 = (byte~) main::$1
Alias (byte) fct::return#2 = (byte) fct::a#0 (byte~) fct::$0 (byte) fct::return#6 (byte) fct::return#3
Successful SSA optimization Pass2AliasElimination
Constant (const byte*) main::screen = (byte*) 1024
Constant (const byte*) main::z#0 = (byte*) 1104
Constant (const byte) main::x#0 = $aa
Constant (const byte) main::x#1 = $55
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) fct::x#0 = main::x#0
Constant (const byte*) fct::z#0 = main::z#0
Constant (const byte) fct::x#1 = main::x#1
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::screen in [12] *((const byte*) main::screen + (byte) 0) ← (byte) main::a1#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Constant right-side identified [6] (byte*) main::z#1 ← ++ (const byte*) main::z#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::z#1 = ++main::z#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) fct::z#1 = main::z#1
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const byte*) main::z#0
Inlining constant with different constant siblings (const byte) main::x#0
Inlining constant with different constant siblings (const byte) main::x#1
Inlining constant with different constant siblings (const byte*) main::z#1
Inlining constant with var siblings (const byte) fct::x#0
Inlining constant with var siblings (const byte*) fct::z#0
Inlining constant with var siblings (const byte) fct::x#1
Inlining constant with var siblings (const byte*) fct::z#1
Constant inlined fct::z#0 = (byte*) 1104
Constant inlined fct::z#1 = ++(byte*) 1104
Constant inlined main::z#0 = (byte*) 1104
Constant inlined main::z#1 = ++(byte*) 1104
Constant inlined main::x#0 = (byte) $aa
Constant inlined main::x#1 = (byte) $55
Constant inlined fct::x#0 = (byte) $aa
Constant inlined fct::x#1 = (byte) $55
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *((byte*) 1104+2)
Consolidated array index constant in *((byte*) 1104+3)
Consolidated array index constant in *(main::screen+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2
Calls in [main] to fct:7 fct:11
Created 2 initial phi equivalence classes
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @3
Renumbering block @2 to @1
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] *((byte*) 1104+(byte) 2) ← (byte) $f0
[5] *((byte*) 1104+(byte) 3) ← (byte) $f
[6] call fct
[7] (byte) fct::return#0 ← (byte) fct::return#2
to:main::@1
main::@1: scope:[main] from main
[8] (byte) main::a1#0 ← (byte) fct::return#0
[9] *((const byte*) main::screen) ← (byte) main::a1#0
[10] call fct
[11] (byte) fct::return#1 ← (byte) fct::return#2
to:main::@2
main::@2: scope:[main] from main::@1
[12] (byte) main::a2#0 ← (byte) fct::return#1
[13] *((const byte*) main::screen+(byte) 1) ← (byte) main::a2#0
to:main::@return
main::@return: scope:[main] from main::@2
[14] return
to:@return
(byte()) fct((byte) fct::x , (byte*) fct::z)
fct: scope:[fct] from main main::@1
[15] (byte*) fct::z#2 ← phi( main/(byte*) 1104 main::@1/++(byte*) 1104 )
[15] (byte) fct::x#2 ← phi( main/(byte) $aa main::@1/(byte) $55 )
[16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte) 2)
to:fct::@return
fct::@return: scope:[fct] from fct
[17] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte()) fct((byte) fct::x , (byte*) fct::z)
(byte) fct::a !reg byte a
(byte) fct::return
(byte) fct::return#0 4.0
(byte) fct::return#1 4.0
(byte) fct::return#2 1.5
(byte) fct::x !reg byte x
(byte) fct::x#2 !reg byte x 2.0
(byte*) fct::z
(byte*) fct::z#2 2.0
(void()) main()
(byte) main::a1
(byte) main::a1#0 4.0
(byte) main::a2
(byte) main::a2#0 4.0
(byte) main::x
(byte*) main::z
Initial phi equivalence classes
[ fct::x#2 ]
[ fct::z#2 ]
Added variable fct::return#0 to zero page equivalence class [ fct::return#0 ]
Added variable main::a1#0 to zero page equivalence class [ main::a1#0 ]
Added variable fct::return#1 to zero page equivalence class [ fct::return#1 ]
Added variable main::a2#0 to zero page equivalence class [ main::a2#0 ]
Added variable fct::return#2 to zero page equivalence class [ fct::return#2 ]
Complete equivalence classes
[ fct::x#2 ]
[ fct::z#2 ]
[ fct::return#0 ]
[ main::a1#0 ]
[ fct::return#1 ]
[ main::a2#0 ]
[ fct::return#2 ]
Allocated zp ZP_WORD:2 [ fct::z#2 ]
Allocated zp ZP_BYTE:4 [ fct::return#0 ]
Allocated zp ZP_BYTE:5 [ main::a1#0 ]
Allocated zp ZP_BYTE:6 [ fct::return#1 ]
Allocated zp ZP_BYTE:7 [ main::a2#0 ]
Allocated zp ZP_BYTE:8 [ fct::return#2 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Tests a sub-optimal fragment synthesis
// vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 < vbuaa=pbuz1_derefidx_vbuc1_band_vbuxx < vbuaa=pbuz1_derefidx_vbuaa_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuaa < vbuaa=vbuaa_band_pbuz1_derefidx_vbuyy - clobber:A Y cycles:11.5
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @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: {
.label screen = $400
.label a1 = 5
.label a2 = 7
// [4] *((byte*) 1104+(byte) 2) ← (byte) $f0 -- _deref_pbuc1=vbuc2
lda #$f0
sta $450+2
// [5] *((byte*) 1104+(byte) 3) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta $450+3
// [6] call fct
// [15] phi from main to fct [phi:main->fct]
fct_from_main:
// [15] phi (byte*) fct::z#2 = (byte*) 1104 [phi:main->fct#0] -- pbuz1=pbuc1
lda #<$450
sta.z fct.z
lda #>$450
sta.z fct.z+1
// [15] phi (byte) fct::x#2 = (byte) $aa [phi:main->fct#1] -- vbuxx=vbuc1
ldx #$aa
jsr fct
// [7] (byte) fct::return#0 ← (byte) fct::return#2 -- vbuz1=vbuz2
lda.z fct.return_2
sta.z fct.return
jmp __b1
// main::@1
__b1:
// [8] (byte) main::a1#0 ← (byte) fct::return#0 -- vbuz1=vbuz2
lda.z fct.return
sta.z a1
// [9] *((const byte*) main::screen) ← (byte) main::a1#0 -- _deref_pbuc1=vbuz1
lda.z a1
sta screen
// [10] call fct
// [15] phi from main::@1 to fct [phi:main::@1->fct]
fct_from___b1:
// [15] phi (byte*) fct::z#2 = ++(byte*) 1104 [phi:main::@1->fct#0] -- pbuz1=pbuc1
lda #<$450+1
sta.z fct.z
lda #>$450+1
sta.z fct.z+1
// [15] phi (byte) fct::x#2 = (byte) $55 [phi:main::@1->fct#1] -- vbuxx=vbuc1
ldx #$55
jsr fct
// [11] (byte) fct::return#1 ← (byte) fct::return#2 -- vbuz1=vbuz2
lda.z fct.return_2
sta.z fct.return_1
jmp __b2
// main::@2
__b2:
// [12] (byte) main::a2#0 ← (byte) fct::return#1 -- vbuz1=vbuz2
lda.z fct.return_1
sta.z a2
// [13] *((const byte*) main::screen+(byte) 1) ← (byte) main::a2#0 -- _deref_pbuc1=vbuz1
lda.z a2
sta screen+1
jmp __breturn
// main::@return
__breturn:
// [14] return
rts
}
// fct
// fct(byte register(X) x, byte* zeropage(2) z)
fct: {
.label return = 4
.label return_1 = 6
.label return_2 = 8
.label z = 2
// [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte) 2) -- vbuz1=vbuxx_band_pbuz2_derefidx_vbuc1
ldy #2
txa
and (z),y
sta.z return_2
jmp __breturn
// fct::@return
__breturn:
// [17] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((byte*) 1104+(byte) 2) ← (byte) $f0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((byte*) 1104+(byte) 3) ← (byte) $f [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte) 2) [ fct::return#2 ] ( main:2::fct:6 [ fct::return#2 ] main:2::fct:10 [ fct::return#2 ] ) always clobbers reg byte a reg byte y
Potential registers reg byte x [ fct::x#2 ] : reg byte x ,
Potential registers zp ZP_WORD:2 [ fct::z#2 ] : zp ZP_WORD:2 ,
Potential registers zp ZP_BYTE:4 [ fct::return#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:5 [ main::a1#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:6 [ fct::return#1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:7 [ main::a2#0 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:8 [ fct::return#2 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [fct] 4: zp ZP_BYTE:4 [ fct::return#0 ] 4: zp ZP_BYTE:6 [ fct::return#1 ] 2: reg byte x [ fct::x#2 ] 2: zp ZP_WORD:2 [ fct::z#2 ] 1.5: zp ZP_BYTE:8 [ fct::return#2 ]
Uplift Scope [main] 4: zp ZP_BYTE:5 [ main::a1#0 ] 4: zp ZP_BYTE:7 [ main::a2#0 ]
Uplift Scope []
Uplifting [fct] best 113 combination reg byte a [ fct::return#0 ] reg byte a [ fct::return#1 ] reg byte x [ fct::x#2 ] zp ZP_WORD:2 [ fct::z#2 ] reg byte a [ fct::return#2 ]
Uplifting [main] best 101 combination reg byte a [ main::a1#0 ] reg byte a [ main::a2#0 ]
Uplifting [] best 101 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests a sub-optimal fragment synthesis
// vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 < vbuaa=pbuz1_derefidx_vbuc1_band_vbuxx < vbuaa=pbuz1_derefidx_vbuaa_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuaa < vbuaa=vbuaa_band_pbuz1_derefidx_vbuyy - clobber:A Y cycles:11.5
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @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: {
.label screen = $400
// [4] *((byte*) 1104+(byte) 2) ← (byte) $f0 -- _deref_pbuc1=vbuc2
lda #$f0
sta $450+2
// [5] *((byte*) 1104+(byte) 3) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta $450+3
// [6] call fct
// [15] phi from main to fct [phi:main->fct]
fct_from_main:
// [15] phi (byte*) fct::z#2 = (byte*) 1104 [phi:main->fct#0] -- pbuz1=pbuc1
lda #<$450
sta.z fct.z
lda #>$450
sta.z fct.z+1
// [15] phi (byte) fct::x#2 = (byte) $aa [phi:main->fct#1] -- vbuxx=vbuc1
ldx #$aa
jsr fct
// [7] (byte) fct::return#0 ← (byte) fct::return#2
jmp __b1
// main::@1
__b1:
// [8] (byte) main::a1#0 ← (byte) fct::return#0
// [9] *((const byte*) main::screen) ← (byte) main::a1#0 -- _deref_pbuc1=vbuaa
sta screen
// [10] call fct
// [15] phi from main::@1 to fct [phi:main::@1->fct]
fct_from___b1:
// [15] phi (byte*) fct::z#2 = ++(byte*) 1104 [phi:main::@1->fct#0] -- pbuz1=pbuc1
lda #<$450+1
sta.z fct.z
lda #>$450+1
sta.z fct.z+1
// [15] phi (byte) fct::x#2 = (byte) $55 [phi:main::@1->fct#1] -- vbuxx=vbuc1
ldx #$55
jsr fct
// [11] (byte) fct::return#1 ← (byte) fct::return#2
jmp __b2
// main::@2
__b2:
// [12] (byte) main::a2#0 ← (byte) fct::return#1
// [13] *((const byte*) main::screen+(byte) 1) ← (byte) main::a2#0 -- _deref_pbuc1=vbuaa
sta screen+1
jmp __breturn
// main::@return
__breturn:
// [14] return
rts
}
// fct
// fct(byte register(X) x, byte* zeropage(2) z)
fct: {
.label z = 2
// [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte) 2) -- vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1
ldy #2
txa
and (z),y
jmp __breturn
// fct::@return
__breturn:
// [17] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
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 fct_from_main:
Removing instruction __b1:
Removing instruction fct_from___b1:
Removing instruction __b2:
Removing instruction __breturn:
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
(byte()) fct((byte) fct::x , (byte*) fct::z)
(label) fct::@return
(byte) fct::a !reg byte a
(byte) fct::return
(byte) fct::return#0 reg byte a 4.0
(byte) fct::return#1 reg byte a 4.0
(byte) fct::return#2 reg byte a 1.5
(byte) fct::x !reg byte x
(byte) fct::x#2 !reg byte x 2.0
(byte*) fct::z
(byte*) fct::z#2 z zp ZP_WORD:2 2.0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::a1
(byte) main::a1#0 reg byte a 4.0
(byte) main::a2
(byte) main::a2#0 reg byte a 4.0
(const byte*) main::screen screen = (byte*) 1024
(byte) main::x
(byte*) main::z
reg byte x [ fct::x#2 ]
zp ZP_WORD:2 [ fct::z#2 ]
reg byte a [ fct::return#0 ]
reg byte a [ main::a1#0 ]
reg byte a [ fct::return#1 ]
reg byte a [ main::a2#0 ]
reg byte a [ fct::return#2 ]
FINAL ASSEMBLER
Score: 77
// File Comments
// Tests a sub-optimal fragment synthesis
// vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1 < vbuaa=pbuz1_derefidx_vbuc1_band_vbuxx < vbuaa=pbuz1_derefidx_vbuaa_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuxx < vbuaa=pbuz1_derefidx_vbuyy_band_vbuaa < vbuaa=vbuaa_band_pbuz1_derefidx_vbuyy - clobber:A Y cycles:11.5
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
// @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: {
.label screen = $400
// z[2] = $f0
// [4] *((byte*) 1104+(byte) 2) ← (byte) $f0 -- _deref_pbuc1=vbuc2
lda #$f0
sta $450+2
// z[3] = $0f
// [5] *((byte*) 1104+(byte) 3) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta $450+3
// fct(x, z)
// [6] call fct
// [15] phi from main to fct [phi:main->fct]
// [15] phi (byte*) fct::z#2 = (byte*) 1104 [phi:main->fct#0] -- pbuz1=pbuc1
lda #<$450
sta.z fct.z
lda #>$450
sta.z fct.z+1
// [15] phi (byte) fct::x#2 = (byte) $aa [phi:main->fct#1] -- vbuxx=vbuc1
ldx #$aa
jsr fct
// fct(x, z)
// [7] (byte) fct::return#0 ← (byte) fct::return#2
// main::@1
// a1 = fct(x, z)
// [8] (byte) main::a1#0 ← (byte) fct::return#0
// screen[0] = a1
// [9] *((const byte*) main::screen) ← (byte) main::a1#0 -- _deref_pbuc1=vbuaa
sta screen
// fct(x, z)
// [10] call fct
// [15] phi from main::@1 to fct [phi:main::@1->fct]
// [15] phi (byte*) fct::z#2 = ++(byte*) 1104 [phi:main::@1->fct#0] -- pbuz1=pbuc1
lda #<$450+1
sta.z fct.z
lda #>$450+1
sta.z fct.z+1
// [15] phi (byte) fct::x#2 = (byte) $55 [phi:main::@1->fct#1] -- vbuxx=vbuc1
ldx #$55
jsr fct
// fct(x, z)
// [11] (byte) fct::return#1 ← (byte) fct::return#2
// main::@2
// a2 = fct(x, z)
// [12] (byte) main::a2#0 ← (byte) fct::return#1
// screen[1] = a2
// [13] *((const byte*) main::screen+(byte) 1) ← (byte) main::a2#0 -- _deref_pbuc1=vbuaa
sta screen+1
// main::@return
// }
// [14] return
rts
}
// fct
// fct(byte register(X) x, byte* zeropage(2) z)
fct: {
.label z = 2
// x & z[2]
// [16] (byte) fct::return#2 ← (byte) fct::x#2 & *((byte*) fct::z#2 + (byte) 2) -- vbuaa=vbuxx_band_pbuz1_derefidx_vbuc1
ldy #2
txa
and (z),y
// fct::@return
// }
// [17] return
rts
}
// File Data