summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-04-06 17:01:43 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-04-06 17:01:43 +0000
commit4812c91f56252bb0a72234abf12a2fe5ffe515e8 (patch)
treea6a08f5a526d5b625de04336b45fdeaefa895ac3 /llvm/lib
parent045afc4f66711cd56d3e3407935633f1716d4a5f (diff)
downloadbcm5719-llvm-4812c91f56252bb0a72234abf12a2fe5ffe515e8.tar.gz
bcm5719-llvm-4812c91f56252bb0a72234abf12a2fe5ffe515e8.zip
[RegisterBankInfo] Implement the verify method of the InstructionMapping helper class.
This checks that all the register operands get a proper mapping. llvm-svn: 265563
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
index b07688adc29..6e8307917c7 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
@@ -14,6 +14,9 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegisterInfo.h"
@@ -231,4 +234,26 @@ void RegisterBankInfo::ValueMapping::verify(unsigned ExpectedBitWidth) const {
void RegisterBankInfo::InstructionMapping::verify(
const MachineInstr &MI) const {
// Check that all the register operands are properly mapped.
+ const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
+ // Check the constructor invariant.
+ assert(NumOperands == MI.getNumOperands() &&
+ "NumOperands must match, see constructor");
+ for (unsigned Idx = 0; Idx < NumOperands; ++Idx) {
+ const MachineOperand &MO = MI.getOperand(Idx);
+ const RegisterBankInfo::ValueMapping &MOMapping = getOperandMapping(Idx);
+ if (!MO.isReg()) {
+ assert(MOMapping.BreakDown.empty() &&
+ "We should not care about non-reg mapping");
+ continue;
+ }
+ unsigned Reg = MO.getReg();
+ // Register size in bits.
+ // This size must match what the mapping expect.
+ unsigned RegSize = MRI.getSize(Reg);
+ // If Reg is not a generic register, query the register class to
+ // get its size.
+ if (!RegSize)
+ RegSize = MRI.getRegClass(Reg)->getSize() * 8;
+ MOMapping.verify(RegSize);
+ }
}
OpenPOWER on IntegriCloud