15 #ifndef LLVM_IR_INSTRTYPES_H 16 #define LLVM_IR_INSTRTYPES_H 71 void *
operator new(
size_t s) {
72 return User::operator
new(s, 1);
84 I->
getOpcode() == Instruction::ExtractValue ||
88 return isa<Instruction>(V) && classof(cast<Instruction>(V));
139 #define HANDLE_UNARY_INST(N, OPC, CLASS) \ 140 static UnaryOperator *Create##OPC(Value *V, const Twine &Name = "") {\ 141 return Create(Instruction::OPC, V, Name);\ 143 #include "llvm/IR/Instruction.def" 144 #define HANDLE_UNARY_INST(N, OPC, CLASS) \ 145 static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \ 147 return Create(Instruction::OPC, V, Name, BB);\ 149 #include "llvm/IR/Instruction.def" 150 #define HANDLE_UNARY_INST(N, OPC, CLASS) \ 151 static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \ 153 return Create(Instruction::OPC, V, Name, I);\ 155 #include "llvm/IR/Instruction.def" 160 const Twine &Name =
"") {
167 const Twine &Name =
"") {
168 return CreateWithCopiedFlags(Instruction::FNeg, Op, FMFSource, Name);
180 return isa<Instruction>(V) && classof(cast<Instruction>(V));
204 void *
operator new(
size_t s) {
205 return User::operator
new(s, 2);
230 #define HANDLE_BINARY_INST(N, OPC, CLASS) \ 231 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ 232 const Twine &Name = "") {\ 233 return Create(Instruction::OPC, V1, V2, Name);\ 235 #include "llvm/IR/Instruction.def" 236 #define HANDLE_BINARY_INST(N, OPC, CLASS) \ 237 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ 238 const Twine &Name, BasicBlock *BB) {\ 239 return Create(Instruction::OPC, V1, V2, Name, BB);\ 241 #include "llvm/IR/Instruction.def" 242 #define HANDLE_BINARY_INST(N, OPC, CLASS) \ 243 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ 244 const Twine &Name, Instruction *I) {\ 245 return Create(Instruction::OPC, V1, V2, Name, I);\ 247 #include "llvm/IR/Instruction.def" 252 const Twine &Name =
"") {
260 const Twine &Name =
"") {
261 return CreateWithCopiedFlags(Instruction::FAdd, V1, V2, FMFSource, Name);
265 const Twine &Name =
"") {
266 return CreateWithCopiedFlags(Instruction::FSub, V1, V2, FMFSource, Name);
270 const Twine &Name =
"") {
271 return CreateWithCopiedFlags(Instruction::FMul, V1, V2, FMFSource, Name);
275 const Twine &Name =
"") {
276 return CreateWithCopiedFlags(Instruction::FDiv, V1, V2, FMFSource, Name);
280 const Twine &Name =
"") {
281 return CreateWithCopiedFlags(Instruction::FRem, V1, V2, FMFSource, Name);
284 const Twine &Name =
"") {
286 return CreateWithCopiedFlags(Instruction::FSub, Zero, Op, FMFSource, Name);
290 const Twine &Name =
"") {
309 const Twine &Name =
"") {
328 const Twine &Name =
"") {
346 #define DEFINE_HELPERS(OPC, NUWNSWEXACT) \ 347 static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \ 348 const Twine &Name = "") { \ 349 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name); \ 351 static BinaryOperator *Create##NUWNSWEXACT##OPC( \ 352 Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { \ 353 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, BB); \ 355 static BinaryOperator *Create##NUWNSWEXACT##OPC( \ 356 Value *V1, Value *V2, const Twine &Name, Instruction *I) { \ 357 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \ 374 #undef DEFINE_HELPERS 381 static BinaryOperator *
CreateNeg(
Value *Op,
const Twine &Name =
"",
382 Instruction *InsertBefore =
nullptr);
385 static BinaryOperator *CreateNSWNeg(
Value *Op,
const Twine &Name =
"",
386 Instruction *InsertBefore =
nullptr);
387 static BinaryOperator *CreateNSWNeg(
Value *Op,
const Twine &Name,
389 static BinaryOperator *CreateNUWNeg(
Value *Op,
const Twine &Name =
"",
390 Instruction *InsertBefore =
nullptr);
391 static BinaryOperator *CreateNUWNeg(
Value *Op,
const Twine &Name,
393 static BinaryOperator *CreateFNeg(
Value *Op,
const Twine &Name =
"",
394 Instruction *InsertBefore =
nullptr);
395 static BinaryOperator *CreateFNeg(
Value *Op,
const Twine &Name,
397 static BinaryOperator *CreateNot(
Value *Op,
const Twine &Name =
"",
398 Instruction *InsertBefore =
nullptr);
399 static BinaryOperator *CreateNot(
Value *Op,
const Twine &Name,
418 return isa<Instruction>(V) && classof(cast<Instruction>(V));
444 : UnaryInstruction(Ty, iType, S, InsertBefore) {
450 : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
465 const Twine &Name =
"",
483 static CastInst *CreateZExtOrBitCast(
486 const Twine &Name =
"",
491 static CastInst *CreateZExtOrBitCast(
499 static CastInst *CreateSExtOrBitCast(
502 const Twine &Name =
"",
507 static CastInst *CreateSExtOrBitCast(
526 const Twine &Name =
"",
531 static CastInst *CreatePointerBitCastOrAddrSpaceCast(
539 static CastInst *CreatePointerBitCastOrAddrSpaceCast(
542 const Twine &Name =
"",
552 static CastInst *CreateBitOrPointerCast(
555 const Twine &Name =
"",
564 const Twine &Name =
"",
581 const Twine &Name =
"",
594 static CastInst *CreateTruncOrBitCast(
597 const Twine &Name =
"",
602 static CastInst *CreateTruncOrBitCast(
610 static bool isCastable(
616 static bool isBitCastable(
626 static bool isBitOrNoopPointerCastable(
646 bool isIntegerCast()
const;
653 bool isLosslessCast()
const;
662 static bool isNoopCast(
680 static unsigned isEliminableCastPair(
712 return isa<Instruction>(V) && classof(cast<Instruction>(V));
750 FIRST_FCMP_PREDICATE = FCMP_FALSE,
751 LAST_FCMP_PREDICATE = FCMP_TRUE,
752 BAD_FCMP_PREDICATE = FCMP_TRUE + 1,
763 FIRST_ICMP_PREDICATE = ICMP_EQ,
764 LAST_ICMP_PREDICATE = ICMP_SLE,
765 BAD_ICMP_PREDICATE = ICMP_SLE + 1
780 void *
operator new(
size_t s) {
781 return User::operator
new(s, 2);
808 return Predicate(getSubclassDataFromInstruction());
815 return P >= FIRST_FCMP_PREDICATE && P <= LAST_FCMP_PREDICATE;
819 return P >= FIRST_ICMP_PREDICATE && P <= LAST_ICMP_PREDICATE;
898 bool isEquality()
const;
939 static bool isUnsigned(
Predicate predicate);
943 static bool isSigned(
Predicate predicate);
949 static bool isUnordered(
Predicate predicate);
955 static bool isFalseWhenEqual(
Predicate predicate);
967 return I->
getOpcode() == Instruction::ICmp ||
971 return isa<Instruction>(V) && classof(cast<Instruction>(V));
976 if (
VectorType* vt = dyn_cast<VectorType>(opnd_type)) {
978 vt->getElementCount());
986 void setValueSubclassData(
unsigned short D) {
1003 OperandBundleUse() =
default;
1005 : Inputs(Inputs), Tag(Tag) {}
1010 if (isDeoptOperandBundle())
1011 if (A == Attribute::ReadOnly || A == Attribute::NoCapture)
1012 return Inputs[Idx]->getType()->isPointerTy();
1020 return Tag->getKey();
1029 return Tag->getValue();
1055 std::vector<InputTy> Inputs;
1059 : Tag(
std::move(Tag)), Inputs(
std::move(Inputs)) {}
1061 : Tag(
std::move(Tag)), Inputs(Inputs) {}
1065 Inputs.insert(Inputs.end(), OBU.
Inputs.begin(), OBU.
Inputs.end());
1103 static constexpr
int CalledOperandOpEndIdx = -1;
1108 template <
class... ArgsTy>
1120 case Instruction::Invoke:
1122 case Instruction::CallBr:
1123 return getNumSubclassExtraOperandsDynamic();
1130 unsigned getNumSubclassExtraOperandsDynamic()
const;
1137 I->
getOpcode() == Instruction::Invoke ||
1141 return isa<Instruction>(V) && classof(cast<Instruction>(V));
1160 return const_cast<CallBase *
>(
this)->data_operands_begin();
1165 return op_end() - getNumSubclassExtraOperands() - 1;
1168 return const_cast<CallBase *
>(
this)->data_operands_end();
1171 return make_range(data_operands_begin(), data_operands_end());
1174 return make_range(data_operands_begin(), data_operands_end());
1177 return data_operands_end() == data_operands_begin();
1180 return std::distance(data_operands_begin(), data_operands_end());
1184 assert(
this == U->getUser() &&
1185 "Only valid to query with a use of this instruction!");
1186 return data_operands_begin() <= U && U < data_operands_end();
1189 return isDataOperand(&UI.getUse());
1195 return getDataOperandNo(&UI.getUse());
1201 assert(isDataOperand(U) &&
"Data operand # out of range!");
1202 return U - data_operands_begin();
1208 return const_cast<CallBase *
>(
this)->arg_begin();
1215 return data_operands_end() - getNumTotalBundleOperands();
1218 return const_cast<CallBase *
>(
this)->arg_end();
1229 unsigned arg_size()
const {
return arg_end() - arg_begin(); }
1242 assert(i < getNumArgOperands() &&
"Out of bounds!");
1243 return getOperand(i);
1247 assert(i < getNumArgOperands() &&
"Out of bounds!");
1253 assert(i < getNumArgOperands() &&
"Out of bounds!");
1257 assert(i < getNumArgOperands() &&
"Out of bounds!");
1262 assert(
this == U->getUser() &&
1263 "Only valid to query with a use of this instruction!");
1264 return arg_begin() <= U && U < arg_end();
1267 return isArgOperand(&UI.getUse());
1288 return dyn_cast_or_null<Function>(getCalledOperand());
1292 bool isIndirectCall()
const;
1296 return isCallee(&UI.getUse());
1300 bool isCallee(
const Use *U)
const {
return &getCalledOperandUse() == U; }
1305 return const_cast<CallBase *
>(
this)->getCaller();
1310 bool isMustTailCall()
const;
1313 bool isTailCall()
const;
1336 assert(FTy == cast<FunctionType>(
1337 cast<PointerType>(Fn->
getType())->getElementType()));
1341 setCalledOperand(Fn);
1345 return static_cast<CallingConv::ID>(getSubclassDataFromInstruction() >> 2);
1349 auto ID =
static_cast<unsigned>(CC);
1351 setInstructionSubclassData((getSubclassDataFromInstruction() & 3) |
1356 bool isInlineAsm()
const {
return isa<InlineAsm>(getCalledOperand()); }
1374 assert(Kind != Attribute::NoBuiltin &&
1375 "Use CallBase::isNoBuiltin() to check for Attribute::NoBuiltin");
1376 return hasFnAttrImpl(Kind);
1398 assert(ArgNo < getNumArgOperands() &&
"Out of bounds");
1406 assert(ArgNo < getNumArgOperands() &&
"Out of bounds");
1428 assert(ArgNo < getNumArgOperands() &&
"Out of bounds");
1436 assert(ArgNo < getNumArgOperands() &&
"Out of bounds");
1475 assert(ArgNo < getNumArgOperands() &&
"Out of bounds");
1481 assert(ArgNo < getNumArgOperands() &&
"Out of bounds");
1500 assert(i < (getNumArgOperands() + getNumTotalBundleOperands() + 1) &&
1501 "Data operand index out of bounds!");
1508 return hasRetAttr(Kind);
1512 if (i < (getNumArgOperands() + 1))
1513 return paramHasAttr(i - 1, Kind);
1515 assert(hasOperandBundles() && i >= (getBundleOperandsStartIndex() + 1) &&
1516 "Must be either a call argument or an operand bundle!");
1517 return bundleOperandHasAttr(i - 1, Kind);
1524 return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
1529 return paramHasAttr(ArgNo, Attribute::ByVal);
1534 return paramHasAttr(ArgNo, Attribute::InAlloca);
1539 return paramHasAttr(ArgNo, Attribute::ByVal) ||
1540 paramHasAttr(ArgNo, Attribute::InAlloca);
1546 return !arg_empty() && paramHasAttr(arg_size() - 1, Attribute::InAlloca);
1552 return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
1558 return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadOnly) ||
1559 dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
1565 return dataOperandHasImpliedAttr(OpNo + 1, Attribute::WriteOnly) ||
1566 dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
1613 Value *getReturnedArgOperand()
const;
1618 return hasFnAttrImpl(Attribute::NoBuiltin) &&
1619 !hasFnAttrImpl(Attribute::Builtin);
1623 bool isStrictFP()
const {
return hasFnAttr(Attribute::StrictFP); }
1626 bool isNoInline()
const {
return hasFnAttr(Attribute::NoInline); }
1638 return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
1646 return doesNotAccessMemory() || hasFnAttr(Attribute::WriteOnly);
1655 return hasFnAttr(Attribute::ArgMemOnly);
1664 return hasFnAttr(Attribute::InaccessibleMemOnly);
1673 return hasFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
1677 Attribute::InaccessibleMemOrArgMemOnly);
1712 if (getNumArgOperands() == 0)
1716 return paramHasAttr(0, Attribute::StructRet);
1735 return std::distance(bundle_op_info_begin(), bundle_op_info_end());
1743 assert(hasOperandBundles() &&
"Don't call otherwise!");
1744 return bundle_op_info_begin()->Begin;
1749 assert(hasOperandBundles() &&
"Don't call otherwise!");
1750 return bundle_op_info_end()[-1].End;
1755 return hasOperandBundles() && Idx >= getBundleOperandsStartIndex() &&
1756 Idx < getBundleOperandsEndIndex();
1761 assert(
this == U->getUser() &&
1762 "Only valid to query with a use of this instruction!");
1763 return hasOperandBundles() && isBundleOperand(U - op_begin());
1766 return isBundleOperand(&UI.getUse());
1772 if (!hasOperandBundles())
1775 unsigned Begin = getBundleOperandsStartIndex();
1776 unsigned End = getBundleOperandsEndIndex();
1778 assert(Begin <= End &&
"Should be!");
1784 assert(Index < getNumOperandBundles() &&
"Index out of bounds!");
1785 return operandBundleFromBundleOpInfo(*(bundle_op_info_begin() + Index));
1792 for (
unsigned i = 0,
e = getNumOperandBundles(); i !=
e; ++i)
1793 if (getOperandBundleAt(i).getTagName() == Name)
1803 for (
unsigned i = 0,
e = getNumOperandBundles(); i !=
e; ++i)
1804 if (getOperandBundleAt(i).getTagID() == ID)
1815 assert(countOperandBundlesOfType(Name) < 2 &&
"Precondition violated!");
1817 for (
unsigned i = 0,
e = getNumOperandBundles(); i !=
e; ++i) {
1831 assert(countOperandBundlesOfType(ID) < 2 &&
"Precondition violated!");
1833 for (
unsigned i = 0,
e = getNumOperandBundles(); i !=
e; ++i) {
1850 for (
unsigned i = 0,
e = getNumOperandBundles(); i !=
e; ++i)
1859 return operandBundleFromBundleOpInfo(getBundleOpInfoForOperand(OpIdx));
1868 return hasOperandBundles();
1874 for (
auto &BOI : bundle_op_infos()) {
1890 auto &BOI = getBundleOpInfoForOperand(OpIdx);
1891 auto OBU = operandBundleFromBundleOpInfo(BOI);
1892 return OBU.operandHasAttr(OpIdx - BOI.Begin, A);
1902 return std::equal(bundle_op_info_begin(), bundle_op_info_end(),
1909 for (
unsigned i = 0,
e = getNumOperandBundles(); i !=
e; ++i) {
1910 uint32_t ID = getOperandBundleAt(i).getTagID();
1932 case Attribute::InaccessibleMemOrArgMemOnly:
1933 return hasReadingOperandBundles();
1935 case Attribute::InaccessibleMemOnly:
1936 return hasReadingOperandBundles();
1938 case Attribute::ArgMemOnly:
1939 return hasReadingOperandBundles();
1941 case Attribute::ReadNone:
1942 return hasReadingOperandBundles();
1944 case Attribute::ReadOnly:
1945 return hasClobberingOperandBundles();
1967 return Tag == Other.
Tag && Begin == Other.
Begin && End == Other.
End;
1975 auto begin = op_begin();
2030 if (!hasDescriptor())
2033 uint8_t *BytesBegin = getDescriptor().begin();
2040 auto *NonConstThis =
const_cast<CallBase *
>(
this);
2047 if (!hasDescriptor())
2050 uint8_t *BytesEnd = getDescriptor().end();
2057 auto *NonConstThis =
const_cast<CallBase *
>(
this);
2063 return make_range(bundle_op_info_begin(), bundle_op_info_end());
2068 return make_range(bundle_op_info_begin(), bundle_op_info_end());
2078 const unsigned BeginIndex);
2085 for (
auto &BOI : bundle_op_infos())
2086 if (BOI.Begin <= OpIdx && OpIdx < BOI.End)
2096 for (
auto &
B : Bundles)
2097 Total +=
B.input_size();
2106 bool hasFnAttrOnCalledFunction(
StringRef Kind)
const;
2108 template <
typename AttrKind>
bool hasFnAttrImpl(AttrKind Kind)
const {
2114 if (isFnAttrDisallowedByOpBundle(Kind))
2117 return hasFnAttrOnCalledFunction(Kind);
2167 Op<-1>() = ParentPad;
2186 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2198 #endif // LLVM_IR_INSTRTYPES_H bool isFPPredicate() const
void setArgOperand(unsigned i, Value *v)
bool hasOperandBundles() const
Return true if this User has any operand bundles.
iterator_range< User::op_iterator > data_ops()
bool hasReadingOperandBundles() const
Return true if this operand bundle user has operand bundles that may read from the heap...
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
bool hasClobberingOperandBundles() const
Return true if this operand bundle user has operand bundles that may write to the heap...
User::op_iterator data_operands_end()
A parsed version of the target data layout string in and methods for querying it. ...
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
reference emplace_back(ArgTypes &&... Args)
bool data_operands_empty() const
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
bool cannotDuplicate() const
Determine if the invoke cannot be duplicated.
void setCalledFunction(FunctionCallee Fn)
Sets the function called, including updating the function type.
This class is the base class for the comparison instructions.
Type * getSrcTy() const
Return the source type, as a convenience.
static IntegerType * getInt1Ty(LLVMContext &C)
bool doesNotAccessMemory(unsigned OpNo) const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
OperandBundleDefT(std::string Tag, ArrayRef< InputTy > Inputs)
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
bool isFuncletPad() const
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
This class represents lattice values for constants.
BinaryOps getOpcode() const
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
bool isConvergent() const
Determine if the invoke is convergent.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
unsigned getBundleOperandsStartIndex() const
Return the index of the first bundle operand in the Use array.
bool isArgOperand(const Use *U) const
unsigned getNumSubclassExtraOperands() const
void setDoesNotAccessMemory()
The two locations do not alias at all.
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the data operand corresponding to it.
LLVMContext & getContext() const
All values hold a context through their type.
const Use & getOperandUse(unsigned i) const
void addParamAttr(unsigned ArgNo, Attribute Attr)
Adds the attribute to the indicated argument.
static bool classof(const Value *V)
bool bundleOperandHasAttr(unsigned OpIdx, Attribute::AttrKind A) const
Return true if the bundle operand at index OpIdx has the attribute A.
void setArgOperand(unsigned i, Value *v)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
typename std::vector< InputTy >::const_iterator input_iterator
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Get the attribute of a given kind from a given arg.
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
User::op_iterator data_operands_begin()
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
ArrayRef< InputTy > inputs() const
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal...
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
void setCalledFunction(FunctionType *FTy, Value *Fn)
Sets the function called, including updating to the specified function type.
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
UnaryInstruction(Type *Ty, unsigned iType, Value *V, Instruction *IB=nullptr)
static bool classof(const Instruction *I)
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
static BinaryOperator * CreateFRemFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Predicate getSignedPredicate()
For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert.
bool isBundleOperand(unsigned Idx) const
Return true if the operand at index Idx is a bundle operand.
Value * getArgOperand(unsigned i) const
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
iterator_range< User::const_op_iterator > arg_operands() const
void removeParamAttr(unsigned ArgNo, StringRef Kind)
Removes the attribute from the given argument.
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
size_t input_size() const
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
Used to keep track of an operand bundle.
Type * getPointerElementType() const
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
This is the base class for all instructions that perform data casts.
static Constant * getNegativeZero(Type *Ty)
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr, BasicBlock *InsertAtEnd)
Constructor with insert-at-end-of-block semantics for subclasses.
A Use represents the edge between a Value definition and its users.
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
static bool classof(const Value *V)
This file contains the simple types necessary to represent the attributes associated with functions a...
void removeAttribute(unsigned i, StringRef Kind)
removes the attribute from the list of attributes.
static BinaryOperator * CreateWithCopiedFlags(BinaryOps Opc, Value *V1, Value *V2, Instruction *CopyO, const Twine &Name="")
bool operator==(const BundleOpInfo &Other) const
static bool isOrdered(const Instruction *I)
bool isBundleOperand(const Use *U) const
Returns true if the use is a bundle operand.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
OtherOps getOpcode() const
Get the opcode casted to the right type.
bool doesNotThrow() const
Determine if the call cannot unwind.
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag...
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
const BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx) const
Return the BundleOpInfo for the operand at index OpIdx.
Type * getType() const
All values are typed, get the type of this value.
User::const_op_iterator data_operands_end() const
bool isFuncletOperandBundle() const
Return true if this is a "funclet" operand bundle.
unsigned getRetAlignment() const
Extract the alignment of the return value.
void setOnlyReadsMemory()
static BinaryOperator * CreateFMulFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
Value * getCalledOperand() const
void setParentPad(Value *ParentPad)
const_op_range arg_operands() const
arg_operands - iteration adapter for range-for loops.
void setCalledOperand(Value *V)
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
OperandBundleUse getOperandBundleForOperand(unsigned OpIdx) const
Return the operand bundle for the operand at index OpIdx.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
iterator_range< User::op_iterator > arg_operands()
OperandBundleUse(StringMapEntry< uint32_t > *Tag, ArrayRef< Use > Inputs)
bool doesNoCfCheck() const
Determine if the call should not perform indirect branch tracking.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
void setOnlyAccessesInaccessibleMemOrArgMem()
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
bool hasFnAttr(StringRef Kind) const
Determine whether this call has the given attribute.
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
initializer< Ty > init(const Ty &Val)
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
static bool isIntPredicate(Predicate P)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM_NODISCARD AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
bool isNoInline() const
Return true if the call should not be inlined.
unsigned arg_size() const
Value * getCalledValue() const
LLVM Basic Block Representation.
void setCannotDuplicate()
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
The instances of the Type class are immutable: once they are created, they are never changed...
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
unsigned countOperandBundlesOfType(uint32_t ID) const
Return the number of operand bundles with the tag ID attached to this instruction.
bool isInlineAsm() const
Check if this call is an inline asm statement.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
FunctionType * getFunctionType() const
void mutateFunctionType(FunctionType *FTy)
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
iterator_range< User::const_op_iterator > args() const
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
void setCallingConv(CallingConv::ID CC)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static bool classof(const Value *V)
bool isDeoptOperandBundle() const
Return true if this is a "deopt" operand bundle.
unsigned getBundleOperandsEndIndex() const
Return the index of the last bundle operand in the Use array.
bool hasDescriptor() const
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
bool isFnAttrDisallowedByOpBundle(Attribute::AttrKind A) const
Is the function attribute A disallowed by some operand bundle on this operand bundle user...
static bool classof(const Instruction *I)
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
const_bundle_op_iterator bundle_op_info_begin() const
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
The highest possible calling convention ID. Must be some 2^k - 1.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const_bundle_op_iterator bundle_op_info_end() const
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
User::const_op_iterator arg_begin() const
Value * getParentPad() const
Convenience accessors.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const
Return true if the operand at index Idx in this operand bundle has the attribute A.
LLVM_NODISCARD AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
bool doesNotReturn() const
Determine if the call cannot return.
bool returnDoesNotAlias() const
Determine if the return value is marked with NoAlias attribute.
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand's Use.
static unsigned getIntrinsicID(const SDNode *N)
void setOnlyAccessesInaccessibleMemory()
OperandBundleDefT(std::string Tag, std::vector< InputTy > Inputs)
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type *> Tys=None)
Return the function type for an intrinsic.
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics for subclasses.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
void setDoesNotReadMemory()
User::const_op_iterator arg_end() const
Type * getReturnType() const
#define DEFINE_HELPERS(OPC, NUWNSWEXACT)
bool hasByValArgument() const
Determine if any call argument is an aggregate passed by value.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
Type * getDestTy() const
Return the destination type, as a convenience.
Use & getArgOperandUse(unsigned i)
AttributeList getAttributes() const
Return the parameter attributes for this call.
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of funcletpad arguments.
void setValueSubclassData(unsigned short D)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
FunctionType * getFunctionType() const
Returns the FunctionType for me.
bool isIntPredicate() const
bool isTrueWhenEqual() const
This is just a convenience.
A range adaptor for a pair of iterators.
Class to represent vector types.
bool isFalseWhenEqual() const
This is just a convenience.
static bool isFPPredicate(Predicate P)
A lightweight accessor for an operand bundle meant to be passed around by value.
Attribute getAttribute(unsigned i, StringRef Kind) const
Get the attribute of a given kind at a position.
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Use & getCalledOperandUse()
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
bool isFnAttrDisallowedByOpBundle(StringRef S) const
Is the function attribute S disallowed by some operand bundle on this operand bundle user...
static BinaryOperator * CreateFDivFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
static BinaryOperator * CreateFNegFMF(Value *Op, Instruction *FMFSource, const Twine &Name="")
user_iterator_impl< const User > const_user_iterator
bool hasStructRetAttr() const
Determine if the call returns a structure through first pointer argument.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
OperandBundleDefT(const OperandBundleUse &OBU)
Predicate getPredicate() const
Return the predicate for this instruction.
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a call or parameter.
bool isBundleOperand(Value::const_user_iterator UI) const
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
unsigned getNumArgOperands() const
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Return an operand bundle by tag ID, if present.
LLVM_NODISCARD AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
bool isArgOperand(Value::const_user_iterator UI) const
UnaryOps getOpcode() const
AttributeList Attrs
parameter attributes for callable
iterator_range< const_bundle_op_iterator > bundle_op_infos() const
Return the range [bundle_op_info_begin, bundle_op_info_end).
CallingConv::ID getCallingConv() const
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
input_iterator input_begin() const
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
bool isDataOperand(const Use *U) const
bool onlyReadsMemory(unsigned OpNo) const
input_iterator input_end() const
StringRef getTagName() const
Return the tag of this operand bundle as a string.
unsigned getDataOperandNo(const Use *U) const
Given a use for a data operand, get the data operand number that corresponds to it.
unsigned data_operands_size() const
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
static bool classof(const Value *V)
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Compile-time customization of User operands.
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
FunctionType * getFunctionType()
static BinaryOperator * CreateNeg(Value *S1, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
bool doesNotReadMemory(unsigned OpNo) const
static BinaryOperator * CreateFAddFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
static bool isReturnNonNull(Function *F, const SCCNodeSet &SCCNodes, bool &Speculative)
Tests whether this function is known to not return null.
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
bool hasIdenticalOperandBundleSchema(const CallBase &Other) const
Return true if Other has the same sequence of operand bundle tags with the same number of operands on...
Instruction(const Instruction &)=delete
static bool classof(const Value *V)
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
op_range arg_operands()
arg_operands - iteration adapter for range-for loops.
bool hasArgument(const Value *V) const
Returns true if this CallSite passes the given Value* as an argument to the called function...
bool isDataOperand(Value::const_user_iterator UI) const
const Function * getCaller() const
LLVM Value Representation.
void setOnlyAccessesArgMemory()
static bool classof(const Value *V)
static bool classof(const Instruction *I)
A container for an operand bundle being viewed as a set of values rather than a set of uses...
static bool isCommutative(Instruction *I)
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
StringRef - Represent a constant reference to a string, i.e.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
static bool classof(const Instruction *I)
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
const Use & getCalledOperandUse() const
static bool classof(const Instruction *I)
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i has the attribute A.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static BinaryOperator * CreateFSubFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
static UnaryOperator * CreateFNegFMF(Value *Op, Instruction *FMFSource, const Twine &Name="")
User::const_op_iterator data_operands_begin() const
static bool classof(const Value *V)
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
void addAttribute(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand's Use.
static UnaryOperator * CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO, const Twine &Name="")
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
iterator_range< User::const_op_iterator > data_ops() const
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Predicate getSwappedPredicate(Predicate Opcode)
Assume the condition register is set by MI(a,b), return the predicate if we modify the instructions s...