diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-24 21:57:24 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-24 21:57:24 -0600 |
commit | c5ff7e6a0d4d589d2f3c6143efc933a532baf0a5 (patch) | |
tree | 26eb7f2a7fff60fb85dd88e257777c030bba3c60 | |
parent | 62091005231095abbf8e2cebbfce708815cb63f0 (diff) |
Backed up callee/caller saved registers in VaporizeVisitor
-rw-r--r-- | V2VM.java | 10 | ||||
-rw-r--r-- | vaporize/library/VaporizeVisitor.java | 47 |
2 files changed, 51 insertions, 6 deletions
@@ -65,11 +65,11 @@ public class V2VM { }; boolean allowLocals = true; String[] registers = { - "v0", "v1", - "a0", "a1", "a2", "a3", - "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", - "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", - "t8", + "$v0", "$v1", + "$a0", "$a1", "$a2", "$a3", + "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", + "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", + "$t8", }; boolean allowStack = false; 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(), |