Add a regs_overlap function to the isa module.

Test it with the arm32 register banks which have the most interesting
properties. Most other registers have a single register unit.
This commit is contained in:
Jakob Stoklund Olesen
2017-05-08 12:20:35 -07:00
parent aecd90a1b9
commit aaa70a677d
3 changed files with 47 additions and 2 deletions

View File

@@ -188,6 +188,16 @@ impl fmt::Display for RegClassIndex {
}
}
/// Test of two registers overlap.
///
/// A register is identified as a `(RegClass, RegUnit)` pair. The register class is needed to
/// determine the width (in regunits) of the register.
pub fn regs_overlap(rc1: RegClass, reg1: RegUnit, rc2: RegClass, reg2: RegUnit) -> bool {
let end1 = reg1 + rc1.width as RegUnit;
let end2 = reg2 + rc2.width as RegUnit;
!(end1 <= reg2 || end2 <= reg1)
}
/// Information about the registers in an ISA.
///
/// The `RegUnit` data structure collects all relevant static information about the registers in an