[llvm] r265479 - [RegisterBank] Implement the verify method to check for the obvious mistakes.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 15:34:01 PDT 2016
Author: qcolombet
Date: Tue Apr 5 17:34:01 2016
New Revision: 265479
URL: http://llvm.org/viewvc/llvm-project?rev=265479&view=rev
Log:
[RegisterBank] Implement the verify method to check for the obvious mistakes.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/RegisterBank.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBank.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBank.cpp?rev=265479&r1=265478&r2=265479&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBank.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBank.cpp Tue Apr 5 17:34:01 2016
@@ -23,10 +23,33 @@ const unsigned RegisterBank::InvalidID =
RegisterBank::RegisterBank() : ID(InvalidID), Name(nullptr), Size(0) {}
void RegisterBank::verify(const TargetRegisterInfo &TRI) const {
- // Verify that the Size of the register bank is big enough to cover all the
- // register classes it covers.
- // Verify that the register bank covers all the sub and super classes of the
- // classes it covers.
+ assert(isValid() && "Invalid register bank");
+ assert(ContainedRegClasses.size() == TRI.getNumRegClasses() &&
+ "TRI does not match the initialization process?");
+ for (unsigned RCId = 0, End = TRI.getNumRegClasses(); RCId != End; ++RCId) {
+ const TargetRegisterClass &RC = *TRI.getRegClass(RCId);
+
+ if (!contains(RC))
+ continue;
+ // Verify that the register bank covers all the sub classes of the
+ // classes it covers.
+
+ // Use a different (slow in that case) method than
+ // RegisterBankInfo to find the subclasses of RC, to make sure
+ // both agree on the contains.
+ for (unsigned SubRCId = 0; SubRCId != End; ++SubRCId) {
+ const TargetRegisterClass &SubRC = *TRI.getRegClass(RCId);
+
+ if (!RC.hasSubClassEq(&SubRC))
+ continue;
+
+ // Verify that the Size of the register bank is big enough to cover
+ // all the register classes it covers.
+ assert((getSize() >= SubRC.getSize() * 8) &&
+ "Size is not big enough for all the subclasses!");
+ assert(contains(SubRC) && "Not all subclasses are covered");
+ }
+ }
}
bool RegisterBank::contains(const TargetRegisterClass &RC) const {
More information about the llvm-commits
mailing list