Skip to content

Commit

Permalink
[GISel] Remove remainder of the concept of an invalid RegisterBank. (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
topperc committed Nov 2, 2023
1 parent f4b54f7 commit d22d42c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
8 changes: 0 additions & 8 deletions llvm/include/llvm/CodeGen/RegisterBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class RegisterBank {
const char *Name;
BitVector ContainedRegClasses;

/// Sentinel value used to recognize register bank not properly
/// initialized yet.
static const unsigned InvalidID;

/// Only the RegisterBankInfo can initialize RegisterBank properly.
friend RegisterBankInfo;

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

/// Check whether this instance is ready to be used.
bool isValid() const;

/// Check if this register bank is valid. In other words,
/// if it has been properly constructed.
///
Expand All @@ -63,7 +56,6 @@ class RegisterBank {
/// Check whether this register bank covers \p RC.
/// In other words, check if this register bank fully covers
/// the registers that \p RC contains.
/// \pre isValid()
bool covers(const TargetRegisterClass &RC) const;

/// Check whether \p OtherRB is the same as this.
Expand Down
11 changes: 0 additions & 11 deletions llvm/lib/CodeGen/RegisterBank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

using namespace llvm;

const unsigned RegisterBank::InvalidID = UINT_MAX;

RegisterBank::RegisterBank(unsigned ID, const char *Name,
const uint32_t *CoveredClasses,
unsigned NumRegClasses)
Expand All @@ -32,7 +30,6 @@ RegisterBank::RegisterBank(unsigned ID, const char *Name,

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

Expand Down Expand Up @@ -61,16 +58,9 @@ bool RegisterBank::verify(const RegisterBankInfo &RBI,
}

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

bool RegisterBank::isValid() const {
return ID != InvalidID && Name != nullptr &&
// A register bank that does not cover anything is useless.
!ContainedRegClasses.empty();
}

bool RegisterBank::operator==(const RegisterBank &OtherRB) const {
// There must be only one instance of a given register bank alive
// for the whole compilation.
Expand All @@ -92,7 +82,6 @@ void RegisterBank::print(raw_ostream &OS, bool IsForDebug,
if (!IsForDebug)
return;
OS << "(ID:" << getID() << ")\n"
<< "isValid:" << isValid() << '\n'
<< "Number of Covered register classes: " << ContainedRegClasses.count()
<< '\n';
// Print all the subclasses if we can.
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/RegisterBankInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ RegisterBankInfo::RegisterBankInfo(const RegisterBank **RegBanks,
#ifndef NDEBUG
for (unsigned Idx = 0, End = getNumRegBanks(); Idx != End; ++Idx) {
assert(RegBanks[Idx] != nullptr && "Invalid RegisterBank");
assert(RegBanks[Idx]->isValid() && "RegisterBank should be valid");
assert(RegBanks[Idx]->getID() == Idx &&
"RegisterBank ID should match index");
}
#endif // NDEBUG
}
Expand Down

0 comments on commit d22d42c

Please sign in to comment.