Go to the documentation of this file.
15 #ifndef LLVM_IR_INSTRTYPES_H
16 #define LLVM_IR_INSTRTYPES_H
70 void *
operator new(
size_t S) {
return User::operator
new(
S, 1); }
71 void operator delete(
void *Ptr) { User::operator
delete(Ptr); }
78 return I->isUnaryOp() ||
79 I->getOpcode() == Instruction::Alloca ||
81 I->getOpcode() == Instruction::VAArg ||
82 I->getOpcode() == Instruction::ExtractValue ||
83 (
I->getOpcode() >= CastOpsBegin &&
I->getOpcode() < CastOpsEnd);
86 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
137 #define HANDLE_UNARY_INST(N, OPC, CLASS) \
138 static UnaryOperator *Create##OPC(Value *V, const Twine &Name = "") {\
139 return Create(Instruction::OPC, V, Name);\
141 #include "llvm/IR/Instruction.def"
142 #define HANDLE_UNARY_INST(N, OPC, CLASS) \
143 static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
145 return Create(Instruction::OPC, V, Name, BB);\
147 #include "llvm/IR/Instruction.def"
148 #define HANDLE_UNARY_INST(N, OPC, CLASS) \
149 static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
151 return Create(Instruction::OPC, V, Name, I);\
153 #include "llvm/IR/Instruction.def"
155 static UnaryOperator *
167 return CreateWithCopiedFlags(Instruction::FNeg,
Op, FMFSource,
Name,
177 return I->isUnaryOp();
180 return isa<Instruction>(V) && classof(cast<Instruction>(V));
204 void *
operator new(
size_t S) {
return User::operator
new(
S, 2); }
205 void operator delete(
void *Ptr) { User::operator
delete(Ptr); }
229 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
230 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
231 const Twine &Name = "") {\
232 return Create(Instruction::OPC, V1, V2, Name);\
234 #include "llvm/IR/Instruction.def"
235 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
236 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
237 const Twine &Name, BasicBlock *BB) {\
238 return Create(Instruction::OPC, V1, V2, Name, BB);\
240 #include "llvm/IR/Instruction.def"
241 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
242 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
243 const Twine &Name, Instruction *I) {\
244 return Create(Instruction::OPC, V1, V2, Name, I);\
246 #include "llvm/IR/Instruction.def"
340 #define DEFINE_HELPERS(OPC, NUWNSWEXACT) \
341 static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \
342 const Twine &Name = "") { \
343 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name); \
345 static BinaryOperator *Create##NUWNSWEXACT##OPC( \
346 Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { \
347 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, BB); \
349 static BinaryOperator *Create##NUWNSWEXACT##OPC( \
350 Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
351 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \
368 #undef DEFINE_HELPERS
405 return I->isBinaryOp();
408 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
473 static CastInst *CreateZExtOrBitCast(
481 static CastInst *CreateZExtOrBitCast(
489 static CastInst *CreateSExtOrBitCast(
497 static CastInst *CreateSExtOrBitCast(
521 static CastInst *CreatePointerBitCastOrAddrSpaceCast(
529 static CastInst *CreatePointerBitCastOrAddrSpaceCast(
542 static CastInst *CreateBitOrPointerCast(
584 static CastInst *CreateTruncOrBitCast(
592 static CastInst *CreateTruncOrBitCast(
600 static bool isBitCastable(
610 static bool isBitOrNoopPointerCastable(
630 bool isIntegerCast()
const;
637 bool isLosslessCast()
const;
646 static bool isNoopCast(
664 static unsigned isEliminableCastPair(
691 return castIsValid(
op,
S->getType(), DstTy);
699 return isa<Instruction>(V) && classof(cast<Instruction>(V));
760 Predicate::LAST_FCMP_PREDICATE,
767 Predicate::LAST_ICMP_PREDICATE,
783 void *
operator new(
size_t S) {
return User::operator
new(
S, 2); }
784 void operator delete(
void *Ptr) { User::operator
delete(Ptr); }
816 "FIRST_FCMP_PREDICATE is required to be 0");
1036 return I->getOpcode() == Instruction::ICmp ||
1037 I->getOpcode() == Instruction::FCmp;
1040 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1045 if (
VectorType* vt = dyn_cast<VectorType>(opnd_type)) {
1047 vt->getElementCount());
1055 void setValueSubclassData(
unsigned short D) {
1074 : Inputs(Inputs),
Tag(
Tag) {}
1079 if (isDeoptOperandBundle())
1080 if (A == Attribute::ReadOnly || A == Attribute::NoCapture)
1081 return Inputs[Idx]->getType()->isPointerTy();
1089 return Tag->getKey();
1098 return Tag->getValue();
1127 template <
typename InputTy>
class OperandBundleDefT {
1129 std::vector<InputTy> Inputs;
1182 Bitfield::areContiguous<CallInstReservedField, CallingConvField>(),
1183 "Bitfields must be contiguous");
1191 template <
class... ArgsTy>
1203 case Instruction::Invoke:
1205 case Instruction::CallBr:
1247 I->getOpcode() == Instruction::Invoke ||
1248 I->getOpcode() == Instruction::CallBr;
1251 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1294 assert(
this == U->getUser() &&
1295 "Only valid to query with a use of this instruction!");
1362 assert(
this == U->getUser() &&
1363 "Only valid to query with a use of this instruction!");
1448 assert(cast<PointerType>(Fn->
getType())->isOpaqueOrPointeeTypeMatches(
FTy));
1456 return getSubclassData<CallingConvField>();
1460 setSubclassData<CallingConvField>(CC);
1485 "Use CallBase::isNoBuiltin() to check for Attribute::NoBuiltin");
1486 return hasFnAttrImpl(
Kind);
1596 return hasRetAttrImpl(
Kind);
1619 return getFnAttrOnCalledFunction(
Kind);
1627 return getFnAttrOnCalledFunction(
Kind);
1656 "Data operand index out of bounds!");
1666 "Must be either a call argument or an operand bundle!");
1737 return F->getAttributes().getRetAlignment();
1755 return F->getAttributes().getParamByValType(ArgNo);
1764 return F->getAttributes().getParamPreallocatedType(ArgNo);
1773 return F->getAttributes().getParamInAllocaType(ArgNo);
1782 return F->getAttributes().getParamStructRetType(ArgNo);
1840 return hasFnAttrImpl(Attribute::NoBuiltin) &&
1841 !hasFnAttrImpl(Attribute::Builtin);
1856 return hasImpliedFnAttr(Attribute::ReadOnly);
1863 return hasImpliedFnAttr(Attribute::WriteOnly);
1870 return hasFnAttr(Attribute::ArgMemOnly);
1877 return hasFnAttr(Attribute::InaccessibleMemOnly);
1880 addFnAttr(Attribute::InaccessibleMemOnly);
1886 return hasFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
1889 addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
1974 assert(
this == U->getUser() &&
1975 "Only valid to query with a use of this instruction!");
1991 assert(Begin <= End &&
"Should be!");
2098 return OBU.operandHasAttr(OpIdx - BOI.Begin, A);
2109 Other.bundle_op_info_begin());
2138 case Attribute::InaccessibleMemOrArgMemOnly:
2141 case Attribute::InaccessibleMemOnly:
2144 case Attribute::ArgMemOnly:
2147 case Attribute::ReadNone:
2150 case Attribute::ReadOnly:
2153 case Attribute::WriteOnly:
2249 auto *NonConstThis =
const_cast<CallBase *
>(
this);
2266 auto *NonConstThis =
const_cast<CallBase *
>(
this);
2287 const unsigned BeginIndex);
2303 for (
auto &
B : Bundles)
2304 Total +=
B.input_size();
2315 template <
typename AttrKind>
bool hasFnAttrImpl(AttrKind
Kind)
const {
2324 return hasFnAttrOnCalledFunction(
Kind);
2326 template <
typename AK> Attribute getFnAttrOnCalledFunction(AK
Kind)
const;
2336 assert((
Kind == Attribute::ReadOnly ||
Kind == Attribute::WriteOnly) &&
2337 "use hasFnAttrImpl instead");
2344 return hasFnAttrOnCalledFunction(
Kind) ||
2345 hasFnAttrOnCalledFunction(Attribute::ReadNone);
2350 template <
typename AttrKind>
bool hasRetAttrImpl(AttrKind
Kind)
const {
2356 return F->getAttributes().hasRetAttr(
Kind);
2407 Op<-1>() = ParentPad;
2426 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2438 #endif // LLVM_IR_INSTRTYPES_H
LLVM_NODISCARD AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
Value * getArgOperandWithAttribute(Attribute::AttrKind Kind) const
If one of the arguments has the specified attribute, returns its operand value.
const_bundle_op_iterator bundle_op_info_end() const
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
LLVM_NODISCARD AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
bool hasStructRetAttr() const
Determine if the call returns a structure through first pointer argument.
uint64_t getRetDereferenceableBytes() const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide more efficient getOperand methods.
bool returnDoesNotAlias() const
Determine if the return value is marked with NoAlias attribute.
void addAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
user_iterator_impl< const User > const_user_iterator
ArrayRef< InputTy > inputs() const
const_bundle_op_iterator bundle_op_info_begin() const
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
OperandBundleUse getOperandBundleForOperand(unsigned OpIdx) const
Return the operand bundle for the operand at index OpIdx.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
LLVM_NODISCARD AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
User::const_op_iterator arg_begin() const
This is an optimization pass for GlobalISel generic memory operations.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM_NODISCARD AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
static IntegerType * getInt1Ty(LLVMContext &C)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
unsigned getBundleOperandsEndIndex() const
Return the index of the last bundle operand in the Use array.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
LLVM_NODISCARD AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
A parsed version of the target data layout string in and methods for querying it.
User::const_op_iterator arg_end() const
bool isBundleOperand(const Use *U) const
Returns true if the use is a bundle operand.
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.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Predicate getUnsignedPredicate()
For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert.
bool doesNotReturn() const
Determine if the call cannot return.
void removeFnAttr(Attribute::AttrKind Kind)
Removes the attribute from the function.
static CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, Instruction *InsertPt=nullptr)
Create a clone of CB with operand bundle ID removed.
Use & getArgOperandUse(unsigned i)
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
void swapOperands()
This is just a convenience that dispatches to the subclasses.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
void mutateFunctionType(FunctionType *FTy)
static BinaryOperator * CreateWithCopiedFlags(BinaryOps Opc, Value *V1, Value *V2, Instruction *CopyO, const Twine &Name="", Instruction *InsertBefore=nullptr)
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Use & getCalledOperandUse()
void removeParamAttrs(unsigned ArgNo, const AttributeMask &AttrsToRemove)
Removes the attributes from the given argument.
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
static BinaryOperator * CreateFRemFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of funcletpad arguments.
Predicate getFlippedSignednessPredicate()
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert.
static auto FCmpPredicates()
Returns the sequence of all FCmp predicates.
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
static BinaryOperator * CreateFDivFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
bool isInlineAsm() const
Check if this call is an inline asm statement.
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
AttributeList Attrs
parameter attributes for callable
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
static auto ICmpPredicates()
Returns the sequence of all ICmp predicates.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
DEFINE_HELPERS(Add, NSW) DEFINE_HELPERS(Add
bool isCommutative() const
This is just a convenience that dispatches to the subclasses.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
static CallBase * addOperandBundle(CallBase *CB, uint32_t ID, OperandBundleDef OB, Instruction *InsertPt=nullptr)
Create a clone of CB with operand bundle OB added.
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
@ ICMP_SGT
signed greater than
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isFalseWhenEqual() const
This is just a convenience.
bool isPassingUndefUB(unsigned ArgNo) const
Determine whether passing undef to this argument is undefined behavior.
LLVM_NODISCARD AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
AttributeList getAttributes() const
Return the parameter attributes for this call.
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
bool isOperandBundleOfType(uint32_t ID, unsigned Idx) const
Return true if the operand at index Idx is a bundle operand that has tag ID ID.
A container for an operand bundle being viewed as a set of values rather than a set of uses.
FunctionType * getFunctionType() const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand's Use.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
bool hasArgument(const Value *V) const
Returns true if this CallSite passes the given Value* as an argument to the called function.
bool hasDescriptor() const
unsigned getDataOperandNo(const Use *U) const
Given a use for a data operand, get the data operand number that corresponds to it.
void addFnAttr(Attribute Attr)
Adds the attribute to the function.
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics for subclasses.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
OtherOps getOpcode() const
Get the opcode casted to the right type.
OperandBundleDefT(std::string Tag, std::vector< InputTy > Inputs)
@ ICMP_SLE
signed less or equal
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
static StringRef getPredicateName(Predicate P)
NUW NUW NUW NUW Exact static Exact BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
void setValueSubclassData(unsigned short D)
bool isFnAttrDisallowedByOpBundle(StringRef S) const
Is the function attribute S disallowed by some operand bundle on this operand bundle user?
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
op_range arg_operands()
arg_operands - iteration adapter for range-for loops.
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand's Use.
Type * getDestTy() const
Return the destination type, as a convenience.
void setOnlyAccessesArgMemory()
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Return an operand bundle by tag ID, if present.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Get the attribute of a given kind for the function.
unsigned getArgOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the arg operand number corresponding to it.
LLVM Basic Block Representation.
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...
MaybeAlign getParamStackAlign(unsigned ArgNo) const
uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
@ FCMP_ULT
1 1 0 0 True if unordered or less than
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
void setOnlyAccessesInaccessibleMemory()
const Use & getOperandUse(unsigned i) const
UnaryOps getOpcode() const
bool isDataOperand(Value::const_user_iterator UI) const
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
bool swapOperands()
Exchange the two operands to this instruction.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool isFnAttrDisallowedByOpBundle(Attribute::AttrKind A) const
Is the function attribute A disallowed by some operand bundle on this operand bundle user?
bool hasByValArgument() const
Determine if any call argument is an aggregate passed by value.
unsigned data_operands_size() const
Compile-time customization of User operands.
bool isFPPredicate() const
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
bool isDeoptOperandBundle() const
Return true if this is a "deopt" operand bundle.
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
const Use & getCalledOperandUse() const
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
Predicate getSignedPredicate()
For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert.
void removeFnAttrs(const AttributeMask &AttrsToRemove)
Removes the attributes from the function.
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
@ ICMP_ULE
unsigned less or equal
BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx)
Return the BundleOpInfo for the operand at index OpIdx.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
typename std::vector< InputTy >::const_iterator input_iterator
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, Instruction *InsertBefore)
void removeRetAttrs(const AttributeMask &AttrsToRemove)
Removes the attributes from the return value.
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
static bool classof(const Value *V)
static bool classof(const Value *V)
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
bool isConvergent() const
Determine if the invoke is convergent.
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const
Get the attribute of a given kind at a position.
BinaryOps getOpcode() const
void setDoesNotAccessMemory()
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
bool isArgOperand(Value::const_user_iterator UI) const
static UnaryOperator * CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO, const Twine &Name="", Instruction *InsertBefore=nullptr)
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a call or parameter.
User::const_op_iterator data_operands_begin() const
FunctionType * getFunctionType()
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Used to keep track of an operand bundle.
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
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.
bool isDataOperand(const Use *U) const
LLVM_NODISCARD AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
User::op_iterator data_operands_end()
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t getParamDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
Type * getSrcTy() const
Return the source type, as a convenience.
CallingConv::ID getCallingConv() const
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
LLVM_NODISCARD AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
bool onlyReadsMemory(unsigned OpNo) const
Function * getCaller()
Helper to get the caller (the parent function).
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
bool isBundleOperand(Value::const_user_iterator UI) const
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
bool isStrictPredicate() const
This class is the base class for the comparison instructions.
bool isFuncletOperandBundle() const
Return true if this is a "funclet" operand bundle.
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.
Base class of all SIMD vector types.
uint64_t getParamDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a parameter (0=unknown).
Value(Type *Ty, unsigned scid)
Type * getParamElementType(unsigned ArgNo) const
Extract the elementtype type for a parameter.
void addDereferenceableRetAttr(uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
unsigned getBundleOperandsStartIndex() const
Return the index of the first bundle operand in the Use array.
input_iterator input_end() const
void addRetAttr(Attribute Attr)
Adds the attribute to the return value.
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
const Function * getCaller() const
bool isTailCall() const
Tests if this call site is marked as a tail call.
static UnaryOperator * CreateFNegFMF(Value *Op, Instruction *FMFSource, const Twine &Name="", Instruction *InsertBefore=nullptr)
bool doesNotAccessMemory(unsigned OpNo) const
OperandBundleDefT(std::string Tag, ArrayRef< InputTy > Inputs)
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
MaybeAlign getRetAlign() const
Extract the alignment of the return value.
iterator_range< const_bundle_op_iterator > bundle_op_infos() const
Return the range [bundle_op_info_begin, bundle_op_info_end).
static BinaryOperator * CreateFMulFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
static bool classof(const Value *V)
bool isCFGuardTargetOperandBundle() const
Return true if this is a "cfguardtarget" operand bundle.
static bool classof(const Instruction *I)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static bool isIntPredicate(Predicate P)
iterator_range< User::op_iterator > data_ops()
size_t input_size() const
uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, Value *RHS, const Twine &Name="", Instruction *InsertBefore=nullptr, Instruction *FlagsSource=nullptr)
OperandBundleUse(StringMapEntry< uint32_t > *Tag, ArrayRef< Use > Inputs)
unsigned getNumSubclassExtraOperands() const
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
iterator_range< User::const_op_iterator > data_ops() const
initializer< Ty > init(const Ty &Val)
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool cannotMerge() const
Determine if the call cannot be tail merged.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
void addRetAttr(Attribute::AttrKind Kind)
Adds the attribute to the return value.
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
void addAttributeAtIndex(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
@ MaxID
The highest possible calling convention ID. Must be some 2^k - 1.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setArgOperand(unsigned i, Value *v)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool hasOperandBundles() const
Return true if this User has any operand bundles.
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
uint64_t getRetDereferenceableOrNullBytes() const
Extract the number of dereferenceable_or_null bytes for a call (0=unknown).
unsigned getNumSubclassExtraOperandsDynamic() const
Get the number of extra operands for instructions that don't have a fixed number of extra operands.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static CallBase * Create(CallBase *CB, ArrayRef< OperandBundleDef > Bundles, Instruction *InsertPt=nullptr)
Create a clone of CB with a different set of operand bundles and insert it before InsertPt.
const BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx) const
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a call or parameter.
void setOperand(unsigned i, Value *Val)
@ ICMP_SLT
signed less than
bool isIntPredicate() const
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
void addParamAttr(unsigned ArgNo, Attribute Attr)
Adds the attribute to the indicated argument.
UnaryInstruction(Type *Ty, unsigned iType, Value *V, Instruction *IB=nullptr)
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Attribute getFnAttr(StringRef Kind) const
Get the attribute of a given kind for the function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
static bool classof(const Instruction *I)
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
StringRef - Represent a constant reference to a string, i.e.
Type * getParamPreallocatedType(unsigned ArgNo) const
Extract the preallocated type for a call or parameter.
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
@ ICMP_ULT
unsigned less than
bool cannotDuplicate() const
Determine if the invoke cannot be duplicated.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
bool hasClobberingOperandBundles() const
Return true if this operand bundle user has operand bundles that may write to the heap.
static constexpr unsigned NextBit
A lightweight accessor for an operand bundle meant to be passed around by value.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
LLVMContext & getContext() const
All values hold a context through their type.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool classof(const Instruction *I)
OperandBundleDefT< Value * > OperandBundleDef
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
This is the base class for all instructions that perform data casts.
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
bool hasFnAttr(StringRef Kind) const
Determine whether this call has the given attribute.
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i has the attribute A.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
void setArgOperand(unsigned i, Value *v)
bool onlyWritesMemory(unsigned OpNo) const
bool doesNotThrow() const
Determine if the call cannot unwind.
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
static bool isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2)
Determine if Pred1 implies Pred2 is false when two compares have matching operands.
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
static bool classof(const Instruction *I)
OperandBundleDefT(const OperandBundleUse &OBU)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
unsigned countOperandBundlesOfType(uint32_t ID) const
Return the number of operand bundles with the tag ID attached to this instruction.
Instruction(const Instruction &)=delete
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Get the attribute of a given kind from a given arg.
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
static bool isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2)
Determine if Pred1 implies Pred2 is true when two compares have matching operands.
bool isBundleOperand(unsigned Idx) const
Return true if the operand at index Idx is a bundle operand.
void setCalledFunction(FunctionCallee Fn)
Sets the function called, including updating the function type.
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the data operand corresponding to it.
bool isArgOperand(const Use *U) const
static BinaryOperator * CreateFAddFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
bool data_operands_empty() const
bool isNonStrictPredicate() const
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
bool isNoInline() const
Return true if the call should not be inlined.
unsigned arg_size() const
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
User::const_op_iterator data_operands_end() const
bool isReturnNonNull() const
Return true if the return value is known to be not null.
input_iterator input_begin() const
static BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
bool operator==(const BundleOpInfo &Other) const
static bool classof(const Value *V)
static bool classof(const Value *V)
bool isIndirectCall() const
Return true if the callsite is an indirect call.
bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const
Return true if the operand at index Idx in this operand bundle has the attribute A.
void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
LLVM_NODISCARD AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
bool isEquality() const
Determine if this is an equals/not equals predicate.
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
unsigned getArgOperandNo(const Use *U) const
Given a use for a arg operand, get the arg operand number that corresponds to it.
Describes an element of a Bitfield.
@ ICMP_SGE
signed greater or equal
op_iterator populateBundleOperandInfos(ArrayRef< OperandBundleDef > Bundles, const unsigned BeginIndex)
Populate the BundleOpInfo instances and the Use& vector from Bundles.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
void setOnlyAccessesInaccessibleMemOrArgMem()
Predicate getStrictPredicate() const
For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT.
Value * getCalledOperand() const
bool doesNoCfCheck() const
Determine if the call should not perform indirect branch tracking.
iterator_range< User::const_op_iterator > args() const
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
bool isTrueWhenEqual() const
This is just a convenience.
void setCalledOperand(Value *V)
static CmpInst * Create(OtherOps Op, Predicate predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
static bool isFPPredicate(Predicate P)
void setOnlyWritesMemory()
void removeAttributeAtIndex(unsigned i, StringRef Kind)
removes the attribute from the list of attributes.
StringRef getTagName() const
Return the tag of this operand bundle as a string.
bool hasRetAttr(StringRef Kind) const
Determine whether the return value has the given attribute.
@ ICMP_UGT
unsigned greater than
static bool classof(const Value *V)
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Value * getArgOperand(unsigned i) const
static constexpr int CalledOperandOpEndIdx
The last operand is the called operand.
Value * getReturnedArgOperand() const
If one of the arguments has the 'returned' attribute, returns its operand value.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
User::op_iterator data_operands_begin()
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
LLVM_NODISCARD AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Predicate getPredicate() const
Return the predicate for this instruction.
static BinaryOperator * CreateNUWNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
BinaryOperator * cloneImpl() const
A range adaptor for a pair of iterators.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
static bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
LLVM_NODISCARD AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void removeParamAttr(unsigned ArgNo, StringRef Kind)
Removes the attribute from the given argument.
void addDereferenceableParamAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr, BasicBlock *InsertAtEnd)
Constructor with insert-at-end-of-block semantics for subclasses.
static bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
bool isPassPointeeByValueArgument(unsigned ArgNo) const
Determine whether this argument is passed by value, in an alloca, or is preallocated.
void setCalledFunction(FunctionType *FTy, Value *Fn)
Sets the function called, including updating to the specified function type.
void removeRetAttr(Attribute::AttrKind Kind)
Removes the attribute from the return value.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a call or parameter.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Value * getOperand(unsigned i) const
Value * getParentPad() const
Convenience accessors.
void setCannotDuplicate()
bool onlyWritesMemory() const
Determine if the call does not access or only writes memory.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
void setParentPad(Value *ParentPad)
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Type * getReturnType() const
LLVM Value Representation.
const_op_range arg_operands() const
arg_operands - iteration adapter for range-for loops.
bool hasReadingOperandBundles() const
Return true if this operand bundle user has operand bundles that may read from the heap.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Bitfield::Element< Predicate, 0, 6, LAST_ICMP_PREDICATE > PredicateField
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
static bool classof(const Instruction *I)
static BinaryOperator * CreateFSubFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
friend class BasicBlock
Various leaf nodes.
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
Optional< std::vector< StOtherPiece > > Other
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
void setCallingConv(CallingConv::ID CC)
Class to represent function types.
A Use represents the edge between a Value definition and its users.
bool doesNotAccessMemory() const
Determine if the call does not access memory.
void setOnlyReadsMemory()