2020-06-27 19:18:00 +00:00
|
|
|
Inlined call call _init
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
|
|
|
|
(void()) main()
|
2020-06-27 19:18:00 +00:00
|
|
|
main: scope:[main] from _start::@1
|
2019-12-25 23:57:19 +00:00
|
|
|
(byte) print::ch ← (byte) 'c'
|
|
|
|
call print
|
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main
|
|
|
|
(byte) print::ch ← (byte) 'm'
|
|
|
|
call print
|
|
|
|
to:main::@2
|
|
|
|
main::@2: scope:[main] from main::@1
|
|
|
|
(byte) print::ch ← (byte) 'l'
|
|
|
|
call print
|
|
|
|
to:main::@3
|
|
|
|
main::@3: scope:[main] from main::@2
|
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@3
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
|
|
|
|
(void()) print((byte) print::ch)
|
|
|
|
print: scope:[print] from main main::@1 main::@2
|
|
|
|
asm { ldxidx ldach staSCREEN,x incidx }
|
|
|
|
to:print::@return
|
|
|
|
print::@return: scope:[print] from print
|
|
|
|
return
|
|
|
|
to:@return
|
2020-06-27 19:18:00 +00:00
|
|
|
|
|
|
|
(void()) _start()
|
|
|
|
_start: scope:[_start] from
|
|
|
|
to:_start::_init1
|
|
|
|
_start::_init1: scope:[_start] from _start
|
|
|
|
(volatile byte) idx ← (byte) 0
|
|
|
|
to:_start::@1
|
|
|
|
_start::@1: scope:[_start] from _start::_init1
|
2019-12-25 23:57:19 +00:00
|
|
|
call main
|
2020-06-27 19:18:00 +00:00
|
|
|
to:_start::@2
|
|
|
|
_start::@2: scope:[_start] from _start::@1
|
|
|
|
to:_start::@return
|
|
|
|
_start::@return: scope:[_start] from _start::@2
|
|
|
|
return
|
|
|
|
to:@return
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte*) SCREEN = (byte*)(number) $400
|
2020-06-27 19:18:00 +00:00
|
|
|
(void()) _start()
|
|
|
|
(label) _start::@1
|
|
|
|
(label) _start::@2
|
|
|
|
(label) _start::@return
|
|
|
|
(label) _start::_init1
|
2020-03-29 19:00:25 +00:00
|
|
|
(volatile byte) idx loadstore !zp[-1]:3
|
2019-12-25 23:57:19 +00:00
|
|
|
(void()) main()
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@return
|
|
|
|
(void()) print((byte) print::ch)
|
|
|
|
(label) print::@return
|
|
|
|
(byte) print::ch loadstore !zp[-1]:2
|
|
|
|
|
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
2020-06-27 19:18:00 +00:00
|
|
|
Adding NOP phi() at start of _start
|
|
|
|
Adding NOP phi() at start of _start::@1
|
|
|
|
Adding NOP phi() at start of _start::@2
|
2019-12-25 23:57:19 +00:00
|
|
|
Adding NOP phi() at start of main::@3
|
|
|
|
CALL GRAPH
|
2020-06-27 19:18:00 +00:00
|
|
|
Calls in [_start] to main:3
|
2019-12-25 23:57:19 +00:00
|
|
|
Calls in [main] to print:7 print:9 print:11
|
|
|
|
|
|
|
|
Created 0 initial phi equivalence classes
|
|
|
|
Coalesced down to 0 phi equivalence classes
|
2020-06-27 19:18:00 +00:00
|
|
|
Culled Empty Block (label) _start::@2
|
2019-12-25 23:57:19 +00:00
|
|
|
Culled Empty Block (label) main::@3
|
2020-06-27 19:18:00 +00:00
|
|
|
Adding NOP phi() at start of _start
|
|
|
|
Adding NOP phi() at start of _start::@1
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
2020-06-27 19:18:00 +00:00
|
|
|
|
|
|
|
(void()) _start()
|
|
|
|
_start: scope:[_start] from
|
2019-12-25 23:57:19 +00:00
|
|
|
[0] phi()
|
2020-06-27 19:18:00 +00:00
|
|
|
to:_start::_init1
|
|
|
|
_start::_init1: scope:[_start] from _start
|
2020-03-29 19:00:25 +00:00
|
|
|
[1] (volatile byte) idx ← (byte) 0
|
2020-06-27 19:18:00 +00:00
|
|
|
to:_start::@1
|
|
|
|
_start::@1: scope:[_start] from _start::_init1
|
2019-12-25 23:57:19 +00:00
|
|
|
[2] phi()
|
|
|
|
[3] call main
|
2020-06-27 19:18:00 +00:00
|
|
|
to:_start::@return
|
|
|
|
_start::@return: scope:[_start] from _start::@1
|
|
|
|
[4] return
|
|
|
|
to:@return
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2020-06-27 19:18:00 +00:00
|
|
|
main: scope:[main] from _start::@1
|
2019-12-25 23:57:19 +00:00
|
|
|
[5] (byte) print::ch ← (byte) 'c'
|
|
|
|
[6] call print
|
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main
|
|
|
|
[7] (byte) print::ch ← (byte) 'm'
|
|
|
|
[8] call print
|
|
|
|
to:main::@2
|
|
|
|
main::@2: scope:[main] from main::@1
|
|
|
|
[9] (byte) print::ch ← (byte) 'l'
|
|
|
|
[10] call print
|
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@2
|
|
|
|
[11] return
|
|
|
|
to:@return
|
|
|
|
|
|
|
|
(void()) print((byte) print::ch)
|
|
|
|
print: scope:[print] from main main::@1 main::@2
|
|
|
|
asm { ldxidx ldach staSCREEN,x incidx }
|
|
|
|
to:print::@return
|
|
|
|
print::@return: scope:[print] from print
|
|
|
|
[13] return
|
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
2020-06-27 19:18:00 +00:00
|
|
|
(void()) _start()
|
2020-03-29 19:00:25 +00:00
|
|
|
(volatile byte) idx loadstore !zp[-1]:3 0.2222222222222222
|
2019-12-25 23:57:19 +00:00
|
|
|
(void()) main()
|
|
|
|
(void()) print((byte) print::ch)
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) print::ch loadstore !zp[-1]:2 11.0
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
Added variable idx to live range equivalence class [ idx ]
|
|
|
|
Added variable print::ch to live range equivalence class [ print::ch ]
|
|
|
|
Complete equivalence classes
|
|
|
|
[ idx ]
|
|
|
|
[ print::ch ]
|
|
|
|
|
|
|
|
INITIAL ASM
|
|
|
|
Target platform is c64basic / MOS6502X
|
|
|
|
// File Comments
|
|
|
|
// Test declaring a variable as at a hard-coded address
|
|
|
|
// zero-page hard-coded address parameter
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
2020-06-27 19:18:00 +00:00
|
|
|
:BasicUpstart(_start)
|
2019-12-25 23:57:19 +00:00
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label idx = 3
|
2020-06-27 19:18:00 +00:00
|
|
|
// _start
|
|
|
|
_start: {
|
|
|
|
jmp _init1
|
|
|
|
// _start::_init1
|
|
|
|
_init1:
|
|
|
|
// [1] (volatile byte) idx ← (byte) 0 -- vbuz1=vbuc1
|
|
|
|
lda #0
|
|
|
|
sta.z idx
|
|
|
|
// [2] phi from _start::_init1 to _start::@1 [phi:_start::_init1->_start::@1]
|
|
|
|
__b1_from__init1:
|
|
|
|
jmp __b1
|
|
|
|
// _start::@1
|
|
|
|
__b1:
|
|
|
|
// [3] call main
|
|
|
|
jsr main
|
|
|
|
jmp __breturn
|
|
|
|
// _start::@return
|
|
|
|
__breturn:
|
|
|
|
// [4] return
|
|
|
|
rts
|
|
|
|
}
|
2019-12-25 23:57:19 +00:00
|
|
|
// main
|
|
|
|
main: {
|
|
|
|
// [5] (byte) print::ch ← (byte) 'c' -- vbuz1=vbuc1
|
|
|
|
lda #'c'
|
|
|
|
sta.z print.ch
|
|
|
|
// [6] call print
|
|
|
|
jsr print
|
|
|
|
jmp __b1
|
|
|
|
// main::@1
|
|
|
|
__b1:
|
|
|
|
// [7] (byte) print::ch ← (byte) 'm' -- vbuz1=vbuc1
|
|
|
|
lda #'m'
|
|
|
|
sta.z print.ch
|
|
|
|
// [8] call print
|
|
|
|
jsr print
|
|
|
|
jmp __b2
|
|
|
|
// main::@2
|
|
|
|
__b2:
|
|
|
|
// [9] (byte) print::ch ← (byte) 'l' -- vbuz1=vbuc1
|
|
|
|
lda #'l'
|
|
|
|
sta.z print.ch
|
|
|
|
// [10] call print
|
|
|
|
jsr print
|
|
|
|
jmp __breturn
|
|
|
|
// main::@return
|
|
|
|
__breturn:
|
|
|
|
// [11] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// print
|
2019-12-26 08:51:41 +00:00
|
|
|
// print(byte zp(2) ch)
|
2019-12-25 23:57:19 +00:00
|
|
|
print: {
|
|
|
|
.label ch = 2
|
|
|
|
// asm { ldxidx ldach staSCREEN,x incidx }
|
|
|
|
ldx idx
|
|
|
|
lda ch
|
|
|
|
sta SCREEN,x
|
|
|
|
inc idx
|
|
|
|
jmp __breturn
|
|
|
|
// print::@return
|
|
|
|
__breturn:
|
|
|
|
// [13] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// File Data
|
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2020-03-29 19:00:25 +00:00
|
|
|
Statement [1] (volatile byte) idx ← (byte) 0 [ idx ] ( [ idx ] { } ) always clobbers reg byte a
|
2020-03-22 23:10:07 +00:00
|
|
|
Statement [5] (byte) print::ch ← (byte) 'c' [ idx print::ch ] ( main:3 [ idx print::ch ] { } ) always clobbers reg byte a
|
|
|
|
Statement [7] (byte) print::ch ← (byte) 'm' [ idx print::ch ] ( main:3 [ idx print::ch ] { } ) always clobbers reg byte a
|
|
|
|
Statement [9] (byte) print::ch ← (byte) 'l' [ idx print::ch ] ( main:3 [ idx print::ch ] { } ) always clobbers reg byte a
|
2019-12-25 23:57:19 +00:00
|
|
|
Statement asm { ldxidx ldach staSCREEN,x incidx } always clobbers reg byte a reg byte x
|
|
|
|
Potential registers zp[1]:3 [ idx ] : zp[1]:3 ,
|
|
|
|
Potential registers zp[1]:2 [ print::ch ] : zp[1]:2 ,
|
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplift Scope [print] 11: zp[1]:2 [ print::ch ]
|
2019-12-25 23:57:19 +00:00
|
|
|
Uplift Scope [] 0.22: zp[1]:3 [ idx ]
|
|
|
|
Uplift Scope [main]
|
2020-06-27 19:18:00 +00:00
|
|
|
Uplift Scope [_start]
|
2019-12-25 23:57:19 +00:00
|
|
|
|
2020-06-27 19:18:00 +00:00
|
|
|
Uplifting [print] best 129 combination zp[1]:2 [ print::ch ]
|
|
|
|
Uplifting [] best 129 combination zp[1]:3 [ idx ]
|
|
|
|
Uplifting [main] best 129 combination
|
|
|
|
Uplifting [_start] best 129 combination
|
2019-12-25 23:57:19 +00:00
|
|
|
Attempting to uplift remaining variables inzp[1]:2 [ print::ch ]
|
2020-06-27 19:18:00 +00:00
|
|
|
Uplifting [print] best 129 combination zp[1]:2 [ print::ch ]
|
2019-12-25 23:57:19 +00:00
|
|
|
Attempting to uplift remaining variables inzp[1]:3 [ idx ]
|
2020-06-27 19:18:00 +00:00
|
|
|
Uplifting [] best 129 combination zp[1]:3 [ idx ]
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
|
|
// File Comments
|
|
|
|
// Test declaring a variable as at a hard-coded address
|
|
|
|
// zero-page hard-coded address parameter
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
2020-06-27 19:18:00 +00:00
|
|
|
:BasicUpstart(_start)
|
2019-12-25 23:57:19 +00:00
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label idx = 3
|
2020-06-27 19:18:00 +00:00
|
|
|
// _start
|
|
|
|
_start: {
|
|
|
|
jmp _init1
|
|
|
|
// _start::_init1
|
|
|
|
_init1:
|
|
|
|
// [1] (volatile byte) idx ← (byte) 0 -- vbuz1=vbuc1
|
|
|
|
lda #0
|
|
|
|
sta.z idx
|
|
|
|
// [2] phi from _start::_init1 to _start::@1 [phi:_start::_init1->_start::@1]
|
|
|
|
__b1_from__init1:
|
|
|
|
jmp __b1
|
|
|
|
// _start::@1
|
|
|
|
__b1:
|
|
|
|
// [3] call main
|
|
|
|
jsr main
|
|
|
|
jmp __breturn
|
|
|
|
// _start::@return
|
|
|
|
__breturn:
|
|
|
|
// [4] return
|
|
|
|
rts
|
|
|
|
}
|
2019-12-25 23:57:19 +00:00
|
|
|
// main
|
|
|
|
main: {
|
|
|
|
// [5] (byte) print::ch ← (byte) 'c' -- vbuz1=vbuc1
|
|
|
|
lda #'c'
|
|
|
|
sta.z print.ch
|
|
|
|
// [6] call print
|
|
|
|
jsr print
|
|
|
|
jmp __b1
|
|
|
|
// main::@1
|
|
|
|
__b1:
|
|
|
|
// [7] (byte) print::ch ← (byte) 'm' -- vbuz1=vbuc1
|
|
|
|
lda #'m'
|
|
|
|
sta.z print.ch
|
|
|
|
// [8] call print
|
|
|
|
jsr print
|
|
|
|
jmp __b2
|
|
|
|
// main::@2
|
|
|
|
__b2:
|
|
|
|
// [9] (byte) print::ch ← (byte) 'l' -- vbuz1=vbuc1
|
|
|
|
lda #'l'
|
|
|
|
sta.z print.ch
|
|
|
|
// [10] call print
|
|
|
|
jsr print
|
|
|
|
jmp __breturn
|
|
|
|
// main::@return
|
|
|
|
__breturn:
|
|
|
|
// [11] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// print
|
2019-12-26 08:51:41 +00:00
|
|
|
// print(byte zp(2) ch)
|
2019-12-25 23:57:19 +00:00
|
|
|
print: {
|
|
|
|
.label ch = 2
|
|
|
|
// asm { ldxidx ldach staSCREEN,x incidx }
|
|
|
|
ldx idx
|
|
|
|
lda ch
|
|
|
|
sta SCREEN,x
|
|
|
|
inc idx
|
|
|
|
jmp __breturn
|
|
|
|
// print::@return
|
|
|
|
__breturn:
|
|
|
|
// [13] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// File Data
|
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
2020-06-27 19:18:00 +00:00
|
|
|
Removing instruction jmp _init1
|
2019-12-25 23:57:19 +00:00
|
|
|
Removing instruction jmp __b1
|
2020-06-27 19:18:00 +00:00
|
|
|
Removing instruction jmp __breturn
|
2019-12-25 23:57:19 +00:00
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __b2
|
|
|
|
Removing instruction jmp __breturn
|
|
|
|
Removing instruction jmp __breturn
|
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2020-06-27 19:18:00 +00:00
|
|
|
Removing instruction __b1_from__init1:
|
2019-12-25 23:57:19 +00:00
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
2020-06-27 19:18:00 +00:00
|
|
|
Removing instruction _init1:
|
|
|
|
Removing instruction __b1:
|
|
|
|
Removing instruction __breturn:
|
2019-12-25 23:57:19 +00:00
|
|
|
Removing instruction __b1:
|
|
|
|
Removing instruction __b2:
|
|
|
|
Removing instruction __breturn:
|
|
|
|
Removing instruction __breturn:
|
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte*) SCREEN = (byte*) 1024
|
2020-06-27 19:18:00 +00:00
|
|
|
(void()) _start()
|
|
|
|
(label) _start::@1
|
|
|
|
(label) _start::@return
|
|
|
|
(label) _start::_init1
|
2020-03-29 19:00:25 +00:00
|
|
|
(volatile byte) idx loadstore !zp[-1]:3 zp[1]:3 0.2222222222222222
|
2019-12-25 23:57:19 +00:00
|
|
|
(void()) main()
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@return
|
|
|
|
(void()) print((byte) print::ch)
|
|
|
|
(label) print::@return
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) print::ch loadstore !zp[-1]:2 zp[1]:2 11.0
|
2019-12-25 23:57:19 +00:00
|
|
|
|
|
|
|
zp[1]:3 [ idx ]
|
|
|
|
zp[1]:2 [ print::ch ]
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
|
|
Score: 81
|
|
|
|
|
|
|
|
// File Comments
|
|
|
|
// Test declaring a variable as at a hard-coded address
|
|
|
|
// zero-page hard-coded address parameter
|
|
|
|
// Upstart
|
|
|
|
.pc = $801 "Basic"
|
2020-06-27 19:18:00 +00:00
|
|
|
:BasicUpstart(_start)
|
2019-12-25 23:57:19 +00:00
|
|
|
.pc = $80d "Program"
|
|
|
|
// Global Constants & labels
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label idx = 3
|
2020-06-27 19:18:00 +00:00
|
|
|
// _start
|
|
|
|
_start: {
|
|
|
|
// _start::_init1
|
|
|
|
// idx
|
|
|
|
// [1] (volatile byte) idx ← (byte) 0 -- vbuz1=vbuc1
|
|
|
|
lda #0
|
|
|
|
sta.z idx
|
|
|
|
// [2] phi from _start::_init1 to _start::@1 [phi:_start::_init1->_start::@1]
|
|
|
|
// _start::@1
|
|
|
|
// [3] call main
|
|
|
|
jsr main
|
|
|
|
// _start::@return
|
|
|
|
// [4] return
|
|
|
|
rts
|
|
|
|
}
|
2019-12-25 23:57:19 +00:00
|
|
|
// main
|
|
|
|
main: {
|
|
|
|
// print('c')
|
|
|
|
// [5] (byte) print::ch ← (byte) 'c' -- vbuz1=vbuc1
|
|
|
|
lda #'c'
|
|
|
|
sta.z print.ch
|
|
|
|
// [6] call print
|
|
|
|
jsr print
|
|
|
|
// main::@1
|
|
|
|
// print('m')
|
|
|
|
// [7] (byte) print::ch ← (byte) 'm' -- vbuz1=vbuc1
|
|
|
|
lda #'m'
|
|
|
|
sta.z print.ch
|
|
|
|
// [8] call print
|
|
|
|
jsr print
|
|
|
|
// main::@2
|
|
|
|
// print('l')
|
|
|
|
// [9] (byte) print::ch ← (byte) 'l' -- vbuz1=vbuc1
|
|
|
|
lda #'l'
|
|
|
|
sta.z print.ch
|
|
|
|
// [10] call print
|
|
|
|
jsr print
|
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [11] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// print
|
2019-12-26 08:51:41 +00:00
|
|
|
// print(byte zp(2) ch)
|
2019-12-25 23:57:19 +00:00
|
|
|
print: {
|
|
|
|
.label ch = 2
|
|
|
|
// asm
|
|
|
|
// asm { ldxidx ldach staSCREEN,x incidx }
|
|
|
|
ldx idx
|
|
|
|
lda ch
|
|
|
|
sta SCREEN,x
|
|
|
|
inc idx
|
|
|
|
// print::@return
|
|
|
|
// }
|
|
|
|
// [13] return
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
// File Data
|
|
|
|
|