mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-29 09:29:31 +00:00
235 lines
8.5 KiB
Plaintext
235 lines
8.5 KiB
Plaintext
Fixing struct type size struct Point to 3
|
|
Fixing struct type size struct Point to 3
|
|
Fixing struct type SIZE_OF struct Point to 3
|
|
Fixing struct type SIZE_OF struct Point to 3
|
|
Removing C-classic struct-unwound assignment main::point1 = struct-unwound {*(&main::point1)}
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
void main()
|
|
main: scope:[main] from __start
|
|
*(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
|
|
SCREEN[0] = *((char *)&main::point1+OFFSET_STRUCT_POINT_X)
|
|
SCREEN[1] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
|
|
SCREEN[2] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1]
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
return
|
|
to:@return
|
|
|
|
void __start()
|
|
__start: scope:[__start] from
|
|
call main
|
|
to:__start::@1
|
|
__start::@1: scope:[__start] from __start
|
|
to:__start::@return
|
|
__start::@return: scope:[__start] from __start::@1
|
|
return
|
|
to:@return
|
|
|
|
SYMBOL TABLE SSA
|
|
__constant struct Point $0 = { x: 2, initials: { 'j', 'g' } }
|
|
__constant char OFFSET_STRUCT_POINT_INITIALS = 1
|
|
__constant char OFFSET_STRUCT_POINT_X = 0
|
|
__constant char * const SCREEN = (char *)$400
|
|
__constant char SIZEOF_STRUCT_POINT = 3
|
|
void __start()
|
|
void main()
|
|
__loadstore struct Point main::point1
|
|
|
|
Adding number conversion cast (unumber) 0 in SCREEN[0] = *((char *)&main::point1+OFFSET_STRUCT_POINT_X)
|
|
Adding number conversion cast (unumber) 0 in SCREEN[1] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
|
|
Adding number conversion cast (unumber) 1 in SCREEN[1] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[(unumber)0]
|
|
Adding number conversion cast (unumber) 1 in SCREEN[2] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1]
|
|
Adding number conversion cast (unumber) 2 in SCREEN[2] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[(unumber)1]
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant pointer cast (char *) 1024
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 1
|
|
Simplifying constant integer cast 1
|
|
Simplifying constant integer cast 2
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (char) 0
|
|
Finalized unsigned number type (char) 0
|
|
Finalized unsigned number type (char) 1
|
|
Finalized unsigned number type (char) 1
|
|
Finalized unsigned number type (char) 2
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Simplifying expression containing zero (char *)&main::point1 in [1] SCREEN[0] = *((char *)&main::point1+OFFSET_STRUCT_POINT_X)
|
|
Simplifying expression containing zero SCREEN in [1] SCREEN[0] = *((char *)&main::point1)
|
|
Simplifying expression containing zero (char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] SCREEN[1] = ((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused constant OFFSET_STRUCT_POINT_X
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Removing unused procedure __start
|
|
Removing unused procedure block __start
|
|
Removing unused procedure block __start::@1
|
|
Removing unused procedure block __start::@return
|
|
Successful SSA optimization PassNEliminateEmptyStart
|
|
Consolidated array index constant in *(SCREEN+1)
|
|
Consolidated array index constant in *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1)
|
|
Consolidated array index constant in *(SCREEN+2)
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
|
Finalized unsigned number type (char) 2
|
|
Finalized unsigned number type (char) 2
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
CALL GRAPH
|
|
|
|
Created 0 initial phi equivalence classes
|
|
Coalesced down to 0 phi equivalence classes
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
void main()
|
|
main: scope:[main] from
|
|
[0] *(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
|
|
[1] *SCREEN = *((char *)&main::point1)
|
|
[2] *(SCREEN+1) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS)
|
|
[3] *(SCREEN+2) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1)
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[4] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
void main()
|
|
__loadstore struct Point main::point1
|
|
|
|
Initial phi equivalence classes
|
|
Added variable main::point1 to live range equivalence class [ main::point1 ]
|
|
Complete equivalence classes
|
|
[ main::point1 ]
|
|
Allocated zp[3]:2 [ main::point1 ]
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [0] *(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a reg byte y
|
|
Statement [1] *SCREEN = *((char *)&main::point1) [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
|
|
Statement [2] *(SCREEN+1) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS) [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
|
|
Statement [3] *(SCREEN+2) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Potential registers zp[3]:2 [ main::point1 ] : zp[3]:2 ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [Point]
|
|
Uplift Scope [main] 0: zp[3]:2 [ main::point1 ]
|
|
Uplift Scope []
|
|
|
|
Uplifting [Point] best 46 combination
|
|
Uplifting [main] best 46 combination zp[3]:2 [ main::point1 ]
|
|
Uplifting [] best 46 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Minimal struct with C-Standard behavior - member is array, copy assignment
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="struct-28.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
|
|
:BasicUpstart(main)
|
|
// Global Constants & labels
|
|
.const SIZEOF_STRUCT_POINT = 3
|
|
.const OFFSET_STRUCT_POINT_INITIALS = 1
|
|
.label SCREEN = $400
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
.label point1 = 2
|
|
// [0] *(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
|
|
ldy #SIZEOF_STRUCT_POINT
|
|
!:
|
|
lda __0-1,y
|
|
sta point1-1,y
|
|
dey
|
|
bne !-
|
|
// [1] *SCREEN = *((char *)&main::point1) -- _deref_pbuc1=_deref_pbuc2
|
|
lda.z point1
|
|
sta SCREEN
|
|
// [2] *(SCREEN+1) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS) -- _deref_pbuc1=_deref_pbuc2
|
|
lda.z point1+OFFSET_STRUCT_POINT_INITIALS
|
|
sta SCREEN+1
|
|
// [3] *(SCREEN+2) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) -- _deref_pbuc1=_deref_pbuc2
|
|
lda.z point1+OFFSET_STRUCT_POINT_INITIALS+1
|
|
sta SCREEN+2
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [4] return
|
|
rts
|
|
}
|
|
// File Data
|
|
.segment Data
|
|
__0: .byte 2, 'j', 'g'
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
__constant struct Point $0 = { x: 2, initials: { 'j', 'g' } }
|
|
__constant char OFFSET_STRUCT_POINT_INITIALS = 1
|
|
__constant char * const SCREEN = (char *) 1024
|
|
__constant char SIZEOF_STRUCT_POINT = 3
|
|
void main()
|
|
__loadstore struct Point main::point1 // zp[3]:2
|
|
|
|
zp[3]:2 [ main::point1 ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 43
|
|
|
|
// File Comments
|
|
// Minimal struct with C-Standard behavior - member is array, copy assignment
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="struct-28.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
|
|
:BasicUpstart(main)
|
|
// Global Constants & labels
|
|
.const SIZEOF_STRUCT_POINT = 3
|
|
.const OFFSET_STRUCT_POINT_INITIALS = 1
|
|
.label SCREEN = $400
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
.label point1 = 2
|
|
// __ma struct Point point1 = { 2, { 'j', 'g' } }
|
|
// [0] *(&main::point1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3
|
|
ldy #SIZEOF_STRUCT_POINT
|
|
!:
|
|
lda __0-1,y
|
|
sta point1-1,y
|
|
dey
|
|
bne !-
|
|
// SCREEN[0] = point1.x
|
|
// [1] *SCREEN = *((char *)&main::point1) -- _deref_pbuc1=_deref_pbuc2
|
|
lda.z point1
|
|
sta SCREEN
|
|
// SCREEN[1] = point1.initials[0]
|
|
// [2] *(SCREEN+1) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS) -- _deref_pbuc1=_deref_pbuc2
|
|
lda.z point1+OFFSET_STRUCT_POINT_INITIALS
|
|
sta SCREEN+1
|
|
// SCREEN[2] = point1.initials[1]
|
|
// [3] *(SCREEN+2) = *((char *)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) -- _deref_pbuc1=_deref_pbuc2
|
|
lda.z point1+OFFSET_STRUCT_POINT_INITIALS+1
|
|
sta SCREEN+2
|
|
// main::@return
|
|
// }
|
|
// [4] return
|
|
rts
|
|
}
|
|
// File Data
|
|
.segment Data
|
|
__0: .byte 2, 'j', 'g'
|
|
|