modified function call sp = fp - (sp_off + n_args + 1)*wordSize

master
bill 4 years ago
parent 273ee2a092
commit b8781807fd

@ -327,11 +327,11 @@ public class CodeGenImpl extends CodeGenBase
curr = curr.getParentFuncInfo();
}
backend.emitSW(tmp, SP, -1 * wordSize, "Push static link onto active frame.");
backend.emitSW(tmp, FP, -(1+sp_off) * wordSize, "Push static link onto active frame.");
freeRegister(tmpHandle);
}
else {
backend.emitSW(FP, SP, -1 * wordSize, "Push static link onto active frame.");
backend.emitSW(FP, FP, -(1+sp_off) * wordSize, "Push static link onto active frame.");
}
List<Expr> args = node.args;
@ -368,12 +368,12 @@ public class CodeGenImpl extends CodeGenBase
// All expressions should save their end result in A0
// So, once expr is evaluated add value inside A0 onto stack as an actual argument
backend.emitSW(A0, SP, -slotNum * wordSize, "Push actual argument for " + formalParamName + " onto stack");
backend.emitSW(A0, FP, -(slotNum+sp_off) * wordSize, "Push actual argument for " + formalParamName + " onto stack");
}
backend.emitADDI(SP, SP, -spaceRequiredForArgs, "Set SP to last argument.");
backend.emitADDI(SP, FP, -spaceRequiredForArgs-sp_off*wordSize, "Set SP to last argument.");
backend.emitJAL(calleeFunctionInfo.getCodeLabel(), "Invoke function: " + functionId.name);
backend.emitADDI(SP, SP, spaceRequiredForArgs, "Set SP to stack frame top.");
backend.emitADDI(SP, FP, spaceRequiredForArgs+sp_off*wordSize, "Set SP to stack frame top.");
}
return A0;
@ -1030,7 +1030,7 @@ public class CodeGenImpl extends CodeGenBase
backend.emitMV(iter, Register.ZERO, "Initialize index variable");
backend.emitSW(iter, Register.FP, -sp_off*wordSize, "Store index on stack");
incSp(1);
backend.emitADDI(Register.SP, Register.SP, -2*wordSize, "Set SP to last argument");
//backend.emitADDI(Register.SP, Register.SP, -2*wordSize, "Set SP to last argument");
backend.emitLocalLabel(startLoop, "Start for loop");
backend.emitLW(iter, Register.FP, -(sp_off-1)*wordSize, "Load index from stack");
backend.emitLW(l, Register.FP, -(sp_off-2)*wordSize, "Load string location from stack");

Loading…
Cancel
Save