aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/iBranch.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-20 17:45:12 +0000
committerChris Lattner <sabre@nondot.org>2003-11-20 17:45:12 +0000
commit4b74c8333495c609fa81421df32e46db616672e1 (patch)
tree1f238f6a4b006f1543946172c52a29e721ad58a4 /lib/VMCore/iBranch.cpp
parentdd56927846f8092cbca6084de584cdc18117b0aa (diff)
downloadexternal_llvm-4b74c8333495c609fa81421df32e46db616672e1.tar.gz
external_llvm-4b74c8333495c609fa81421df32e46db616672e1.tar.bz2
external_llvm-4b74c8333495c609fa81421df32e46db616672e1.zip
* Finegrainify namespacification
* Add new constructors to allow insertion of terminator instructions at the end of basic blocks. * Move a ReturnInst method out-of-line, so that the vtable and type info don't need to be emitted to every translation unit that uses the class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/iBranch.cpp')
-rw-r--r--lib/VMCore/iBranch.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/VMCore/iBranch.cpp b/lib/VMCore/iBranch.cpp
index 59dc303d70..1a169c6d0e 100644
--- a/lib/VMCore/iBranch.cpp
+++ b/lib/VMCore/iBranch.cpp
@@ -15,8 +15,15 @@
#include "llvm/iTerminators.h"
#include "llvm/BasicBlock.h"
#include "llvm/Type.h"
+using namespace llvm;
+
+// Out-of-line ReturnInst method, put here so the C++ compiler can choose to
+// emit the vtable for the class in this translation unit.
+void ReturnInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+ assert(0 && "ReturnInst has no successors!");
+}
+
-namespace llvm {
BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond,
Instruction *InsertBefore)
@@ -35,6 +42,23 @@ BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond,
"May only branch on boolean predicates!!!!");
}
+BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond,
+ BasicBlock *InsertAtEnd)
+ : TerminatorInst(Instruction::Br, InsertAtEnd) {
+ assert(True != 0 && "True branch destination may not be null!!!");
+ Operands.reserve(False ? 3 : 1);
+ Operands.push_back(Use(True, this));
+ if (False) {
+ Operands.push_back(Use(False, this));
+ Operands.push_back(Use(Cond, this));
+ }
+
+ assert(!!False == !!Cond &&
+ "Either both cond and false or neither can be specified!");
+ assert((Cond == 0 || Cond->getType() == Type::BoolTy) &&
+ "May only branch on boolean predicates!!!!");
+}
+
BranchInst::BranchInst(BasicBlock *True, Instruction *InsertBefore)
: TerminatorInst(Instruction::Br, InsertBefore) {
assert(True != 0 && "True branch destination may not be null!!!");
@@ -42,6 +66,13 @@ BranchInst::BranchInst(BasicBlock *True, Instruction *InsertBefore)
Operands.push_back(Use(True, this));
}
+BranchInst::BranchInst(BasicBlock *True, BasicBlock *InsertAtEnd)
+ : TerminatorInst(Instruction::Br, InsertAtEnd) {
+ assert(True != 0 && "True branch destination may not be null!!!");
+ Operands.reserve(1);
+ Operands.push_back(Use(True, this));
+}
+
BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) {
Operands.reserve(BI.Operands.size());
Operands.push_back(Use(BI.Operands[0], this));
@@ -51,5 +82,3 @@ BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) {
Operands.push_back(Use(BI.Operands[2], this));
}
}
-
-} // End llvm namespace