1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-02-13 13:33:32 +00:00

Renamed stack pull/push/idx - including fragments. #316

This commit is contained in:
jespergravgaard 2019-09-23 07:42:13 +02:00
parent cbec257332
commit a11929dbd3
24 changed files with 236 additions and 125 deletions

View File

@ -356,13 +356,13 @@ public class AsmFragmentInstanceSpecFactory {
String name = "la" + nextLabelIdx++;
bind(name, value);
return name;
} else if(value instanceof ParamStackValue) {
ParamStackValue paramStackValue = (ParamStackValue) value;
return "_stackget"+paramStackValue.getValueType().getTypeName()+"_"+bind(paramStackValue.getStackOffset());
} else if(value instanceof ParamStackPush) {
return "_stackpush"+((ParamStackPush) value).getType().getTypeName()+"_";
} else if(value instanceof ParamStackPull) {
return "_stackpull"+((ParamStackPull) value).getType().getTypeName()+"_";
} else if(value instanceof StackIdxValue) {
StackIdxValue stackIdxValue = (StackIdxValue) value;
return "_stackidx"+ stackIdxValue.getValueType().getTypeName()+"_"+bind(stackIdxValue.getStackOffset());
} else if(value instanceof StackPushValue) {
return "_stackpush"+((StackPushValue) value).getType().getTypeName()+"_";
} else if(value instanceof StackPullValue) {
return "_stackpull"+((StackPullValue) value).getType().getTypeName()+"_";
}
throw new RuntimeException("Binding of value type not supported " + value.toString(program));
}

View File

