mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-20 02:32:36 +00:00
Added a second test
This commit is contained in:
parent
0116c9e21d
commit
67b4257ad9
@ -114,7 +114,7 @@ public class Compiler {
|
||||
for (Pass2SsaOptimization optimization : optimizations) {
|
||||
boolean stepOptimized = optimization.optimize();
|
||||
if (stepOptimized) {
|
||||
log.append("Succesful SSA optimization "+optimization+"");
|
||||
log.append("Succesful SSA optimization "+optimization.getClass().getSimpleName()+"");
|
||||
ssaOptimized = true;
|
||||
log.append("CONTROL FLOW GRAPH");
|
||||
log.append(controlFlowGraph.toString());
|
||||
@ -141,7 +141,7 @@ public class Compiler {
|
||||
for (Pass4AsmOptimization optimization : pass4Optimizations) {
|
||||
boolean stepOtimized = optimization.optimize();
|
||||
if(stepOtimized) {
|
||||
log.append("Succesful ASM optimization "+optimization);
|
||||
log.append("Succesful ASM optimization "+optimization.getClass().getSimpleName());
|
||||
asmOptimized = true;
|
||||
log.append("ASSEMBLER");
|
||||
log.append(asmProgram.toString());
|
||||
|
@ -108,7 +108,8 @@ public class Scope implements Symbol {
|
||||
if (scopeSym instanceof Scope) {
|
||||
return ((Scope) scopeSym).getSymbol(rest);
|
||||
} else {
|
||||
throw new RuntimeException("Error looking up symbol " + name);
|
||||
return null;
|
||||
//throw new RuntimeException("Error looking up symbol " + name);
|
||||
}
|
||||
} else {
|
||||
Symbol symbol = symbols.get(name);
|
||||
|
@ -1,7 +1,5 @@
|
||||
package dk.camelot64.kickc.test;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.SourceTree;
|
||||
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
|
||||
import dk.camelot64.kickc.Compiler;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
@ -33,6 +31,7 @@ public class TestCompilationOutput {
|
||||
public static void main(String[] args) throws IOException, URISyntaxException {
|
||||
TestCompilationOutput tester = new TestCompilationOutput();
|
||||
tester.testFile("flipper-rex2");
|
||||
tester.testFile("bresenham");
|
||||
}
|
||||
|
||||
private void testFile(String fileName) throws IOException, URISyntaxException {
|
||||
|
109
src/dk/camelot64/kickc/test/ref/bresenham.asm
Normal file
109
src/dk/camelot64/kickc/test/ref/bresenham.asm
Normal file
@ -0,0 +1,109 @@
|
||||
BBEGIN:
|
||||
B1_from_BBEGIN:
|
||||
// (byte) y#2 = (byte) 0 // zpby1=coby1
|
||||
lda #0
|
||||
sta 14
|
||||
// (byte) e#3 = (byte) 12 // zpby1=coby1
|
||||
lda #12
|
||||
sta 13
|
||||
// (byte) x#2 = (byte) 0 // zpby1=coby1
|
||||
lda #0
|
||||
sta 12
|
||||
// (byte*) cursor#3 = (word) 1024 // zpptrby1=cowo1
|
||||
lda #<1024
|
||||
sta 10
|
||||
lda #>1024
|
||||
sta 10+1
|
||||
jmp B1
|
||||
B1_from_B3:
|
||||
// (byte) y#2 = (byte) y#5 // zpby1=zpby2
|
||||
lda 18
|
||||
sta 14
|
||||
// (byte) e#3 = (byte) e#5 // zpby1=zpby2
|
||||
lda 15
|
||||
sta 13
|
||||
// (byte) x#2 = (byte) x#1 // zpby1=zpby2
|
||||
lda 2
|
||||
sta 12
|
||||
// (byte*) cursor#3 = (byte*) cursor#5 // zpptrby1=zpptrby2
|
||||
lda 16
|
||||
sta 10
|
||||
lda 16+1
|
||||
sta 10+1
|
||||
B1:
|
||||
// *((byte*) cursor#3) ← (byte) 81 // zpiby1=coby1
|
||||
ldy #0
|
||||
lda #81
|
||||
sta (10),y
|
||||
// (byte) x#1 ← (byte) x#2 + (byte) 1 // zpby1=zpby2_plus_1
|
||||
lda 12
|
||||
clc
|
||||
adc #1
|
||||
sta 2
|
||||
// (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 // zpptrby1=zpptrby2_plus_1
|
||||
lda 10
|
||||
clc
|
||||
adc #1
|
||||
sta 3
|
||||
lda 10+1
|
||||
adc #0
|
||||
sta 3+1
|
||||
// (byte) e#1 ← (byte) e#3 + (byte) 24 // zpby1=zpby2_plus_coby1
|
||||
lda 13
|
||||
clc
|
||||
adc #24
|
||||
sta 5
|
||||
// if((byte) 39<(byte) e#1) goto @2 // coby1_lt_zpby1_then_la1
|
||||
lda #39
|
||||
cmp 5
|
||||
bcc B2
|
||||
B3_from_B1:
|
||||
// (byte) y#5 = (byte) y#2 // zpby1=zpby2
|
||||
lda 14
|
||||
sta 18
|
||||
// (byte*) cursor#5 = (byte*) cursor#1 // zpptrby1=zpptrby2
|
||||
lda 3
|
||||
sta 16
|
||||
lda 3+1
|
||||
sta 16+1
|
||||
// (byte) e#5 = (byte) e#1 // zpby1=zpby2
|
||||
lda 5
|
||||
sta 15
|
||||
B3:
|
||||
// if((byte) x#1<(byte) 40) goto @1 // zpby1_lt_coby1_then_la1
|
||||
lda 2
|
||||
cmp #40
|
||||
bcc B1_from_B3
|
||||
BEND:
|
||||
B2:
|
||||
// (byte) y#1 ← (byte) y#2 + (byte) 1 // zpby1=zpby2_plus_1
|
||||
lda 14
|
||||
clc
|
||||
adc #1
|
||||
sta 6
|
||||
// (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 // zpptrby1=zpptrby2_plus_coby1
|
||||
lda #40
|
||||
clc
|
||||
adc 3
|
||||
sta 7
|
||||
lda #0
|
||||
adc 3+1
|
||||
sta 7+1
|
||||
// (byte) e#2 ← (byte) e#1 - (byte) 39 // zpby1=zpby2_minus_coby1
|
||||
lda 5
|
||||
sec
|
||||
sbc #39
|
||||
sta 9
|
||||
B3_from_B2:
|
||||
// (byte) y#5 = (byte) y#1 // zpby1=zpby2
|
||||
lda 6
|
||||
sta 18
|
||||
// (byte*) cursor#5 = (byte*) cursor#2 // zpptrby1=zpptrby2
|
||||
lda 7
|
||||
sta 16
|
||||
lda 7+1
|
||||
sta 16+1
|
||||
// (byte) e#5 = (byte) e#2 // zpby1=zpby2
|
||||
lda 9
|
||||
sta 15
|
||||
jmp B3
|
25
src/dk/camelot64/kickc/test/ref/bresenham.cfg
Normal file
25
src/dk/camelot64/kickc/test/ref/bresenham.cfg
Normal file
@ -0,0 +1,25 @@
|
||||
@BEGIN: from
|
||||
to:@1
|
||||
@1: from @3 @BEGIN
|
||||
(byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 )
|
||||
(byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) 12 )
|
||||
(byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 )
|
||||
(byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(word) 1024 )
|
||||
*((byte*) cursor#3) ← (byte) 81
|
||||
(byte) x#1 ← (byte) x#2 + (byte) 1
|
||||
(byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1
|
||||
(byte) e#1 ← (byte) e#3 + (byte) 24
|
||||
if((byte) 39<(byte) e#1) goto @2
|
||||
to:@3
|
||||
@2: from @1
|
||||
(byte) y#1 ← (byte) y#2 + (byte) 1
|
||||
(byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40
|
||||
(byte) e#2 ← (byte) e#1 - (byte) 39
|
||||
to:@3
|
||||
@3: from @1 @2
|
||||
(byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 )
|
||||
(byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 )
|
||||
(byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 )
|
||||
if((byte) x#1<(byte) 40) goto @1
|
||||
to:@END
|
||||
@END: from @3
|
1385
src/dk/camelot64/kickc/test/ref/bresenham.log
Normal file
1385
src/dk/camelot64/kickc/test/ref/bresenham.log
Normal file
File diff suppressed because it is too large
Load Diff
30
src/dk/camelot64/kickc/test/ref/bresenham.sym
Normal file
30
src/dk/camelot64/kickc/test/ref/bresenham.sym
Normal file
@ -0,0 +1,30 @@
|
||||
(label) @1
|
||||
(label) @2
|
||||
(label) @3
|
||||
(label) @BEGIN
|
||||
(label) @END
|
||||
(byte[1000]) SCREEN
|
||||
(byte) STAR
|
||||
(byte*) cursor
|
||||
(byte*) cursor#1 zp ptr byte:3
|
||||
(byte*) cursor#2 zp ptr byte:7
|
||||
(byte*) cursor#3 zp ptr byte:10
|
||||
(byte*) cursor#5 zp ptr byte:16
|
||||
(byte) e
|
||||
(byte) e#1 zp byte:5
|
||||
(byte) e#2 zp byte:9
|
||||
(byte) e#3 zp byte:13
|
||||
(byte) e#5 zp byte:15
|
||||
(byte) x
|
||||
(byte) x#1 zp byte:2
|
||||
(byte) x#2 zp byte:12
|
||||
(byte) x0
|
||||
(byte) x1
|
||||
(byte) xd
|
||||
(byte) y
|
||||
(byte) y#1 zp byte:6
|
||||
(byte) y#2 zp byte:14
|
||||
(byte) y#5 zp byte:18
|
||||
(byte) y0
|
||||
(byte) y1
|
||||
(byte) yd
|
@ -936,7 +936,7 @@ Culled Empty Block (label) @13
|
||||
Culled Empty Block (label) @14
|
||||
Culled Empty Block (label) @16
|
||||
Culled Empty Block (label) @17
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2CullEmptyBlocks@21a34544
|
||||
Succesful SSA optimization Pass2CullEmptyBlocks
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
(byte[1000]) SCREEN#0 ← (word) 1024
|
||||
@ -1159,7 +1159,7 @@ Constant (byte~) plot::$0 (byte) 200
|
||||
Constant (byte) plot::y#0 (byte) 16
|
||||
Constant (byte) plot::i#0 (byte) 0
|
||||
Constant (byte) plot::x#0 (byte) 0
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2ConstantPropagation@742e84e1
|
||||
Succesful SSA optimization Pass2ConstantPropagation
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -1353,7 +1353,7 @@ plot::@return: from @15
|
||||
@END: from @20
|
||||
|
||||
Consolidated constant in assignment (byte*~) plot::$2
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2ConstantAdditionElimination@1a160b5e
|
||||
Succesful SSA optimization Pass2ConstantAdditionElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -1567,7 +1567,7 @@ Alias (byte[256]) buffer1#11 = (byte[256]) buffer1#4
|
||||
Alias (byte) plot::y#2 = (byte) plot::y#3
|
||||
Alias (byte*) plot::line#2 = (byte*) plot::line#3
|
||||
Alias (byte*) plot::line#1 = (byte*~) plot::$5
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2AliasElimination@3a1af7aa
|
||||
Succesful SSA optimization Pass2AliasElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -1724,7 +1724,7 @@ Redundant Phi (byte[256]) buffer1#21 (word) 4096
|
||||
Redundant Phi (byte[1000]) SCREEN#10 (word) 1024
|
||||
Redundant Phi (byte*) RASTER#7 (word) 53266
|
||||
Redundant Phi (byte[256]) buffer1#5 (word) 4096
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2RedundantPhiElimination@4079d7b3
|
||||
Succesful SSA optimization Pass2RedundantPhiElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -1890,7 +1890,7 @@ Self Phi Eliminated (byte[256]) buffer2#2
|
||||
Self Phi Eliminated (byte) plot::y#2
|
||||
Self Phi Eliminated (byte*) plot::line#2
|
||||
Self Phi Eliminated (byte[256]) buffer1#11
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2SelfPhiElimination@7f4049d6
|
||||
Succesful SSA optimization Pass2SelfPhiElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2046,7 +2046,7 @@ Simple Condition (boolean~) flip::$3 if((byte) flip::r#1!=(byte) 0) goto flip::@
|
||||
Simple Condition (boolean~) flip::$5 if((byte) flip::i#1!=(byte) 0) goto flip::@3
|
||||
Simple Condition (boolean~) plot::$4 if((byte) plot::x#1<(byte) 16) goto plot::@2
|
||||
Simple Condition (boolean~) plot::$6 if((byte) plot::y#1!=(byte) 0) goto plot::@1
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2ConditionalJumpSimplification@55afc1de
|
||||
Succesful SSA optimization Pass2ConditionalJumpSimplification
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2187,7 +2187,7 @@ plot::@return: from @15
|
||||
Culled Empty Block (label) @18
|
||||
Culled Empty Block (label) @5
|
||||
Culled Empty Block (label) @12
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2CullEmptyBlocks@21a34544
|
||||
Succesful SSA optimization Pass2CullEmptyBlocks
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2320,7 +2320,7 @@ plot::@return: from @15
|
||||
@END: from @20
|
||||
|
||||
Constant (byte[256]) buffer1#1 (word) 4096
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2ConstantPropagation@742e84e1
|
||||
Succesful SSA optimization Pass2ConstantPropagation
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2464,7 +2464,7 @@ Alias (byte[256]) buffer1#2 = (byte[256]) buffer1#6 (byte[256]) buffer1#3
|
||||
Alias (byte) plot::y#2 = (byte) plot::y#4
|
||||
Alias (byte*) plot::line#2 = (byte*) plot::line#4
|
||||
Alias (byte[256]) buffer1#11 = (byte[256]) buffer1#8
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2AliasElimination@3a1af7aa
|
||||
Succesful SSA optimization Pass2AliasElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2584,7 +2584,7 @@ Self Phi Eliminated (byte*) RASTER#1
|
||||
Self Phi Eliminated (byte[256]) buffer1#2
|
||||
Self Phi Eliminated (byte[256]) buffer2#1
|
||||
Self Phi Eliminated (byte[256]) buffer1#11
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2SelfPhiElimination@7f4049d6
|
||||
Succesful SSA optimization Pass2SelfPhiElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2703,7 +2703,7 @@ Alias (byte[256]) buffer2#1 = (byte[256]) buffer2#10 (byte[256]) buffer2#13
|
||||
Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#20 (byte[256]) buffer1#2 (byte[256]) buffer1#11
|
||||
Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#9
|
||||
Alias (byte*) RASTER#1 = (byte*) RASTER#5
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2AliasElimination@3a1af7aa
|
||||
Succesful SSA optimization Pass2AliasElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2813,7 +2813,7 @@ Self Phi Eliminated (byte[256]) buffer1#10
|
||||
Self Phi Eliminated (byte[256]) buffer2#1
|
||||
Self Phi Eliminated (byte[1000]) SCREEN#1
|
||||
Self Phi Eliminated (byte*) RASTER#1
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2SelfPhiElimination@7f4049d6
|
||||
Succesful SSA optimization Pass2SelfPhiElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -2923,7 +2923,7 @@ Constant (byte[256]) buffer1#10 (word) 4096
|
||||
Constant (byte[256]) buffer2#1 (word) 4352
|
||||
Constant (byte[1000]) SCREEN#1 (word) 1024
|
||||
Constant (byte*) RASTER#1 (word) 53266
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2ConstantPropagation@742e84e1
|
||||
Succesful SSA optimization Pass2ConstantPropagation
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -3031,7 +3031,7 @@ 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
|
||||
Culled Empty Block (label) @1
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2CullEmptyBlocks@21a34544
|
||||
Succesful SSA optimization Pass2CullEmptyBlocks
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -3132,7 +3132,7 @@ plot::@return: from @15
|
||||
@END: from @20
|
||||
|
||||
Constant (byte*) plot::line#0 (word) 1236
|
||||
Succesful SSA optimization dk.camelot64.kickc.icl.Pass2ConstantPropagation@742e84e1
|
||||
Succesful SSA optimization Pass2ConstantPropagation
|
||||
CONTROL FLOW GRAPH
|
||||
@BEGIN: from
|
||||
call prepare param-assignment
|
||||
@ -3461,7 +3461,7 @@ Removing instruction jmp flip__B3
|
||||
Removing instruction jmp flip__Breturn
|
||||
Removing instruction jmp prepare__B1
|
||||
Removing instruction jmp prepare__Breturn
|
||||
Succesful ASM optimization dk.camelot64.kickc.icl.Pass4NextJumpElimination@bb2d83d
|
||||
Succesful ASM optimization Pass4NextJumpElimination
|
||||
ASSEMBLER
|
||||
BBEGIN:
|
||||
jsr prepare
|
||||
@ -3651,7 +3651,7 @@ Removing instruction jmp flip__B1
|
||||
Removing instruction jmp flip__B2
|
||||
Removing instruction jmp flip__B3
|
||||
Removing instruction jmp prepare__B1
|
||||
Succesful ASM optimization dk.camelot64.kickc.icl.Pass4NextJumpElimination@bb2d83d
|
||||
Succesful ASM optimization Pass4NextJumpElimination
|
||||
ASSEMBLER
|
||||
BBEGIN:
|
||||
jsr prepare
|
||||
|
Loading…
Reference in New Issue
Block a user