diff --git a/src/main/java/dk/camelot64/kickc/TODO.txt b/src/main/java/dk/camelot64/kickc/TODO.txt index 1161a61ac..94ab8c41a 100644 --- a/src/main/java/dk/camelot64/kickc/TODO.txt +++ b/src/main/java/dk/camelot64/kickc/TODO.txt @@ -7,7 +7,6 @@ Known Problems - (useuninitialized.kc) Using an uninitialized variable fails in the optimizer phase. It should fail much earlier. Features -- Inline contants that are only call parameters used once (eg. x0#0 and x0#1 in callconstparam.kc) - Move the main code into a main() function, and disallow code outside functions. The main function per default has no parameters and exits with RTS. - Improve locality of block sequence for if(cond) { stmt1; } else { stmt2; } to if(!cond) goto @else stmt1; jmp @end; @else: stmt2; @end: - Optimize if/else by swapping if & else if cond is easier to evaluate than !cond. @@ -161,3 +160,4 @@ Done + Add ALU support for lo/hi operators on pointers - to avoid unnecessary zp-variable holding for cases like byte v = y&$7 | findConstVarVersions() { @@ -129,8 +131,16 @@ public class Pass2ConstantInlining extends Pass2SsaOptimization { Collection scopeSymbols = constant.getScope().getAllSymbols(); for (Symbol symbol : scopeSymbols) { if(symbol.getRef().isVersion() && symbol.getRef().getFullNameUnversioned().equals(baseName)) { + ConstantValue value = constant.getValue(); if(symbol instanceof Variable) { - aliases.put(constant.getRef(), constant.getValue()); + aliases.put(constant.getRef(), value); + break; + } else if(symbol instanceof ConstantVar) { + ConstantValue otherValue = ((ConstantVar) symbol).getValue(); + if(!otherValue.equals(value) && !(value instanceof ConstantString) && !(value instanceof ConstantArray) && !(otherValue instanceof ConstantRef)) { + aliases.put(constant.getRef(), value); + break; + } } } } diff --git a/src/main/java/dk/camelot64/kickc/test/TestPrograms.java b/src/main/java/dk/camelot64/kickc/test/TestPrograms.java index f13b8c29d..596b0e09a 100644 --- a/src/main/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/main/java/dk/camelot64/kickc/test/TestPrograms.java @@ -29,8 +29,7 @@ public class TestPrograms extends TestCase { } public void testCallConstParam() throws IOException, URISyntaxException { - String filename = "callconstparam"; - compileAndCompare(filename); + compileAndCompare("callconstparam"); } diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm index 1847436e7..4bfaddd4b 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm @@ -30,18 +30,17 @@ main: { sta D018 jsr initscreen jsr initplottables - lda #line.y0 + lda #0 sta line.y ldx #$a - lda #line.x0 sta line.x lda #$14 sta line.x1 jsr line - lda #line.y0_1 + lda #$14 sta line.y ldx #$28 - lda #line.x0_1 + lda #$a sta line.x lda #$28 sta line.x1 @@ -49,10 +48,6 @@ main: { rts } line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.cfg b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.cfg index f8e11bf26..4a37b86e9 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.cfg +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.cfg @@ -24,9 +24,9 @@ main::@return: scope:[main] from main::@3 [9] return [ ] to:@return line: scope:[line] from main::@2 main::@3 - [10] (byte) line::y#0 ← phi( main::@2/(const byte) line::y0#0 main::@3/(const byte) line::y0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] + [10] (byte) line::y#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 20 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [10] (byte) line::y1#2 ← phi( main::@2/(byte) 10 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] - [10] (byte) line::x#0 ← phi( main::@2/(const byte) line::x0#0 main::@3/(const byte) line::x0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] + [10] (byte) line::x#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 10 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [10] (byte) line::x1#2 ← phi( main::@2/(byte) 20 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [11] (byte) line::xd#0 ← (byte) line::x1#2 - (byte) line::x#0 [ line::x1#2 line::x#0 line::y1#2 line::y#0 line::xd#0 ] [12] (byte) line::yd#0 ← (byte) line::y1#2 - (byte) line::y#0 [ line::x1#2 line::x#0 line::y#0 line::xd#0 line::yd#0 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log index e38b7fb34..6f7454d06 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log @@ -4703,6 +4703,8 @@ Constant inlined plot::plotter#0 = (const byte*) BITMAP#0 Constant inlined initscreen::$0 = (const byte*) BITMAP#0+(word) 8192 Constant inlined initscreen::$2 = (const byte*) SCREEN#0+(word) 1024 Constant inlined plot_bit#1 = (const byte[]) plot_bit#0 +Constant inlined line::y0#1 = (byte) 20 +Constant inlined line::y0#0 = (byte) 0 Constant inlined initplottables::$1 = >(const byte*) BITMAP#0 Constant inlined line::y1#0 = (byte) 10 Constant inlined line::y1#1 = (byte) 40 @@ -4721,6 +4723,8 @@ Constant inlined plot_ylo#12 = (const byte[]) plot_ylo#0 Constant inlined plot_xhi#1 = (const byte[]) plot_xhi#0 Constant inlined BITMAP#13 = (const byte*) BITMAP#0 Constant inlined plot_yhi#12 = (const byte[]) plot_yhi#0 +Constant inlined line::x0#0 = (byte) 0 +Constant inlined line::x0#1 = (byte) 10 Constant inlined plot_yhi#14 = (const byte[]) plot_yhi#0 Constant inlined initscreen::b#0 = (const byte*) BITMAP#0 Constant inlined plot_yhi#1 = (const byte[]) plot_yhi#0 @@ -4749,9 +4753,9 @@ main::@return: scope:[main] from main::@3 return to:@return line: scope:[line] from main::@2 main::@3 - (byte) line::y#0 ← phi( main::@2/(const byte) line::y0#0 main::@3/(const byte) line::y0#1 ) + (byte) line::y#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 20 ) (byte) line::y1#2 ← phi( main::@2/(byte) 10 main::@3/(byte) 40 ) - (byte) line::x#0 ← phi( main::@2/(const byte) line::x0#0 main::@3/(const byte) line::x0#1 ) + (byte) line::x#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 10 ) (byte) line::x1#2 ← phi( main::@2/(byte) 20 main::@3/(byte) 40 ) (byte) line::xd#0 ← (byte) line::x1#2 - (byte) line::x#0 (byte) line::yd#0 ← (byte) line::y1#2 - (byte) line::y#0 @@ -4956,8 +4960,6 @@ FINAL SYMBOL TABLE (byte) line::x#1 (byte) line::x#2 (byte) line::x0 -(const byte) line::x0#0 = (byte) 0 -(const byte) line::x0#1 = (byte) 10 (byte) line::x1 (byte) line::x1#2 (byte) line::xd @@ -4968,8 +4970,6 @@ FINAL SYMBOL TABLE (byte) line::y#2 (byte) line::y#4 (byte) line::y0 -(const byte) line::y0#0 = (byte) 0 -(const byte) line::y0#1 = (byte) 20 (byte) line::y1 (byte) line::y1#2 (byte) line::yd @@ -5045,9 +5045,9 @@ main::@return: scope:[main] from main::@3 return to:@return line: scope:[line] from main::@2 main::@3 - (byte) line::y#0 ← phi( main::@2/(const byte) line::y0#0 main::@3/(const byte) line::y0#1 ) + (byte) line::y#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 20 ) (byte) line::y1#2 ← phi( main::@2/(byte) 10 main::@3/(byte) 40 ) - (byte) line::x#0 ← phi( main::@2/(const byte) line::x0#0 main::@3/(const byte) line::x0#1 ) + (byte) line::x#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 10 ) (byte) line::x1#2 ← phi( main::@2/(byte) 20 main::@3/(byte) 40 ) (byte) line::xd#0 ← (byte) line::x1#2 - (byte) line::x#0 (byte) line::yd#0 ← (byte) line::y1#2 - (byte) line::y#0 @@ -5241,9 +5241,9 @@ main::@return: scope:[main] from main::@3 [9] return [ ] to:@return line: scope:[line] from main::@2 main::@3 - [10] (byte) line::y#0 ← phi( main::@2/(const byte) line::y0#0 main::@3/(const byte) line::y0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] + [10] (byte) line::y#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 20 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [10] (byte) line::y1#2 ← phi( main::@2/(byte) 10 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] - [10] (byte) line::x#0 ← phi( main::@2/(const byte) line::x0#0 main::@3/(const byte) line::x0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] + [10] (byte) line::x#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 10 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [10] (byte) line::x1#2 ← phi( main::@2/(byte) 20 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [11] (byte) line::xd#0 ← (byte) line::x1#2 - (byte) line::x#0 [ line::x1#2 line::x#0 line::y1#2 line::y#0 line::xd#0 ] [12] (byte) line::yd#0 ← (byte) line::y1#2 - (byte) line::y#0 [ line::x1#2 line::x#0 line::y#0 line::xd#0 line::yd#0 ] @@ -5461,9 +5461,9 @@ main::@return: scope:[main] from main::@3 [9] return [ ] to:@return line: scope:[line] from main::@2 main::@3 - [10] (byte) line::y#0 ← phi( main::@2/(const byte) line::y0#0 main::@3/(const byte) line::y0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] + [10] (byte) line::y#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 20 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [10] (byte) line::y1#2 ← phi( main::@2/(byte) 10 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] - [10] (byte) line::x#0 ← phi( main::@2/(const byte) line::x0#0 main::@3/(const byte) line::x0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] + [10] (byte) line::x#0 ← phi( main::@2/(byte) 0 main::@3/(byte) 10 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [10] (byte) line::x1#2 ← phi( main::@2/(byte) 20 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ] [11] (byte) line::xd#0 ← (byte) line::x1#2 - (byte) line::x#0 [ line::x1#2 line::x#0 line::y1#2 line::y#0 line::xd#0 ] [12] (byte) line::yd#0 ← (byte) line::y1#2 - (byte) line::y#0 [ line::x1#2 line::x#0 line::y#0 line::xd#0 line::yd#0 ] @@ -5901,14 +5901,14 @@ main: { //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] line_from_b2: - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- zpby1=coby1 lda #$a sta line.y1 - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 + lda #0 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -5920,14 +5920,14 @@ main: { //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] line_from_b3: - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- zpby1=coby1 lda #$28 sta line.y1 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -5941,10 +5941,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label _10 = 20 .label xd = 16 .label yd = 17 @@ -6570,13 +6566,13 @@ main: { //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] line_from_b2: - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- xby=coby1 ldx #$a - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 + lda #0 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -6587,13 +6583,13 @@ main: { //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] line_from_b3: - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- xby=coby1 ldx #$28 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -6606,10 +6602,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 @@ -6911,6 +6903,7 @@ initscreen: { rts } +Removing instruction lda #0 Removing instruction lda #0 Removing instruction ldy #0 Removing instruction lda #0 @@ -6974,13 +6967,12 @@ main: { //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] line_from_b2: - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- xby=coby1 ldx #$a - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -6991,13 +6983,13 @@ main: { //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] line_from_b3: - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- xby=coby1 ldx #$28 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -7010,10 +7002,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 @@ -7394,13 +7382,12 @@ main: { b2: //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- xby=coby1 ldx #$a - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -7410,13 +7397,13 @@ main: { b3: //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- xby=coby1 ldx #$28 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -7429,10 +7416,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 @@ -7792,13 +7775,12 @@ main: { //SEG15 main::@2 //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- xby=coby1 ldx #$a - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -7807,13 +7789,13 @@ main: { //SEG22 main::@3 //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- xby=coby1 ldx #$28 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -7825,10 +7807,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 @@ -8161,13 +8139,12 @@ main: { //SEG15 main::@2 //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- xby=coby1 ldx #$a - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -8176,13 +8153,13 @@ main: { //SEG22 main::@3 //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- xby=coby1 ldx #$28 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -8194,10 +8171,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 @@ -8562,8 +8535,6 @@ FINAL SYMBOL TABLE (byte) line::x#1 x zp ZP_BYTE:3 4.125 (byte) line::x#2 x zp ZP_BYTE:3 8.75 (byte) line::x0 -(const byte) line::x0#0 x0 = (byte) 0 -(const byte) line::x0#1 x0#1 = (byte) 10 (byte) line::x1 (byte) line::x1#2 x1 zp ZP_BYTE:2 0.8125 (byte) line::xd @@ -8574,8 +8545,6 @@ FINAL SYMBOL TABLE (byte) line::y#2 y zp ZP_BYTE:4 6.571428571428571 (byte) line::y#4 y zp ZP_BYTE:4 11.0 (byte) line::y0 -(const byte) line::y0#0 y0 = (byte) 0 -(const byte) line::y0#1 y0#1 = (byte) 20 (byte) line::y1 (byte) line::y1#2 reg byte x 1.0 (byte) line::yd @@ -8692,13 +8661,12 @@ main: { //SEG15 main::@2 //SEG16 [7] call line param-assignment [ ] //SEG17 [10] phi from main::@2 to line [phi:main::@2->line] - //SEG18 [10] phi (byte) line::y#0 = (const byte) line::y0#0 [phi:main::@2->line#0] -- zpby1=coby1 - lda #line.y0 + //SEG18 [10] phi (byte) line::y#0 = (byte) 0 [phi:main::@2->line#0] -- zpby1=coby1 + lda #0 sta line.y //SEG19 [10] phi (byte) line::y1#2 = (byte) 10 [phi:main::@2->line#1] -- xby=coby1 ldx #$a - //SEG20 [10] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main::@2->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG20 [10] phi (byte) line::x#0 = (byte) 0 [phi:main::@2->line#2] -- zpby1=coby1 sta line.x //SEG21 [10] phi (byte) line::x1#2 = (byte) 20 [phi:main::@2->line#3] -- zpby1=coby1 lda #$14 @@ -8707,13 +8675,13 @@ main: { //SEG22 main::@3 //SEG23 [8] call line param-assignment [ ] //SEG24 [10] phi from main::@3 to line [phi:main::@3->line] - //SEG25 [10] phi (byte) line::y#0 = (const byte) line::y0#1 [phi:main::@3->line#0] -- zpby1=coby1 - lda #line.y0_1 + //SEG25 [10] phi (byte) line::y#0 = (byte) 20 [phi:main::@3->line#0] -- zpby1=coby1 + lda #$14 sta line.y //SEG26 [10] phi (byte) line::y1#2 = (byte) 40 [phi:main::@3->line#1] -- xby=coby1 ldx #$28 - //SEG27 [10] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@3->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG27 [10] phi (byte) line::x#0 = (byte) 10 [phi:main::@3->line#2] -- zpby1=coby1 + lda #$a sta line.x //SEG28 [10] phi (byte) line::x1#2 = (byte) 40 [phi:main::@3->line#3] -- zpby1=coby1 lda #$28 @@ -8725,10 +8693,6 @@ main: { } //SEG31 line line: { - .const x0 = 0 - .const y0 = 0 - .const x0_1 = $a - .const y0_1 = $14 .label xd = 8 .label yd = 9 .label x = 3 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym index 9475011d4..721148920 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.sym @@ -89,8 +89,6 @@ (byte) line::x#1 x zp ZP_BYTE:3 4.125 (byte) line::x#2 x zp ZP_BYTE:3 8.75 (byte) line::x0 -(const byte) line::x0#0 x0 = (byte) 0 -(const byte) line::x0#1 x0#1 = (byte) 10 (byte) line::x1 (byte) line::x1#2 x1 zp ZP_BYTE:2 0.8125 (byte) line::xd @@ -101,8 +99,6 @@ (byte) line::y#2 y zp ZP_BYTE:4 6.571428571428571 (byte) line::y#4 y zp ZP_BYTE:4 11.0 (byte) line::y0 -(const byte) line::y0#0 y0 = (byte) 0 -(const byte) line::y0#1 y0#1 = (byte) 20 (byte) line::y1 (byte) line::y1#2 reg byte x 1.0 (byte) line::yd diff --git a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.asm b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.asm index 889516435..84f9791c3 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.asm @@ -7,17 +7,15 @@ main: { sta screen lda #>$400 sta screen+1 - ldx #line.x0 + ldx #1 jsr line lda #5 sta line.x1 - ldx #line.x0_1 + ldx #3 jsr line rts } line: { - .const x0 = 1 - .const x0_1 = 3 .label x1 = 2 b1: txa diff --git a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.cfg b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.cfg index 61ff454d0..6e695ccdb 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.cfg +++ b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.cfg @@ -15,7 +15,7 @@ main::@return: scope:[main] from main::@1 line: scope:[line] from main main::@1 [5] (byte) line::x1#2 ← phi( main/(byte) 2 main::@1/(byte) 5 ) [ line::x#0 screen#14 line::x1#2 ] [5] (byte*) screen#14 ← phi( main/(word) 1024 main::@1/(byte*) screen#1 ) [ line::x#0 screen#14 line::x1#2 ] - [5] (byte) line::x#0 ← phi( main/(const byte) line::x0#0 main::@1/(const byte) line::x0#1 ) [ line::x#0 screen#14 line::x1#2 ] + [5] (byte) line::x#0 ← phi( main/(byte) 1 main::@1/(byte) 3 ) [ line::x#0 screen#14 line::x1#2 ] to:line::@1 line::@1: scope:[line] from line line::@1 [6] (byte*) screen#11 ← phi( line/(byte*) screen#14 line::@1/(byte*) screen#1 ) [ line::x1#2 line::x#2 screen#11 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log index 98fa74bc9..aa18b0e00 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.log @@ -560,6 +560,8 @@ line::@return: scope:[line] from line::@1 to:@return @end: scope:[] from @begin +Constant inlined line::x0#0 = (byte) 1 +Constant inlined line::x0#1 = (byte) 3 Constant inlined screen#0 = (word) 1024 Constant inlined line::x1#0 = (byte) 2 Constant inlined line::x1#1 = (byte) 5 @@ -580,7 +582,7 @@ main::@return: scope:[main] from main::@1 line: scope:[line] from main main::@1 (byte) line::x1#2 ← phi( main/(byte) 2 main::@1/(byte) 5 ) (byte*) screen#14 ← phi( main/(word) 1024 main::@1/(byte*) screen#1 ) - (byte) line::x#0 ← phi( main/(const byte) line::x0#0 main::@1/(const byte) line::x0#1 ) + (byte) line::x#0 ← phi( main/(byte) 1 main::@1/(byte) 3 ) to:line::@1 line::@1: scope:[line] from line line::@1 (byte*) screen#11 ← phi( line/(byte*) screen#14 line::@1/(byte*) screen#1 ) @@ -606,8 +608,6 @@ FINAL SYMBOL TABLE (byte) line::x#1 (byte) line::x#2 (byte) line::x0 -(const byte) line::x0#0 = (byte) 1 -(const byte) line::x0#1 = (byte) 3 (byte) line::x1 (byte) line::x1#2 (void()) main() @@ -639,7 +639,7 @@ main::@return: scope:[main] from main::@1 line: scope:[line] from main main::@1 (byte) line::x1#2 ← phi( main/(byte) 2 main::@1/(byte) 5 ) (byte*) screen#14 ← phi( main/(word) 1024 main::@1/(byte*~) screen#15 ) - (byte) line::x#0 ← phi( main/(const byte) line::x0#0 main::@1/(const byte) line::x0#1 ) + (byte) line::x#0 ← phi( main/(byte) 1 main::@1/(byte) 3 ) (byte~) line::x#3 ← (byte) line::x#0 (byte*~) screen#16 ← (byte*) screen#14 to:line::@1 @@ -691,7 +691,7 @@ main::@return: scope:[main] from main::@1 line: scope:[line] from main main::@1 [6] (byte) line::x1#2 ← phi( main/(byte) 2 main::@1/(byte) 5 ) [ line::x#0 screen#14 line::x1#2 ] [6] (byte*) screen#14 ← phi( main/(word) 1024 main::@1/(byte*~) screen#15 ) [ line::x#0 screen#14 line::x1#2 ] - [6] (byte) line::x#0 ← phi( main/(const byte) line::x0#0 main::@1/(const byte) line::x0#1 ) [ line::x#0 screen#14 line::x1#2 ] + [6] (byte) line::x#0 ← phi( main/(byte) 1 main::@1/(byte) 3 ) [ line::x#0 screen#14 line::x1#2 ] [7] (byte~) line::x#3 ← (byte) line::x#0 [ screen#14 line::x1#2 line::x#3 ] [8] (byte*~) screen#16 ← (byte*) screen#14 [ line::x1#2 line::x#3 screen#16 ] to:line::@1 @@ -745,7 +745,7 @@ main::@return: scope:[main] from main::@1 line: scope:[line] from main main::@1 [5] (byte) line::x1#2 ← phi( main/(byte) 2 main::@1/(byte) 5 ) [ line::x#0 screen#14 line::x1#2 ] [5] (byte*) screen#14 ← phi( main/(word) 1024 main::@1/(byte*) screen#1 ) [ line::x#0 screen#14 line::x1#2 ] - [5] (byte) line::x#0 ← phi( main/(const byte) line::x0#0 main::@1/(const byte) line::x0#1 ) [ line::x#0 screen#14 line::x1#2 ] + [5] (byte) line::x#0 ← phi( main/(byte) 1 main::@1/(byte) 3 ) [ line::x#0 screen#14 line::x1#2 ] to:line::@1 line::@1: scope:[line] from line line::@1 [6] (byte*) screen#11 ← phi( line/(byte*) screen#14 line::@1/(byte*) screen#1 ) [ line::x1#2 line::x#2 screen#11 ] @@ -833,8 +833,8 @@ main: { sta screen lda #>$400 sta screen+1 - //SEG10 [5] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main->line#2] -- zpby1=coby1 - lda #line.x0 + //SEG10 [5] phi (byte) line::x#0 = (byte) 1 [phi:main->line#2] -- zpby1=coby1 + lda #1 sta line.x jsr line jmp b1 @@ -847,8 +847,8 @@ main: { lda #5 sta line.x1 //SEG15 [5] phi (byte*) screen#14 = (byte*) screen#1 [phi:main::@1->line#1] -- register_copy - //SEG16 [5] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@1->line#2] -- zpby1=coby1 - lda #line.x0_1 + //SEG16 [5] phi (byte) line::x#0 = (byte) 3 [phi:main::@1->line#2] -- zpby1=coby1 + lda #3 sta line.x jsr line jmp breturn @@ -859,8 +859,6 @@ main: { } //SEG19 line line: { - .const x0 = 1 - .const x0_1 = 3 .label x = 3 .label x1 = 2 //SEG20 [6] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1] @@ -943,8 +941,8 @@ main: { sta screen lda #>$400 sta screen+1 - //SEG10 [5] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main->line#2] -- xby=coby1 - ldx #line.x0 + //SEG10 [5] phi (byte) line::x#0 = (byte) 1 [phi:main->line#2] -- xby=coby1 + ldx #1 jsr line //SEG11 main::@1 b1: @@ -955,8 +953,8 @@ main: { lda #5 sta line.x1 //SEG15 [5] phi (byte*) screen#14 = (byte*) screen#1 [phi:main::@1->line#1] -- register_copy - //SEG16 [5] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@1->line#2] -- xby=coby1 - ldx #line.x0_1 + //SEG16 [5] phi (byte) line::x#0 = (byte) 3 [phi:main::@1->line#2] -- xby=coby1 + ldx #3 jsr line //SEG17 main::@return breturn: @@ -965,8 +963,6 @@ main: { } //SEG19 line line: { - .const x0 = 1 - .const x0_1 = 3 .label x1 = 2 //SEG20 [6] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1] b1_from_line: @@ -1024,8 +1020,8 @@ main: { sta screen lda #>$400 sta screen+1 - //SEG10 [5] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main->line#2] -- xby=coby1 - ldx #line.x0 + //SEG10 [5] phi (byte) line::x#0 = (byte) 1 [phi:main->line#2] -- xby=coby1 + ldx #1 jsr line //SEG11 main::@1 b1: @@ -1035,8 +1031,8 @@ main: { lda #5 sta line.x1 //SEG15 [5] phi (byte*) screen#14 = (byte*) screen#1 [phi:main::@1->line#1] -- register_copy - //SEG16 [5] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@1->line#2] -- xby=coby1 - ldx #line.x0_1 + //SEG16 [5] phi (byte) line::x#0 = (byte) 3 [phi:main::@1->line#2] -- xby=coby1 + ldx #3 jsr line //SEG17 main::@return breturn: @@ -1045,8 +1041,6 @@ main: { } //SEG19 line line: { - .const x0 = 1 - .const x0_1 = 3 .label x1 = 2 //SEG20 [6] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1] //SEG21 [6] phi (byte*) screen#11 = (byte*) screen#14 [phi:line/line::@1->line::@1#0] -- register_copy @@ -1100,8 +1094,8 @@ main: { sta screen lda #>$400 sta screen+1 - //SEG10 [5] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main->line#2] -- xby=coby1 - ldx #line.x0 + //SEG10 [5] phi (byte) line::x#0 = (byte) 1 [phi:main->line#2] -- xby=coby1 + ldx #1 jsr line //SEG11 main::@1 //SEG12 [3] call line param-assignment [ ] @@ -1110,8 +1104,8 @@ main: { lda #5 sta line.x1 //SEG15 [5] phi (byte*) screen#14 = (byte*) screen#1 [phi:main::@1->line#1] -- register_copy - //SEG16 [5] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@1->line#2] -- xby=coby1 - ldx #line.x0_1 + //SEG16 [5] phi (byte) line::x#0 = (byte) 3 [phi:main::@1->line#2] -- xby=coby1 + ldx #3 jsr line //SEG17 main::@return //SEG18 [4] return [ ] @@ -1119,8 +1113,6 @@ main: { } //SEG19 line line: { - .const x0 = 1 - .const x0_1 = 3 .label x1 = 2 //SEG20 [6] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1] //SEG21 [6] phi (byte*) screen#11 = (byte*) screen#14 [phi:line/line::@1->line::@1#0] -- register_copy @@ -1157,8 +1149,6 @@ FINAL SYMBOL TABLE (byte) line::x#1 reg byte x 16.5 (byte) line::x#2 reg byte x 11.666666666666666 (byte) line::x0 -(const byte) line::x0#0 x0 = (byte) 1 -(const byte) line::x0#1 x0#1 = (byte) 3 (byte) line::x1 (byte) line::x1#2 x1 zp ZP_BYTE:2 1.8333333333333333 (void()) main() @@ -1193,8 +1183,8 @@ main: { sta screen lda #>$400 sta screen+1 - //SEG10 [5] phi (byte) line::x#0 = (const byte) line::x0#0 [phi:main->line#2] -- xby=coby1 - ldx #line.x0 + //SEG10 [5] phi (byte) line::x#0 = (byte) 1 [phi:main->line#2] -- xby=coby1 + ldx #1 jsr line //SEG11 main::@1 //SEG12 [3] call line param-assignment [ ] @@ -1203,8 +1193,8 @@ main: { lda #5 sta line.x1 //SEG15 [5] phi (byte*) screen#14 = (byte*) screen#1 [phi:main::@1->line#1] -- register_copy - //SEG16 [5] phi (byte) line::x#0 = (const byte) line::x0#1 [phi:main::@1->line#2] -- xby=coby1 - ldx #line.x0_1 + //SEG16 [5] phi (byte) line::x#0 = (byte) 3 [phi:main::@1->line#2] -- xby=coby1 + ldx #3 jsr line //SEG17 main::@return //SEG18 [4] return [ ] @@ -1212,8 +1202,6 @@ main: { } //SEG19 line line: { - .const x0 = 1 - .const x0_1 = 3 .label x1 = 2 //SEG20 [6] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1] //SEG21 [6] phi (byte*) screen#11 = (byte*) screen#14 [phi:line/line::@1->line::@1#0] -- register_copy diff --git a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.sym b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.sym index 4d3b23ebc..6bdff846b 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/callconstparam.sym @@ -8,8 +8,6 @@ (byte) line::x#1 reg byte x 16.5 (byte) line::x#2 reg byte x 11.666666666666666 (byte) line::x0 -(const byte) line::x0#0 x0 = (byte) 1 -(const byte) line::x0#1 x0#1 = (byte) 3 (byte) line::x1 (byte) line::x1#2 x1 zp ZP_BYTE:2 1.8333333333333333 (void()) main() diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log index e71c24b50..3730e6d58 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log @@ -3446,8 +3446,8 @@ Multiple usages for variable. Not optimizing sub-constant (byte) flip::srcIdx#2 Multiple usages for variable. Not optimizing sub-constant (byte) flip::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) flip::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) plot::i#2 -Constant inlined buffer2#1 = (const byte[256]) buffer2#0 Constant inlined flip::r#0 = (byte) 16 +Constant inlined buffer2#1 = (const byte[256]) buffer2#0 Constant inlined SCREEN#1 = (const byte[1000]) SCREEN#0 Constant inlined plot::x#0 = (byte) 0 Constant inlined flip::dstIdx#0 = (byte) 15 @@ -3459,8 +3459,8 @@ Constant inlined flip::srcIdx#0 = (byte) 0 Constant inlined RASTER#1 = (const byte*) RASTER#0 Constant inlined buffer1#10 = (const byte[256]) buffer1#0 Constant inlined prepare::i#0 = (byte) 0 -Constant inlined main::c#0 = (byte) 25 Constant inlined plot::y#0 = (byte) 16 +Constant inlined main::c#0 = (byte) 25 Constant inlined plot::$1 = (const byte[1000]) SCREEN#0 Constant inlined plot::$0 = (byte) 5*(byte) 40 Constant inlined plot::line#0 = (const byte[1000]) SCREEN#0+(byte) 5*(byte) 40+(byte) 12