@ -796,21 +796,21 @@ public interface ProgramValue {
}
/** Value inside a parameter stack value . */
class ProgramValueParamStackValue implements ProgramValue {
private final ParamStackValue paramValue;
class ProgramValueStackIdxValue implements ProgramValue {
private final StackIdxValue stackIdxValue;
ProgramValueParamStackValue(ParamStackValue paramValue) {
this.paramValue = paramValue;
ProgramValueStackIdxValue(StackIdxValue stackIdxValue) {
this.stackIdxValue = stackIdxValue;
}
@Override
public Value get() {
return paramValue.getStackOffset();
return stackIdxValue.getStackOffset();
}
@Override
public void set(Value val) {
paramValue.setStackOffset((ConstantRef) val);
stackIdxValue.setStackOffset((ConstantRef) val);
}
}

View File

@ -246,8 +246,8 @@ public class ProgramValueIterator {
subValues.add(new ProgramValue.ProgramValueLValueIntermediateVariable((LvalueIntermediate) value));
} else if(value instanceof ParamValue) {
subValues.add(new ProgramValue.ProgramValueParamValue((ParamValue) value));
} else if(value instanceof ParamStackValue) {
subValues.add(new ProgramValue.ProgramValueParamStackValue((ParamStackValue) value));
} else if(value instanceof StackIdxValue) {
subValues.add(new ProgramValue.ProgramValueStackIdxValue((StackIdxValue) value));
} else if(value == null ||
value instanceof VariableRef ||
value instanceof VariableVersion ||

View File

@ -116,7 +116,7 @@ public class SymbolTypeInference {
return ((StructZero)rValue).getTypeStruct();
} else if(rValue instanceof ParamValue) {
return inferType(symbols, ((ParamValue) rValue).getParameter());
} else if(rValue instanceof ParamStackValue) {
} else if(rValue instanceof StackIdxValue) {
return SymbolType.BYTE;
} else if(rValue instanceof StructUnwoundPlaceholder) {
return ((StructUnwoundPlaceholder) rValue).getTypeStruct();

View File

@ -3,8 +3,8 @@ package dk.camelot64.kickc.model.values;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.types.SymbolType;
/** The value passed into a function for a specific parameter using the stack. */
public class ParamStackValue implements LValue {
/** The value on the stack at a specific offset from the current stack-pointer. */
public class StackIdxValue implements LValue {
/** The constant holding the stack offset of the parameter. */
private ConstantValue stackOffset;
@ -12,7 +12,7 @@ public class ParamStackValue implements LValue {
/** The type of the value to fetch from the stack. */
private SymbolType valueType;
public ParamStackValue(ConstantValue stackOffset, SymbolType valueType) {
public StackIdxValue(ConstantValue stackOffset, SymbolType valueType) {
this.stackOffset = stackOffset;
this.valueType = valueType;
}
@ -35,7 +35,7 @@ public class ParamStackValue implements LValue {
@Override
public String toString(Program program) {
return "paramstack("+valueType.getTypeName()+","+stackOffset.toString(program)+")";
return "stackidx("+valueType.getTypeName()+","+stackOffset.toString(program)+")";
}

View File

@ -4,12 +4,12 @@ import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.types.SymbolType;
/** A value pulled from the stack. */
public class ParamStackPull implements RValue {
public class StackPullValue implements RValue {
/** The type of value being pushed. */
private SymbolType type;
public ParamStackPull(SymbolType type) {
public StackPullValue(SymbolType type) {
this.type = type;
}
@ -19,6 +19,6 @@ public class ParamStackPull implements RValue {
@Override
public String toString(Program program) {
return "paramstackpull(" + type.getTypeName()+ ")";
return "stackpull(" + type.getTypeName()+ ")";
}
}

View File

@ -4,12 +4,12 @@ import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.types.SymbolType;
/** A value pushed to the stack. */
public class ParamStackPush implements LValue {
public class StackPushValue implements LValue {
/** The type of value being pushed. */
private SymbolType type;
public ParamStackPush(SymbolType type) {
public StackPushValue(SymbolType type) {
this.type = type;
}
@ -19,6 +19,6 @@ public class ParamStackPush implements LValue {
@Override
public String toString(Program program) {
return "paramstackpush(" + type.getTypeName()+ ")";
return "stackpush(" + type.getTypeName()+ ")";
}
}

View File

@ -756,7 +756,7 @@ public class Pass4CodeGeneration {
// Push parameters to the stack
for(RValue parameter : call.getParameters()) {
SymbolType parameterType = SymbolTypeInference.inferType(program.getScope(), parameter);
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new ParamStackPush(parameterType), parameter, program, block.getScope());
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new StackPushValue(parameterType), parameter, program, block.getScope());
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
ensureEncoding(asm, asmFragmentInstanceSpecFactory);
generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec());
@ -793,7 +793,7 @@ public class Pass4CodeGeneration {
// Pull result from the stack
if(call.getlValue() != null) {
SymbolType returnType = procedure.getReturnType();
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(call.getlValue(), new ParamStackPull(returnType), program, block.getScope());
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(call.getlValue(), new StackPullValue(returnType), program, block.getScope());
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
ensureEncoding(asm, asmFragmentInstanceSpecFactory);
generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec());
@ -821,7 +821,7 @@ public class Pass4CodeGeneration {
int returnOffset = parameterBytes - returnType.getSizeBytes();
// TODO: Put the return stack offset into a named constant (look at PassNCallingConventionStack)
ConstantValue returnValueStackOffset = new ConstantInteger((long)returnOffset, SymbolType.BYTE);
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new ParamStackValue(returnValueStackOffset, returnType), returnStatement.getValue(), program, block.getScope());
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new StackIdxValue(returnValueStackOffset, returnType), returnStatement.getValue(), program, block.getScope());
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
ensureEncoding(asm, asmFragmentInstanceSpecFactory);
generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec());

View File

@ -60,7 +60,7 @@ public class PassNCallingConventionStack extends Pass2SsaOptimization {
long STACK_BASE = 0x103L;
getScope().add(new ConstantVar("STACK_BASE", getScope(), SymbolType.WORD, new ConstantInteger(STACK_BASE, SymbolType.WORD), Scope.SEGMENT_DATA_DEFAULT));
// Convert ParamValue to ParamStackValue
// Convert ParamValue to StackIdxValue
ProgramValueIterator.execute(getGraph(), (programValue, currentStmt, stmtIt, currentBlock) -> {
if(programValue.get() instanceof ParamValue) {
// Convert ParamValues to calling-convention specific param-value
@ -68,9 +68,9 @@ public class PassNCallingConventionStack extends Pass2SsaOptimization {
VariableRef parameterRef = paramValue.getParameter();
SymbolType parameterType = SymbolTypeInference.inferType(getScope(), paramValue.getParameter());
if(offsetConstants.containsKey(parameterRef)) {
ParamStackValue paramStackValue = new ParamStackValue(offsetConstants.get(parameterRef), parameterType);
programValue.set(paramStackValue);
getLog().append("Calling convention " + Procedure.CallingConvension.STACK_CALL + " replacing " + paramValue.toString(getProgram()) + " with " + paramStackValue.toString(getProgram()));
StackIdxValue stackIdxValue = new StackIdxValue(offsetConstants.get(parameterRef), parameterType);
programValue.set(stackIdxValue);
getLog().append("Calling convention " + Procedure.CallingConvension.STACK_CALL + " replacing " + paramValue.toString(getProgram()) + " with " + stackIdxValue.toString(getProgram()));
}
}
});

View File

@ -42,7 +42,7 @@ public class TestPrograms {
@Test
public void testProcedureCallingConventionStack3() throws IOException, URISyntaxException {
compileAndCompare("procedure-callingconvention-stack-3"); //, log().verboseCreateSsa().verboseParse().verboseStatementSequence());
compileAndCompare("procedure-callingconvention-stack-3", log().verboseLiveRanges()); //, log().verboseCreateSsa().verboseParse().verboseStatementSequence());
}
@Test

View File

@ -22,8 +22,8 @@ main::@return: scope:[main] from main
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
plus: scope:[plus] from
[10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B)
[10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B)
[12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus

View File

@ -90,8 +90,8 @@ Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Calling convention STACK_CALL adding prepare/execute/finalize for [5] (byte~) main::$0 ← call plus (byte) '0' (byte) 7
Calling convention STACK_CALL replacing param((byte) plus::a) with paramstack(byte,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((byte) plus::b) with paramstack(byte,(const byte) plus::OFFSET_STACK_B)
Calling convention STACK_CALL replacing param((byte) plus::a) with stackidx(byte,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((byte) plus::b) with stackidx(byte,(const byte) plus::OFFSET_STACK_B)
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
@ -118,8 +118,8 @@ main::@return: scope:[main] from main
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
plus: scope:[plus] from
[10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B)
[10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B)
[12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus
@ -217,11 +217,11 @@ plus: {
.label a = 3
.label b = 4
.label return = 5
// [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuz1=_stackgetbyte_vbuc1
// [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -234,7 +234,7 @@ plus: {
// plus::@return
breturn:
// [13] return (byte) plus::return#0
// [13] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuz1
// [13] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuz1
lda.z return
tsx
sta STACK_BASE+1,x
@ -245,16 +245,16 @@ plus: {
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] (byte~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
Statement [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ 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:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ plus::a#0 ]
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:3 [ plus::a#0 ]
Statement [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] ) always clobbers reg byte a
Statement [13] return (byte) plus::return#0 [ ] ( main:2::plus:6 [ ] ) always clobbers reg byte x
Statement [5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] (byte~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
Statement [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ 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:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] ) always clobbers reg byte a
Statement [13] return (byte) plus::return#0 [ ] ( main:2::plus:6 [ ] ) always clobbers reg byte x
Potential registers zp ZP_BYTE:2 [ main::$0 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
@ -331,11 +331,11 @@ plus: {
.const OFFSET_STACK_A = 0
.const OFFSET_STACK_B = 1
.label a = 2
// [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackgetbyte_vbuc1
// [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 -- vbuaa=vbuz1_plus_vbuaa
@ -345,7 +345,7 @@ plus: {
// plus::@return
breturn:
// [13] return (byte) plus::return#0
// [13] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuaa
// [13] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuaa
tsx
sta STACK_BASE+1,x
rts
@ -451,11 +451,11 @@ plus: {
.const OFFSET_STACK_A = 0
.const OFFSET_STACK_B = 1
.label a = 2
// [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackgetbyte_vbuc1
// [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// return a+b;
@ -465,7 +465,7 @@ plus: {
// plus::@return
// }
// [13] return (byte) plus::return#0
// [13] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuaa
// [13] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuaa
tsx
sta STACK_BASE+1,x
rts

View File

@ -22,8 +22,8 @@ main::@return: scope:[main] from main
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
plus: scope:[plus] from
[10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B)
[10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B)
[12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus

View File

@ -90,8 +90,8 @@ Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Calling convention STACK_CALL adding prepare/execute/finalize for [5] (byte~) main::$0 ← call plus (byte) '0' (byte) 7
Calling convention STACK_CALL replacing param((byte) plus::a) with paramstack(byte,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((byte) plus::b) with paramstack(byte,(const byte) plus::OFFSET_STACK_B)
Calling convention STACK_CALL replacing param((byte) plus::a) with stackidx(byte,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((byte) plus::b) with stackidx(byte,(const byte) plus::OFFSET_STACK_B)
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
@ -118,8 +118,8 @@ main::@return: scope:[main] from main
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
plus: scope:[plus] from
[10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B)
[10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A)
[11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B)
[12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus
@ -217,11 +217,11 @@ plus: {
.label a = 3
.label b = 4
.label return = 5
// [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuz1=_stackgetbyte_vbuc1
// [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -234,7 +234,7 @@ plus: {
// plus::@return
breturn:
// [13] return (byte) plus::return#0
// [13] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuz1
// [13] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuz1
lda.z return
tsx
sta STACK_BASE+1,x
@ -245,16 +245,16 @@ plus: {
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] (byte~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
Statement [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ 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:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ plus::a#0 ]
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:3 [ plus::a#0 ]
Statement [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] ) always clobbers reg byte a
Statement [13] return (byte) plus::return#0 [ ] ( main:2::plus:6 [ ] ) always clobbers reg byte x
Statement [5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] (byte~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
Statement [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ 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:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] ) always clobbers reg byte a
Statement [13] return (byte) plus::return#0 [ ] ( main:2::plus:6 [ ] ) always clobbers reg byte x
Potential registers zp ZP_BYTE:2 [ main::$0 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
@ -331,11 +331,11 @@ plus: {
.const OFFSET_STACK_A = 0
.const OFFSET_STACK_B = 1
.label a = 2
// [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackgetbyte_vbuc1
// [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// [12] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 -- vbuaa=vbuz1_plus_vbuaa
@ -345,7 +345,7 @@ plus: {
// plus::@return
breturn:
// [13] return (byte) plus::return#0
// [13] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuaa
// [13] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuaa
tsx
sta STACK_BASE+1,x
rts
@ -451,11 +451,11 @@ plus: {
.const OFFSET_STACK_A = 0
.const OFFSET_STACK_B = 1
.label a = 2
// [10] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [10] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [11] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackgetbyte_vbuc1
// [11] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// return a+b;
@ -465,7 +465,7 @@ plus: {
// plus::@return
// }
// [13] return (byte) plus::return#0
// [13] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuaa
// [13] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuaa
tsx
sta STACK_BASE+1,x
rts

View File

@ -22,8 +22,8 @@ main::@return: scope:[main] from main
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B)
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B)
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus

View File

@ -107,8 +107,8 @@ Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Calling convention STACK_CALL adding prepare/execute/finalize for [5] (word~) main::$0 ← call plus (word) $1234 (word) $2345
Calling convention STACK_CALL replacing param((word) plus::a) with paramstack(word,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((word) plus::b) with paramstack(word,(const byte) plus::OFFSET_STACK_B)
Calling convention STACK_CALL replacing param((word) plus::a) with stackidx(word,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((word) plus::b) with stackidx(word,(const byte) plus::OFFSET_STACK_B)
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
@ -135,8 +135,8 @@ main::@return: scope:[main] from main
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B)
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B)
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus
@ -243,13 +243,13 @@ plus: {
.label a = 4
.label b = 6
.label return = 8
// [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackgetword_vbuc1
// [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
lda STACK_BASE+OFFSET_STACK_A+1,x
sta.z a+1
// [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackgetword_vbuc1
// [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -267,7 +267,7 @@ plus: {
// plus::@return
breturn:
// [13] return (word) plus::return#0
// [13] return (word) plus::return#0 -- _stackgetword_vbuc1=vwuz1
// [13] return (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
tsx
lda.z return
sta STACK_BASE+2,x
@ -281,8 +281,8 @@ REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] callprepare plus (word) $1234 (word) $2345 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] (word~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
Statement [8] *((const word*) SCREEN#0) ← (word~) main::$0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] ) always clobbers reg byte a
Statement [13] return (word) plus::return#0 [ ] ( main:2::plus:6 [ ] ) always clobbers reg byte a reg byte x
Potential registers zp ZP_WORD:2 [ main::$0 ] : zp ZP_WORD:2 ,
@ -374,13 +374,13 @@ plus: {
.label a = 2
.label b = 4
.label return = 2
// [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackgetword_vbuc1
// [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
lda STACK_BASE+OFFSET_STACK_A+1,x
sta.z a+1
// [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackgetword_vbuc1
// [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -398,7 +398,7 @@ plus: {
// plus::@return
breturn:
// [13] return (word) plus::return#0
// [13] return (word) plus::return#0 -- _stackgetword_vbuc1=vwuz1
// [13] return (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
tsx
lda.z return
sta STACK_BASE+2,x
@ -519,13 +519,13 @@ plus: {
.label a = 2
.label b = 4
.label return = 2
// [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackgetword_vbuc1
// [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
lda STACK_BASE+OFFSET_STACK_A+1,x
sta.z a+1
// [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackgetword_vbuc1
// [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -543,7 +543,7 @@ plus: {
// plus::@return
// }
// [13] return (word) plus::return#0
// [13] return (word) plus::return#0 -- _stackgetword_vbuc1=vwuz1
// [13] return (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
tsx
lda.z return
sta STACK_BASE+2,x

View File

@ -22,8 +22,8 @@ main::@return: scope:[main] from main
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B)
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B)
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus

View File

@ -104,8 +104,8 @@ Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Calling convention STACK_CALL adding prepare/execute/finalize for [5] (word~) main::$0 ← call plus (byte) '0' (byte) 7
Calling convention STACK_CALL replacing param((word) plus::a) with paramstack(word,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((word) plus::b) with paramstack(word,(const byte) plus::OFFSET_STACK_B)
Calling convention STACK_CALL replacing param((word) plus::a) with stackidx(word,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((word) plus::b) with stackidx(word,(const byte) plus::OFFSET_STACK_B)
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
@ -132,8 +132,8 @@ main::@return: scope:[main] from main
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B)
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A)
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B)
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus
@ -142,6 +142,117 @@ plus::@return: scope:[plus] from plus
VARIABLE REGISTER WEIGHTS
Adding empty live range for unused variable main::$0
Adding used var main::$0 to [7] main::$0 ← callfinalize plus
Adding empty live range for unused variable plus::a#0
Adding empty live range for unused variable plus::b#0
Adding empty live range for unused variable plus::return#0
Adding used var plus::a#0 to [11] plus::b#0 ← stackidx(word,plus::OFFSET_STACK_B)
Adding used var plus::b#0 to [11] plus::b#0 ← stackidx(word,plus::OFFSET_STACK_B)
Adding used var plus::return#0 to [12] plus::return#0 ← plus::a#0 + plus::b#0
Propagating live ranges...
CONTROL FLOW GRAPH - LIVE RANGES IN PROGRESS
@begin: scope:[] from
[0] phi() [ ] ( [ ] )
to:@1
@1: scope:[] from @begin
[1] phi() [ ] ( [ ] )
[2] call main [ ] ( [ ] )
to:@end
@end: scope:[] from @1
[3] phi() [ ] ( [ ] )
(void()) main()
main: scope:[main] from @1
[4] phi() [ ] ( main:2 [ ] )
[5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] )
[6] callexecute plus [ ] ( main:2 [ ] )
[7] (word~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] )
[8] *((const word*) SCREEN#0) ← (word~) main::$0 [ ] ( main:2 [ ] )
to:main::@return
main::@return: scope:[main] from main
[9] return [ ] ( main:2 [ ] )
to:@return
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ ] ( main:2::plus:6 [ ] )
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] )
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] )
to:plus::@return
plus::@return: scope:[plus] from plus
[13] return (word) plus::return#0 [ ] ( main:2::plus:6 [ ] )
to:@return
Propagated alive var plus::a#0 to [10] plus::a#0 ← stackidx(word,plus::OFFSET_STACK_A)
Propagating live ranges...
CONTROL FLOW GRAPH - LIVE RANGES IN PROGRESS
@begin: scope:[] from
[0] phi() [ ] ( [ ] )
to:@1
@1: scope:[] from @begin
[1] phi() [ ] ( [ ] )
[2] call main [ ] ( [ ] )
to:@end
@end: scope:[] from @1
[3] phi() [ ] ( [ ] )
(void()) main()
main: scope:[main] from @1
[4] phi() [ ] ( main:2 [ ] )
[5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] )
[6] callexecute plus [ ] ( main:2 [ ] )
[7] (word~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] )
[8] *((const word*) SCREEN#0) ← (word~) main::$0 [ ] ( main:2 [ ] )
to:main::@return
main::@return: scope:[main] from main
[9] return [ ] ( main:2 [ ] )
to:@return
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ ] )
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] )
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] )
to:plus::@return
plus::@return: scope:[plus] from plus
[13] return (word) plus::return#0 [ ] ( main:2::plus:6 [ ] )
to:@return
Propagating live ranges...
CONTROL FLOW GRAPH - LIVE RANGES IN PROGRESS
@begin: scope:[] from
[0] phi() [ ] ( [ ] )
to:@1
@1: scope:[] from @begin
[1] phi() [ ] ( [ ] )
[2] call main [ ] ( [ ] )
to:@end
@end: scope:[] from @1
[3] phi() [ ] ( [ ] )
(void()) main()
main: scope:[main] from @1
[4] phi() [ ] ( main:2 [ ] )
[5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] )
[6] callexecute plus [ ] ( main:2 [ ] )
[7] (word~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] )
[8] *((const word*) SCREEN#0) ← (word~) main::$0 [ ] ( main:2 [ ] )
to:main::@return
main::@return: scope:[main] from main
[9] return [ ] ( main:2 [ ] )
to:@return
__stackcall (word()) plus((word) plus::a , (word) plus::b)
plus: scope:[plus] from
[10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ ] )
[11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] )
[12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] )
to:plus::@return
plus::@return: scope:[plus] from plus
[13] return (word) plus::return#0 [ ] ( main:2::plus:6 [ ] )
to:@return
(word*) SCREEN
(void()) main()
(word~) main::$0 2.0
@ -239,13 +350,13 @@ plus: {
.label a = 4
.label b = 6
.label return = 8
// [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackgetword_vbuc1
// [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
lda STACK_BASE+OFFSET_STACK_A+1,x
sta.z a+1
// [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackgetword_vbuc1
// [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -263,7 +374,7 @@ plus: {
// plus::@return
breturn:
// [13] return (word) plus::return#0
// [13] return (word) plus::return#0 -- _stackgetword_vbuc1=vwuz1
// [13] return (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
tsx
lda.z return
sta STACK_BASE+2,x
@ -277,8 +388,8 @@ REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] callprepare plus (byte) '0' (byte) 7 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] (word~) main::$0 ← callfinalize plus [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
Statement [8] *((const word*) SCREEN#0) ← (word~) main::$0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] ) always clobbers reg byte a reg byte x
Statement [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ ] ) always clobbers reg byte a reg byte x
Statement [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [12] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] ) always clobbers reg byte a
Statement [13] return (word) plus::return#0 [ ] ( main:2::plus:6 [ ] ) always clobbers reg byte a reg byte x
Potential registers zp ZP_WORD:2 [ main::$0 ] : zp ZP_WORD:2 ,
@ -369,13 +480,13 @@ plus: {
.label a = 2
.label b = 4
.label return = 2
// [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackgetword_vbuc1
// [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
lda STACK_BASE+OFFSET_STACK_A+1,x
sta.z a+1
// [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackgetword_vbuc1
// [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -393,7 +504,7 @@ plus: {
// plus::@return
breturn:
// [13] return (word) plus::return#0
// [13] return (word) plus::return#0 -- _stackgetword_vbuc1=vwuz1
// [13] return (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
tsx
lda.z return
sta STACK_BASE+2,x
@ -513,13 +624,13 @@ plus: {
.label a = 2
.label b = 4
.label return = 2
// [10] (word) plus::a#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackgetword_vbuc1
// [10] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
lda STACK_BASE+OFFSET_STACK_A+1,x
sta.z a+1
// [11] (word) plus::b#0 ← paramstack(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackgetword_vbuc1
// [11] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -537,7 +648,7 @@ plus: {
// plus::@return
// }
// [13] return (word) plus::return#0
// [13] return (word) plus::return#0 -- _stackgetword_vbuc1=vwuz1
// [13] return (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
tsx
lda.z return
sta STACK_BASE+2,x

View File

@ -29,8 +29,8 @@ main::@return: scope:[main] from main::@1
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
plus: scope:[plus] from
[15] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A)
[16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B)
[15] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A)
[16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B)
[17] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus

View File

@ -170,8 +170,8 @@ Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Calling convention STACK_CALL adding prepare/execute/finalize for [7] (byte) main::w#0 ← call plus (byte) '0' (byte) main::v#0
Calling convention STACK_CALL replacing param((byte) plus::a) with paramstack(byte,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((byte) plus::b) with paramstack(byte,(const byte) plus::OFFSET_STACK_B)
Calling convention STACK_CALL replacing param((byte) plus::a) with stackidx(byte,(const byte) plus::OFFSET_STACK_A)
Calling convention STACK_CALL replacing param((byte) plus::b) with stackidx(byte,(const byte) plus::OFFSET_STACK_B)
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
@ -205,8 +205,8 @@ main::@return: scope:[main] from main::@1
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
plus: scope:[plus] from
[15] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A)
[16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B)
[15] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A)
[16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B)
[17] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0
to:plus::@return
plus::@return: scope:[plus] from plus
@ -352,11 +352,11 @@ plus: {
.label a = 6
.label b = 7
.label return = 8
// [15] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [15] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuz1=_stackgetbyte_vbuc1
// [16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
sta.z b
@ -369,7 +369,7 @@ plus: {
// plus::@return
breturn:
// [18] return (byte) plus::return#0
// [18] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuz1
// [18] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuz1
lda.z return
tsx
sta STACK_BASE+1,x
@ -382,9 +382,9 @@ Statement [7] callprepare plus (byte) '0' (byte) main::v#0 [ main::a#2 ] ( main
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::a#2 main::a#1 ]
Statement [9] (byte) main::w#0 ← callfinalize plus [ main::a#2 main::w#0 ] ( main:2 [ main::a#2 main::w#0 ] ) always clobbers reg byte a
Statement [10] (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 [15] (byte) plus::a#0 ← paramstack(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
Statement [15] (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
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:2 [ main::a#2 main::a#1 ]
Statement [16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:8 [ main::a#2 plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:8 [ main::a#2 plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ plus::a#0 ]
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:6 [ plus::a#0 ]
Statement [17] (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
@ -392,8 +392,8 @@ Statement [18] return (byte) plus::return#0 [ ] ( main:2::plus:8 [ main::a#2 ] )
Statement [7] callprepare plus (byte) '0' (byte) main::v#0 [ main::a#2 ] ( main:2 [ main::a#2 ] ) always clobbers reg byte a
Statement [9] (byte) main::w#0 ← callfinalize plus [ main::a#2 main::w#0 ] ( main:2 [ main::a#2 main::w#0 ] ) always clobbers reg byte a
Statement [10] (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 [15] (byte) plus::a#0 ← paramstack(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
Statement [16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:8 [ main::a#2 plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [15] (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
Statement [16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:8 [ main::a#2 plus::a#0 plus::b#0 ] ) always clobbers reg byte a reg byte x
Statement [17] (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 [18] return (byte) plus::return#0 [ ] ( main:2::plus:8 [ main::a#2 ] ) always clobbers reg byte x
Potential registers zp ZP_BYTE:2 [ main::a#2 main::a#1 ] : zp ZP_BYTE:2 , reg byte y ,
@ -499,11 +499,11 @@ plus: {
.const OFFSET_STACK_A = 0
.const OFFSET_STACK_B = 1
.label a = 2
// [15] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [15] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackgetbyte_vbuc1
// [16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// [17] (byte) plus::return#0 ← (byte) plus::a#0 + (byte) plus::b#0 -- vbuaa=vbuz1_plus_vbuaa
@ -513,7 +513,7 @@ plus: {
// plus::@return
breturn:
// [18] return (byte) plus::return#0
// [18] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuaa
// [18] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuaa
tsx
sta STACK_BASE+1,x
rts
@ -661,11 +661,11 @@ plus: {
.const OFFSET_STACK_A = 0
.const OFFSET_STACK_B = 1
.label a = 2
// [15] (byte) plus::a#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackgetbyte_vbuc1
// [15] (byte) plus::a#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// [16] (byte) plus::b#0 ← paramstack(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackgetbyte_vbuc1
// [16] (byte) plus::b#0 ← stackidx(byte,(const byte) plus::OFFSET_STACK_B) -- vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// return a+b;
@ -675,7 +675,7 @@ plus: {
// plus::@return
// }
// [18] return (byte) plus::return#0
// [18] return (byte) plus::return#0 -- _stackgetbyte_vbuc1=vbuaa
// [18] return (byte) plus::return#0 -- _stackidxbyte_vbuc1=vbuaa
tsx
sta STACK_BASE+1,x
rts