From f29648ca266cb1d25d20d2d6be4fb18e86912f99 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 9 Jun 2019 10:55:18 +0200 Subject: [PATCH] Added test with 3-level nested struct value. --- .../dk/camelot64/kickc/test/TestPrograms.java | 5 + src/test/kc/struct-7.kc | 28 ++ src/test/ref/struct-7.asm | 26 + src/test/ref/struct-7.cfg | 20 + src/test/ref/struct-7.log | 468 ++++++++++++++++++ src/test/ref/struct-7.sym | 1 + 6 files changed, 548 insertions(+) create mode 100644 src/test/kc/struct-7.kc create mode 100644 src/test/ref/struct-7.asm create mode 100644 src/test/ref/struct-7.cfg create mode 100644 src/test/ref/struct-7.log create mode 100644 src/test/ref/struct-7.sym diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index e942b872d..b4fffe0fb 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -70,6 +70,11 @@ public class TestPrograms { assertError("struct-err-0", "Unknown struct type"); } + @Test + public void testStruct7() throws IOException, URISyntaxException { + compileAndCompare("struct-7"); + } + @Test public void testStruct6() throws IOException, URISyntaxException { compileAndCompare("struct-6"); diff --git a/src/test/kc/struct-7.kc b/src/test/kc/struct-7.kc new file mode 100644 index 000000000..09ea8aa02 --- /dev/null +++ b/src/test/kc/struct-7.kc @@ -0,0 +1,28 @@ +// Minimal struct - nesting structs 3 levels + +struct Point { + byte x; + byte y; +}; + +struct Circle { + struct Point center; + byte radius; +}; + +struct TwoCircles { + struct Circle c1; + struct Circle c2; +}; + + +void main() { + struct TwoCircles t = { { { 1, 2}, 3 }, { { 4, 5}, 6 } }; + const byte* SCREEN = 0x0400; + SCREEN[0] = t.c1.center.x; + SCREEN[1] = t.c1.center.y; + SCREEN[2] = t.c1.radius; + SCREEN[3] = t.c2.center.x; + SCREEN[4] = t.c2.center.y; + SCREEN[5] = t.c2.radius; +} diff --git a/src/test/ref/struct-7.asm b/src/test/ref/struct-7.asm new file mode 100644 index 000000000..52c8e6fb1 --- /dev/null +++ b/src/test/ref/struct-7.asm @@ -0,0 +1,26 @@ +// Minimal struct - nesting structs 3 levels +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +main: { + .const t_c1_center_x = 1 + .const t_c1_center_y = 2 + .const t_c1_radius = 3 + .const t_c2_center_x = 4 + .const t_c2_center_y = 5 + .const t_c2_radius = 6 + .label SCREEN = $400 + lda #t_c1_center_x + sta SCREEN + lda #t_c1_center_y + sta SCREEN+1 + lda #t_c1_radius + sta SCREEN+2 + lda #t_c2_center_x + sta SCREEN+3 + lda #t_c2_center_y + sta SCREEN+4 + lda #t_c2_radius + sta SCREEN+5 + rts +} diff --git a/src/test/ref/struct-7.cfg b/src/test/ref/struct-7.cfg new file mode 100644 index 000000000..bb02bb150 --- /dev/null +++ b/src/test/ref/struct-7.cfg @@ -0,0 +1,20 @@ +@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] *((const byte*) main::SCREEN#0) ← (const byte) main::t_c1_center_x#0 + [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) main::t_c1_center_y#0 + [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) main::t_c1_radius#0 + [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) main::t_c2_center_x#0 + [8] *((const byte*) main::SCREEN#0+(byte) 4) ← (const byte) main::t_c2_center_y#0 + [9] *((const byte*) main::SCREEN#0+(byte) 5) ← (const byte) main::t_c2_radius#0 + to:main::@return +main::@return: scope:[main] from main + [10] return + to:@return diff --git a/src/test/ref/struct-7.log b/src/test/ref/struct-7.log new file mode 100644 index 000000000..58e491d60 --- /dev/null +++ b/src/test/ref/struct-7.log @@ -0,0 +1,468 @@ +Created struct value member variable (struct Circle) main::t_c1 +Created struct value member variable (struct Circle) main::t_c2 +Converted struct value to member variables (struct TwoCircles) main::t +Adding struct value list initializer (struct Circle) main::t_c1 ← { { (number) 1, (number) 2 }, (number) 3 } +Adding struct value list initializer (struct Circle) main::t_c2 ← { { (number) 4, (number) 5 }, (number) 6 } +Replacing struct member reference (struct TwoCircles) main::t.c1 with member variable reference (struct Circle) main::t_c1 +Replacing struct member reference (struct TwoCircles) main::t.c1 with member variable reference (struct Circle) main::t_c1 +Replacing struct member reference (struct TwoCircles) main::t.c1 with member variable reference (struct Circle) main::t_c1 +Replacing struct member reference (struct TwoCircles) main::t.c2 with member variable reference (struct Circle) main::t_c2 +Replacing struct member reference (struct TwoCircles) main::t.c2 with member variable reference (struct Circle) main::t_c2 +Replacing struct member reference (struct TwoCircles) main::t.c2 with member variable reference (struct Circle) main::t_c2 +Created struct value member variable (struct Point) main::t_c1_center +Created struct value member variable (byte) main::t_c1_radius +Converted struct value to member variables (struct Circle) main::t_c1 +Created struct value member variable (struct Point) main::t_c2_center +Created struct value member variable (byte) main::t_c2_radius +Converted struct value to member variables (struct Circle) main::t_c2 +Adding struct value list initializer (struct Point) main::t_c1_center ← { (number) 1, (number) 2 } +Adding struct value list initializer (byte) main::t_c1_radius ← (number) 3 +Adding struct value list initializer (struct Point) main::t_c2_center ← { (number) 4, (number) 5 } +Adding struct value list initializer (byte) main::t_c2_radius ← (number) 6 +Replacing struct member reference (struct Circle) main::t_c1.center with member variable reference (struct Point) main::t_c1_center +Replacing struct member reference (struct Circle) main::t_c1.center with member variable reference (struct Point) main::t_c1_center +Replacing struct member reference (struct Circle) main::t_c1.radius with member variable reference (byte) main::t_c1_radius +Replacing struct member reference (struct Circle) main::t_c2.center with member variable reference (struct Point) main::t_c2_center +Replacing struct member reference (struct Circle) main::t_c2.center with member variable reference (struct Point) main::t_c2_center +Replacing struct member reference (struct Circle) main::t_c2.radius with member variable reference (byte) main::t_c2_radius +Created struct value member variable (byte) main::t_c1_center_x +Created struct value member variable (byte) main::t_c1_center_y +Converted struct value to member variables (struct Point) main::t_c1_center +Created struct value member variable (byte) main::t_c2_center_x +Created struct value member variable (byte) main::t_c2_center_y +Converted struct value to member variables (struct Point) main::t_c2_center +Adding struct value list initializer (byte) main::t_c1_center_x ← (number) 1 +Adding struct value list initializer (byte) main::t_c1_center_y ← (number) 2 +Adding struct value list initializer (byte) main::t_c2_center_x ← (number) 4 +Adding struct value list initializer (byte) main::t_c2_center_y ← (number) 5 +Replacing struct member reference (struct Point) main::t_c1_center.x with member variable reference (byte) main::t_c1_center_x +Replacing struct member reference (struct Point) main::t_c1_center.y with member variable reference (byte) main::t_c1_center_y +Replacing struct member reference (struct Point) main::t_c2_center.x with member variable reference (byte) main::t_c2_center_x +Replacing struct member reference (struct Point) main::t_c2_center.y with member variable reference (byte) main::t_c2_center_y +Adding pointer type conversion cast (byte*) main::SCREEN in (byte*) main::SCREEN ← (number) $400 +Identified constant variable (byte) main::t_c1_radius +Identified constant variable (byte) main::t_c2_radius +Identified constant variable (byte) main::t_c1_center_x +Identified constant variable (byte) main::t_c1_center_y +Identified constant variable (byte) main::t_c2_center_x +Identified constant variable (byte) main::t_c2_center_y + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + to:@1 +main: scope:[main] from @1 + (byte) main::t_c1_center_x#0 ← (number) 1 + (byte) main::t_c1_center_y#0 ← (number) 2 + (byte) main::t_c1_radius#0 ← (number) 3 + (byte) main::t_c2_center_x#0 ← (number) 4 + (byte) main::t_c2_center_y#0 ← (number) 5 + (byte) main::t_c2_radius#0 ← (number) 6 + (byte*) main::SCREEN#0 ← ((byte*)) (number) $400 + *((byte*) main::SCREEN#0 + (number) 0) ← (byte) main::t_c1_center_x#0 + *((byte*) main::SCREEN#0 + (number) 1) ← (byte) main::t_c1_center_y#0 + *((byte*) main::SCREEN#0 + (number) 2) ← (byte) main::t_c1_radius#0 + *((byte*) main::SCREEN#0 + (number) 3) ← (byte) main::t_c2_center_x#0 + *((byte*) main::SCREEN#0 + (number) 4) ← (byte) main::t_c2_center_y#0 + *((byte*) main::SCREEN#0 + (number) 5) ← (byte) main::t_c2_radius#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 +(struct Point) Circle::center +(byte) Circle::radius +(byte) Point::x +(byte) Point::y +(struct Circle) TwoCircles::c1 +(struct Circle) TwoCircles::c2 +(void()) main() +(label) main::@return +(byte*) main::SCREEN +(byte*) main::SCREEN#0 +(struct TwoCircles) main::t +(struct Circle) main::t_c1 +(struct Point) main::t_c1_center +(byte) main::t_c1_center_x +(byte) main::t_c1_center_x#0 +(byte) main::t_c1_center_y +(byte) main::t_c1_center_y#0 +(byte) main::t_c1_radius +(byte) main::t_c1_radius#0 +(struct Circle) main::t_c2 +(struct Point) main::t_c2_center +(byte) main::t_c2_center_x +(byte) main::t_c2_center_x#0 +(byte) main::t_c2_center_y +(byte) main::t_c2_center_y#0 +(byte) main::t_c2_radius +(byte) main::t_c2_radius#0 + +Adding number conversion cast (unumber) 1 in (byte) main::t_c1_center_x#0 ← (number) 1 +Adding number conversion cast (unumber) 2 in (byte) main::t_c1_center_y#0 ← (number) 2 +Adding number conversion cast (unumber) 3 in (byte) main::t_c1_radius#0 ← (number) 3 +Adding number conversion cast (unumber) 4 in (byte) main::t_c2_center_x#0 ← (number) 4 +Adding number conversion cast (unumber) 5 in (byte) main::t_c2_center_y#0 ← (number) 5 +Adding number conversion cast (unumber) 6 in (byte) main::t_c2_radius#0 ← (number) 6 +Adding number conversion cast (unumber) 0 in *((byte*) main::SCREEN#0 + (number) 0) ← (byte) main::t_c1_center_x#0 +Adding number conversion cast (unumber) 1 in *((byte*) main::SCREEN#0 + (number) 1) ← (byte) main::t_c1_center_y#0 +Adding number conversion cast (unumber) 2 in *((byte*) main::SCREEN#0 + (number) 2) ← (byte) main::t_c1_radius#0 +Adding number conversion cast (unumber) 3 in *((byte*) main::SCREEN#0 + (number) 3) ← (byte) main::t_c2_center_x#0 +Adding number conversion cast (unumber) 4 in *((byte*) main::SCREEN#0 + (number) 4) ← (byte) main::t_c2_center_y#0 +Adding number conversion cast (unumber) 5 in *((byte*) main::SCREEN#0 + (number) 5) ← (byte) main::t_c2_radius#0 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte) main::t_c1_center_x#0 ← (unumber)(number) 1 +Inlining cast (byte) main::t_c1_center_y#0 ← (unumber)(number) 2 +Inlining cast (byte) main::t_c1_radius#0 ← (unumber)(number) 3 +Inlining cast (byte) main::t_c2_center_x#0 ← (unumber)(number) 4 +Inlining cast (byte) main::t_c2_center_y#0 ← (unumber)(number) 5 +Inlining cast (byte) main::t_c2_radius#0 ← (unumber)(number) 6 +Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400 +Successful SSA optimization Pass2InlineCast +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 3 +Simplifying constant integer cast 4 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 3 +Simplifying constant integer cast 4 +Simplifying constant integer cast 5 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) 3 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) 6 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) 3 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) 5 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Constant (const byte) main::t_c1_center_x#0 = 1 +Constant (const byte) main::t_c1_center_y#0 = 2 +Constant (const byte) main::t_c1_radius#0 = 3 +Constant (const byte) main::t_c2_center_x#0 = 4 +Constant (const byte) main::t_c2_center_y#0 = 5 +Constant (const byte) main::t_c2_radius#0 = 6 +Constant (const byte*) main::SCREEN#0 = (byte*) 1024 +Successful SSA optimization Pass2ConstantIdentification +Simplifying expression containing zero main::SCREEN#0 in [7] *((const byte*) main::SCREEN#0 + (byte) 0) ← (const byte) main::t_c1_center_x#0 +Successful SSA optimization PassNSimplifyExpressionWithZero +Consolidated array index constant in *(main::SCREEN#0+1) +Consolidated array index constant in *(main::SCREEN#0+2) +Consolidated array index constant in *(main::SCREEN#0+3) +Consolidated array index constant in *(main::SCREEN#0+4) +Consolidated array index constant in *(main::SCREEN#0+5) +Successful SSA optimization Pass2ConstantAdditionElimination +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() +main: scope:[main] from @1 + [4] *((const byte*) main::SCREEN#0) ← (const byte) main::t_c1_center_x#0 + [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) main::t_c1_center_y#0 + [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) main::t_c1_radius#0 + [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) main::t_c2_center_x#0 + [8] *((const byte*) main::SCREEN#0+(byte) 4) ← (const byte) main::t_c2_center_y#0 + [9] *((const byte*) main::SCREEN#0+(byte) 5) ← (const byte) main::t_c2_radius#0 + to:main::@return +main::@return: scope:[main] from main + [10] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(struct Point) Circle::center +(byte) Circle::radius +(byte) Point::x +(byte) Point::y +(struct Circle) TwoCircles::c1 +(struct Circle) TwoCircles::c2 +(void()) main() +(byte*) main::SCREEN +(struct TwoCircles) main::t +(struct Circle) main::t_c1 +(struct Point) main::t_c1_center +(byte) main::t_c1_center_x +(byte) main::t_c1_center_y +(byte) main::t_c1_radius +(struct Circle) main::t_c2 +(struct Point) main::t_c2_center +(byte) main::t_c2_center_x +(byte) main::t_c2_center_y +(byte) main::t_c2_radius + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +//SEG0 File Comments +// Minimal struct - nesting structs 3 levels +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call main + jsr main +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + .const t_c1_center_x = 1 + .const t_c1_center_y = 2 + .const t_c1_radius = 3 + .const t_c2_center_x = 4 + .const t_c2_center_y = 5 + .const t_c2_radius = 6 + .label SCREEN = $400 + //SEG10 [4] *((const byte*) main::SCREEN#0) ← (const byte) main::t_c1_center_x#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_center_x + sta SCREEN + //SEG11 [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) main::t_c1_center_y#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_center_y + sta SCREEN+1 + //SEG12 [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) main::t_c1_radius#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_radius + sta SCREEN+2 + //SEG13 [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) main::t_c2_center_x#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_center_x + sta SCREEN+3 + //SEG14 [8] *((const byte*) main::SCREEN#0+(byte) 4) ← (const byte) main::t_c2_center_y#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_center_y + sta SCREEN+4 + //SEG15 [9] *((const byte*) main::SCREEN#0+(byte) 5) ← (const byte) main::t_c2_radius#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_radius + sta SCREEN+5 + jmp breturn + //SEG16 main::@return + breturn: + //SEG17 [10] return + rts +} + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [4] *((const byte*) main::SCREEN#0) ← (const byte) main::t_c1_center_x#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) main::t_c1_center_y#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) main::t_c1_radius#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) main::t_c2_center_x#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [8] *((const byte*) main::SCREEN#0+(byte) 4) ← (const byte) main::t_c2_center_y#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [9] *((const byte*) main::SCREEN#0+(byte) 5) ← (const byte) main::t_c2_radius#0 [ ] ( main:2 [ ] ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [Point] +Uplift Scope [Circle] +Uplift Scope [TwoCircles] +Uplift Scope [main] +Uplift Scope [] + +Uplifting [Point] best 57 combination +Uplifting [Circle] best 57 combination +Uplifting [TwoCircles] best 57 combination +Uplifting [main] best 57 combination +Uplifting [] best 57 combination + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 File Comments +// Minimal struct - nesting structs 3 levels +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call main + jsr main +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + .const t_c1_center_x = 1 + .const t_c1_center_y = 2 + .const t_c1_radius = 3 + .const t_c2_center_x = 4 + .const t_c2_center_y = 5 + .const t_c2_radius = 6 + .label SCREEN = $400 + //SEG10 [4] *((const byte*) main::SCREEN#0) ← (const byte) main::t_c1_center_x#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_center_x + sta SCREEN + //SEG11 [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) main::t_c1_center_y#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_center_y + sta SCREEN+1 + //SEG12 [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) main::t_c1_radius#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_radius + sta SCREEN+2 + //SEG13 [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) main::t_c2_center_x#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_center_x + sta SCREEN+3 + //SEG14 [8] *((const byte*) main::SCREEN#0+(byte) 4) ← (const byte) main::t_c2_center_y#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_center_y + sta SCREEN+4 + //SEG15 [9] *((const byte*) main::SCREEN#0+(byte) 5) ← (const byte) main::t_c2_radius#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_radius + sta SCREEN+5 + jmp breturn + //SEG16 main::@return + breturn: + //SEG17 [10] return + rts +} + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp bend +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction b1_from_bbegin: +Removing instruction b1: +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 bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(struct Point) Circle::center +(byte) Circle::radius +(byte) Point::x +(byte) Point::y +(struct Circle) TwoCircles::c1 +(struct Circle) TwoCircles::c2 +(void()) main() +(label) main::@return +(byte*) main::SCREEN +(const byte*) main::SCREEN#0 SCREEN = (byte*) 1024 +(struct TwoCircles) main::t +(struct Circle) main::t_c1 +(struct Point) main::t_c1_center +(byte) main::t_c1_center_x +(const byte) main::t_c1_center_x#0 t_c1_center_x = (byte) 1 +(byte) main::t_c1_center_y +(const byte) main::t_c1_center_y#0 t_c1_center_y = (byte) 2 +(byte) main::t_c1_radius +(const byte) main::t_c1_radius#0 t_c1_radius = (byte) 3 +(struct Circle) main::t_c2 +(struct Point) main::t_c2_center +(byte) main::t_c2_center_x +(const byte) main::t_c2_center_x#0 t_c2_center_x = (byte) 4 +(byte) main::t_c2_center_y +(const byte) main::t_c2_center_y#0 t_c2_center_y = (byte) 5 +(byte) main::t_c2_radius +(const byte) main::t_c2_radius#0 t_c2_radius = (byte) 6 + + + +FINAL ASSEMBLER +Score: 42 + +//SEG0 File Comments +// Minimal struct - nesting structs 3 levels +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG2 Global Constants & labels +//SEG3 @begin +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +//SEG5 @1 +//SEG6 [2] call main +//SEG7 [3] phi from @1 to @end [phi:@1->@end] +//SEG8 @end +//SEG9 main +main: { + .const t_c1_center_x = 1 + .const t_c1_center_y = 2 + .const t_c1_radius = 3 + .const t_c2_center_x = 4 + .const t_c2_center_y = 5 + .const t_c2_radius = 6 + .label SCREEN = $400 + //SEG10 [4] *((const byte*) main::SCREEN#0) ← (const byte) main::t_c1_center_x#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_center_x + sta SCREEN + //SEG11 [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) main::t_c1_center_y#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_center_y + sta SCREEN+1 + //SEG12 [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) main::t_c1_radius#0 -- _deref_pbuc1=vbuc2 + lda #t_c1_radius + sta SCREEN+2 + //SEG13 [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) main::t_c2_center_x#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_center_x + sta SCREEN+3 + //SEG14 [8] *((const byte*) main::SCREEN#0+(byte) 4) ← (const byte) main::t_c2_center_y#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_center_y + sta SCREEN+4 + //SEG15 [9] *((const byte*) main::SCREEN#0+(byte) 5) ← (const byte) main::t_c2_radius#0 -- _deref_pbuc1=vbuc2 + lda #t_c2_radius + sta SCREEN+5 + //SEG16 main::@return + //SEG17 [10] return + rts +} + diff --git a/src/test/ref/struct-7.sym b/src/test/ref/struct-7.sym new file mode 100644 index 000000000..1daabbadc --- /dev/null +++ b/src/test/ref/struct-7.sym @@ -0,0 +1 @@ +program \ No newline at end of file