2019-08-03 11:22:27 +00:00
|
|
|
Culled Empty Block (label) main::@1
|
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
@begin: scope:[] from
|
2019-09-29 18:57:23 +00:00
|
|
|
(byte[]) strTemp ← (const string) $0
|
2019-08-03 11:22:27 +00:00
|
|
|
to:@1
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(signed word()) main()
|
2019-08-03 11:22:27 +00:00
|
|
|
main: scope:[main] from @1
|
2019-09-29 18:57:23 +00:00
|
|
|
*((byte[]) strTemp + (number) 2) ← (byte) 'e'pm
|
|
|
|
*((byte[]) strTemp + (number) 3) ← (number) 0
|
2019-08-03 11:22:27 +00:00
|
|
|
asm { ldy#0 loop: ldastrTemp,y beqdone jsr$FFD2 iny jmploop done: }
|
|
|
|
(signed word) main::return#0 ← (number) 0
|
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
|
|
|
(signed word) main::return#3 ← phi( main/(signed word) main::return#0 )
|
|
|
|
(signed word) main::return#1 ← (signed word) main::return#3
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
@1: scope:[] from @begin
|
|
|
|
call main
|
|
|
|
(signed word) main::return#2 ← (signed word) main::return#1
|
|
|
|
to:@2
|
|
|
|
@2: scope:[] from @1
|
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @2
|
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
2019-08-07 17:36:19 +00:00
|
|
|
(const string) $0 = (string) "v=X"pm
|
2019-08-03 11:22:27 +00:00
|
|
|
(label) @1
|
|
|
|
(label) @2
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(signed word()) main()
|
|
|
|
(label) main::@return
|
|
|
|
(signed word) main::return
|
|
|
|
(signed word) main::return#0
|
|
|
|
(signed word) main::return#1
|
|
|
|
(signed word) main::return#2
|
|
|
|
(signed word) main::return#3
|
|
|
|
(byte[]) strTemp
|
|
|
|
|
2019-09-29 18:57:23 +00:00
|
|
|
Adding number conversion cast (unumber) 2 in *((byte[]) strTemp + (number) 2) ← (byte) 'e'pm
|
|
|
|
Adding number conversion cast (unumber) 0 in *((byte[]) strTemp + (number) 3) ← (number) 0
|
|
|
|
Adding number conversion cast (unumber) 3 in *((byte[]) strTemp + (number) 3) ← ((unumber)) (number) 0
|
2019-08-03 11:22:27 +00:00
|
|
|
Adding number conversion cast (snumber) 0 in (signed word) main::return#0 ← (number) 0
|
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
2019-09-29 18:57:23 +00:00
|
|
|
Inlining cast *((byte[]) strTemp + (unumber)(number) 3) ← (unumber)(number) 0
|
2019-08-03 11:22:27 +00:00
|
|
|
Inlining cast (signed word) main::return#0 ← (snumber)(number) 0
|
|
|
|
Successful SSA optimization Pass2InlineCast
|
|
|
|
Simplifying constant integer cast 2
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Simplifying constant integer cast 3
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 2
|
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Finalized unsigned number type (byte) 3
|
|
|
|
Finalized signed number type (signed byte) 0
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
|
|
Alias (signed word) main::return#0 = (signed word) main::return#3 (signed word) main::return#1
|
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2019-09-29 18:57:23 +00:00
|
|
|
Constant (const byte[]) strTemp = $0
|
2019-08-03 11:22:27 +00:00
|
|
|
Constant (const signed word) main::return#0 = 0
|
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
|
|
Constant (const signed word) main::return#2 = main::return#0
|
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
|
|
Eliminating unused constant (const signed word) main::return#2
|
|
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
|
|
Eliminating unused constant (const signed word) main::return#0
|
|
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
2019-09-29 18:57:23 +00:00
|
|
|
Constant inlined $0 = (const byte[]) strTemp
|
2019-08-03 11:22:27 +00:00
|
|
|
Successful SSA optimization Pass2ConstantInlining
|
2019-09-29 18:57:23 +00:00
|
|
|
Consolidated array index constant in *(strTemp+2)
|
|
|
|
Consolidated array index constant in *(strTemp+3)
|
2019-08-03 11:22:27 +00:00
|
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
|
|
|
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()
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(signed word()) main()
|
2019-08-03 11:22:27 +00:00
|
|
|
main: scope:[main] from @1
|
2019-09-29 18:57:23 +00:00
|
|
|
[4] *((const byte[]) strTemp+(byte) 2) ← (byte) 'e'pm
|
|
|
|
[5] *((const byte[]) strTemp+(byte) 3) ← (byte) 0
|
2019-08-03 11:22:27 +00:00
|
|
|
asm { ldy#0 loop: ldastrTemp,y beqdone jsr$FFD2 iny jmploop done: }
|
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
|
|
|
[7] return
|
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
|
|
(signed word()) main()
|
|
|
|
(signed word) main::return
|
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
Complete equivalence classes
|
|
|
|
|
|
|
|
INITIAL ASM
|
2019-09-08 00:29:17 +00:00
|
|
|
Target platform is c64basic / MOS6502X
|
2019-08-03 11:22:27 +00:00
|
|
|
// File Comments
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
2019-09-29 21:13:37 +00:00
|
|
|
:BasicUpstart(__bbegin)
|
2019-08-03 11:22:27 +00:00
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
2019-09-29 21:13:37 +00:00
|
|
|
__bbegin:
|
2019-08-03 11:22:27 +00:00
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
2019-08-03 11:22:27 +00:00
|
|
|
// @1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-08-03 11:22:27 +00:00
|
|
|
// [2] call main
|
|
|
|
jsr main
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
2019-08-03 11:22:27 +00:00
|
|
|
// @end
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend:
|
2019-08-03 11:22:27 +00:00
|
|
|
// main
|
|
|
|
main: {
|
2019-09-29 18:57:23 +00:00
|
|
|
// [4] *((const byte[]) strTemp+(byte) 2) ← (byte) 'e'pm -- _deref_pbuc1=vbuc2
|
2019-08-03 22:13:33 +00:00
|
|
|
.encoding "petscii_mixed"
|
2019-08-18 21:18:53 +00:00
|
|
|
lda #'e'
|
2019-08-03 11:22:27 +00:00
|
|
|
sta strTemp+2
|
2019-09-29 18:57:23 +00:00
|
|
|
// [5] *((const byte[]) strTemp+(byte) 3) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
2019-08-03 11:22:27 +00:00
|
|
|
lda #0
|
|
|
|
sta strTemp+3
|
|
|
|
// asm { ldy#0 loop: ldastrTemp,y beqdone jsr$FFD2 iny jmploop done: }
|
|
|
|
ldy #0
|
|
|
|
loop:
|
|
|
|
lda strTemp,y
|
|
|
|
beq done
|
|
|
|
jsr $ffd2
|
|
|
|
iny
|
|
|
|
jmp loop
|
|
|
|
done:
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-08-03 11:22:27 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-08-03 11:22:27 +00:00
|
|
|
// [7] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// File Data
|
2019-08-07 17:36:19 +00:00
|
|
|
strTemp: .text "v=X"
|
|
|
|
.byte 0
|
2019-08-03 11:22:27 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2019-09-29 18:57:23 +00:00
|
|
|
Statement [4] *((const byte[]) strTemp+(byte) 2) ← (byte) 'e'pm [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
|
|
Statement [5] *((const byte[]) strTemp+(byte) 3) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
2019-08-03 11:22:27 +00:00
|
|
|
Statement asm { ldy#0 loop: ldastrTemp,y beqdone jsr$FFD2 iny jmploop done: } always clobbers reg byte a reg byte x reg byte y
|
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
|
|
Uplift Scope [main]
|
|
|
|
Uplift Scope []
|
|
|
|
|
|
|
|
Uplifting [main] best 53 combination
|
|
|
|
Uplifting [] best 53 combination
|
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
|
|
// File Comments
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
2019-09-29 21:13:37 +00:00
|
|
|
:BasicUpstart(__bbegin)
|
2019-08-03 11:22:27 +00:00
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
2019-09-29 21:13:37 +00:00
|
|
|
__bbegin:
|
2019-08-03 11:22:27 +00:00
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
2019-08-03 11:22:27 +00:00
|
|
|
// @1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-08-03 11:22:27 +00:00
|
|
|
// [2] call main
|
|
|
|
jsr main
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
2019-08-03 11:22:27 +00:00
|
|
|
// @end
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend:
|
2019-08-03 11:22:27 +00:00
|
|
|
// main
|
|
|
|
main: {
|
2019-09-29 18:57:23 +00:00
|
|
|
// [4] *((const byte[]) strTemp+(byte) 2) ← (byte) 'e'pm -- _deref_pbuc1=vbuc2
|
2019-08-03 22:13:33 +00:00
|
|
|
.encoding "petscii_mixed"
|
2019-08-18 21:18:53 +00:00
|
|
|
lda #'e'
|
2019-08-03 11:22:27 +00:00
|
|
|
sta strTemp+2
|
2019-09-29 18:57:23 +00:00
|
|
|
// [5] *((const byte[]) strTemp+(byte) 3) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
2019-08-03 11:22:27 +00:00
|
|
|
lda #0
|
|
|
|
sta strTemp+3
|
|
|
|
// asm { ldy#0 loop: ldastrTemp,y beqdone jsr$FFD2 iny jmploop done: }
|
|
|
|
ldy #0
|
|
|
|
loop:
|
|
|
|
lda strTemp,y
|
|
|
|
beq done
|
|
|
|
jsr $ffd2
|
|
|
|
iny
|
|
|
|
jmp loop
|
|
|
|
done:
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-08-03 11:22:27 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-08-03 11:22:27 +00:00
|
|
|
// [7] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// File Data
|
2019-08-07 17:36:19 +00:00
|
|
|
strTemp: .text "v=X"
|
|
|
|
.byte 0
|
2019-08-03 11:22:27 +00:00
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __bend
|
|
|
|
Removing instruction jmp __breturn
|
2019-08-03 11:22:27 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
|
|
Replacing instruction ldy #0 with TAY
|
2019-09-29 21:13:37 +00:00
|
|
|
Replacing label __bbegin with __b1
|
|
|
|
Removing instruction __bbegin:
|
|
|
|
Removing instruction __b1_from___bbegin:
|
|
|
|
Removing instruction __bend_from___b1:
|
|
|
|
Removing instruction __breturn:
|
2019-08-03 11:22:27 +00:00
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __bend:
|
2019-08-03 11:22:27 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
Updating BasicUpstart to call main directly
|
|
|
|
Removing instruction jsr main
|
|
|
|
Succesful ASM optimization Pass5SkipBegin
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __b1:
|
2019-08-03 11:22:27 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
|
|
|
(label) @1
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(signed word()) main()
|
|
|
|
(label) main::@return
|
|
|
|
(signed word) main::return
|
2019-09-29 18:57:23 +00:00
|
|
|
(const byte[]) strTemp strTemp = (string) "v=X"pm
|
2019-08-03 11:22:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
|
|
Score: 38
|
|
|
|
|
|
|
|
// File Comments
|
|
|
|
// 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: {
|
|
|
|
// strTemp[2] = 'e'
|
2019-09-29 18:57:23 +00:00
|
|
|
// [4] *((const byte[]) strTemp+(byte) 2) ← (byte) 'e'pm -- _deref_pbuc1=vbuc2
|
2019-08-03 22:13:33 +00:00
|
|
|
.encoding "petscii_mixed"
|
2019-08-18 21:18:53 +00:00
|
|
|
lda #'e'
|
2019-08-03 11:22:27 +00:00
|
|
|
sta strTemp+2
|
|
|
|
// strTemp[3] = 0
|
2019-09-29 18:57:23 +00:00
|
|
|
// [5] *((const byte[]) strTemp+(byte) 3) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
2019-08-03 11:22:27 +00:00
|
|
|
lda #0
|
|
|
|
sta strTemp+3
|
|
|
|
// asm
|
|
|
|
// asm { ldy#0 loop: ldastrTemp,y beqdone jsr$FFD2 iny jmploop done: }
|
|
|
|
tay
|
|
|
|
loop:
|
|
|
|
lda strTemp,y
|
|
|
|
beq done
|
|
|
|
jsr $ffd2
|
|
|
|
iny
|
|
|
|
jmp loop
|
|
|
|
done:
|
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [7] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// File Data
|
2019-08-07 17:36:19 +00:00
|
|
|
strTemp: .text "v=X"
|
|
|
|
.byte 0
|
2019-08-03 11:22:27 +00:00
|
|
|
|