summaryrefslogtreecommitdiff
path: root/vaporize/SpillEverywhere.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-26 15:50:38 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-26 15:50:38 -0600
commit1851f5e76018ec1df3b55dce6cc9a64c9497bf7a (patch)
tree30f629f7b137a494d4202487f4e22df2d9456481 /vaporize/SpillEverywhere.java
parent012298517078170762112abe2654dc69b2f146e1 (diff)
Rearrange directory structure
Diffstat (limited to 'vaporize/SpillEverywhere.java')
-rw-r--r--vaporize/SpillEverywhere.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/vaporize/SpillEverywhere.java b/vaporize/SpillEverywhere.java
new file mode 100644
index 0000000..317c79d
--- /dev/null
+++ b/vaporize/SpillEverywhere.java
@@ -0,0 +1,92 @@
+package vaporize;
+
+import cs132.vapor.ast.*;
+import st.*;
+import misc.*;
+import java.util.*;
+
+public class SpillEverywhere extends VInstr.VisitorPR<String, String, RuntimeException> {
+
+ private VaporProgram vp;
+ private Kettle kettle;
+
+ public SpillEverywhere(VaporProgram vp, ArrayList<String> vapor) {
+ this.vp = vp;
+ this.kettle = new Kettle(vapor);
+
+ 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);
+ }
+ }
+ MinimalLogger.info(kettle.dump());
+ }
+
+
+ public String visit(String p, VMemRead n) throws RuntimeException {
+ MinimalLogger.info(String.format("->%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n).trim(),
+ n.sourcePos.toString()));
+ return null;
+ }
+
+ public String visit(String p, VMemWrite n) throws RuntimeException {
+ MinimalLogger.info(String.format("->%s (%s:%s)",
+ n.getClass().getSimpleName(),
+ 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)",
+ n.getClass().getSimpleName(),
+ 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)",
+ n.getClass().getSimpleName(),
+ 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)",
+ n.getClass().getSimpleName(),
+ 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)",
+ n.getClass().getSimpleName(),
+ 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)",
+ n.op.name,
+ 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)",
+ n.getClass().getSimpleName(),
+ this.kettle.get(n).trim(),
+ n.sourcePos.toString()));
+ return null;
+ }
+
+}