summaryrefslogtreecommitdiff
path: root/vaporize/LIRVar.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/LIRVar.java
parent012298517078170762112abe2654dc69b2f146e1 (diff)
Rearrange directory structure
Diffstat (limited to 'vaporize/LIRVar.java')
-rw-r--r--vaporize/LIRVar.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/vaporize/LIRVar.java b/vaporize/LIRVar.java
new file mode 100644
index 0000000..da23af5
--- /dev/null
+++ b/vaporize/LIRVar.java
@@ -0,0 +1,80 @@
+package vaporize;
+
+import misc.*;
+
+public class LIRVar implements Comparable<LIRVar> {
+
+ private String alias;
+ private TransientInterval interval;
+
+ private String register;
+
+ public LIRVar(String alias, int fd, int lu) {
+ this.alias = alias;
+ this.interval = new TransientInterval(fd, lu);
+ this.register = null;
+ }
+
+ @Override public String toString() {
+ return String.format("%s: %d -> %d",
+ this.alias,
+ this.interval.first_def,
+ this.interval.last_use);
+ }
+
+ @Override public boolean equals(Object other) {
+ return (other instanceof LIRVar &&
+ ((LIRVar) other).alias.equals(this.alias) &&
+ ((LIRVar) other).interval.equals(this.interval)) ||
+ (other instanceof String &&
+ this.alias.equals((String) other));
+ }
+
+ @Override public int hashCode() {
+ return alias.hashCode();
+ }
+
+ @Override public int compareTo(LIRVar other) {
+ int ret;
+ if (this.interval.first_def > other.interval.first_def)
+ ret = 1;
+ else if (this.interval.first_def < other.interval.first_def)
+ ret = -1;
+ else
+ ret = 0;
+ return ret;
+ }
+
+ protected boolean trySetLastUse(int last_use) {
+ /**
+ * If the passed last_use is greater than
+ * the this.last_use, override this.last_use.
+ */
+ boolean ret = last_use > this.interval.last_use;
+
+ if (ret)
+ this.interval.last_use = last_use;
+ else
+ MinimalLogger.info(String.format("Bad order! %s %d >= %d",
+ this.alias,
+ this.interval.last_use,
+ last_use));
+ return ret;
+ }
+
+ public void assignRegister(String register) {
+ this.register = register;
+ }
+
+ public int getFirstDef() {
+ return this.interval.first_def;
+ }
+
+ public int getLastUse() {
+ return this.interval.last_use;
+ }
+
+ public String getAssignedRegister() {
+ return this.register;
+ }
+}