From 04fd097fb51346f655c7bdc0c88b85e29359ef1c Mon Sep 17 00:00:00 2001 From: bd-912 Date: Sat, 20 Apr 2024 23:43:30 -0600 Subject: Non-function live-interval computation algorithm --- vaporize/library/LIRVar.java | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 vaporize/library/LIRVar.java (limited to 'vaporize/library/LIRVar.java') diff --git a/vaporize/library/LIRVar.java b/vaporize/library/LIRVar.java new file mode 100644 index 0000000..4fab8c8 --- /dev/null +++ b/vaporize/library/LIRVar.java @@ -0,0 +1,64 @@ +package vaporize.library; + +import misc.*; + +public class LIRVar implements Comparable { + + 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) { + LIRVar o; + return (other instanceof LIRVar && + ((o = (LIRVar) other)).alias.equals(this.alias) && + o.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; + return ret; + } + + public void assignRegister(String register) { + this.register = register; + } +} -- cgit v1.2.3