diff options
Diffstat (limited to 'vaporize/VaporizeVisitor.java')
-rw-r--r-- | vaporize/VaporizeVisitor.java | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/vaporize/VaporizeVisitor.java b/vaporize/VaporizeVisitor.java index ba319cb..f9ad6c0 100644 --- a/vaporize/VaporizeVisitor.java +++ b/vaporize/VaporizeVisitor.java @@ -26,7 +26,9 @@ 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() + 14)); + vp.functions[i].ident, Math.max(vp.functions[i].params.length-4, 0), + interval_list.get(i).getOutNum(), + interval_list.get(i).getSpilledNum() + 14)); for (int j = 0; j < this.callee_save.length; ++j) { this.addVaporm(String.format(" local[%s] = %s", j, @@ -34,11 +36,16 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException> } for (int j = 0; j < vp.functions[i].params.length; ++j) - this.addVaporm(String.format(" %s = %s", - interval_list.get(i).getInterval(vp.functions[i].params[j].toString()) - .getAssignedRegister(), - arg_pass[j])); - + if (j < 4) { // is in a registers + this.addVaporm(String.format(" %s = %s", + interval_list.get(i).getInterval(vp.functions[i].params[j].toString()) + .getAssignedRegister(), + arg_pass[j])); + } else // is in 'out' + this.addVaporm(String.format(" %s = in[%s]", + interval_list.get(i).getInterval(vp.functions[i].params[j].toString()) + .getAssignedRegister(), + j-4)); TreeSet<Node> f = this.sortFunction(vp.functions[i]); MinimalLogger.info(String.format("Starting loop with function:\n %s", @@ -77,9 +84,12 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException> if (r.contains("local")) {// SPILL int i = this.spill_stack.size(); String reg = this.spillers[i]; - this.addVaporm(String.format(" %s = %s", - reg, - r)); + String str = String.format(" %s = %s", + reg, + r); + MinimalLogger.info(String.format("Adding string:\n%s", + str)); + this.vaporm.add(str); this.spill_stack.push(String.format(" %s = %s", r, reg)); @@ -101,6 +111,7 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException> MinimalLogger.info(String.format("Adding string:\n%s", str)); this.vaporm.add(str); + this.emptySpillStack(); } public void visit(LIRDict d, VAssign n) throws RuntimeException { @@ -132,16 +143,21 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException> this.caller_save[i])); } - // FIXME for arg num > 4! for (int i = 0; i < n.args.length; ++i) { String reg = (n.args[i] instanceof VVarRef.Local) ? this.getRegister(n.args[i].toString()) : n.args[i].toString(); - MinimalLogger.info(String.format("Adding argument for %s", - n.args[i].toString())); - this.addVaporm(String.format(" %s = %s", - this.arg_pass[i], - reg)); + if (i < 4) {// we have registers + MinimalLogger.info(String.format("Adding argument for %s", + n.args[i].toString())); + this.addVaporm(String.format(" %s = %s", + this.arg_pass[i], + reg)); + } else { // use 'out' + this.addVaporm(String.format(" out[%s] = %s", + i-4, + reg)); + } } MinimalLogger.severe(String.format("n addr: %s", |