diff options
| author | Quentin Colombet <qcolombet@apple.com> | 2016-04-06 16:40:23 +0000 |
|---|---|---|
| committer | Quentin Colombet <qcolombet@apple.com> | 2016-04-06 16:40:23 +0000 |
| commit | 3768f7005d442fb7ff40e1324d2ca9630d255f35 (patch) | |
| tree | 9204c9a2e13690b4b41a7ee47d58f3f5aca95dc9 /llvm/lib/CodeGen | |
| parent | 2423fc419c1f5d0b07553905860f70338a1742c8 (diff) | |
| download | llvm-3768f7005d442fb7ff40e1324d2ca9630d255f35.zip llvm-3768f7005d442fb7ff40e1324d2ca9630d255f35.tar.gz llvm-3768f7005d442fb7ff40e1324d2ca9630d255f35.tar.bz2 | |
[RegisterBankInfo] Implement the verify method for the ValueMapping helper class.
The method checks that the value is fully defined accross the different partial
mappings and that the partial mappings are compatible between each other.
llvm-svn: 265556
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index ef8cbead..b07688a 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -210,10 +210,22 @@ void RegisterBankInfo::PartialMapping::print(raw_ostream &OS) const { OS << "nullptr"; } -void RegisterBankInfo::ValueMapping::verify() const { - // Check that all the partial mapping have the same bitwidth. - // Check that the union of the partial mappings covers the whole value. - // Check that each register bank is big enough to hold the partial value. +void RegisterBankInfo::ValueMapping::verify(unsigned ExpectedBitWidth) const { + assert(!BreakDown.empty() && "Value mapped nowhere?!"); + unsigned ValueBitWidth = BreakDown.back().Mask.getBitWidth(); + assert(ValueBitWidth == ExpectedBitWidth && "BitWidth does not match"); + APInt ValueMask(ValueBitWidth, 0); + for (const RegisterBankInfo::PartialMapping &PartMap : BreakDown) { + // Check that all the partial mapping have the same bitwidth. + assert(PartMap.Mask.getBitWidth() == ValueBitWidth && + "Value does not have the same size accross the partial mappings"); + // Check that the union of the partial mappings covers the whole value. + ValueMask |= PartMap.Mask; + // Check that each register bank is big enough to hold the partial value: + // this check is done by PartialMapping::verify + PartMap.verify(); + } + assert(ValueMask.isAllOnesValue() && "Value is not fully mapped"); } void RegisterBankInfo::InstructionMapping::verify( |
