Add a few register utilities.

This commit is contained in:
Jakob Stoklund Olesen
2017-05-02 09:59:58 -07:00
parent aaa70a677d
commit f8a3a01f96
3 changed files with 51 additions and 1 deletions

View File

@@ -151,6 +151,11 @@ impl RegClassData {
let uoffset = offset * self.width as usize;
self.first + uoffset as RegUnit
}
/// Does this register class contain `regunit`?
pub fn contains(&self, regunit: RegUnit) -> bool {
self.mask[(regunit / 32) as usize] & (1u32 << (regunit % 32)) != 0
}
}
impl fmt::Display for RegClassData {