
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  *main::PTR = byte0 main::STRING
  *(main::PTR+1) = byte1 main::STRING
  main::$0 = *(main::PTR+1) w= *main::PTR
  main::ptr#0 = (char *)main::$0
  *main::SCREEN = *main::ptr#0
  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
void __start()
void main()
unsigned int main::$0
__constant char * const main::PTR = (char *)$9ffe
__constant char * const main::SCREEN = (char *)$400
__constant const char main::STRING[] = "camelot"z
char *main::ptr
char *main::ptr#0

Adding number conversion cast (unumber) 1 in *(main::PTR+1) = byte1 main::STRING
Adding number conversion cast (unumber) 1 in main::$0 = *(main::PTR+1) w= *main::PTR
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 40958
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
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
Inlining Noop Cast [3] main::ptr#0 = (char *)main::$0 keeping main::ptr#0
Successful SSA optimization Pass2NopCastInlining
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::PTR = byte0 main::STRING
  [1] *(main::PTR+1) = byte1 main::STRING
  [2] main::ptr#0 = *(main::PTR+1) w= *main::PTR
  [3] *main::SCREEN = *((char *)main::ptr#0)
  to:main::@return
main::@return: scope:[main]  from main
  [4] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char *main::ptr
unsigned int main::ptr#0 // 2.0

Initial phi equivalence classes
Added variable main::ptr#0 to live range equivalence class [ main::ptr#0 ]
Complete equivalence classes
[ main::ptr#0 ]
Allocated zp[2]:2 [ main::ptr#0 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *main::PTR = byte0 main::STRING [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(main::PTR+1) = byte1 main::STRING [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] main::ptr#0 = *(main::PTR+1) w= *main::PTR [ main::ptr#0 ] (  [ main::ptr#0 ] { }  ) always clobbers reg byte a 
Statement [3] *main::SCREEN = *((char *)main::ptr#0) [ ] (  [ ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[2]:2 [ main::ptr#0 ] : zp[2]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 2: zp[2]:2 [ main::ptr#0 ] 
Uplift Scope [] 

Uplifting [main] best 46 combination zp[2]:2 [ main::ptr#0 ] 
Uplifting [] best 46 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test assigning address of inline string to pointer
// The result should be an labelled .text in the ASM
// Erroneously tries to inline the string completely leading to a CompileError
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-string-3.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
.segment Code
  // main
main: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label ptr = 2
    // [0] *main::PTR = byte0 main::STRING -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
    // [1] *(main::PTR+1) = byte1 main::STRING -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
    // [2] main::ptr#0 = *(main::PTR+1) w= *main::PTR -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR+1
    sta.z ptr+1
    lda PTR
    sta.z ptr
    // [3] *main::SCREEN = *((char *)main::ptr#0) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
  .segment Data
    STRING: .text "camelot"
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda PTR+1
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
__constant char * const main::PTR = (char *) 40958
__constant char * const main::SCREEN = (char *) 1024
__constant const char main::STRING[] = "camelot"z
char *main::ptr
unsigned int main::ptr#0 // ptr zp[2]:2 2.0

zp[2]:2 [ main::ptr#0 ]


FINAL ASSEMBLER
Score: 39

  // File Comments
// Test assigning address of inline string to pointer
// The result should be an labelled .text in the ASM
// Erroneously tries to inline the string completely leading to a CompileError
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-string-3.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
.segment Code
  // main
main: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label ptr = 2
    // *PTR = BYTE0(STRING)
    // [0] *main::PTR = byte0 main::STRING -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
    // *(PTR+1)= BYTE1(STRING)
    // [1] *(main::PTR+1) = byte1 main::STRING -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
    // MAKEWORD( *(PTR+1), *PTR )
    // [2] main::ptr#0 = *(main::PTR+1) w= *main::PTR -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    sta.z ptr+1
    lda PTR
    sta.z ptr
    // *SCREEN = *ptr
    // [3] *main::SCREEN = *((char *)main::ptr#0) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN
    // main::@return
    // }
    // [4] return 
    rts
  .segment Data
    STRING: .text "camelot"
}
  // File Data

