
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  SCREEN[0] = *((const char *)&y+OFFSET_STRUCT_$0_X)
  SCREEN[0] = *((char *)&y+OFFSET_STRUCT_$0_Z)
  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 char OFFSET_STRUCT_$0_X = 0
__constant char OFFSET_STRUCT_$0_Z = 1
__constant char * const SCREEN = (char *)$400
void __start()
void main()
__loadstore volatile struct $0 y = { x: 1, z: 2 }

Adding number conversion cast (unumber) 0 in SCREEN[0] = *((const char *)&y+OFFSET_STRUCT_$0_X)
Adding number conversion cast (unumber) 0 in SCREEN[0] = *((char *)&y+OFFSET_STRUCT_$0_Z)
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero (const char *)&y in [0] SCREEN[0] = *((const char *)&y+OFFSET_STRUCT_$0_X)
Simplifying expression containing zero SCREEN in [0] SCREEN[0] = *((const char *)&y)
Simplifying expression containing zero SCREEN in [1] SCREEN[0] = *((char *)&y+OFFSET_STRUCT_$0_Z)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_$0_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
Constant inlined OFFSET_STRUCT_$0_Z = 1
Successful SSA optimization Pass2ConstantInlining
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] *SCREEN = *((const char *)&y)
  [1] *SCREEN = *((char *)&y+1)
  to:main::@return
main::@return: scope:[main]  from main
  [2] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore volatile struct $0 y = { x: 1, z: 2 }

Initial phi equivalence classes
Added variable y to live range equivalence class [ y ]
Complete equivalence classes
[ y ]
Allocated mem[2] [ y ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *SCREEN = *((const char *)&y) [ y ] (  [ y ] { }  ) always clobbers reg byte a 
Statement [1] *SCREEN = *((char *)&y+1) [ ] (  [ ] { }  ) always clobbers reg byte a 
Potential registers mem[2] [ y ] : mem[2] , 

REGISTER UPLIFT SCOPES
Uplift Scope [$0] 
Uplift Scope [main] 
Uplift Scope [] 0: mem[2] [ y ] 

Uplifting [$0] best 25 combination 
Uplifting [main] best 25 combination 
Uplifting [] best 25 combination mem[2] [ y ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test that struct variable and members can both have type directives
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-directives.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    // [0] *SCREEN = *((const char *)&y) -- _deref_pbuc1=_deref_pbuc2 
    lda y
    sta SCREEN
    // [1] *SCREEN = *((char *)&y+1) -- _deref_pbuc1=_deref_pbuc2 
    lda y+1
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [2] return 
    rts
}
  // File Data
.segment Data
  y: .byte 1, 2

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
void main()
__loadstore volatile struct $0 y = { x: 1, z: 2 } // mem[2]

mem[2] [ y ]


FINAL ASSEMBLER
Score: 22

  // File Comments
// Test that struct variable and members can both have type directives
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-directives.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    // SCREEN[0] = y.x
    // [0] *SCREEN = *((const char *)&y) -- _deref_pbuc1=_deref_pbuc2 
    lda y
    sta SCREEN
    // SCREEN[0] = y.z
    // [1] *SCREEN = *((char *)&y+1) -- _deref_pbuc1=_deref_pbuc2 
    lda y+1
    sta SCREEN
    // main::@return
    // }
    // [2] return 
    rts
}
  // File Data
.segment Data
  y: .byte 1, 2

