diff --git a/src/test/ref/arrays-init-short.asm b/src/test/ref/arrays-init-short.asm new file mode 100644 index 000000000..0903e1798 --- /dev/null +++ b/src/test/ref/arrays-init-short.asm @@ -0,0 +1,33 @@ +// Test a short array initializer - the rest should be zero-filled +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label SCREEN = $400 +main: { + ldx #0 + b1: + lda msg1,x + cmp #0 + bne b2 + ldx #0 + b3: + lda msg2,x + cmp #0 + bne b4 + rts + b4: + lda msg2,x + sta SCREEN+$28,x + inx + jmp b3 + b2: + lda msg1,x + sta SCREEN,x + inx + jmp b1 +} + msg1: .text "camelot" + .byte 0 + .fill 8, 0 + msg2: .byte 'c', 'm', 'l' + .fill 13, 0 diff --git a/src/test/ref/arrays-init-short.cfg b/src/test/ref/arrays-init-short.cfg new file mode 100644 index 000000000..7e96c0af1 --- /dev/null +++ b/src/test/ref/arrays-init-short.cfg @@ -0,0 +1,31 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() +main: scope:[main] from @1 + [4] phi() + to:main::@1 +main::@1: scope:[main] from main main::@2 + [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) + [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 + to:main::@3 +main::@3: scope:[main] from main::@1 main::@4 + [7] (byte) main::i1#2 ← phi( main::@1/(byte) 0 main::@4/(byte) main::i1#1 ) + [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 + to:main::@return +main::@return: scope:[main] from main::@3 + [9] return + to:@return +main::@4: scope:[main] from main::@3 + [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) + [11] (byte) main::i1#1 ← ++ (byte) main::i1#2 + to:main::@3 +main::@2: scope:[main] from main::@1 + [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) + [13] (byte) main::i#1 ← ++ (byte) main::i#2 + to:main::@1 diff --git a/src/test/ref/arrays-init-short.log b/src/test/ref/arrays-init-short.log new file mode 100644 index 000000000..db0728326 --- /dev/null +++ b/src/test/ref/arrays-init-short.log @@ -0,0 +1,537 @@ +Warning! Adding boolean cast to non-boolean condition *((byte[$10]) msg1 + (byte) main::i) +Warning! Adding boolean cast to non-boolean condition *((byte[$10]) msg2 + (byte) main::i1) +Culled Empty Block (label) main::@4 +Culled Empty Block (label) main::@5 +Culled Empty Block (label) main::@6 +Culled Empty Block (label) main::@10 +Culled Empty Block (label) main::@9 +Culled Empty Block (label) main::@11 +Culled Empty Block (label) main::@12 + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte[$10]) msg1#0 ← (const string) $0 + (byte[$10]) msg2#0 ← { (byte) 'c', (byte) 'm', (byte) 'l' } + (byte*) SCREEN#0 ← ((byte*)) (number) $400 + to:@1 +main: scope:[main] from @1 + (byte) main::i#0 ← (number) 0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) + (bool~) main::$1 ← (number) 0 != *((byte[$10]) msg1#0 + (byte) main::i#2) + if((bool~) main::$1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 + (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 ) + *((byte*) SCREEN#0 + (byte) main::i#3) ← *((byte[$10]) msg1#0 + (byte) main::i#3) + (byte) main::i#1 ← ++ (byte) main::i#3 + to:main::@1 +main::@3: scope:[main] from main::@1 + (byte) main::i1#0 ← (number) 0 + to:main::@7 +main::@7: scope:[main] from main::@3 main::@8 + (byte) main::i1#2 ← phi( main::@3/(byte) main::i1#0 main::@8/(byte) main::i1#1 ) + (bool~) main::$2 ← (number) 0 != *((byte[$10]) msg2#0 + (byte) main::i1#2) + if((bool~) main::$2) goto main::@8 + to:main::@return +main::@8: scope:[main] from main::@7 + (byte) main::i1#3 ← phi( main::@7/(byte) main::i1#2 ) + (byte*~) main::$0 ← (byte*) SCREEN#0 + (number) $28 + *((byte*~) main::$0 + (byte) main::i1#3) ← *((byte[$10]) msg2#0 + (byte) main::i1#3) + (byte) main::i1#1 ← ++ (byte) main::i1#3 + to:main::@7 +main::@return: scope:[main] from main::@7 + return + to:@return +@1: scope:[] from @begin + call main + to:@2 +@2: scope:[] from @1 + to:@end +@end: scope:[] from @2 + +SYMBOL TABLE SSA +(const string) $0 = (string) "camelot" +(label) @1 +(label) @2 +(label) @begin +(label) @end +(byte*) SCREEN +(byte*) SCREEN#0 +(void()) main() +(byte*~) main::$0 +(bool~) main::$1 +(bool~) main::$2 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@7 +(label) main::@8 +(label) main::@return +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte) main::i#3 +(byte) main::i1 +(byte) main::i1#0 +(byte) main::i1#1 +(byte) main::i1#2 +(byte) main::i1#3 +(byte[$10]) msg1 +(byte[$10]) msg1#0 +(byte[$10]) msg2 +(byte[$10]) msg2#0 + +Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0 +Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (number) 0 != *((byte[$10]) msg1#0 + (byte) main::i#2) +Adding number conversion cast (unumber) 0 in (byte) main::i1#0 ← (number) 0 +Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← (number) 0 != *((byte[$10]) msg2#0 + (byte) main::i1#2) +Adding number conversion cast (unumber) $28 in (byte*~) main::$0 ← (byte*) SCREEN#0 + (number) $28 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400 +Inlining cast (byte) main::i#0 ← (unumber)(number) 0 +Inlining cast (byte) main::i1#0 ← (unumber)(number) 0 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast $28 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $28 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Alias (byte) main::i#2 = (byte) main::i#3 +Alias (byte) main::i1#2 = (byte) main::i1#3 +Successful SSA optimization Pass2AliasElimination +Simple Condition (bool~) main::$1 [6] if((byte) 0!=*((byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 +Simple Condition (bool~) main::$2 [13] if((byte) 0!=*((byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@8 +Successful SSA optimization Pass2ConditionalJumpSimplification +Identified constant from value list (byte[$10]) { (byte) 'c', (byte) 'm', (byte) 'l' } +Successful SSA optimization Pass2ConstantInitializerValueLists +Constant (const byte[$10]) msg1#0 = $0 +Constant (const byte[$10]) msg2#0 = { 'c', 'm', 'l' } +Constant (const byte*) SCREEN#0 = (byte*) 1024 +Constant (const byte) main::i#0 = 0 +Constant (const byte) main::i1#0 = 0 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [6] (byte*~) main::$0 ← (const byte*) SCREEN#0 + (byte) $28 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte*) main::$0 = SCREEN#0+$28 +Successful SSA optimization Pass2ConstantIdentification +Inlining constant with var siblings (const byte) main::i#0 +Inlining constant with var siblings (const byte) main::i1#0 +Constant inlined main::i#0 = (byte) 0 +Constant inlined main::i1#0 = (byte) 0 +Constant inlined $0 = (const byte[$10]) msg1#0 +Constant inlined main::$0 = (const byte*) SCREEN#0+(byte) $28 +Successful SSA optimization Pass2ConstantInlining +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 +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@3 +CALL GRAPH +Calls in [] to main:2 + +Created 2 initial phi equivalence classes +Coalesced [14] main::i1#4 ← main::i1#1 +Coalesced [17] main::i#4 ← main::i#1 +Coalesced down to 2 phi equivalence classes +Culled Empty Block (label) @2 +Culled Empty Block (label) main::@3 +Renumbering block main::@7 to main::@3 +Renumbering block main::@8 to main::@4 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main + +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() +main: scope:[main] from @1 + [4] phi() + to:main::@1 +main::@1: scope:[main] from main main::@2 + [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) + [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 + to:main::@3 +main::@3: scope:[main] from main::@1 main::@4 + [7] (byte) main::i1#2 ← phi( main::@1/(byte) 0 main::@4/(byte) main::i1#1 ) + [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 + to:main::@return +main::@return: scope:[main] from main::@3 + [9] return + to:@return +main::@4: scope:[main] from main::@3 + [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) + [11] (byte) main::i1#1 ← ++ (byte) main::i1#2 + to:main::@3 +main::@2: scope:[main] from main::@1 + [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) + [13] (byte) main::i#1 ← ++ (byte) main::i#2 + to:main::@1 + + +VARIABLE REGISTER WEIGHTS +(byte*) SCREEN +(void()) main() +(byte) main::i +(byte) main::i#1 22.0 +(byte) main::i#2 18.333333333333332 +(byte) main::i1 +(byte) main::i1#1 22.0 +(byte) main::i1#2 18.333333333333332 +(byte[$10]) msg1 +(byte[$10]) msg2 + +Initial phi equivalence classes +[ main::i#2 main::i#1 ] +[ main::i1#2 main::i1#1 ] +Complete equivalence classes +[ main::i#2 main::i#1 ] +[ main::i1#2 main::i1#1 ] +Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Allocated zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test a short array initializer - the rest should be zero-filled + // Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // @begin +bbegin: + // [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 + // @1 +b1: + // [2] call main + // [4] phi from @1 to main [phi:@1->main] +main_from_b1: + jsr main + // [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend + // @end +bend: + // main +main: { + .label i = 2 + .label i1 = 3 + // [5] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta.z i + jmp b1 + // main::@1 + b1: + // [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1 + lda #0 + ldy.z i + cmp msg1,y + bne b2 + // [7] phi from main::@1 to main::@3 [phi:main::@1->main::@3] + b3_from_b1: + // [7] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@3#0] -- vbuz1=vbuc1 + lda #0 + sta.z i1 + jmp b3 + // main::@3 + b3: + // [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1 + lda #0 + ldy.z i1 + cmp msg2,y + bne b4 + jmp breturn + // main::@return + breturn: + // [9] return + rts + // main::@4 + b4: + // [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z i1 + lda msg2,y + sta SCREEN+$28,y + // [11] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1 + inc.z i1 + // [7] phi from main::@4 to main::@3 [phi:main::@4->main::@3] + b3_from_b4: + // [7] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@4->main::@3#0] -- register_copy + jmp b3 + // main::@2 + b2: + // [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z i + lda msg1,y + sta SCREEN,y + // [13] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc.z i + // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + b1_from_b2: + // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + jmp b1 +} + // File Data + msg1: .text "camelot" + .byte 0 + .fill 8, 0 + msg2: .byte 'c', 'm', 'l' + .fill 13, 0 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Statement [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 [ main::i1#2 ] ( main:2 [ main::i1#2 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] +Statement [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) [ main::i1#2 ] ( main:2 [ main::i1#2 ] ) always clobbers reg byte a +Statement [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Statement [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Statement [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 [ main::i1#2 ] ( main:2 [ main::i1#2 ] ) always clobbers reg byte a +Statement [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) [ main::i1#2 ] ( main:2 [ main::i1#2 ] ) always clobbers reg byte a +Statement [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a +Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 40.33: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 40.33: zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] +Uplift Scope [] + +Uplifting [main] best 618 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::i1#2 main::i1#1 ] +Uplifting [] best 618 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test a short array initializer - the rest should be zero-filled + // Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // @begin +bbegin: + // [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 + // @1 +b1: + // [2] call main + // [4] phi from @1 to main [phi:@1->main] +main_from_b1: + jsr main + // [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend + // @end +bend: + // main +main: { + // [5] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + jmp b1 + // main::@1 + b1: + // [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 + lda msg1,x + cmp #0 + bne b2 + // [7] phi from main::@1 to main::@3 [phi:main::@1->main::@3] + b3_from_b1: + // [7] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@3#0] -- vbuxx=vbuc1 + ldx #0 + jmp b3 + // main::@3 + b3: + // [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 + lda msg2,x + cmp #0 + bne b4 + jmp breturn + // main::@return + breturn: + // [9] return + rts + // main::@4 + b4: + // [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda msg2,x + sta SCREEN+$28,x + // [11] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuxx=_inc_vbuxx + inx + // [7] phi from main::@4 to main::@3 [phi:main::@4->main::@3] + b3_from_b4: + // [7] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@4->main::@3#0] -- register_copy + jmp b3 + // main::@2 + b2: + // [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda msg1,x + sta SCREEN,x + // [13] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + b1_from_b2: + // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + jmp b1 +} + // File Data + msg1: .text "camelot" + .byte 0 + .fill 8, 0 + msg2: .byte 'c', 'm', 'l' + .fill 13, 0 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp b3 +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction b1_from_bbegin: +Removing instruction b1: +Removing instruction main_from_b1: +Removing instruction bend_from_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction bend: +Removing instruction b1_from_main: +Removing instruction b3_from_b1: +Removing instruction breturn: +Removing instruction b3_from_b4: +Removing instruction b1_from_b2: +Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = (byte*) 1024 +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 22.0 +(byte) main::i#2 reg byte x 18.333333333333332 +(byte) main::i1 +(byte) main::i1#1 reg byte x 22.0 +(byte) main::i1#2 reg byte x 18.333333333333332 +(byte[$10]) msg1 +(const byte[$10]) msg1#0 msg1 = (string) "camelot" +(byte[$10]) msg2 +(const byte[$10]) msg2#0 msg2 = { (byte) 'c', (byte) 'm', (byte) 'l' } + +reg byte x [ main::i#2 main::i#1 ] +reg byte x [ main::i1#2 main::i1#1 ] + + +FINAL ASSEMBLER +Score: 516 + + // File Comments +// Test a short array initializer - the rest should be zero-filled + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // @begin + // [1] phi from @begin to @1 [phi:@begin->@1] + // @1 + // [2] call main + // [4] phi from @1 to main [phi:@1->main] + // [3] phi from @1 to @end [phi:@1->@end] + // @end + // main +main: { + // [5] phi from main to main::@1 [phi:main->main::@1] + // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + // main::@1 + b1: + // for(char i=0;msg1[i];i++) + // [6] if((byte) 0!=*((const byte[$10]) msg1#0 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 + lda msg1,x + cmp #0 + bne b2 + // [7] phi from main::@1 to main::@3 [phi:main::@1->main::@3] + // [7] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@3#0] -- vbuxx=vbuc1 + ldx #0 + // main::@3 + b3: + // for(char i=0;msg2[i];i++) + // [8] if((byte) 0!=*((const byte[$10]) msg2#0 + (byte) main::i1#2)) goto main::@4 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 + lda msg2,x + cmp #0 + bne b4 + // main::@return + // } + // [9] return + rts + // main::@4 + b4: + // (SCREEN+40)[i] = msg2[i] + // [10] *((const byte*) SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((const byte[$10]) msg2#0 + (byte) main::i1#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda msg2,x + sta SCREEN+$28,x + // for(char i=0;msg2[i];i++) + // [11] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuxx=_inc_vbuxx + inx + // [7] phi from main::@4 to main::@3 [phi:main::@4->main::@3] + // [7] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@4->main::@3#0] -- register_copy + jmp b3 + // main::@2 + b2: + // SCREEN[i] = msg1[i] + // [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← *((const byte[$10]) msg1#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda msg1,x + sta SCREEN,x + // for(char i=0;msg1[i];i++) + // [13] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + jmp b1 +} + // File Data + msg1: .text "camelot" + .byte 0 + .fill 8, 0 + msg2: .byte 'c', 'm', 'l' + .fill 13, 0 + diff --git a/src/test/ref/arrays-init-short.sym b/src/test/ref/arrays-init-short.sym new file mode 100644 index 000000000..7bae6fe46 --- /dev/null +++ b/src/test/ref/arrays-init-short.sym @@ -0,0 +1,24 @@ +(label) @1 +(label) @begin +(label) @end +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = (byte*) 1024 +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 22.0 +(byte) main::i#2 reg byte x 18.333333333333332 +(byte) main::i1 +(byte) main::i1#1 reg byte x 22.0 +(byte) main::i1#2 reg byte x 18.333333333333332 +(byte[$10]) msg1 +(const byte[$10]) msg1#0 msg1 = (string) "camelot" +(byte[$10]) msg2 +(const byte[$10]) msg2#0 msg2 = { (byte) 'c', (byte) 'm', (byte) 'l' } + +reg byte x [ main::i#2 main::i#1 ] +reg byte x [ main::i1#2 main::i1#1 ]