2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
2019-09-18 21:00:30 +00:00
|
|
|
|
2020-10-05 20:58:02 +00:00
|
|
|
void main()
|
2020-06-27 20:36:52 +00:00
|
|
|
main: scope:[main] from __start
|
2020-10-05 20:58:02 +00:00
|
|
|
*(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
|
|
|
|
main::p = struct-unwound {*(&main::p)}
|
|
|
|
main::$2 = (byte*)main::q
|
|
|
|
main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
|
|
|
|
main::SCREEN[0] = *main::$0
|
|
|
|
main::$3 = (byte*)main::q
|
|
|
|
main::$1 = main::$3 + OFFSET_STRUCT_POINT_Y
|
|
|
|
main::SCREEN[1] = *main::$1
|
2019-06-16 17:54:03 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
|
|
|
return
|
|
|
|
to:@return
|
2020-06-27 19:18:00 +00:00
|
|
|
|
2020-10-05 20:58:02 +00:00
|
|
|
void __start()
|
2020-06-27 20:36:52 +00:00
|
|
|
__start: scope:[__start] from
|
2019-06-16 17:54:03 +00:00
|
|
|
call main
|
2020-06-27 20:36:52 +00:00
|
|
|
to:__start::@1
|
|
|
|
__start::@1: scope:[__start] from __start
|
|
|
|
to:__start::@return
|
|
|
|
__start::@return: scope:[__start] from __start::@1
|
2020-06-27 19:18:00 +00:00
|
|
|
return
|
|
|
|
to:@return
|
2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
2020-10-05 20:58:02 +00:00
|
|
|
const struct Point $0 = { x: 2, y: 3 }
|
|
|
|
const byte OFFSET_STRUCT_POINT_X = 0
|
|
|
|
const byte OFFSET_STRUCT_POINT_Y = 1
|
|
|
|
const byte SIZEOF_STRUCT_POINT = 2
|
|
|
|
void __start()
|
|
|
|
void main()
|
|
|
|
byte*~ main::$0
|
|
|
|
byte*~ main::$1
|
|
|
|
byte*~ main::$2
|
|
|
|
byte*~ main::$3
|
|
|
|
const nomodify byte* main::SCREEN = (byte*)$400
|
|
|
|
volatile struct Point main::p loadstore
|
|
|
|
const struct Point* main::q = &main::p
|
|
|
|
|
|
|
|
Adding number conversion cast (unumber) 0 in main::SCREEN[0] = *main::$0
|
|
|
|
Adding number conversion cast (unumber) 1 in main::SCREEN[1] = *main::$1
|
2019-06-16 17:54:03 +00:00
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
2019-11-03 16:05:55 +00:00
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
2019-06-16 17:54:03 +00:00
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
2020-12-11 23:01:15 +00:00
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Finalized unsigned number type (byte) 1
|
2019-06-16 17:54:03 +00:00
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2020-10-05 20:58:02 +00:00
|
|
|
Removing C-classic struct-unwound assignment [1] main::p = struct-unwound {*(&main::p)}
|
|
|
|
Constant right-side identified [2] main::$2 = (byte*)main::q
|
|
|
|
Constant right-side identified [5] main::$3 = (byte*)main::q
|
2019-11-17 00:51:42 +00:00
|
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
2020-10-05 20:58:02 +00:00
|
|
|
Constant main::$2 = (byte*)main::q
|
|
|
|
Constant main::$3 = (byte*)main::q
|
2019-06-16 17:54:03 +00:00
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
2020-10-05 20:58:02 +00:00
|
|
|
Converting *(pointer+n) to pointer[n] [4] main::SCREEN[0] = *main::$0 -- main::$2[OFFSET_STRUCT_POINT_X]
|
|
|
|
Converting *(pointer+n) to pointer[n] [7] main::SCREEN[1] = *main::$1 -- main::$3[OFFSET_STRUCT_POINT_Y]
|
2020-04-19 09:05:54 +00:00
|
|
|
Successful SSA optimization Pass2InlineDerefIdx
|
2020-10-05 20:58:02 +00:00
|
|
|
Simplifying expression containing zero main::$2 in [3] main::$0 = main::$2 + OFFSET_STRUCT_POINT_X
|
|
|
|
Simplifying expression containing zero main::$2 in [4] main::SCREEN[0] = main::$2[OFFSET_STRUCT_POINT_X]
|
|
|
|
Simplifying expression containing zero main::SCREEN in [4] main::SCREEN[0] = *main::$2
|
2019-06-16 17:54:03 +00:00
|
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
2020-10-05 20:58:02 +00:00
|
|
|
Eliminating unused variable main::$0 and assignment [1] main::$0 = main::$2
|
|
|
|
Eliminating unused variable main::$1 and assignment [3] main::$1 = main::$3 + OFFSET_STRUCT_POINT_Y
|
|
|
|
Eliminating unused constant OFFSET_STRUCT_POINT_X
|
2019-06-16 17:54:03 +00:00
|
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
2020-06-27 20:36:52 +00:00
|
|
|
Removing unused procedure __start
|
|
|
|
Removing unused procedure block __start
|
|
|
|
Removing unused procedure block __start::@1
|
|
|
|
Removing unused procedure block __start::@return
|
2020-06-27 19:18:00 +00:00
|
|
|
Successful SSA optimization PassNEliminateEmptyStart
|
2020-10-05 20:58:02 +00:00
|
|
|
Constant inlined main::$2 = (byte*)main::q
|
|
|
|
Constant inlined main::$3 = (byte*)main::q
|
2019-11-17 00:51:42 +00:00
|
|
|
Successful SSA optimization Pass2ConstantInlining
|
2020-04-19 09:05:54 +00:00
|
|
|
Consolidated array index constant in *((byte*)main::q+OFFSET_STRUCT_POINT_Y)
|
2019-09-29 18:57:23 +00:00
|
|
|
Consolidated array index constant in *(main::SCREEN+1)
|
2019-06-16 17:54:03 +00:00
|
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
|
|
|
CALL GRAPH
|
|
|
|
|
|
|
|
Created 0 initial phi equivalence classes
|
|
|
|
Coalesced down to 0 phi equivalence classes
|
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
2019-09-18 21:00:30 +00:00
|
|
|
|
2020-10-05 20:58:02 +00:00
|
|
|
void main()
|
2020-06-27 19:18:00 +00:00
|
|
|
main: scope:[main] from
|
2020-10-05 20:58:02 +00:00
|
|
|
[0] *(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
|
|
|
|
[1] *main::SCREEN = *((byte*)main::q)
|
|
|
|
[2] *(main::SCREEN+1) = *((byte*)main::q+OFFSET_STRUCT_POINT_Y)
|
2019-06-16 17:54:03 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
2020-06-27 19:18:00 +00:00
|
|
|
[3] return
|
2019-06-16 17:54:03 +00:00
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
2020-10-05 20:58:02 +00:00
|
|
|
void main()
|
|
|
|
volatile struct Point main::p loadstore
|
2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
Initial phi equivalence classes
|
2019-12-27 21:35:05 +00:00
|
|
|
Added variable main::p to live range equivalence class [ main::p ]
|
2019-06-16 17:54:03 +00:00
|
|
|
Complete equivalence classes
|
2019-12-27 21:35:05 +00:00
|
|
|
[ main::p ]
|
|
|
|
Allocated zp[2]:2 [ main::p ]
|
2019-06-16 17:54:03 +00:00
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2020-10-05 20:58:02 +00:00
|
|
|
Statement [0] *(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) [ ] ( [ ] { } ) always clobbers reg byte a reg byte y
|
|
|
|
Statement [1] *main::SCREEN = *((byte*)main::q) [ ] ( [ ] { } ) always clobbers reg byte a
|
|
|
|
Statement [2] *(main::SCREEN+1) = *((byte*)main::q+OFFSET_STRUCT_POINT_Y) [ ] ( [ ] { } ) always clobbers reg byte a
|
2019-12-27 21:35:05 +00:00
|
|
|
Potential registers zp[2]:2 [ main::p ] : zp[2]:2 ,
|
2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
|
|
Uplift Scope [Point]
|
2019-12-27 21:35:05 +00:00
|
|
|
Uplift Scope [main] 0: zp[2]:2 [ main::p ]
|
2019-06-16 17:54:03 +00:00
|
|
|
Uplift Scope []
|
|
|
|
|
2020-06-27 19:18:00 +00:00
|
|
|
Uplifting [Point] best 40 combination
|
|
|
|
Uplifting [main] best 40 combination zp[2]:2 [ main::p ]
|
|
|
|
Uplifting [] best 40 combination
|
2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-06-16 17:54:03 +00:00
|
|
|
// Minimal struct - using address-of
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="struct-ptr-12.prg", type="prg", segments="Program"]
|
|
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
|
|
.segmentdef Basic [start=$0801]
|
|
|
|
.segmentdef Code [start=$80d]
|
|
|
|
.segmentdef Data [startAfter="Code"]
|
|
|
|
.segment Basic
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2020-01-08 23:30:16 +00:00
|
|
|
.const SIZEOF_STRUCT_POINT = 2
|
2019-06-16 17:54:03 +00:00
|
|
|
.const OFFSET_STRUCT_POINT_Y = 1
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2019-06-16 17:54:03 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-12-27 21:35:05 +00:00
|
|
|
.label q = p
|
|
|
|
.label p = 2
|
2020-10-05 20:58:02 +00:00
|
|
|
// [0] *(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
|
2020-01-08 23:30:16 +00:00
|
|
|
ldy #SIZEOF_STRUCT_POINT
|
|
|
|
!:
|
|
|
|
lda __0-1,y
|
|
|
|
sta p-1,y
|
|
|
|
dey
|
|
|
|
bne !-
|
2020-10-05 20:58:02 +00:00
|
|
|
// [1] *main::SCREEN = *((byte*)main::q) -- _deref_pbuc1=_deref_pbuc2
|
2019-09-01 20:06:32 +00:00
|
|
|
lda.z q
|
2019-06-16 17:54:03 +00:00
|
|
|
sta SCREEN
|
2020-10-05 20:58:02 +00:00
|
|
|
// [2] *(main::SCREEN+1) = *((byte*)main::q+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2
|
2019-06-16 17:54:03 +00:00
|
|
|
lda q+OFFSET_STRUCT_POINT_Y
|
|
|
|
sta SCREEN+1
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2020-06-27 19:18:00 +00:00
|
|
|
// [3] return
|
2019-06-16 17:54:03 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Data
|
2020-01-08 23:30:16 +00:00
|
|
|
__0: .byte 2, 3
|
2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction jmp __breturn
|
2019-06-16 17:54:03 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __breturn:
|
2019-06-16 17:54:03 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
2020-10-05 20:58:02 +00:00
|
|
|
const struct Point $0 = { x: 2, y: 3 }
|
|
|
|
const byte OFFSET_STRUCT_POINT_Y = 1
|
|
|
|
const byte SIZEOF_STRUCT_POINT = 2
|
|
|
|
void main()
|
|
|
|
const nomodify byte* main::SCREEN = (byte*) 1024
|
|
|
|
volatile struct Point main::p loadstore zp[2]:2
|
|
|
|
const struct Point* main::q = &main::p
|
2019-06-16 17:54:03 +00:00
|
|
|
|
2019-12-27 21:35:05 +00:00
|
|
|
zp[2]:2 [ main::p ]
|
2019-06-16 17:54:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
2020-01-08 23:30:16 +00:00
|
|
|
Score: 37
|
2019-06-16 17:54:03 +00:00
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-06-16 17:54:03 +00:00
|
|
|
// Minimal struct - using address-of
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="struct-ptr-12.prg", type="prg", segments="Program"]
|
|
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
|
|
.segmentdef Basic [start=$0801]
|
|
|
|
.segmentdef Code [start=$80d]
|
|
|
|
.segmentdef Data [startAfter="Code"]
|
|
|
|
.segment Basic
|
2019-06-16 17:54:03 +00:00
|
|
|
:BasicUpstart(main)
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2020-01-08 23:30:16 +00:00
|
|
|
.const SIZEOF_STRUCT_POINT = 2
|
2019-06-16 17:54:03 +00:00
|
|
|
.const OFFSET_STRUCT_POINT_Y = 1
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2019-06-16 17:54:03 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-12-27 21:35:05 +00:00
|
|
|
.label q = p
|
|
|
|
.label p = 2
|
2019-07-08 14:43:09 +00:00
|
|
|
// p = { 2, 3 }
|
2020-10-05 20:58:02 +00:00
|
|
|
// [0] *(&main::p) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
|
2020-01-08 23:30:16 +00:00
|
|
|
ldy #SIZEOF_STRUCT_POINT
|
|
|
|
!:
|
|
|
|
lda __0-1,y
|
|
|
|
sta p-1,y
|
|
|
|
dey
|
|
|
|
bne !-
|
2019-07-08 14:43:09 +00:00
|
|
|
// SCREEN[0] = q->x
|
2020-10-05 20:58:02 +00:00
|
|
|
// [1] *main::SCREEN = *((byte*)main::q) -- _deref_pbuc1=_deref_pbuc2
|
2019-09-01 20:06:32 +00:00
|
|
|
lda.z q
|
2019-06-16 17:54:03 +00:00
|
|
|
sta SCREEN
|
2019-07-08 14:43:09 +00:00
|
|
|
// SCREEN[1] = q->y
|
2020-10-05 20:58:02 +00:00
|
|
|
// [2] *(main::SCREEN+1) = *((byte*)main::q+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2
|
2019-06-16 17:54:03 +00:00
|
|
|
lda q+OFFSET_STRUCT_POINT_Y
|
|
|
|
sta SCREEN+1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
|
|
|
// }
|
2020-06-27 19:18:00 +00:00
|
|
|
// [3] return
|
2019-06-16 17:54:03 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Data
|
2020-01-08 23:30:16 +00:00
|
|
|
__0: .byte 2, 3
|
2019-06-16 17:54:03 +00:00
|
|
|
|