mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-26 21:56:11 +00:00
[RegisterBank] Provide a way to check if a register bank is valid.
Change the default constructor to create invalid object. The target will have to properly initialize the register banks before using them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265460 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2707ee3256
commit
aa40fb64ae
@ -30,10 +30,17 @@ private:
|
||||
unsigned ID;
|
||||
const char *Name;
|
||||
unsigned Size;
|
||||
BitVector ContainedRegClass;
|
||||
BitVector ContainedRegClasses;
|
||||
|
||||
/// Sentinel value used to recognize register bank not properly
|
||||
/// initialized yet.
|
||||
static const unsigned InvalidID;
|
||||
|
||||
/// Only the RegisterBankInfo can create RegisterBank.
|
||||
RegisterBank() = default;
|
||||
/// The default constructor will leave the object in
|
||||
/// an invalid state. I.e. isValid() == false.
|
||||
/// The field must be updated to fix that.
|
||||
RegisterBank();
|
||||
|
||||
friend RegisterBankInfo;
|
||||
|
||||
@ -48,6 +55,9 @@ public:
|
||||
/// Get the maximal size in bits that fits in this register bank.
|
||||
unsigned getSize() const { return Size; }
|
||||
|
||||
/// 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.
|
||||
void verify(const TargetRegisterInfo &TRI) const;
|
||||
@ -55,6 +65,7 @@ public:
|
||||
/// Check whether this register bank contains \p RC.
|
||||
/// In other words, check if this register bank fully covers
|
||||
/// the registers that \p RC contains.
|
||||
/// \pre isValid()
|
||||
bool contains(const TargetRegisterClass &RC) const;
|
||||
|
||||
/// Check whether \p OtherRB is the same as this.
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
const unsigned RegisterBank::InvalidID = UINT_MAX;
|
||||
|
||||
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.
|
||||
@ -26,7 +30,14 @@ void RegisterBank::verify(const TargetRegisterInfo &TRI) const {
|
||||
}
|
||||
|
||||
bool RegisterBank::contains(const TargetRegisterClass &RC) const {
|
||||
return ContainedRegClass.test(RC.getID());
|
||||
assert(isValid() && "RB hasn't been initialized yet");
|
||||
return ContainedRegClasses.test(RC.getID());
|
||||
}
|
||||
|
||||
bool RegisterBank::isValid() const {
|
||||
return ID != InvalidID && Name != nullptr && Size != 0 &&
|
||||
// A register bank that does not cover anything is useless.
|
||||
!ContainedRegClasses.empty();
|
||||
}
|
||||
|
||||
bool RegisterBank::operator==(const RegisterBank &OtherRB) const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user