
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1

(void()) main()
main: scope:[main]  from @1
  *((const byte*) main::PTR) ← <(const byte*) main::STRING
  *((const byte*) main::PTR+(number) 1) ← >(const byte*) main::STRING
  (byte*~) main::$0 ← ((byte*)) { *((const byte*) main::PTR+(number) 1), *((const byte*) main::PTR) }
  (byte*) main::ptr#0 ← (byte*~) main::$0
  *((const byte*) main::SCREEN) ← *((byte*) main::ptr#0)
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(byte*~) main::$0
(label) main::@return
(const byte*) main::PTR = (byte*)(number) $9ffe
(const byte*) main::SCREEN = (byte*)(number) $400
(const byte*) main::STRING[]  = (byte*) "camelot"z
(byte*) main::ptr
(byte*) main::ptr#0

Fixing inline constructor with main::$1 ← (byte)*(main::PTR+1) w= (byte)*(main::PTR)
Successful SSA optimization Pass2FixInlineConstructors
Adding number conversion cast (unumber) 1 in *((const byte*) main::PTR+(number) 1) ← >(const byte*) main::STRING
Adding number conversion cast (unumber) 1 in (var~) main::$1 ← (byte)*((const byte*) main::PTR+(number) 1) w= (byte)*((const byte*) main::PTR)
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 40958
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast *((const byte*) main::PTR+(unumber)(number) 1)
Simplifying constant integer cast 1
Simplifying constant integer cast *((const byte*) main::PTR)
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding pointer type conversion cast (byte*) main::$0 in (byte*~) main::$0 ← (word~) main::$1
Successful SSA optimization PassNAddTypeConversionAssignment
Alias (byte*) main::ptr#0 = (byte*~) main::$0 
Successful SSA optimization Pass2AliasElimination
Inlining cast (byte*) main::ptr#0 ← (byte*)(word~) main::$1
Successful SSA optimization Pass2InlineCast
Inlining Noop Cast [3] (byte*) main::ptr#0 ← (byte*)(word~) main::$1 keeping main::ptr#0
Successful SSA optimization Pass2NopCastInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()

(void()) main()
main: scope:[main]  from @1
  [4] *((const byte*) main::PTR) ← <(const byte*) main::STRING
  [5] *((const byte*) main::PTR+(byte) 1) ← >(const byte*) main::STRING
  [6] (word) main::ptr#0 ← *((const byte*) main::PTR+(byte) 1) w= *((const byte*) main::PTR)
  [7] *((const byte*) main::SCREEN) ← *((byte*)(word) main::ptr#0)
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*) main::ptr
(word) 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 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // 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
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label ptr = 2
    // [4] *((const byte*) main::PTR) ← <(const byte*) main::STRING -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
    // [5] *((const byte*) main::PTR+(byte) 1) ← >(const byte*) main::STRING -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
    // [6] (word) main::ptr#0 ← *((const byte*) main::PTR+(byte) 1) w= *((const byte*) main::PTR) -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR
    sta.z ptr
    lda PTR+1
    sta.z ptr+1
    // [7] *((const byte*) main::SCREEN) ← *((byte*)(word) main::ptr#0) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
    STRING: .text "camelot"
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) main::PTR) ← <(const byte*) main::STRING [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) main::PTR+(byte) 1) ← >(const byte*) main::STRING [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] (word) main::ptr#0 ← *((const byte*) main::PTR+(byte) 1) w= *((const byte*) main::PTR) [ main::ptr#0 ] ( main:2 [ main::ptr#0 ] ) always clobbers reg byte a 
Statement [7] *((const byte*) main::SCREEN) ← *((byte*)(word) main::ptr#0) [ ] ( main:2 [ ] ) 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 58 combination zp[2]:2 [ main::ptr#0 ] 
Uplifting [] best 58 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
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label ptr = 2
    // [4] *((const byte*) main::PTR) ← <(const byte*) main::STRING -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
    // [5] *((const byte*) main::PTR+(byte) 1) ← >(const byte*) main::STRING -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
    // [6] (word) main::ptr#0 ← *((const byte*) main::PTR+(byte) 1) w= *((const byte*) main::PTR) -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR
    sta.z ptr
    lda PTR+1
    sta.z ptr+1
    // [7] *((const byte*) main::SCREEN) ← *((byte*)(word) main::ptr#0) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
    STRING: .text "camelot"
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(const byte*) main::PTR = (byte*) 40958
(const byte*) main::SCREEN = (byte*) 1024
(const byte*) main::STRING[]  = (byte*) "camelot"z
(byte*) main::ptr
(word) main::ptr#0 ptr zp[2]:2 2.0

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


FINAL ASSEMBLER
Score: 43

  // 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
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label PTR = $9ffe
    .label SCREEN = $400
    .label ptr = 2
    // *PTR = <STRING
    // [4] *((const byte*) main::PTR) ← <(const byte*) main::STRING -- _deref_pbuc1=vbuc2 
    lda #<STRING
    sta PTR
    // *(PTR+1)= >STRING
    // [5] *((const byte*) main::PTR+(byte) 1) ← >(const byte*) main::STRING -- _deref_pbuc1=vbuc2 
    lda #>STRING
    sta PTR+1
    // (byte*) { *(PTR+1), *PTR }
    // [6] (word) main::ptr#0 ← *((const byte*) main::PTR+(byte) 1) w= *((const byte*) main::PTR) -- vwuz1=_deref_pbuc1_word__deref_pbuc2 
    lda PTR
    sta.z ptr
    lda PTR+1
    sta.z ptr+1
    // *SCREEN = *ptr
    // [7] *((const byte*) main::SCREEN) ← *((byte*)(word) main::ptr#0) -- _deref_pbuc1=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN
    // main::@return
    // }
    // [8] return 
    rts
    STRING: .text "camelot"
}
  // File Data

