blob: da23af5b99abf5f1975392ab9fa2473482da0642 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
}
}
|