Changeset View
Changeset View
Standalone View
Standalone View
include/llvm/IR/CallSite.h
Show All 35 Lines | |||||
class CallInst; | class CallInst; | ||||
class InvokeInst; | class InvokeInst; | ||||
template <typename FunTy = const Function, | template <typename FunTy = const Function, | ||||
typename BBTy = const BasicBlock, | typename BBTy = const BasicBlock, | ||||
typename ValTy = const Value, | typename ValTy = const Value, | ||||
typename UserTy = const User, | typename UserTy = const User, | ||||
typename UseTy = const Use, | |||||
typename InstrTy = const Instruction, | typename InstrTy = const Instruction, | ||||
typename CallTy = const CallInst, | typename CallTy = const CallInst, | ||||
typename InvokeTy = const InvokeInst, | typename InvokeTy = const InvokeInst, | ||||
typename IterTy = User::const_op_iterator> | typename IterTy = User::const_op_iterator> | ||||
class CallSiteBase { | class CallSiteBase { | ||||
protected: | protected: | ||||
PointerIntPair<InstrTy*, 1, bool> I; | PointerIntPair<InstrTy*, 1, bool> I; | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | #define CALLSITE_DELEGATE_SETTER(METHOD) \ | ||||
/// @brief Determine if the call cannot unwind. | /// @brief Determine if the call cannot unwind. | ||||
bool doesNotThrow() const { | bool doesNotThrow() const { | ||||
CALLSITE_DELEGATE_GETTER(doesNotThrow()); | CALLSITE_DELEGATE_GETTER(doesNotThrow()); | ||||
} | } | ||||
void setDoesNotThrow() { | void setDoesNotThrow() { | ||||
CALLSITE_DELEGATE_SETTER(setDoesNotThrow()); | CALLSITE_DELEGATE_SETTER(setDoesNotThrow()); | ||||
} | } | ||||
int getNumOperandBundles() const { | |||||
CALLSITE_DELEGATE_GETTER(getNumOperandBundles()); | |||||
} | |||||
bool hasOperandBundles() const { | |||||
CALLSITE_DELEGATE_GETTER(hasOperandBundles()); | |||||
} | |||||
int getNumTotalBundleOperands() const { | |||||
CALLSITE_DELEGATE_GETTER(getNumTotalBundleOperands()); | |||||
} | |||||
OperandBundleSetT<UseTy> getOperandBundle(unsigned Index) const { | |||||
CALLSITE_DELEGATE_GETTER(getOperandBundle(Index)); | |||||
} | |||||
#undef CALLSITE_DELEGATE_GETTER | #undef CALLSITE_DELEGATE_GETTER | ||||
#undef CALLSITE_DELEGATE_SETTER | #undef CALLSITE_DELEGATE_SETTER | ||||
/// @brief Determine whether this argument is not captured. | /// @brief Determine whether this argument is not captured. | ||||
bool doesNotCapture(unsigned ArgNo) const { | bool doesNotCapture(unsigned ArgNo) const { | ||||
return paramHasAttr(ArgNo + 1, Attribute::NoCapture); | return paramHasAttr(ArgNo + 1, Attribute::NoCapture); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | for (arg_iterator AI = this->arg_begin(), E = this->arg_end(); AI != E; | ||||
++AI) | ++AI) | ||||
if (AI->get() == Arg) | if (AI->get() == Arg) | ||||
return true; | return true; | ||||
return false; | return false; | ||||
} | } | ||||
private: | private: | ||||
unsigned getArgumentEndOffset() const { | unsigned getArgumentEndOffset() const { | ||||
if (isCall()) | if (isCall()) { | ||||
return 1; // Skip Callee | // Skip [ operand bundles ], Callee | ||||
else | auto *CI = cast<CallInst>(getInstruction()); | ||||
return 3; // Skip BB, BB, Callee | return 1 + CI->getNumTotalBundleOperands(); | ||||
} else { | |||||
// Skip [ operand bundles ], BB, BB, Callee | |||||
auto *II = cast<InvokeInst>(getInstruction()); | |||||
return 3 + II->getNumTotalBundleOperands(); | |||||
} | |||||
} | } | ||||
IterTy getCallee() const { | IterTy getCallee() const { | ||||
if (isCall()) // Skip Callee | if (isCall()) // Skip Callee | ||||
return cast<CallInst>(getInstruction())->op_end() - 1; | return cast<CallInst>(getInstruction())->op_end() - 1; | ||||
else // Skip BB, BB, Callee | else // Skip BB, BB, Callee | ||||
return cast<InvokeInst>(getInstruction())->op_end() - 3; | return cast<InvokeInst>(getInstruction())->op_end() - 3; | ||||
} | } | ||||
}; | }; | ||||
class CallSite : public CallSiteBase<Function, BasicBlock, Value, User, | class CallSite : public CallSiteBase<Function, BasicBlock, Value, User, Use, | ||||
Instruction, CallInst, InvokeInst, | Instruction, CallInst, InvokeInst, | ||||
User::op_iterator> { | User::op_iterator> { | ||||
public: | public: | ||||
CallSite() {} | CallSite() {} | ||||
CallSite(CallSiteBase B) : CallSiteBase(B) {} | CallSite(CallSiteBase B) : CallSiteBase(B) {} | ||||
CallSite(CallInst *CI) : CallSiteBase(CI) {} | CallSite(CallInst *CI) : CallSiteBase(CI) {} | ||||
CallSite(InvokeInst *II) : CallSiteBase(II) {} | CallSite(InvokeInst *II) : CallSiteBase(II) {} | ||||
explicit CallSite(Instruction *II) : CallSiteBase(II) {} | explicit CallSite(Instruction *II) : CallSiteBase(II) {} | ||||
Show All 26 Lines |