Changed the fundemental architecture of Operands for Instructions. Now
[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, 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* MT = M->getMethodType();
19   const MethodType::ParamTypes &PL = MT->getParamTypes();
20   assert(params.size() == PL.size() && "Calling a function with bad signature");
21 #ifndef NDEBUG
22   MethodType::ParamTypes::const_iterator It = PL.begin();
23 #endif
24   for (unsigned i = 0; i < params.size(); i++) {
25     assert(*It++ == params[i]->getType() && "Call Operands not correct type!");
26     Operands.push_back(Use(params[i], this));
27   }
28 }
29
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));
35 }
36