Add an Index<Value> implementation to Liveness.

Use it to access live ranges that are supposed to be there.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-29 15:13:04 -07:00
parent 3fbcdb4ea6
commit 51dcabd87c
4 changed files with 17 additions and 12 deletions

View File

@@ -183,6 +183,7 @@ use regalloc::affinity::Affinity;
use regalloc::liverange::LiveRange;
use sparse_map::SparseMap;
use std::mem;
use std::ops::Index;
/// A set of live ranges, indexed by value number.
type LiveRangeSet = SparseMap<Value, LiveRange>;
@@ -451,3 +452,14 @@ impl Liveness {
}
}
}
impl Index<Value> for Liveness {
type Output = LiveRange;
fn index(&self, index: Value) -> &LiveRange {
match self.ranges.get(index) {
Some(lr) => lr,
None => panic!("{} has no live range", index),
}
}
}