diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-20 17:45:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-20 17:45:12 +0000 |
commit | 4b74c8333495c609fa81421df32e46db616672e1 (patch) | |
tree | 1f238f6a4b006f1543946172c52a29e721ad58a4 /lib/VMCore/iCall.cpp | |
parent | dd56927846f8092cbca6084de584cdc18117b0aa (diff) | |
download | external_llvm-4b74c8333495c609fa81421df32e46db616672e1.zip external_llvm-4b74c8333495c609fa81421df32e46db616672e1.tar.gz external_llvm-4b74c8333495c609fa81421df32e46db616672e1.tar.bz2 |
* 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/iCall.cpp')
-rw-r--r-- | lib/VMCore/iCall.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index c385afc..2d41dcd 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -16,8 +16,8 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" - -namespace llvm { +#include "llvm/Support/CallSite.h" +using namespace llvm; //===----------------------------------------------------------------------===// // CallInst Implementation @@ -124,6 +124,32 @@ InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, Operands.push_back(Use(params[i], this)); } +InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, + BasicBlock *IfException, + const std::vector<Value*> ¶ms, + const std::string &Name, BasicBlock *InsertAtEnd) + : TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Invoke, Name) { + Operands.reserve(3+params.size()); + Operands.push_back(Use(Func, this)); + Operands.push_back(Use((Value*)IfNormal, this)); + Operands.push_back(Use((Value*)IfException, this)); + const FunctionType *MTy = + cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); + + const FunctionType::ParamTypes &PL = MTy->getParamTypes(); + assert((params.size() == PL.size()) || + (MTy->isVarArg() && params.size() > PL.size()) && + "Calling a function with bad signature"); + + for (unsigned i = 0; i < params.size(); i++) + Operands.push_back(Use(params[i], this)); + + if (InsertAtEnd) + InsertAtEnd->getInstList().push_back(this); +} + InvokeInst::InvokeInst(const InvokeInst &CI) : TerminatorInst(CI.getType(), Instruction::Invoke) { Operands.reserve(CI.Operands.size()); @@ -146,12 +172,6 @@ Function *InvokeInst::getCalledFunction() { return 0; } -} // End llvm namespace - -#include "llvm/Support/CallSite.h" - -namespace llvm { - Function *CallSite::getCalledFunction() const { Value *Callee = getCalledValue(); if (Function *F = dyn_cast<Function>(Callee)) @@ -160,5 +180,3 @@ Function *CallSite::getCalledFunction() const { return cast<Function>(CPR->getValue()); return 0; } - -} // End llvm namespace |