f739730b67d593f22770d7408a7bac9c6a5da401
[oota-llvm.git] / lib / VMCore / iCall.cpp
1 //===-- iCall.cpp - Implement the call & icall instructions ------*- C++ -*--=//
2 //
3 // This file implements the call and icall instructions.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "llvm/iOther.h"
8 #include "llvm/DerivedTypes.h"
9 #include "llvm/Method.h"
10
11 CallInst::CallInst(Method *M, const vector<Value*> &params, 
12                    const string &Name) 
13   : Instruction(M->getReturnType(), Instruction::Call, Name) {
14
15   Operands.reserve(1+params.size());
16   Operands.push_back(Use(M, this));
17
18   const MethodType::ParamTypes &PL = M->getMethodType()->getParamTypes();
19   assert((params.size() == PL.size()) || 
20          (M->getMethodType()->isVarArg() && params.size() > PL.size()) &&
21          "Calling a function with bad signature");
22 #ifndef NDEBUG
23   MethodType::ParamTypes::const_iterator It = PL.begin();
24 #endif
25   for (unsigned i = 0; i < params.size(); i++)
26     Operands.push_back(Use(params[i], this));
27 }
28
29 CallInst::CallInst(const CallInst &CI) 
30   : Instruction(CI.getType(), Instruction::Call) {
31   Operands.reserve(CI.Operands.size());
32   for (unsigned i = 0; i < CI.Operands.size(); ++i)
33     Operands.push_back(Use(CI.Operands[i], this));
34 }
35