[MachineVerifier] Teach how to check some of the properties of generic

virtual registers.

Generic virtual registers:
- May not have a register class
- May not have a register bank
- If they do not have a register class they must have a size
- If they have a register bank, the size of the register bank must be
  greater or equal to the size of the virtual register (basically check
  that the virtual register will fit into that register class)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265798 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Quentin Colombet 2016-04-08 16:35:22 +00:00
parent b246969303
commit 7500ba0386

View File

@ -984,7 +984,30 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
}
} else {
// Virtual register.
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
const TargetRegisterClass *RC = MRI->getRegClassOrNull(Reg);
if (!RC) {
// This is a generic virtual register.
// It must have a size and it must not have a SubIdx.
unsigned Size = MRI->getSize(Reg);
if (!Size) {
report("Generic virtual register must have a size", MO, MONum);
return;
}
// Make sure the register fits into its register bank if any.
const RegisterBank *RegBank = MRI->getRegBankOrNull(Reg);
if (RegBank && RegBank->getSize() < Size) {
report("Register bank is too small for virtual register", MO,
MONum);
errs() << "Register bank " << RegBank->getName() << " too small("
<< RegBank->getSize() << ") to fit " << Size << "-bits\n";
return;
}
if (SubIdx) {
report("Generic virtual register does not subregister index", MO, MONum);
return;
}
break;
}
if (SubIdx) {
const TargetRegisterClass *SRC =
TRI->getSubClassWithSubReg(RC, SubIdx);