summaryrefslogtreecommitdiff
path: root/vaporize/library/SpillEverywhere.java
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize/library/SpillEverywhere.java')
-rw-r--r--vaporize/library/SpillEverywhere.java54
1 files changed, 20 insertions, 34 deletions
diff --git a/vaporize/library/SpillEverywhere.java b/vaporize/library/SpillEverywhere.java
index d6671bf..993bfa6 100644
--- a/vaporize/library/SpillEverywhere.java
+++ b/vaporize/library/SpillEverywhere.java
@@ -9,96 +9,82 @@ public class SpillEverywhere extends VInstr.VisitorPR<String, String, RuntimeExc
private VaporProgram vp;
private Kettle kettle;
- private String vaporm;
-
- // public CFGSimp(VaporProgram v) {
-
- // // nodes
- // for (VInstr s : n.body)
- // this.cfg.addNode(new CFGNode(s));
-
- // // edges
- // for (VInstr s : n.body)
- // s.accept("", this);
-
- // System.out.println(this.cfg.getNodes().toString());
- // }
public SpillEverywhere(VaporProgram vp, ArrayList<String> vapor) {
this.vp = vp;
this.kettle = new Kettle(vapor);
- this.vaporm = "";
- for (VFunction f : vp.functions) {
+ for (VFunction f : this.vp.functions) {
+ MinimalLogger.severe("Num : " + Arrays.toString(f.vars));
+ this.kettle.replaceFunctionDeclare(f, 0, 0, 3); // use three registers for "spill everywhere"
for (VInstr s : f.body) {
s.accept("", this);
}
- this.kettle.replaceFunctionDeclare(f, 0, 0, 0);
}
MinimalLogger.info(kettle.dump());
}
+
public String visit(String p, VMemRead n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VMemWrite n) throws RuntimeException {
- System.out.println("HEY!");
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VAssign n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VBranch n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VGoto n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VCall n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VBuiltIn n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.op.name,
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}
public String visit(String p, VReturn n) throws RuntimeException {
- MinimalLogger.info(String.format("%s (%s:%s)",
+ MinimalLogger.info(String.format("->%s (%s:%s)",
n.getClass().getSimpleName(),
- this.kettle.get(n),
+ this.kettle.get(n).trim(),
n.sourcePos.toString()));
return null;
}