1 //===-- iCall.cpp - Implement the call & icall instructions ------*- C++ -*--=//
3 // This file implements the call and icall instructions.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/iOther.h"
8 #include "llvm/DerivedTypes.h"
9 #include "llvm/Method.h"
11 CallInst::CallInst(Method *M, const vector<Value*> ¶ms,
13 : Instruction(M->getReturnType(), Instruction::Call, Name) {
15 Operands.reserve(1+params.size());
16 Operands.push_back(Use(M, this));
18 const MethodType* MT = M->getMethodType();
19 const MethodType::ParamTypes &PL = MT->getParamTypes();
20 assert((params.size() == PL.size()) ||
21 (MT->isVarArg() && params.size() > PL.size()) &&
22 "Calling a function with bad signature");
24 MethodType::ParamTypes::const_iterator It = PL.begin();
26 for (unsigned i = 0; i < params.size(); i++)
27 Operands.push_back(Use(params[i], this));
30 CallInst::CallInst(const CallInst &CI)
31 : Instruction(CI.getType(), Instruction::Call) {
32 Operands.reserve(CI.Operands.size());
33 for (unsigned i = 0; i < CI.Operands.size(); ++i)
34 Operands.push_back(Use(CI.Operands[i], this));