Implement legalize_signature for RISC-V.

Add an abi module with code that is probably useful to all ISAs when
implementing this function.

Add a unit() method to RegClassData which can be used to index the
register units in a class.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-02 16:01:56 -08:00
parent 07f459fb93
commit 42e7021865
7 changed files with 180 additions and 4 deletions

View File

@@ -108,6 +108,9 @@ pub struct RegClassData {
/// How many register units to allocate per register.
pub width: u8,
/// The first register unit in this class.
pub first: RegUnit,
/// Bit-mask of sub-classes of this register class, including itself.
///
/// Bits correspond to RC indexes.
@@ -142,6 +145,12 @@ impl RegClassData {
pub fn has_subclass<RCI: Into<RegClassIndex>>(&self, other: RCI) -> bool {
self.subclasses & (1 << other.into().0) != 0
}
/// Get a specific register unit in this class.
pub fn unit(&self, offset: usize) -> RegUnit {
let uoffset = offset * self.width as usize;
self.first + uoffset as RegUnit
}
}
/// A small reference to a register class.