summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-04-05 20:48:32 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-04-05 20:48:32 +0000
commitc4db2ad5b87de895e74c86536ddd6b754ad48afe (patch)
treeebe13f37c5e34dd3c7d494bacc41f1dacee4a3a4 /llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp
parent91d3cfed785b46723ebbf8197f70aa0f854c05d7 (diff)
downloadbcm5719-llvm-c4db2ad5b87de895e74c86536ddd6b754ad48afe.tar.gz
bcm5719-llvm-c4db2ad5b87de895e74c86536ddd6b754ad48afe.zip
[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. llvm-svn: 265460
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp
index 5c86e426e1b..4e0aa080039 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp
@@ -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 {
OpenPOWER on IntegriCloud