aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/iOther.h8
-rw-r--r--lib/VMCore/iCall.cpp31
2 files changed, 38 insertions, 1 deletions
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index 18779f9c32..4e7ef5c1e7 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -70,6 +70,7 @@ public:
class CallInst : public Instruction {
CallInst(const CallInst &CI);
void init(Value *Func, const std::vector<Value*> &Params);
+ void init(Value *Func, Value *Actual1, Value *Actual2);
void init(Value *Func, Value *Actual);
void init(Value *Func);
@@ -79,7 +80,12 @@ public:
CallInst(Value *F, const std::vector<Value*> &Par,
const std::string &Name, BasicBlock *InsertAtEnd);
- // Alternate CallInst ctors w/ one actual & no actuals, respectively.
+ // Alternate CallInst ctors w/ two actuals, w/ one actual and no
+ // actuals, respectively.
+ CallInst(Value *F, Value *Actual1, Value *Actual2,
+ const std::string& Name = "", Instruction *InsertBefore = 0);
+ CallInst(Value *F, Value *Actual1, Value *Actual2,
+ const std::string& Name, BasicBlock *InsertAtEnd);
CallInst(Value *F, Value *Actual, const std::string& Name = "",
Instruction *InsertBefore = 0);
CallInst(Value *F, Value *Actual, const std::string& Name,
diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp
index 9a81f7948f..1e88be3e93 100644
--- a/lib/VMCore/iCall.cpp
+++ b/lib/VMCore/iCall.cpp
@@ -38,6 +38,21 @@ void CallInst::init(Value *Func, const std::vector<Value*> &Params)
Operands.push_back(Use(Params[i], this));
}
+void CallInst::init(Value *Func, Value *Actual1, Value *Actual2)
+{
+ Operands.reserve(3);
+ Operands.push_back(Use(Func, this));
+
+ const FunctionType *MTy =
+ cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
+
+ assert((MTy->getNumParams() == 2 ||
+ (MTy->isVarArg() && MTy->getNumParams() == 0)) &&
+ "Calling a function with bad signature");
+ Operands.push_back(Use(Actual1, this));
+ Operands.push_back(Use(Actual2, this));
+}
+
void CallInst::init(Value *Func, Value *Actual)
{
Operands.reserve(2);
@@ -79,6 +94,22 @@ CallInst::CallInst(Value *Func, const std::vector<Value*> &Params,
init(Func, Params);
}
+CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
+ const std::string &Name, Instruction *InsertBefore)
+ : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Call, Name, InsertBefore) {
+ init(Func, Actual1, Actual2);
+}
+
+CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
+ const std::string &Name, BasicBlock *InsertAtEnd)
+ : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Call, Name, InsertAtEnd) {
+ init(Func, Actual1, Actual2);
+}
+
CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())