llvm.org GIT mirror llvm / 22a5b29
Create new accessors to get arguments for call/invoke instructions. It breaks encapsulation to force the users of these classes to know about the internal data structure of the Operands structure. It also can lead to errors, like in the MSIL writer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105539 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 10 years ago
4 changed file(s) with 26 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
939939 /// Provide fast operand accessors
940940 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
941941
942 unsigned getNumArgOperands() const { return getNumOperands() - 1; }
943 Value *getArgOperand(unsigned i) const { return getOperand(i + 1); }
944
942945 /// getCallingConv/setCallingConv - Get or set the calling convention of this
943946 /// function call.
944947 CallingConv::ID getCallingConv() const {
24302433
24312434 /// Provide fast operand accessors
24322435 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
2436
2437 unsigned getNumArgOperands() const { return getNumOperands() - 3; }
2438 Value *getArgOperand(unsigned i) const { return getOperand(i); }
24332439
24342440 /// getCallingConv/setCallingConv - Get or set the calling convention of this
24352441 /// function call.
251251 } else if (CallInst *CI = dyn_cast(*UI)) {
252252 // Make sure that this is just the function being called, not that it is
253253 // passing into the function.
254 for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
255 if (CI->getOperand(i) == V) return true;
254 for (unsigned i = 0, e = CI->getNumArgOperands(); i != e; ++i)
255 if (CI->getArgOperand(i) == V) return true;
256256 } else if (InvokeInst *II = dyn_cast(*UI)) {
257257 // Make sure that this is just the function being called, not that it is
258258 // passing into the function.
259 for (unsigned i = 0, e = II->getNumOperands() - 3; i != e; ++i)
260 if (II->getOperand(i) == V) return true;
259 for (unsigned i = 0, e = II->getNumArgOperands(); i != e; ++i)
260 if (II->getArgOperand(i) == V) return true;
261261 } else if (ConstantExpr *CE = dyn_cast(*UI)) {
262262 if (CE->getOpcode() == Instruction::GetElementPtr ||
263263 CE->getOpcode() == Instruction::BitCast) {
11491149 const InvokeInst* inv = cast(I);
11501150 Out << "std::vector " << iName << "_params;";
11511151 nl(Out);
1152 for (unsigned i = 0; i < inv->getNumOperands() - 3; ++i) {
1152 for (unsigned i = 0; i < inv->getNumArgOperands(); ++i) {
11531153 Out << iName << "_params.push_back("
1154 << opNames[i] << ");";
1155 nl(Out);
1156 }
1154 << getOpName(inv->getArgOperand(i)) << ");";
1155 nl(Out);
1156 }
1157 // FIXME: This shouldn't use magic numbers -3, -2, and -1.
11571158 Out << "InvokeInst *" << iName << " = InvokeInst::Create("
1158 << opNames[Ops - 3] << ", "
1159 << opNames[Ops - 2] << ", "
1160 << opNames[Ops - 1] << ", "
1161 << iName << "_params.begin(), " << iName << "_params.end(), \"";
1159 << getOpName(inv->getCalledFunction()) << ", "
1160 << getOpName(inv->getNormalDest()) << ", "
1161 << getOpName(inv->getUnwindDest()) << ", "
1162 << iName << "_params.begin(), "
1163 << iName << "_params.end(), \"";
11621164 printEscapedString(inv->getName());
11631165 Out << "\", " << bbname << ");";
11641166 nl(Out) << iName << "->setCallingConv(";
844844 // Handle intrinsic function.
845845 printIntrinsicCall(cast(Inst));
846846 } else {
847 const CallInst *CI = cast(Inst);
847848 // Load arguments to stack and call function.
848 for (int I = 1, E = Inst->getNumOperands(); I!=E; ++I)
849 printValueLoad(Inst->getOperand(I));
850 printFunctionCall(Inst->getOperand(0),Inst);
849 for (int I = 0, E = CI->getNumArgOperands(); I!=E; ++I)
850 printValueLoad(CI->getArgOperand(I));
851 printFunctionCall(CI->getCalledFunction(), Inst);
851852 }
852853 }
853854
10011002 std::string Label = "leave$normal_"+utostr(getUniqID());
10021003 Out << ".try {\n";
10031004 // Load arguments
1004 for (int I = 3, E = Inst->getNumOperands(); I!=E; ++I)
1005 printValueLoad(Inst->getOperand(I));
1005 for (int I = 0, E = Inst->getNumArgOperands(); I!=E; ++I)
1006 printValueLoad(Inst->getArgOperand(I));
10061007 // Print call instruction
10071008 printFunctionCall(Inst->getOperand(0),Inst);
10081009 // Save function result and leave "try" block