summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-26 14:16:18 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-26 14:16:18 -0600
commite33c81c013f78589a01143c36225825c8cf42707 (patch)
tree98f5ee66d9da62e1b832999ada68964e175ebf77
parent9252e0f965347ba3b338fe9c35e86a0fa15c9f20 (diff)
VaporizeVisitor add the rest of the (untested) Syntax
-rw-r--r--vaporize/library/VaporizeVisitor.java70
1 files changed, 67 insertions, 3 deletions
diff --git a/vaporize/library/VaporizeVisitor.java b/vaporize/library/VaporizeVisitor.java
index ca1b3de..0dfca02 100644
--- a/vaporize/library/VaporizeVisitor.java
+++ b/vaporize/library/VaporizeVisitor.java
@@ -28,12 +28,40 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
this.callee_save[j]));
}
- for (VInstr s : vp.functions[i].body)
- s.accept(interval_list.get(i), this);
+ 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]));
+
+ TreeSet<Node> f = this.sortFunction(vp.functions[i]);
+ MinimalLogger.info(String.format("Starting loop with function:\n %s",
+ f.toString()));
+
+ for (Node n : f) {
+ if (n instanceof VInstr)
+ ((VInstr) n).accept(interval_list.get(i), this);
+ else
+ this.addVaporm(((VCodeLabel) n).ident + ":");
+ }
}
}
+ public TreeSet<Node> sortFunction(VFunction f) {
+ TreeSet<Node> sort = new TreeSet<Node>((v1, v2) -> {
+ return Integer.compare(v1.sourcePos.line, v2.sourcePos.line);
+ });
+
+ for (VInstr s : f.body) {
+ sort.add(s);
+ }
+ for (VCodeLabel l : f.labels) {
+ sort.add(l);
+ }
+ return sort;
+ }
+
public ArrayList<String> getVaporm() {
return this.vaporm;
}
@@ -109,6 +137,28 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
n.getClass().getSimpleName(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
+ String ret = "";
+ if (n.dest != null) {
+ ret += String.format("%s = ",
+ d.getInterval(((VVarRef.Local) n.dest).ident)
+ .getAssignedRegister());
+ }
+ ret += String.format("%s(",
+ ((VBuiltIn.Op) n.op).name);
+
+ String par;
+ for (VOperand a : n.args) {
+ par = (a instanceof VVarRef.Local) ?
+ d.getInterval(a.toString()).getAssignedRegister()
+ : a.toString();
+ ret += String.format("%s ",
+ par);
+ }
+
+ ret += ")";
+
+ this.addVaporm(String.format(" %s",
+ ret));
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (%s)",
n.getClass().getSimpleName(),
@@ -158,6 +208,19 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
n.getClass().getSimpleName(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
+ String ret = " ";
+ if (n.positive)
+ ret += "if ";
+ else
+ ret += "if0 ";
+
+ ret += d.getInterval(n.value.toString())
+ .getAssignedRegister() + " goto :";
+
+ ret += n.target.ident;
+
+ this.addVaporm(String.format("%s",
+ ret));
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (%s)",
n.getClass().getSimpleName(),
@@ -169,7 +232,8 @@ public class VaporizeVisitor extends VInstr.VisitorP<LIRDict, RuntimeException>
n.getClass().getSimpleName(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
-
+ this.addVaporm(String.format(" goto :%s",
+ (((VAddr.Label) n.target).label).ident));
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (%s)",
n.getClass().getSimpleName(),