namespace llvm {
// Forward declarations.
class MachineRegisterInfo;
+class TargetRegisterInfo;
/// This pass implements the reg bank selector pass used in the GlobalISel
/// pipeline. At the end of this pass, all register operands have been assigned
/// pass uses and updates.
MachineRegisterInfo *MRI;
+ /// Information on the register classes for the current function.
+ const TargetRegisterInfo *TRI;
+
/// Helper class used for every code morphing.
MachineIRBuilder MIRBuilder;
RBI = MF.getSubtarget().getRegBankInfo();
assert(RBI && "Cannot work without RegisterBankInfo");
MRI = &MF.getRegInfo();
+ TRI = MF.getSubtarget().getRegisterInfo();
MIRBuilder.setMF(MF);
}
if (ValMapping.BreakDown.size() > 1)
return false;
- const RegClassOrRegBank &CurAssignment = MRI->getRegClassOrRegBank(Reg);
- // Nothing assigned, the assignment does not match.
- if (!CurAssignment)
- return false;
- // Get the register bank form the current assignment.
- const RegisterBank *CurRegBank = nullptr;
- if (CurAssignment.is<const TargetRegisterClass *>())
- CurRegBank = &RBI->getRegBankFromRegClass(
- *CurAssignment.get<const TargetRegisterClass *>());
- else
- CurRegBank = CurAssignment.get<const RegisterBank *>();
- return CurRegBank == ValMapping.BreakDown[0].RegBank;
+ return RBI->getRegBank(Reg, *MRI, *TRI) == ValMapping.BreakDown[0].RegBank;
}
unsigned