From 1851f5e76018ec1df3b55dce6cc9a64c9497bf7a Mon Sep 17 00:00:00 2001 From: bd-912 Date: Fri, 26 Apr 2024 15:50:38 -0600 Subject: Rearrange directory structure --- vaporize/library/LIRDict.java | 86 ------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 vaporize/library/LIRDict.java (limited to 'vaporize/library/LIRDict.java') 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 intervals; - private int spilled_num; // the number of spilled registers - private ControlFlowGraph cfg; - - public LIRDict(VFunction f, ControlFlowGraph cfg) { - - this.intervals = new TreeSet((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 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; - } - -} -- cgit v1.2.3