
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::idx#0 = 0
  screen[main::idx#0] = cpm
  main::idx#1 = ++ main::idx#0
  screen[main::idx#1] = ccpu
  main::idx#2 = ++ main::idx#1
  screen[main::idx#2] = csm
  main::idx#3 = ++ main::idx#2
  screen[main::idx#3] = csu
  main::idx#4 = ++ main::idx#3
  main::idx#5 = $28
  screen[main::idx#5] = spm[0]
  main::idx#6 = ++ main::idx#5
  screen[main::idx#6] = spu[0]
  main::idx#7 = ++ main::idx#6
  screen[main::idx#7] = ssm[0]
  main::idx#8 = ++ main::idx#7
  screen[main::idx#8] = ssu[0]
  main::idx#9 = ++ main::idx#8
  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()
__constant const char ccpu = 'A'pu
__constant const char cpm = 'A'pm
__constant const char csm = 'A'
__constant const char csu = 'A'su
void main()
char main::idx
char main::idx#0
char main::idx#1
char main::idx#2
char main::idx#3
char main::idx#4
char main::idx#5
char main::idx#6
char main::idx#7
char main::idx#8
char main::idx#9
__constant char * const screen = (char *)$400
__constant const char spm[] = "A"pm
__constant const char spu[] = "A"pu
__constant const char ssm[] = "A"
__constant const char ssu[] = "A"su

Adding number conversion cast (unumber) $28 in main::idx#5 = $28
Adding number conversion cast (unumber) 0 in screen[main::idx#5] = spm[0]
Adding number conversion cast (unumber) 0 in screen[main::idx#6] = spu[0]
Adding number conversion cast (unumber) 0 in screen[main::idx#7] = ssm[0]
Adding number conversion cast (unumber) 0 in screen[main::idx#8] = ssu[0]
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::idx#5 = (unumber)$28
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant main::idx#0 = 0
Constant main::idx#5 = $28
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero screen in [1] screen[main::idx#0] = cpm
Simplifying expression containing zero spm in [10] screen[main::idx#5] = spm[0]
Simplifying expression containing zero spu in [12] screen[main::idx#6] = spu[0]
Simplifying expression containing zero ssm in [14] screen[main::idx#7] = ssm[0]
Simplifying expression containing zero ssu in [16] screen[main::idx#8] = ssu[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::idx#4 and assignment [7] main::idx#4 = ++ main::idx#3
Eliminating unused variable main::idx#9 and assignment [15] main::idx#9 = ++ main::idx#8
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 right-side identified [1] main::idx#1 = ++ main::idx#0
Constant right-side identified [8] main::idx#6 = ++ main::idx#5
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#1 = ++main::idx#0
Constant main::idx#6 = ++main::idx#5
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [2] main::idx#2 = ++ main::idx#1
Constant right-side identified [8] main::idx#7 = ++ main::idx#6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#2 = ++main::idx#1
Constant main::idx#7 = ++main::idx#6
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [3] main::idx#3 = ++ main::idx#2
Constant right-side identified [8] main::idx#8 = ++ main::idx#7
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::idx#3 = ++main::idx#2
Constant main::idx#8 = ++main::idx#7
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings main::idx#0
Inlining constant with different constant siblings main::idx#5
Inlining constant with different constant siblings main::idx#1
Inlining constant with different constant siblings main::idx#6
Inlining constant with different constant siblings main::idx#2
Inlining constant with different constant siblings main::idx#7
Inlining constant with different constant siblings main::idx#3
Inlining constant with different constant siblings main::idx#8
Constant inlined main::idx#0 = 0
Constant inlined main::idx#1 = ++0
Constant inlined main::idx#2 = ++++0
Constant inlined main::idx#3 = ++++++0
Constant inlined main::idx#5 = $28
Constant inlined main::idx#6 = ++$28
Constant inlined main::idx#7 = ++++$28
Constant inlined main::idx#8 = ++++++$28
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(screen+++0)
Consolidated array index constant in *(screen+++++0)
Consolidated array index constant in *(screen+++++++0)
Consolidated array index constant in *(screen+$28)
Consolidated array index constant in *(screen+++$28)
Consolidated array index constant in *(screen+++++$28)
Consolidated array index constant in *(screen+++++++$28)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++$28
Simplifying constant integer increment ++$28
Simplifying constant integer increment ++$29
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++$29
Simplifying constant integer increment ++$2a
Successful SSA optimization Pass2ConstantSimplification
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 = cpm
  [1] *(screen+1) = ccpu
  [2] *(screen+2) = csm
  [3] *(screen+3) = csu
  [4] *(screen+$28) = *spm
  [5] *(screen+$29) = *spu
  [6] *(screen+$2a) = *ssm
  [7] *(screen+$2b) = *ssu
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::idx

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *screen = cpm [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(screen+1) = ccpu [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] *(screen+2) = csm [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] *(screen+3) = csu [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [4] *(screen+$28) = *spm [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [5] *(screen+$29) = *spu [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [6] *(screen+$2a) = *ssm [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [7] *(screen+$2b) = *ssu [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [main] best 65 combination 
Uplifting [] best 65 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests encoding of literal chars
  // Upstart
  // Commodore 64 PRG executable file
.file [name="encoding-literal-char.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
.encoding "petscii_mixed"
  .const cpm = 'A'
.encoding "petscii_upper"
  .const ccpu = 'A'
.encoding "screencode_mixed"
  .const csm = 'A'
.encoding "screencode_upper"
  .const csu = 'A'
  .label screen = $400
.segment Code
  // main
main: {
    // [0] *screen = cpm -- _deref_pbuc1=vbuc2 
    lda #cpm
    sta screen
    // [1] *(screen+1) = ccpu -- _deref_pbuc1=vbuc2 
    lda #ccpu
    sta screen+1
    // [2] *(screen+2) = csm -- _deref_pbuc1=vbuc2 
    lda #csm
    sta screen+2
    // [3] *(screen+3) = csu -- _deref_pbuc1=vbuc2 
    lda #csu
    sta screen+3
    // [4] *(screen+$28) = *spm -- _deref_pbuc1=_deref_pbuc2 
    lda spm
    sta screen+$28
    // [5] *(screen+$29) = *spu -- _deref_pbuc1=_deref_pbuc2 
    lda spu
    sta screen+$29
    // [6] *(screen+$2a) = *ssm -- _deref_pbuc1=_deref_pbuc2 
    lda ssm
    sta screen+$2a
    // [7] *(screen+$2b) = *ssu -- _deref_pbuc1=_deref_pbuc2 
    lda ssu
    sta screen+$2b
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // File Data
.segment Data
.encoding "petscii_mixed"
  spm: .text "A"
  .byte 0
.encoding "petscii_upper"
  spu: .text "A"
  .byte 0
.encoding "screencode_mixed"
  ssm: .text "A"
  .byte 0
.encoding "screencode_upper"
  ssu: .text "A"
  .byte 0

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

FINAL SYMBOL TABLE
__constant const char ccpu = 'A'pu
__constant const char cpm = 'A'pm
__constant const char csm = 'A'
__constant const char csu = 'A'su
void main()
char main::idx
__constant char * const screen = (char *) 1024
__constant const char spm[] = "A"pm
__constant const char spu[] = "A"pu
__constant const char ssm[] = "A"
__constant const char ssu[] = "A"su



FINAL ASSEMBLER
Score: 62

  // File Comments
// Tests encoding of literal chars
  // Upstart
  // Commodore 64 PRG executable file
.file [name="encoding-literal-char.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
.encoding "petscii_mixed"
  .const cpm = 'A'
.encoding "petscii_upper"
  .const ccpu = 'A'
.encoding "screencode_mixed"
  .const csm = 'A'
.encoding "screencode_upper"
  .const csu = 'A'
  .label screen = $400
.segment Code
  // main
main: {
    // screen[idx++] = cpm
    // [0] *screen = cpm -- _deref_pbuc1=vbuc2 
    lda #cpm
    sta screen
    // screen[idx++] = ccpu
    // [1] *(screen+1) = ccpu -- _deref_pbuc1=vbuc2 
    lda #ccpu
    sta screen+1
    // screen[idx++] = csm
    // [2] *(screen+2) = csm -- _deref_pbuc1=vbuc2 
    lda #csm
    sta screen+2
    // screen[idx++] = csu
    // [3] *(screen+3) = csu -- _deref_pbuc1=vbuc2 
    lda #csu
    sta screen+3
    // screen[idx++] = spm[0]
    // [4] *(screen+$28) = *spm -- _deref_pbuc1=_deref_pbuc2 
    lda spm
    sta screen+$28
    // screen[idx++] = spu[0]
    // [5] *(screen+$29) = *spu -- _deref_pbuc1=_deref_pbuc2 
    lda spu
    sta screen+$29
    // screen[idx++] = ssm[0]
    // [6] *(screen+$2a) = *ssm -- _deref_pbuc1=_deref_pbuc2 
    lda ssm
    sta screen+$2a
    // screen[idx++] = ssu[0]
    // [7] *(screen+$2b) = *ssu -- _deref_pbuc1=_deref_pbuc2 
    lda ssu
    sta screen+$2b
    // main::@return
    // }
    // [8] return 
    rts
}
  // File Data
.segment Data
.encoding "petscii_mixed"
  spm: .text "A"
  .byte 0
.encoding "petscii_upper"
  spu: .text "A"
  .byte 0
.encoding "screencode_mixed"
  ssm: .text "A"
  .byte 0
.encoding "screencode_upper"
  ssu: .text "A"
  .byte 0

