2019-12-25 16:37:44 +00:00
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
@begin: scope:[] from
|
2020-03-29 19:00:25 +00:00
|
|
|
(volatile byte) i ← (byte) 3
|
2019-12-25 16:37:44 +00:00
|
|
|
to:@1
|
|
|
|
|
|
|
|
(void()) main()
|
|
|
|
main: scope:[main] from @1
|
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@2
|
2020-03-29 19:00:25 +00:00
|
|
|
(bool~) main::$0 ← (volatile byte) i < (number) 7
|
2019-12-25 16:37:44 +00:00
|
|
|
if((bool~) main::$0) goto main::@2
|
|
|
|
to:main::@return
|
|
|
|
main::@2: scope:[main] from main::@1
|
2020-03-29 19:00:25 +00:00
|
|
|
*((const nomodify byte*) SCREEN + (volatile byte) i) ← (volatile byte) i
|
|
|
|
(volatile byte) i ← ++ (volatile byte) i
|
2019-12-25 16:37:44 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@return: scope:[main] from main::@1
|
|
|
|
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
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte*) SCREEN = (byte*)(number) $400
|
|
|
|
(volatile byte) i loadstore
|
2019-12-25 16:37:44 +00:00
|
|
|
(void()) main()
|
|
|
|
(bool~) main::$0
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@return
|
|
|
|
|
2020-03-29 19:00:25 +00:00
|
|
|
Adding number conversion cast (unumber) 7 in (bool~) main::$0 ← (volatile byte) i < (number) 7
|
2019-12-25 16:37:44 +00:00
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
|
|
Simplifying constant integer cast 7
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 7
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2020-03-29 19:00:25 +00:00
|
|
|
Simple Condition (bool~) main::$0 [2] if((volatile byte) i<(byte) 7) goto main::@2
|
2019-12-25 16:37:44 +00:00
|
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
|
|
|
Adding NOP phi() at start of @1
|
|
|
|
Adding NOP phi() at start of @2
|
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
Adding NOP phi() at start of main
|
|
|
|
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 @1
|
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
Adding NOP phi() at start of main
|
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
@begin: scope:[] from
|
2020-03-29 19:00:25 +00:00
|
|
|
[0] (volatile byte) i ← (byte) 3
|
2019-12-25 16:37:44 +00:00
|
|
|
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] phi()
|
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@2
|
2020-03-29 19:00:25 +00:00
|
|
|
[5] if((volatile byte) i<(byte) 7) goto main::@2
|
2019-12-25 16:37:44 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@1
|
|
|
|
[6] return
|
|
|
|
to:@return
|
|
|
|
main::@2: scope:[main] from main::@1
|
2020-03-29 19:00:25 +00:00
|
|
|
[7] *((const nomodify byte*) SCREEN + (volatile byte) i) ← (volatile byte) i
|
|
|
|
[8] (volatile byte) i ← ++ (volatile byte) i
|
2019-12-25 16:37:44 +00:00
|
|
|
to:main::@1
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
2020-03-29 19:00:25 +00:00
|
|
|
(volatile byte) i loadstore 84.49999999999999
|
2019-12-25 16:37:44 +00:00
|
|
|
(void()) main()
|
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
Added variable i to live range equivalence class [ i ]
|
|
|
|
Complete equivalence classes
|
|
|
|
[ i ]
|
|
|
|
Allocated zp[1]:2 [ i ]
|
|
|
|
|
|
|
|
INITIAL ASM
|
|
|
|
Target platform is c64basic / MOS6502X
|
|
|
|
// File Comments
|
|
|
|
// Test that volatile vars are turned into load/store
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(__bbegin)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label i = 2
|
|
|
|
// @begin
|
|
|
|
__bbegin:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [0] (volatile byte) i ← (byte) 3 -- vbuz1=vbuc1
|
2019-12-25 16:37:44 +00:00
|
|
|
lda #3
|
|
|
|
sta.z i
|
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
|
|
|
// @1
|
|
|
|
__b1:
|
|
|
|
// [2] call main
|
|
|
|
// [4] phi from @1 to main [phi:@1->main]
|
|
|
|
main_from___b1:
|
|
|
|
jsr main
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
|
|
|
// @end
|
|
|
|
__bend:
|
|
|
|
// main
|
|
|
|
main: {
|
|
|
|
jmp __b1
|
|
|
|
// main::@1
|
|
|
|
__b1:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [5] if((volatile byte) i<(byte) 7) goto main::@2 -- vbuz1_lt_vbuc1_then_la1
|
2019-12-25 16:37:44 +00:00
|
|
|
lda.z i
|
|
|
|
cmp #7
|
|
|
|
bcc __b2
|
|
|
|
jmp __breturn
|
|
|
|
// main::@return
|
|
|
|
__breturn:
|
|
|
|
// [6] return
|
|
|
|
rts
|
|
|
|
// main::@2
|
|
|
|
__b2:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [7] *((const nomodify byte*) SCREEN + (volatile byte) i) ← (volatile byte) i -- pbuc1_derefidx_vbuz1=vbuz1
|
2019-12-25 16:37:44 +00:00
|
|
|
ldy.z i
|
|
|
|
tya
|
|
|
|
sta SCREEN,y
|
2020-03-29 19:00:25 +00:00
|
|
|
// [8] (volatile byte) i ← ++ (volatile byte) i -- vbuz1=_inc_vbuz1
|
2019-12-25 16:37:44 +00:00
|
|
|
inc.z i
|
|
|
|
jmp __b1
|
|
|
|
}
|
|
|
|
// File Data
|
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2020-03-29 19:00:25 +00:00
|
|
|
Statement [0] (volatile byte) i ← (byte) 3 [ i ] ( [ i ] { } ) always clobbers reg byte a
|
|
|
|
Statement [5] if((volatile byte) i<(byte) 7) goto main::@2 [ i ] ( main:2 [ i ] { } ) always clobbers reg byte a
|
|
|
|
Statement [7] *((const nomodify byte*) SCREEN + (volatile byte) i) ← (volatile byte) i [ i ] ( main:2 [ i ] { } ) always clobbers reg byte a reg byte y
|
2019-12-25 16:37:44 +00:00
|
|
|
Potential registers zp[1]:2 [ i ] : zp[1]:2 ,
|
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplift Scope [] 84.5: zp[1]:2 [ i ]
|
2019-12-25 16:37:44 +00:00
|
|
|
Uplift Scope [main]
|
|
|
|
|
|
|
|
Uplifting [] best 338 combination zp[1]:2 [ i ]
|
|
|
|
Uplifting [main] best 338 combination
|
|
|
|
Attempting to uplift remaining variables inzp[1]:2 [ i ]
|
|
|
|
Uplifting [] best 338 combination zp[1]:2 [ i ]
|
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
|
|
// File Comments
|
|
|
|
// Test that volatile vars are turned into load/store
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(__bbegin)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label i = 2
|
|
|
|
// @begin
|
|
|
|
__bbegin:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [0] (volatile byte) i ← (byte) 3 -- vbuz1=vbuc1
|
2019-12-25 16:37:44 +00:00
|
|
|
lda #3
|
|
|
|
sta.z i
|
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
|
|
|
// @1
|
|
|
|
__b1:
|
|
|
|
// [2] call main
|
|
|
|
// [4] phi from @1 to main [phi:@1->main]
|
|
|
|
main_from___b1:
|
|
|
|
jsr main
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
|
|
|
// @end
|
|
|
|
__bend:
|
|
|
|
// main
|
|
|
|
main: {
|
|
|
|
jmp __b1
|
|
|
|
// main::@1
|
|
|
|
__b1:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [5] if((volatile byte) i<(byte) 7) goto main::@2 -- vbuz1_lt_vbuc1_then_la1
|
2019-12-25 16:37:44 +00:00
|
|
|
lda.z i
|
|
|
|
cmp #7
|
|
|
|
bcc __b2
|
|
|
|
jmp __breturn
|
|
|
|
// main::@return
|
|
|
|
__breturn:
|
|
|
|
// [6] return
|
|
|
|
rts
|
|
|
|
// main::@2
|
|
|
|
__b2:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [7] *((const nomodify byte*) SCREEN + (volatile byte) i) ← (volatile byte) i -- pbuc1_derefidx_vbuz1=vbuz1
|
2019-12-25 16:37:44 +00:00
|
|
|
ldy.z i
|
|
|
|
tya
|
|
|
|
sta SCREEN,y
|
2020-03-29 19:00:25 +00:00
|
|
|
// [8] (volatile byte) i ← ++ (volatile byte) i -- vbuz1=_inc_vbuz1
|
2019-12-25 16:37:44 +00:00
|
|
|
inc.z i
|
|
|
|
jmp __b1
|
|
|
|
}
|
|
|
|
// File Data
|
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __bend
|
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __breturn
|
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
|
|
Removing instruction __b1_from___bbegin:
|
|
|
|
Removing instruction main_from___b1:
|
|
|
|
Removing instruction __bend_from___b1:
|
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
|
|
Removing instruction __b1:
|
|
|
|
Removing instruction __bend:
|
|
|
|
Removing instruction __breturn:
|
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
Adding RTS to root block
|
|
|
|
Succesful ASM optimization Pass5AddMainRts
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
|
|
|
(label) @1
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte*) SCREEN = (byte*) 1024
|
|
|
|
(volatile byte) i loadstore zp[1]:2 84.49999999999999
|
2019-12-25 16:37:44 +00:00
|
|
|
(void()) main()
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@return
|
|
|
|
|
|
|
|
zp[1]:2 [ i ]
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
|
|
Score: 278
|
|
|
|
|
|
|
|
// File Comments
|
|
|
|
// Test that volatile vars are turned into load/store
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(__bbegin)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label i = 2
|
|
|
|
// @begin
|
|
|
|
__bbegin:
|
|
|
|
// i = 3
|
2020-03-29 19:00:25 +00:00
|
|
|
// [0] (volatile byte) i ← (byte) 3 -- vbuz1=vbuc1
|
2019-12-25 16:37:44 +00:00
|
|
|
lda #3
|
|
|
|
sta.z i
|
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
|
|
// @1
|
|
|
|
// [2] call main
|
|
|
|
// [4] phi from @1 to main [phi:@1->main]
|
|
|
|
jsr main
|
|
|
|
rts
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
|
|
// @end
|
|
|
|
// main
|
|
|
|
main: {
|
|
|
|
// main::@1
|
|
|
|
__b1:
|
|
|
|
// while(i<7)
|
2020-03-29 19:00:25 +00:00
|
|
|
// [5] if((volatile byte) i<(byte) 7) goto main::@2 -- vbuz1_lt_vbuc1_then_la1
|
2019-12-25 16:37:44 +00:00
|
|
|
lda.z i
|
|
|
|
cmp #7
|
|
|
|
bcc __b2
|
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [6] return
|
|
|
|
rts
|
|
|
|
// main::@2
|
|
|
|
__b2:
|
|
|
|
// SCREEN[i++] = i
|
2020-03-29 19:00:25 +00:00
|
|
|
// [7] *((const nomodify byte*) SCREEN + (volatile byte) i) ← (volatile byte) i -- pbuc1_derefidx_vbuz1=vbuz1
|
2019-12-25 16:37:44 +00:00
|
|
|
ldy.z i
|
|
|
|
tya
|
|
|
|
sta SCREEN,y
|
|
|
|
// SCREEN[i++] = i;
|
2020-03-29 19:00:25 +00:00
|
|
|
// [8] (volatile byte) i ← ++ (volatile byte) i -- vbuz1=_inc_vbuz1
|
2019-12-25 16:37:44 +00:00
|
|
|
inc.z i
|
|
|
|
jmp __b1
|
|
|
|
}
|
|
|
|
// File Data
|
|
|
|
|