diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java index c916e674f..066d3426d 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java @@ -8,6 +8,7 @@ import dk.camelot64.kickc.model.operators.Operators; import dk.camelot64.kickc.model.statements.Statement; import dk.camelot64.kickc.model.statements.StatementAssignment; import dk.camelot64.kickc.model.statements.StatementConditionalJump; +import dk.camelot64.kickc.model.statements.StatementExprSideEffect; import dk.camelot64.kickc.model.symbols.*; import dk.camelot64.kickc.model.types.*; import dk.camelot64.kickc.model.values.*; @@ -58,6 +59,14 @@ public class AsmFragmentInstanceSpecFactory { this.asmFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, signature, bindings, codeScope); } + public AsmFragmentInstanceSpecFactory(StatementExprSideEffect exprSideEffect, Program program) { + this.program = program; + this.bindings = new LinkedHashMap<>(); + ScopeRef codeScope = program.getStatementInfos().getBlock(exprSideEffect).getScope(); + String signature = bind(exprSideEffect.getExpression()); + this.asmFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, signature, bindings, codeScope); + } + public AsmFragmentInstanceSpecFactory(StatementAssignment assignment, Program program) { this.program = program; this.bindings = new LinkedHashMap<>(); @@ -373,6 +382,12 @@ public class AsmFragmentInstanceSpecFactory { SymbolType type = ((StackPullValue) value).getType(); String typeShortName = Operators.getCastUnary(type).getAsmOperator().replace("_", ""); return "_stackpull" + typeShortName + "_"; + } else if(value instanceof StackPullBytes) { + final ConstantInteger bytes = (ConstantInteger) ((StackPullBytes) value).getBytes(); + return "_stackpullbyte_" + AsmFormat.getAsmNumber(bytes.getInteger()); + } else if(value instanceof StackPushBytes) { + final ConstantInteger bytes = (ConstantInteger) ((StackPushBytes) value).getBytes(); + return "_stackpushbyte_" + AsmFormat.getAsmNumber(bytes.getInteger()); } else if(value instanceof MemsetValue) { MemsetValue memsetValue = (MemsetValue) value; ConstantValue sizeConst = memsetValue.getSize(); diff --git a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphBaseVisitor.java b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphBaseVisitor.java index bf58c9ba0..637d57f66 100644 --- a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphBaseVisitor.java +++ b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphBaseVisitor.java @@ -53,8 +53,8 @@ public class ControlFlowGraphBaseVisitor { return visitAsm((StatementAsm) statement); } else if(statement instanceof StatementKickAsm) { return visitKickAsm((StatementKickAsm) statement); - } else if(statement instanceof StatementStackPull) { - return visitStackPull((StatementStackPull) statement); + } else if(statement instanceof StatementExprSideEffect) { + return visitStackPull((StatementExprSideEffect) statement); } else { throw new RuntimeException("Unhandled statement type " + statement); } @@ -120,7 +120,7 @@ public class ControlFlowGraphBaseVisitor { return null; } - public T visitStackPull(StatementStackPull stackPull) { + public T visitStackPull(StatementExprSideEffect stackPull) { return null; } } diff --git a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java index e4d9efa3e..bc829d332 100644 --- a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java +++ b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java @@ -222,7 +222,7 @@ public class ControlFlowGraphCopyVisitor extends ControlFlowGraphBaseVisitor comments) { + super(source, comments); + this.expression = expression; + } + + public RValue getExpression() { + return expression; + } + + public void setExpression(RValue expression) { + this.expression = expression; + } + + @Override + public String toString(Program program, boolean aliveInfo) { + return "sideeffect " + expression.toString(program); + } +} diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementStackPull.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementStackPull.java deleted file mode 100644 index a59e45a28..000000000 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementStackPull.java +++ /dev/null @@ -1,31 +0,0 @@ -package dk.camelot64.kickc.model.statements; - -import dk.camelot64.kickc.model.Comment; -import dk.camelot64.kickc.model.Program; -import dk.camelot64.kickc.model.values.ConstantValue; - -import java.util.List; - -/** Pulls some bytes of the stack. */ -public class StatementStackPull extends StatementBase { - - private ConstantValue pullBytes; - - public StatementStackPull(ConstantValue pullBytes, StatementSource source, List comments) { - super(source, comments); - this.pullBytes = pullBytes; - } - - public ConstantValue getPullBytes() { - return pullBytes; - } - - public void setPullBytes(ConstantValue pullBytes) { - this.pullBytes = pullBytes; - } - - @Override - public String toString(Program program, boolean aliveInfo) { - return "stackpull("+pullBytes.toString(program)+")"; - } -} diff --git a/src/main/java/dk/camelot64/kickc/model/values/StackPullBytes.java b/src/main/java/dk/camelot64/kickc/model/values/StackPullBytes.java new file mode 100644 index 000000000..216e9698b --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/model/values/StackPullBytes.java @@ -0,0 +1,27 @@ +package dk.camelot64.kickc.model.values; + +import dk.camelot64.kickc.model.Program; + +/** Pulls a number og bytes from the stack. */ +public class StackPullBytes implements RValue { + + /** The type of value being pushed. */ + private ConstantValue bytes; + + public StackPullBytes(ConstantValue bytes) { + this.bytes = bytes; + } + + public ConstantValue getBytes() { + return bytes; + } + + public void setBytes(ConstantValue bytes) { + this.bytes = bytes; + } + + @Override + public String toString(Program program) { + return "stackpullbytes(" + bytes.toString(program)+ ")"; + } +} diff --git a/src/main/java/dk/camelot64/kickc/model/values/StackPushBytes.java b/src/main/java/dk/camelot64/kickc/model/values/StackPushBytes.java new file mode 100644 index 000000000..4db4001e4 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/model/values/StackPushBytes.java @@ -0,0 +1,27 @@ +package dk.camelot64.kickc.model.values; + +import dk.camelot64.kickc.model.Program; + +/** Pushes a number og bytes to the stack. */ +public class StackPushBytes implements RValue { + + /** The type of value being pushed. */ + private ConstantValue bytes; + + public StackPushBytes(ConstantValue bytes) { + this.bytes = bytes; + } + + public ConstantValue getBytes() { + return bytes; + } + + public void setBytes(ConstantValue bytes) { + this.bytes = bytes; + } + + @Override + public String toString(Program program) { + return "stackpushbytes(" + bytes.toString(program)+ ")"; + } +} diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index 2ffff4cf3..8c88cff5b 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -882,6 +882,7 @@ public class Pass4CodeGeneration { } } + //throw new RuntimeException("E!"); } else if(statement instanceof StatementCallExecute) { StatementCallExecute call = (StatementCallExecute) statement; Procedure procedure = getScope().getProcedure(call.getProcedure()); @@ -889,10 +890,10 @@ public class Pass4CodeGeneration { asm.getCurrentChunk().setFragment("jsr"); asm.addInstruction("jsr", AsmAddressingMode.ABS, call.getProcedure().getFullName(), false); } - } else if(statement instanceof StatementStackPull) { - String pullSignature = "_stackpullbyte_" + AsmFormat.getAsmConstant(program, ((StatementStackPull) statement).getPullBytes(), 99, block.getScope()); - AsmFragmentInstanceSpec pullFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pullSignature, new LinkedHashMap<>(), block.getScope()); - generateAsm(asm, pullFragmentInstanceSpec); + } else if(statement instanceof StatementExprSideEffect) { + AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory((StatementExprSideEffect)statement, program); + ensureEncoding(asm, asmFragmentInstanceSpecFactory); + generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec()); } else if(statement instanceof StatementReturn) { Procedure procedure = null; ScopeRef scope = block.getScope(); diff --git a/src/main/java/dk/camelot64/kickc/passes/PassNCallingConventionStack.java b/src/main/java/dk/camelot64/kickc/passes/PassNCallingConventionStack.java index 74fd505f5..28f05e1ff 100644 --- a/src/main/java/dk/camelot64/kickc/passes/PassNCallingConventionStack.java +++ b/src/main/java/dk/camelot64/kickc/passes/PassNCallingConventionStack.java @@ -131,8 +131,7 @@ public class PassNCallingConventionStack extends Pass2SsaOptimization { final List comments = call.getComments(); if(stackCleanBytes > 0) { // Clean up the stack - stmtIt.add(new StatementStackPull( new ConstantInteger(stackCleanBytes), source, comments)); - //String pullSignature = "_stackpullbyte_" + stackCleanBytes; + stmtIt.add(new StatementExprSideEffect( new StackPullBytes(new ConstantInteger(stackCleanBytes)), source, comments)); } final RValue value = call.getlValue(); if(value!=null) diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 8a3c429ae..95292bd66 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -281,7 +281,7 @@ public class TestPrograms { @Test public void testProcedureCallingConventionStack11() throws IOException, URISyntaxException { - compileAndCompare("procedure-callingconvention-stack-11"); + compileAndCompare("procedure-callingconvention-stack-11"); //, log().verboseCreateSsa().verboseSSAOptimize()); } @Test diff --git a/src/test/ref/procedure-callingconvention-stack-0.cfg b/src/test/ref/procedure-callingconvention-stack-0.cfg index 5f27ebb47..a8451b52f 100644 --- a/src/test/ref/procedure-callingconvention-stack-0.cfg +++ b/src/test/ref/procedure-callingconvention-stack-0.cfg @@ -12,7 +12,7 @@ main: scope:[main] from @1 [4] callprepare plus (byte) '0' (byte) 7 [5] callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) [7] (byte~) main::$0 ← stackpull(byte) [8] *((const byte*) SCREEN) ← (byte~) main::$0 to:main::@return diff --git a/src/test/ref/procedure-callingconvention-stack-0.log b/src/test/ref/procedure-callingconvention-stack-0.log index ab6ad9428..a3969cfb8 100644 --- a/src/test/ref/procedure-callingconvention-stack-0.log +++ b/src/test/ref/procedure-callingconvention-stack-0.log @@ -14,7 +14,7 @@ CONTROL FLOW GRAPH SSA main: scope:[main] from @2 callprepare plus (byte) '0' (number) 7 callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) (byte~) main::$0 ← stackpull(byte) *((const byte*) SCREEN + (number) 0) ← (byte~) main::$0 to:main::@return @@ -110,7 +110,7 @@ FINAL CONTROL FLOW GRAPH main: scope:[main] from @1 [4] callprepare plus (byte) '0' (byte) 7 [5] callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) [7] (byte~) main::$0 ← stackpull(byte) [8] *((const byte*) SCREEN) ← (byte~) main::$0 to:main::@return @@ -192,7 +192,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← stackpull(byte) -- vbuz1=_stackpullbyte_ pla @@ -242,7 +242,7 @@ plus: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [4] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement stackpull((number) 1) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 1) always clobbers reg byte a Statement [7] (byte~) main::$0 ← stackpull(byte) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:5 [ plus::a#0 ] ) always clobbers reg byte a reg byte x Statement [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:5 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x @@ -251,7 +251,7 @@ Removing always clobbered register reg byte x as potential for zp[1]:3 [ plus::a Statement [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:5 [ plus::return#0 ] ) always clobbers reg byte a Statement [13] stackidx(byte,(const byte) plus::OFFSET_STACK_RETURN) ← (byte) plus::return#0 [ ] ( main:2::plus:5 [ ] ) always clobbers reg byte x Statement [4] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement stackpull((number) 1) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 1) always clobbers reg byte a Statement [7] (byte~) main::$0 ← stackpull(byte) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:5 [ plus::a#0 ] ) always clobbers reg byte a reg byte x Statement [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:5 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x @@ -308,7 +308,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← stackpull(byte) -- vbuaa=_stackpullbyte_ pla @@ -424,7 +424,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← stackpull(byte) -- vbuaa=_stackpullbyte_ pla diff --git a/src/test/ref/procedure-callingconvention-stack-1.cfg b/src/test/ref/procedure-callingconvention-stack-1.cfg index 5f27ebb47..a8451b52f 100644 --- a/src/test/ref/procedure-callingconvention-stack-1.cfg +++ b/src/test/ref/procedure-callingconvention-stack-1.cfg @@ -12,7 +12,7 @@ main: scope:[main] from @1 [4] callprepare plus (byte) '0' (byte) 7 [5] callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) [7] (byte~) main::$0 ← stackpull(byte) [8] *((const byte*) SCREEN) ← (byte~) main::$0 to:main::@return diff --git a/src/test/ref/procedure-callingconvention-stack-1.log b/src/test/ref/procedure-callingconvention-stack-1.log index ab6ad9428..a3969cfb8 100644 --- a/src/test/ref/procedure-callingconvention-stack-1.log +++ b/src/test/ref/procedure-callingconvention-stack-1.log @@ -14,7 +14,7 @@ CONTROL FLOW GRAPH SSA main: scope:[main] from @2 callprepare plus (byte) '0' (number) 7 callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) (byte~) main::$0 ← stackpull(byte) *((const byte*) SCREEN + (number) 0) ← (byte~) main::$0 to:main::@return @@ -110,7 +110,7 @@ FINAL CONTROL FLOW GRAPH main: scope:[main] from @1 [4] callprepare plus (byte) '0' (byte) 7 [5] callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) [7] (byte~) main::$0 ← stackpull(byte) [8] *((const byte*) SCREEN) ← (byte~) main::$0 to:main::@return @@ -192,7 +192,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← stackpull(byte) -- vbuz1=_stackpullbyte_ pla @@ -242,7 +242,7 @@ plus: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [4] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement stackpull((number) 1) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 1) always clobbers reg byte a Statement [7] (byte~) main::$0 ← stackpull(byte) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:5 [ plus::a#0 ] ) always clobbers reg byte a reg byte x Statement [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:5 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x @@ -251,7 +251,7 @@ Removing always clobbered register reg byte x as potential for zp[1]:3 [ plus::a Statement [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:5 [ plus::return#0 ] ) always clobbers reg byte a Statement [13] stackidx(byte,(const byte) plus::OFFSET_STACK_RETURN) ← (byte) plus::return#0 [ ] ( main:2::plus:5 [ ] ) always clobbers reg byte x Statement [4] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement stackpull((number) 1) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 1) always clobbers reg byte a Statement [7] (byte~) main::$0 ← stackpull(byte) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:5 [ plus::a#0 ] ) always clobbers reg byte a reg byte x Statement [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:5 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x @@ -308,7 +308,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← stackpull(byte) -- vbuaa=_stackpullbyte_ pla @@ -424,7 +424,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← stackpull(byte) -- vbuaa=_stackpullbyte_ pla diff --git a/src/test/ref/procedure-callingconvention-stack-10.cfg b/src/test/ref/procedure-callingconvention-stack-10.cfg index 292ca676a..04dc7c350 100644 --- a/src/test/ref/procedure-callingconvention-stack-10.cfg +++ b/src/test/ref/procedure-callingconvention-stack-10.cfg @@ -55,6 +55,6 @@ main::@2: scope:[main] from main::@1 [28] *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$1_y [29] callprepare print *((byte*)&(struct Point) main::p) *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) [30] callexecute print - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) [32] (byte) main::i ← ++ (byte) main::i to:main::@1 diff --git a/src/test/ref/procedure-callingconvention-stack-10.log b/src/test/ref/procedure-callingconvention-stack-10.log index 75d44d887..e7bcb254a 100644 --- a/src/test/ref/procedure-callingconvention-stack-10.log +++ b/src/test/ref/procedure-callingconvention-stack-10.log @@ -67,7 +67,7 @@ main::@2: scope:[main] from main::@1 (struct Point) main::p ← struct-unwound {*((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_X), *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y)} callprepare print *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_X) *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) callexecute print - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) (byte) main::i ← ++ (byte) main::i to:main::@1 main::@return: scope:[main] from main::@1 @@ -257,7 +257,7 @@ main::@2: scope:[main] from main::@1 [28] *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$1_y [29] callprepare print *((byte*)&(struct Point) main::p) *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) [30] callexecute print - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) [32] (byte) main::i ← ++ (byte) main::i to:main::@1 @@ -484,7 +484,7 @@ main: { pha // [30] callexecute print -- jsr jsr print - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [32] (byte) main::i ← ++ (byte) main::i -- vbuz1=_inc_vbuz1 @@ -516,7 +516,7 @@ Statement [25] (byte~) main::$1_x ← stackpull(byte) [ idx get::p main::i main: Statement [26] (byte~) main::$1_y ← stackpull(byte) [ idx get::p main::i main::$1_x main::$1_y main::p ] ( main:2 [ idx get::p main::i main::$1_x main::$1_y main::p ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:10 [ main::$1_x ] Statement [29] callprepare print *((byte*)&(struct Point) main::p) *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) [ idx get::p main::i main::p ] ( main:2 [ idx get::p main::i main::p ] ) always clobbers reg byte a -Statement stackpull((number) 2) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 2) always clobbers reg byte a Statement [0] (byte) idx ← (byte) 0 [ idx get::p main::p ] ( [ idx get::p main::p ] ) always clobbers reg byte a Statement [4] (byte) print::p_x#0 ← stackidx(byte,(const byte) print::OFFSET_STACK_P_X) [ idx print::p_x#0 ] ( main:2::print:30 [ get::p main::i main::p idx print::p_x#0 ] ) always clobbers reg byte a reg byte x Statement [5] (byte) print::p_y#0 ← stackidx(byte,(const byte) print::OFFSET_STACK_P_Y) [ idx print::p_x#0 print::p_y#0 ] ( main:2::print:30 [ get::p main::i main::p idx print::p_x#0 print::p_y#0 ] ) always clobbers reg byte a reg byte x @@ -532,7 +532,7 @@ Statement [23] callprepare get (byte) main::i [ idx get::p main::i main::p ] ( Statement [25] (byte~) main::$1_x ← stackpull(byte) [ idx get::p main::i main::$1_x main::p ] ( main:2 [ idx get::p main::i main::$1_x main::p ] ) always clobbers reg byte a Statement [26] (byte~) main::$1_y ← stackpull(byte) [ idx get::p main::i main::$1_x main::$1_y main::p ] ( main:2 [ idx get::p main::i main::$1_x main::$1_y main::p ] ) always clobbers reg byte a Statement [29] callprepare print *((byte*)&(struct Point) main::p) *((byte*)&(struct Point) main::p+(const byte) OFFSET_STRUCT_POINT_Y) [ idx get::p main::i main::p ] ( main:2 [ idx get::p main::i main::p ] ) always clobbers reg byte a -Statement stackpull((number) 2) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 2) always clobbers reg byte a Potential registers zp[1]:2 [ idx ] : zp[1]:2 , Potential registers zp[1]:3 [ print::p_x#0 ] : zp[1]:3 , reg byte y , Potential registers zp[1]:4 [ print::p_y#0 ] : zp[1]:4 , reg byte x , @@ -708,7 +708,7 @@ main: { pha // [30] callexecute print -- jsr jsr print - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [32] (byte) main::i ← ++ (byte) main::i -- vbuz1=_inc_vbuz1 @@ -939,7 +939,7 @@ main: { pha // [30] callexecute print -- jsr jsr print - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // for(char i=0;i<5;i++) diff --git a/src/test/ref/procedure-callingconvention-stack-2.cfg b/src/test/ref/procedure-callingconvention-stack-2.cfg index bf5a14389..a37b6ee12 100644 --- a/src/test/ref/procedure-callingconvention-stack-2.cfg +++ b/src/test/ref/procedure-callingconvention-stack-2.cfg @@ -12,7 +12,7 @@ main: scope:[main] from @1 [4] callprepare plus (word) $1234 (word) $2345 [5] callexecute plus - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) [7] (word~) main::$0 ← stackpull(word) [8] *((const word*) SCREEN) ← (word~) main::$0 to:main::@return diff --git a/src/test/ref/procedure-callingconvention-stack-2.log b/src/test/ref/procedure-callingconvention-stack-2.log index 6f8841d93..ef2c7c4a5 100644 --- a/src/test/ref/procedure-callingconvention-stack-2.log +++ b/src/test/ref/procedure-callingconvention-stack-2.log @@ -15,7 +15,7 @@ CONTROL FLOW GRAPH SSA main: scope:[main] from @2 callprepare plus (number) $1234 (number) $2345 callexecute plus - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) (word~) main::$0 ← stackpull(word) (number~) main::$1 ← (number) 0 * (const byte) SIZEOF_WORD *((const word*) SCREEN + (number~) main::$1) ← (word~) main::$0 @@ -128,7 +128,7 @@ FINAL CONTROL FLOW GRAPH main: scope:[main] from @1 [4] callprepare plus (word) $1234 (word) $2345 [5] callexecute plus - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) [7] (word~) main::$0 ← stackpull(word) [8] *((const word*) SCREEN) ← (word~) main::$0 to:main::@return @@ -214,7 +214,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [7] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_ @@ -278,7 +278,7 @@ plus: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [4] callprepare plus (word) $1234 (word) $2345 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement stackpull((number) 2) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 2) always clobbers reg byte a Statement [7] (word~) main::$0 ← stackpull(word) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a Statement [8] *((const word*) SCREEN) ← (word~) main::$0 [ ] ( main:2 [ ] ) always clobbers reg byte a Statement [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:5 [ plus::a#0 ] ) always clobbers reg byte a reg byte x @@ -342,7 +342,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [7] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_ @@ -483,7 +483,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [7] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_ diff --git a/src/test/ref/procedure-callingconvention-stack-3.cfg b/src/test/ref/procedure-callingconvention-stack-3.cfg index 1b6799cf8..cb1edf1ee 100644 --- a/src/test/ref/procedure-callingconvention-stack-3.cfg +++ b/src/test/ref/procedure-callingconvention-stack-3.cfg @@ -12,7 +12,7 @@ main: scope:[main] from @1 [4] callprepare plus (byte) '0' (byte) 7 [5] callexecute plus - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) [7] (word~) main::$0 ← stackpull(word) [8] *((const word*) SCREEN) ← (word~) main::$0 to:main::@return diff --git a/src/test/ref/procedure-callingconvention-stack-3.log b/src/test/ref/procedure-callingconvention-stack-3.log index 454f51414..ed1cf51a8 100644 --- a/src/test/ref/procedure-callingconvention-stack-3.log +++ b/src/test/ref/procedure-callingconvention-stack-3.log @@ -15,7 +15,7 @@ CONTROL FLOW GRAPH SSA main: scope:[main] from @2 callprepare plus (byte) '0' (number) 7 callexecute plus - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) (word~) main::$0 ← stackpull(word) (number~) main::$1 ← (number) 0 * (const byte) SIZEOF_WORD *((const word*) SCREEN + (number~) main::$1) ← (word~) main::$0 @@ -125,7 +125,7 @@ FINAL CONTROL FLOW GRAPH main: scope:[main] from @1 [4] callprepare plus (byte) '0' (byte) 7 [5] callexecute plus - stackpull((number) 2) + sideeffect stackpullbytes((number) 2) [7] (word~) main::$0 ← stackpull(word) [8] *((const word*) SCREEN) ← (word~) main::$0 to:main::@return @@ -214,7 +214,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [7] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_ @@ -278,7 +278,7 @@ plus: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [4] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement stackpull((number) 2) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 2) always clobbers reg byte a Statement [7] (word~) main::$0 ← stackpull(word) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a Statement [8] *((const word*) SCREEN) ← (word~) main::$0 [ ] ( main:2 [ ] ) always clobbers reg byte a Statement [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:5 [ plus::a#0 ] ) always clobbers reg byte a reg byte x @@ -345,7 +345,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [7] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_ @@ -489,7 +489,7 @@ main: { pha // [5] callexecute plus -- jsr jsr plus - // stackpull((number) 2) -- _stackpullbyte_2 + // sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2 pla pla // [7] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_ diff --git a/src/test/ref/procedure-callingconvention-stack-4.cfg b/src/test/ref/procedure-callingconvention-stack-4.cfg index b63ac07c4..ca628f513 100644 --- a/src/test/ref/procedure-callingconvention-stack-4.cfg +++ b/src/test/ref/procedure-callingconvention-stack-4.cfg @@ -17,7 +17,7 @@ main::@1: scope:[main] from main main::@1 [6] (byte) main::v#0 ← (byte) main::a#2 + (byte) 1 [7] callprepare plus (byte) '0' (byte) main::v#0 [8] callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) [10] (byte) main::w#0 ← stackpull(byte) [11] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 [12] *((const byte*) SCREEN) ← (byte~) main::$2 diff --git a/src/test/ref/procedure-callingconvention-stack-4.log b/src/test/ref/procedure-callingconvention-stack-4.log index b236288ab..b1c18ff33 100644 --- a/src/test/ref/procedure-callingconvention-stack-4.log +++ b/src/test/ref/procedure-callingconvention-stack-4.log @@ -24,7 +24,7 @@ main::@1: scope:[main] from main main::@1 (byte) main::v#0 ← (number~) main::$0 callprepare plus (byte) '0' (byte) main::v#0 callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) (byte~) main::$1 ← stackpull(byte) (byte) main::w#0 ← (byte~) main::$1 (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 @@ -194,7 +194,7 @@ main::@1: scope:[main] from main main::@1 [6] (byte) main::v#0 ← (byte) main::a#2 + (byte) 1 [7] callprepare plus (byte) '0' (byte) main::v#0 [8] callexecute plus - stackpull((number) 1) + sideeffect stackpullbytes((number) 1) [10] (byte) main::w#0 ← stackpull(byte) [11] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 [12] *((const byte*) SCREEN) ← (byte~) main::$2 @@ -318,7 +318,7 @@ main: { pha // [8] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [10] (byte) main::w#0 ← stackpull(byte) -- vbuz1=_stackpullbyte_ pla @@ -380,7 +380,7 @@ plus: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [7] callprepare plus (byte) '0' (byte) main::v#0 [ main::a#2 ] ( main:2 [ main::a#2 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::a#2 main::a#1 ] -Statement stackpull((number) 1) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 1) always clobbers reg byte a Statement [10] (byte) main::w#0 ← stackpull(byte) [ main::a#2 main::w#0 ] ( main:2 [ main::a#2 main::w#0 ] ) always clobbers reg byte a Statement [11] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 [ main::a#2 main::$2 ] ( main:2 [ main::a#2 main::$2 ] ) always clobbers reg byte a Statement [16] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:8 [ main::a#2 plus::a#0 ] ) always clobbers reg byte a reg byte x @@ -391,7 +391,7 @@ Removing always clobbered register reg byte x as potential for zp[1]:6 [ plus::a Statement [18] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:8 [ main::a#2 plus::return#0 ] ) always clobbers reg byte a Statement [19] stackidx(byte,(const byte) plus::OFFSET_STACK_RETURN) ← (byte) plus::return#0 [ ] ( main:2::plus:8 [ main::a#2 ] ) always clobbers reg byte x Statement [7] callprepare plus (byte) '0' (byte) main::v#0 [ main::a#2 ] ( main:2 [ main::a#2 ] ) always clobbers reg byte a -Statement stackpull((number) 1) always clobbers reg byte a +Statement sideeffect stackpullbytes((number) 1) always clobbers reg byte a Statement [10] (byte) main::w#0 ← stackpull(byte) [ main::a#2 main::w#0 ] ( main:2 [ main::a#2 main::w#0 ] ) always clobbers reg byte a Statement [11] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 [ main::a#2 main::$2 ] ( main:2 [ main::a#2 main::$2 ] ) always clobbers reg byte a Statement [16] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:8 [ main::a#2 plus::a#0 ] ) always clobbers reg byte a reg byte x @@ -471,7 +471,7 @@ main: { pha // [8] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // [10] (byte) main::w#0 ← stackpull(byte) -- vbuaa=_stackpullbyte_ pla @@ -629,7 +629,7 @@ main: { pha // [8] callexecute plus -- jsr jsr plus - // stackpull((number) 1) -- _stackpullbyte_1 + // sideeffect stackpullbytes((number) 1) -- _stackpullbyte_1 pla // w = plus('0', v) // [10] (byte) main::w#0 ← stackpull(byte) -- vbuaa=_stackpullbyte_