summaryrefslogtreecommitdiff
path: root/vaporize
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize')
-rw-r--r--vaporize/library/VaporizeVisitor.java47
1 files changed, 46 insertions, 1 deletions
diff --git a/vaporize/library/VaporizeVisitor.java b/vaporize/library/VaporizeVisitor.java
index 11f0bc5..c51cf99 100644
--- a/vaporize/library/VaporizeVisitor.java
+++ b/vaporize/library/VaporizeVisitor.java
@@ -9,6 +9,11 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
private ArrayList<String> vaporm;
+ String[] callee_save = new String[] { "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7" };
+ String[] caller_save = new String[] { "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8" };
+ String[] arg_pass = new String[] { "$a0", "$a1", "$a2", "$a3" };
+ String[] ret_pass = new String[] { "$v0" };
+
public VaporizeVisitor(VaporProgram vp, ArrayList<String> vaporm, ArrayList<LIRDict> interval_list) {
this.vaporm = vaporm;
@@ -16,9 +21,16 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
// function in vp to be out of order?
for (int i = 0; i < vp.functions.length; ++i) {
this.addVaporm(String.format("func %s [in %d, out %d, local %d]",
- vp.functions[i].ident, 0, 0, interval_list.get(i).getSpilledNum()));
+ vp.functions[i].ident, 0, 0, interval_list.get(i).getSpilledNum() + 17));
+ for (int j = 0; j < this.callee_save.length; ++j) {
+ this.addVaporm(String.format(" local[%s] = %s",
+ j,
+ this.callee_save[j]));
+ }
+
for (VInstr s : vp.functions[i].body)
s.accept(interval_list.get(i), this);
+
}
}
@@ -54,6 +66,33 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
n.getClass().getSimpleName(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
+
+ for (int i = 0; i < this.caller_save.length; ++i) {
+ this.addVaporm(String.format(" local[%s] = %s",
+ i+8,
+ this.caller_save[i]));
+ }
+
+ String ret = " ";
+ // get dest
+ if (n.dest != null) {
+ ret += String.format("%s = ",
+ d.getInterval(((VVarRef.Local) n.dest).ident).getAssignedRegister());
+ }
+ ret += d.getInterval(n.addr.toString()).getAssignedRegister() + "(";
+ for (VOperand a : n.args) {
+ ret += (a instanceof VVarRef.Local) ?
+ d.getInterval(a.toString()).getAssignedRegister()
+ : a.toString();
+ ret += " ";
+ }
+ this.addVaporm(ret + ")"); //FIXME
+
+ for (int i = 0; i < this.caller_save.length; ++i) {
+ this.addVaporm(String.format(" %s = local[%s]",
+ this.caller_save[i],
+ i+8));
+ }
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (%s)",
n.getClass().getSimpleName(),
@@ -136,6 +175,12 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
n.getClass().getSimpleName(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
+ for (int j = 0; j < this.callee_save.length; ++j) {
+ this.addVaporm(String.format(" %s = local[%s]",
+ this.callee_save[j],
+ j));
+ }
+ this.addVaporm(" ret"); //FIXME
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (%s)",
n.getClass().getSimpleName(),