Skip to content

Commit d22d42c

Browse files
authored
[GISel] Remove remainder of the concept of an invalid RegisterBank. (#71118)
RegisterBank no longer has a default constructor so there's no way to create an invalid register bank. Remove InvalidID and the isValid method. Replace the one use of isValid outside of RegBank with a check that the ID matches so there's still some check of sanity.
1 parent f4b54f7 commit d22d42c

File tree

3 files changed

+2
-20
lines changed

3 files changed

+2
-20
lines changed

llvm/include/llvm/CodeGen/RegisterBank.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class RegisterBank {
3131
const char *Name;
3232
BitVector ContainedRegClasses;
3333

34-
/// Sentinel value used to recognize register bank not properly
35-
/// initialized yet.
36-
static const unsigned InvalidID;
37-
3834
/// Only the RegisterBankInfo can initialize RegisterBank properly.
3935
friend RegisterBankInfo;
4036

@@ -49,9 +45,6 @@ class RegisterBank {
4945
/// Should be used only for debugging purposes.
5046
const char *getName() const { return Name; }
5147

52-
/// Check whether this instance is ready to be used.
53-
bool isValid() const;
54-
5548
/// Check if this register bank is valid. In other words,
5649
/// if it has been properly constructed.
5750
///
@@ -63,7 +56,6 @@ class RegisterBank {
6356
/// Check whether this register bank covers \p RC.
6457
/// In other words, check if this register bank fully covers
6558
/// the registers that \p RC contains.
66-
/// \pre isValid()
6759
bool covers(const TargetRegisterClass &RC) const;
6860

6961
/// Check whether \p OtherRB is the same as this.

llvm/lib/CodeGen/RegisterBank.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
using namespace llvm;
2222

23-
const unsigned RegisterBank::InvalidID = UINT_MAX;
24-
2523
RegisterBank::RegisterBank(unsigned ID, const char *Name,
2624
const uint32_t *CoveredClasses,
2725
unsigned NumRegClasses)
@@ -32,7 +30,6 @@ RegisterBank::RegisterBank(unsigned ID, const char *Name,
3230

3331
bool RegisterBank::verify(const RegisterBankInfo &RBI,
3432
const TargetRegisterInfo &TRI) const {
35-
assert(isValid() && "Invalid register bank");
3633
for (unsigned RCId = 0, End = TRI.getNumRegClasses(); RCId != End; ++RCId) {
3734
const TargetRegisterClass &RC = *TRI.getRegClass(RCId);
3835

@@ -61,16 +58,9 @@ bool RegisterBank::verify(const RegisterBankInfo &RBI,
6158
}
6259

6360
bool RegisterBank::covers(const TargetRegisterClass &RC) const {
64-
assert(isValid() && "RB hasn't been initialized yet");
6561
return ContainedRegClasses.test(RC.getID());
6662
}
6763

68-
bool RegisterBank::isValid() const {
69-
return ID != InvalidID && Name != nullptr &&
70-
// A register bank that does not cover anything is useless.
71-
!ContainedRegClasses.empty();
72-
}
73-
7464
bool RegisterBank::operator==(const RegisterBank &OtherRB) const {
7565
// There must be only one instance of a given register bank alive
7666
// for the whole compilation.
@@ -92,7 +82,6 @@ void RegisterBank::print(raw_ostream &OS, bool IsForDebug,
9282
if (!IsForDebug)
9383
return;
9484
OS << "(ID:" << getID() << ")\n"
95-
<< "isValid:" << isValid() << '\n'
9685
<< "Number of Covered register classes: " << ContainedRegClasses.count()
9786
<< '\n';
9887
// Print all the subclasses if we can.

llvm/lib/CodeGen/RegisterBankInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ RegisterBankInfo::RegisterBankInfo(const RegisterBank **RegBanks,
6161
#ifndef NDEBUG
6262
for (unsigned Idx = 0, End = getNumRegBanks(); Idx != End; ++Idx) {
6363
assert(RegBanks[Idx] != nullptr && "Invalid RegisterBank");
64-
assert(RegBanks[Idx]->isValid() && "RegisterBank should be valid");
64+
assert(RegBanks[Idx]->getID() == Idx &&
65+
"RegisterBank ID should match index");
6566
}
6667
#endif // NDEBUG
6768
}

0 commit comments

Comments
 (0)