diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h | 4 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 20 |
2 files changed, 18 insertions, 6 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 6ec3eea1aa0..5932d3413c5 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -64,8 +64,8 @@ public: struct ValueMapping { /// How the value is broken down between the different register banks. SmallVector<PartialMapping, 2> BreakDown; - /// Verify that this mapping makes sense. - void verify() const; + /// Verify that this mapping makes sense for a value of \p ExpectedBitWidth. + void verify(unsigned ExpectedBitWidth) const; }; /// Helper class that represents how the value of an instruction may be diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index ef8cbeadaba..b07688adc29 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( |

