summaryrefslogtreecommitdiff
path: root/vaporize/library/LIRDict.java
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize/library/LIRDict.java')
-rw-r--r--vaporize/library/LIRDict.java86
1 files changed, 0 insertions, 86 deletions
diff --git a/vaporize/library/LIRDict.java b/vaporize/library/LIRDict.java
deleted file mode 100644
index d924d5e..0000000
--- a/vaporize/library/LIRDict.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package vaporize.library;
-
-import cs132.vapor.ast.VFunction;
-import cs132.vapor.ast.VInstr;
-
-import misc.*;
-import cfg.*;
-import java.util.*;
-
-public class LIRDict {
-
- private TreeSet<LIRVar> intervals;
- private int spilled_num; // the number of spilled registers
- private ControlFlowGraph cfg;
-
- public LIRDict(VFunction f, ControlFlowGraph cfg) {
-
- this.intervals = new TreeSet<LIRVar>((v1, v2) -> {
- return (v1.compareTo(v2) != 0) ? v1.compareTo(v2) : v1.equals(v2) ? 0 : 1;
- });
- this.cfg = cfg;
-
- for (VInstr s : f.body) {
- CFGNode n = cfg.getNode(s);
- int line = n.getInstruction().sourcePos.line;
-
- String info = "L" + line;
- for (String var : n.getReaching())
- if (!this.contains(var)) {
- this.intervals.add(new LIRVar(var, line, line));
- MinimalLogger.info(String.format("Reaching on %s --- New var %s",
- info,
- var));
- } else {
- this.getInterval(var).trySetLastUse(line);
- MinimalLogger.info(String.format("Reaching on %s --- Updating var %s",
- info,
- var));
- }
- for (String var : n.getLiveness()) {
- if (!this.contains(var))
- MinimalLogger.severe(String.format("%s was used before defined!",
- var));
- MinimalLogger.info(String.format("Liveness on %s --- Updating var %s",
- info,
- var));
- this.getInterval(var).trySetLastUse(line);
- }
-
- }
- }
-
- public LIRVar getInterval(String s) {
- LIRVar ret = null;
- for (LIRVar v : this.intervals) {
- if (v.equals(s)) {
- ret = v;
- break;
- }
- }
-
- return ret;
- }
-
- public boolean contains(String s) {
- return this.getInterval(s) != null;
- }
-
- public SortedSet<LIRVar> getIntervals() {
- // TODO Make this class iterable instead
- return Collections.unmodifiableSortedSet(this.intervals);
- }
-
- public String getFunction() {
- return this.cfg.getFunction();
- }
-
- public void addSpilledNum() {
- ++this.spilled_num;
- }
-
- public int getSpilledNum() {
- return this.spilled_num;
- }
-
-}