diff options
author | Chris Lattner <sabre@nondot.org> | 2001-06-06 20:29:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-06-06 20:29:01 +0000 |
commit | 009505452b713ed2e3a8e99c5545a6e721c65495 (patch) | |
tree | 136a71c5b87bdf534d1f20a67558b49226b5a4d6 /lib/VMCore/iCall.cpp | |
parent | 8d0afd3d32d1d67f9aa5df250a1d6955aa8f1ac9 (diff) | |
download | external_llvm-009505452b713ed2e3a8e99c5545a6e721c65495.zip external_llvm-009505452b713ed2e3a8e99c5545a6e721c65495.tar.gz external_llvm-009505452b713ed2e3a8e99c5545a6e721c65495.tar.bz2 |
Initial revision
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/iCall.cpp')
-rw-r--r-- | lib/VMCore/iCall.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp new file mode 100644 index 0000000..9ff6bb6 --- /dev/null +++ b/lib/VMCore/iCall.cpp @@ -0,0 +1,48 @@ +//===-- iCall.cpp - Implement the Call & Invoke instructions -----*- C++ -*--=// +// +// This file implements the call and invoke instructions. +// +//===----------------------------------------------------------------------===// + +#include "llvm/iOther.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Method.h" + +CallInst::CallInst(Method *m, vector<Value*> ¶ms, + const string &Name) + : Instruction(m->getReturnType(), Instruction::Call, Name), M(m, this) { + + const MethodType* MT = M->getMethodType(); + const MethodType::ParamTypes &PL = MT->getParamTypes(); + assert(params.size() == PL.size()); +#ifndef NDEBUG + MethodType::ParamTypes::const_iterator It = PL.begin(); +#endif + for (unsigned i = 0; i < params.size(); i++) { + assert(*It++ == params[i]->getType()); + Params.push_back(Use(params[i], this)); + } +} + +CallInst::CallInst(const CallInst &CI) + : Instruction(CI.getType(), Instruction::Call), M(CI.M, this) { + for (unsigned i = 0; i < CI.Params.size(); i++) + Params.push_back(Use(CI.Params[i], this)); +} + +void CallInst::dropAllReferences() { + M = 0; + Params.clear(); +} + +bool CallInst::setOperand(unsigned i, Value *Val) { + if (i > Params.size()) return false; + if (i == 0) { + assert(Val->getValueType() == Value::MethodVal); + M = (Method*)Val; + } else { + // TODO: assert = method arg type + Params[i-1] = Val; + } + return true; +} |