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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user