mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 08:32:39 +00:00
Created StatementExprSideEffect. Converted stack operations to this.
This commit is contained in:
parent
9e2e38e671
commit
7baacebc3d
@ -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();
|
||||
|
@ -53,8 +53,8 @@ public class ControlFlowGraphBaseVisitor<T> {
|
||||
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<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public T visitStackPull(StatementStackPull stackPull) {
|
||||
public T visitStackPull(StatementExprSideEffect stackPull) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public class ControlFlowGraphCopyVisitor extends ControlFlowGraphBaseVisitor<Obj
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitStackPull(StatementStackPull orig) {
|
||||
return new StatementStackPull(orig.getPullBytes(), orig.getSource(), orig.getComments());
|
||||
public Object visitStackPull(StatementExprSideEffect orig) {
|
||||
return new StatementExprSideEffect(orig.getExpression(), orig.getSource(), orig.getComments());
|
||||
}
|
||||
}
|
||||
|
@ -313,22 +313,22 @@ public interface ProgramValue {
|
||||
}
|
||||
|
||||
/** Number of bytes constant used by stack pull . */
|
||||
class StackPullBytes implements ProgramValue {
|
||||
class ExprSideEffect implements ProgramValue {
|
||||
|
||||
private StatementStackPull statementStackPull;
|
||||
private StatementExprSideEffect statementExprSideEffect;
|
||||
|
||||
StackPullBytes(StatementStackPull statementStackPull) {
|
||||
this.statementStackPull = statementStackPull;
|
||||
ExprSideEffect(StatementExprSideEffect statementExprSideEffect) {
|
||||
this.statementExprSideEffect = statementExprSideEffect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value get() {
|
||||
return statementStackPull.getPullBytes();
|
||||
return statementExprSideEffect.getExpression();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Value value) {
|
||||
statementStackPull.setPullBytes((ConstantValue) value);
|
||||
public void set(Value value) {
|
||||
statementExprSideEffect.setExpression((RValue) value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -817,6 +817,46 @@ public interface ProgramValue {
|
||||
|
||||
}
|
||||
|
||||
/** Value inside a StackPullBytes . */
|
||||
class ProgramValueStackPullBytes implements ProgramValue {
|
||||
private final StackPullBytes stackPullBytes;
|
||||
|
||||
ProgramValueStackPullBytes(StackPullBytes stackPullBytes) {
|
||||
this.stackPullBytes = stackPullBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value get() {
|
||||
return stackPullBytes.getBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Value val) {
|
||||
stackPullBytes.setBytes((ConstantValue) val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Value inside a StackPushBytes . */
|
||||
class ProgramValueStackPushBytes implements ProgramValue {
|
||||
private final StackPushBytes stackPushBytes;
|
||||
|
||||
ProgramValueStackPushBytes(StackPushBytes stackPushBytes) {
|
||||
this.stackPushBytes = stackPushBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value get() {
|
||||
return stackPushBytes.getBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Value val) {
|
||||
stackPushBytes.setBytes((ConstantValue) val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Value inside a memset value . */
|
||||
class ProgramValueMemsetValue implements ProgramValue {
|
||||
private final MemsetValue memsetValue;
|
||||
|
@ -166,9 +166,9 @@ public class ProgramValueIterator {
|
||||
for(String label : referenced.keySet()) {
|
||||
execute(new ProgramValue.ProgramValueAsmReferenced(statementAsm, label), handler, statement, statementsIt, block);
|
||||
}
|
||||
} else if(statement instanceof StatementStackPull) {
|
||||
StatementStackPull statementStackPull = (StatementStackPull) statement;
|
||||
execute(new ProgramValue.StackPullBytes(statementStackPull), handler, statement, statementsIt, block);
|
||||
} else if(statement instanceof StatementExprSideEffect) {
|
||||
StatementExprSideEffect statementExprSideEffect = (StatementExprSideEffect) statement;
|
||||
execute(new ProgramValue.ExprSideEffect(statementExprSideEffect), handler, statement, statementsIt, block);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,6 +255,10 @@ public class ProgramValueIterator {
|
||||
subValues.add(new ProgramValue.ProgramValueMempySource((MemcpyValue) value));
|
||||
} else if(value instanceof StackIdxValue) {
|
||||
subValues.add(new ProgramValue.ProgramValueStackIdxValue((StackIdxValue) value));
|
||||
} else if(value instanceof StackPullBytes) {
|
||||
subValues.add(new ProgramValue.ProgramValueStackPullBytes((StackPullBytes) value));
|
||||
} else if(value instanceof StackPushBytes) {
|
||||
subValues.add(new ProgramValue.ProgramValueStackPushBytes((StackPushBytes) value));
|
||||
} else if(value == null ||
|
||||
value instanceof SymbolVariableRef ||
|
||||
value instanceof Variable ||
|
||||
|
@ -0,0 +1,31 @@
|
||||
package dk.camelot64.kickc.model.statements;
|
||||
|
||||
import dk.camelot64.kickc.model.Comment;
|
||||
import dk.camelot64.kickc.model.Program;
|
||||
import dk.camelot64.kickc.model.values.RValue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** An expression that has a side effect. The expression is not assigned anywhere and will not be deleted. */
|
||||
public class StatementExprSideEffect extends StatementBase {
|
||||
|
||||
private RValue expression;
|
||||
|
||||
public StatementExprSideEffect(RValue expression, StatementSource source, List<Comment> 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);
|
||||
}
|
||||
}
|
@ -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<Comment> 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)+")";
|
||||
}
|
||||
}
|
@ -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)+ ")";
|
||||
}
|
||||
}
|
@ -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)+ ")";
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -131,8 +131,7 @@ public class PassNCallingConventionStack extends Pass2SsaOptimization {
|
||||
final List<Comment> 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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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++)
|
||||
|
@ -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
|
||||
|
@ -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_
|
||||
|
@ -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
|
||||
|
@ -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_
|
||||
|
@ -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
|
||||
|
@ -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_
|
||||
|
Loading…
Reference in New Issue
Block a user