-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLiveSet.java
53 lines (51 loc) · 1.14 KB
/
LiveSet.java
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
package com.compilerprogramming.ezlang.compiler;
import java.util.BitSet;
import java.util.List;
public class LiveSet extends BitSet {
public LiveSet(int numRegs) {
super(numRegs);
}
public LiveSet dup() {
return (LiveSet) clone();
}
public void live(Register r) {
set(r.id, true);
}
public void dead(Register r) {
set(r.id, false);
}
public void live(List<Register> regs) {
for (Register r : regs) {
live(r);
}
}
public void add(Register r) {
set(r.id, true);
}
public void remove(Register r) {
set(r.id, false);
}
public void remove(List<Register> regs) {
for (Register r : regs) {
remove(r);
}
}
public boolean contains(Register r) {
return get(r.id);
}
public LiveSet intersect(LiveSet other) {
and(other);
return this;
}
public LiveSet union(LiveSet other) {
or(other);
return this;
}
/**
* Computes this - other.
*/
public LiveSet subtract(LiveSet other) {
andNot(other);
return this;
}
}