1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-16 21:07:56 +00:00
kickc/src/test/ref/struct-24.log

273 lines
11 KiB
Plaintext

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
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
*(&main::point1) = memset(struct Point, SIZEOF_STRUCT_POINT)
main::point1 = struct-unwound {*(&main::point1)}
*((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1] = 'g'
SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
SCREEN[2] = ((byte*)&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
const byte OFFSET_STRUCT_POINT_INITIALS = 1
const byte OFFSET_STRUCT_POINT_X = 0
const nomodify byte* SCREEN = (byte*)$400
const byte SIZEOF_STRUCT_POINT = 3
void __start()
void main()
struct Point main::point1 loadstore
Adding number conversion cast (unumber) 2 in *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Adding number conversion cast (unumber) 0 in ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
Adding number conversion cast (unumber) 1 in ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1] = 'g'
Adding number conversion cast (unumber) 0 in SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Adding number conversion cast (unumber) 0 in SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Adding number conversion cast (unumber) 1 in SCREEN[1] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[(unumber)0]
Adding number conversion cast (unumber) 1 in SCREEN[2] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[1]
Adding number conversion cast (unumber) 2 in SCREEN[2] = ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[(unumber)1]
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = (unumber)2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Simplifying constant integer cast 1
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 (byte) 2
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing C-classic struct-unwound assignment [1] main::point1 = struct-unwound {*(&main::point1)}
Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] ((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)[0] = 'j'
Simplifying expression containing zero (byte*)&main::point1 in [5] SCREEN[0] = *((byte*)&main::point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [5] SCREEN[0] = *((byte*)&main::point1)
Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [6] SCREEN[1] = ((byte*)&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 *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1)
Consolidated array index constant in *(SCREEN+1)
Consolidated array index constant in *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1)
Consolidated array index constant in *(SCREEN+2)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 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) = memset(struct Point, SIZEOF_STRUCT_POINT)
[1] *((byte*)&main::point1) = 2
[2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) = 'j'
[3] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) = 'g'
[4] *SCREEN = *((byte*)&main::point1)
[5] *(SCREEN+1) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS)
[6] *(SCREEN+2) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1)
to:main::@return
main::@return: scope:[main] from main
[7] return
to:@return
VARIABLE REGISTER WEIGHTS
void main()
struct Point main::point1 loadstore
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) = memset(struct Point, SIZEOF_STRUCT_POINT) [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a reg byte y
Statement [1] *((byte*)&main::point1) = 2 [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
Statement [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) = 'j' [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
Statement [3] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) = 'g' [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
Statement [4] *SCREEN = *((byte*)&main::point1) [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
Statement [5] *(SCREEN+1) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) [ main::point1 ] ( [ main::point1 ] { } ) always clobbers reg byte a
Statement [6] *(SCREEN+2) = *((byte*)&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 62 combination
Uplifting [main] best 62 combination zp[3]:2 [ main::point1 ]
Uplifting [] best 62 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Minimal struct with C-Standard behavior - member array
// Upstart
// Commodore 64 PRG executable file
.file [name="struct-24.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) = memset(struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_memset_vbuc2
ldy #SIZEOF_STRUCT_POINT
lda #0
!:
dey
sta point1,y
bne !-
// [1] *((byte*)&main::point1) = 2 -- _deref_pbuc1=vbuc2
lda #2
sta.z point1
// [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) = 'j' -- _deref_pbuc1=vbuc2
lda #'j'
sta point1+OFFSET_STRUCT_POINT_INITIALS
// [3] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) = 'g' -- _deref_pbuc1=vbuc2
lda #'g'
sta point1+OFFSET_STRUCT_POINT_INITIALS+1
// [4] *SCREEN = *((byte*)&main::point1) -- _deref_pbuc1=_deref_pbuc2
lda.z point1
sta SCREEN
// [5] *(SCREEN+1) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) -- _deref_pbuc1=_deref_pbuc2
lda point1+OFFSET_STRUCT_POINT_INITIALS
sta SCREEN+1
// [6] *(SCREEN+2) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) -- _deref_pbuc1=_deref_pbuc2
lda point1+OFFSET_STRUCT_POINT_INITIALS+1
sta SCREEN+2
jmp __breturn
// main::@return
__breturn:
// [7] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
const byte OFFSET_STRUCT_POINT_INITIALS = 1
const nomodify byte* SCREEN = (byte*) 1024
const byte SIZEOF_STRUCT_POINT = 3
void main()
struct Point main::point1 loadstore zp[3]:2
zp[3]:2 [ main::point1 ]
FINAL ASSEMBLER
Score: 59
// File Comments
// Minimal struct with C-Standard behavior - member array
// Upstart
// Commodore 64 PRG executable file
.file [name="struct-24.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
// point1
// [0] *(&main::point1) = memset(struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_memset_vbuc2
ldy #SIZEOF_STRUCT_POINT
lda #0
!:
dey
sta point1,y
bne !-
// point1.x = 2
// [1] *((byte*)&main::point1) = 2 -- _deref_pbuc1=vbuc2
lda #2
sta.z point1
// point1.initials[0] = 'j'
// [2] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) = 'j' -- _deref_pbuc1=vbuc2
lda #'j'
sta point1+OFFSET_STRUCT_POINT_INITIALS
// point1.initials[1] = 'g'
// [3] *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) = 'g' -- _deref_pbuc1=vbuc2
lda #'g'
sta point1+OFFSET_STRUCT_POINT_INITIALS+1
// SCREEN[0] = point1.x
// [4] *SCREEN = *((byte*)&main::point1) -- _deref_pbuc1=_deref_pbuc2
lda.z point1
sta SCREEN
// SCREEN[1] = point1.initials[0]
// [5] *(SCREEN+1) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS) -- _deref_pbuc1=_deref_pbuc2
lda point1+OFFSET_STRUCT_POINT_INITIALS
sta SCREEN+1
// SCREEN[2] = point1.initials[1]
// [6] *(SCREEN+2) = *((byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS+1) -- _deref_pbuc1=_deref_pbuc2
lda point1+OFFSET_STRUCT_POINT_INITIALS+1
sta SCREEN+2
// main::@return
// }
// [7] return
rts
}
// File Data