summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-05-11 21:26:55 +0000
committerReid Kleckner <rnk@google.com>2017-05-11 21:26:55 +0000
commit45a13e1b5477d2d651801c318b68526fa60c0db8 (patch)
tree590a8835c5daf9cd1240a4edeb09dee185707eb6 /llvm/lib
parent4b1c3696e3ac8935742659eb2c518efdac02eedf (diff)
downloadbcm5719-llvm-45a13e1b5477d2d651801c318b68526fa60c0db8.tar.gz
bcm5719-llvm-45a13e1b5477d2d651801c318b68526fa60c0db8.zip
De-virtualize TerminatorInst successor accessors
Use the same switch technique to eliminate virtual successor accessors from TerminatorInst. Extracted from D31261. NFC llvm-svn: 302827
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Instructions.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index b8e324ee29e..ed3ca5738ac 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -45,6 +45,42 @@ User::op_iterator CallSite::getCallee() const {
TerminatorInst::~TerminatorInst() {
}
+unsigned TerminatorInst::getNumSuccessors() const {
+ switch (getOpcode()) {
+#define HANDLE_TERM_INST(N, OPC, CLASS) \
+ case Instruction::OPC: \
+ return static_cast<const CLASS *>(this)->getNumSuccessorsV();
+#include "llvm/IR/Instruction.def"
+ default:
+ break;
+ }
+ llvm_unreachable("not a terminator");
+}
+
+BasicBlock *TerminatorInst::getSuccessor(unsigned idx) const {
+ switch (getOpcode()) {
+#define HANDLE_TERM_INST(N, OPC, CLASS) \
+ case Instruction::OPC: \
+ return static_cast<const CLASS *>(this)->getSuccessorV(idx);
+#include "llvm/IR/Instruction.def"
+ default:
+ break;
+ }
+ llvm_unreachable("not a terminator");
+}
+
+void TerminatorInst::setSuccessor(unsigned idx, BasicBlock *B) {
+ switch (getOpcode()) {
+#define HANDLE_TERM_INST(N, OPC, CLASS) \
+ case Instruction::OPC: \
+ return static_cast<CLASS *>(this)->setSuccessorV(idx, B);
+#include "llvm/IR/Instruction.def"
+ default:
+ break;
+ }
+ llvm_unreachable("not a terminator");
+}
+
//===----------------------------------------------------------------------===//
// UnaryInstruction Class
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud