|
|
@ -536,11 +536,11 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
|
|
|
|
|
|
|
//Store address and length of lists on stack
|
|
|
|
//Store address and length of lists on stack
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Store address of first list");
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Store address of first list");
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
backend.emitSW(Register.T0, Register.FP, -sp_off*wordSize, "Store address of second list");
|
|
|
|
backend.emitSW(Register.T0, Register.FP, -sp_off*wordSize, "Store address of second list");
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
backend.emitSW(Register.T3, Register.FP, -sp_off*wordSize, "Store length of combined list");
|
|
|
|
backend.emitSW(Register.T3, Register.FP, -sp_off*wordSize, "Store length of combined list");
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
|
|
|
|
|
|
|
|
//Allocate space on heap
|
|
|
|
//Allocate space on heap
|
|
|
|
backend.emitLA(Register.A0, listClass.getPrototypeLabel(), "Load empty list");
|
|
|
|
backend.emitLA(Register.A0, listClass.getPrototypeLabel(), "Load empty list");
|
|
|
@ -581,7 +581,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node.right.dispatch(this);
|
|
|
|
node.right.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
sp_off--;
|
|
|
|
sp_off--;
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
@ -656,7 +656,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node.right.dispatch(this);
|
|
|
|
node.right.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
sp_off--;
|
|
|
|
sp_off--;
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
@ -667,7 +667,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node.right.dispatch(this);
|
|
|
|
node.right.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
sp_off--;
|
|
|
|
sp_off--;
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
@ -679,7 +679,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
Label label = generateLocalLabel();
|
|
|
|
Label label = generateLocalLabel();
|
|
|
|
node.left.dispatch(this);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
backend.emitBEQZ(Register.A0, label, "If first operand is false, don't check second");
|
|
|
|
backend.emitBEQZ(Register.A0, label, "If first operand is false, don't check second");
|
|
|
|
node.right.dispatch(this);
|
|
|
|
node.right.dispatch(this);
|
|
|
|
sp_off--;
|
|
|
|
sp_off--;
|
|
|
@ -692,7 +692,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
Label label = generateLocalLabel();
|
|
|
|
Label label = generateLocalLabel();
|
|
|
|
node.left.dispatch(this);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
backend.emitBNEZ(Register.A0, label, "If first operand is true, don't check second");
|
|
|
|
backend.emitBNEZ(Register.A0, label, "If first operand is true, don't check second");
|
|
|
|
node.right.dispatch(this);
|
|
|
|
node.right.dispatch(this);
|
|
|
|
sp_off--;
|
|
|
|
sp_off--;
|
|
|
@ -714,7 +714,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node.right.dispatch(this);
|
|
|
|
node.right.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
node.left.dispatch(this);
|
|
|
|
sp_off--;
|
|
|
|
sp_off--;
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
|
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
|
|
|
@ -783,7 +783,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
node.value.dispatch(this);
|
|
|
|
node.value.dispatch(this);
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Store variable "+node.var.identifier.name+" value in Stack");
|
|
|
|
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Store variable "+node.var.identifier.name+" value in Stack");
|
|
|
|
offsetMap.put(svi, sp_off);
|
|
|
|
offsetMap.put(svi, sp_off);
|
|
|
|
sp_off++;
|
|
|
|
incSp(1);
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|