15#ifndef LLVM_IR_ATTRIBUTES_H
16#define LLVM_IR_ATTRIBUTES_H
22#include "llvm/Config/llvm-config.h"
69 assert(DeadBytes.has_value() &&
70 "This attribute does not specify a byte count. Did you forget to "
71 "check if the attribute covers all reachable memory?");
72 return DeadBytes.value();
78 if (
Data == std::numeric_limits<uint64_t>::max())
84 if (DeadBytes.has_value())
85 return DeadBytes.value();
86 return std::numeric_limits<uint64_t>::max();
90 return DeadBytes.has_value() && DeadBytes.value() == 0;
94 std::optional<uint64_t> DeadBytes;
125 #define GET_ATTR_ENUM
126 #include "llvm/IR/Attributes.inc"
136 return Kind >= FirstEnumAttr && Kind <= LastEnumAttr;
139 return Kind >= FirstIntAttr && Kind <= LastIntAttr;
142 return Kind >= FirstTypeAttr && Kind <= LastTypeAttr;
145 return Kind >= FirstConstantRangeAttr && Kind <= LastConstantRangeAttr;
148 return Kind >= FirstConstantRangeListAttr &&
149 Kind <= LastConstantRangeListAttr;
196 const std::optional<unsigned> &NumElemsArg);
325 LLVM_ABI std::pair<unsigned, std::optional<unsigned>>
403 friend AttributeListImpl;
425 bool operator==(
const AttributeSet &O)
const {
return SetNode == O.SetNode; }
426 bool operator!=(
const AttributeSet &O)
const {
return !(*
this == O); }
465 [[nodiscard]]
LLVM_ABI std::optional<AttributeSet>
497 LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>>
515#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
525 auto Val =
static_cast<uintptr_t
>(-1);
526 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
531 auto Val =
static_cast<uintptr_t
>(-2);
532 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
537 return (
unsigned((uintptr_t)AS.SetNode) >> 4) ^
538 (
unsigned((uintptr_t)AS.SetNode) >> 9);
554 enum AttrIndex :
unsigned {
561 friend class AttrBuilder;
562 friend class AttributeListImpl;
563 friend class AttributeSet;
564 friend class AttributeSetNode;
565 template <
typename Ty,
typename Enable>
friend struct DenseMapInfo;
569 AttributeListImpl *pImpl =
nullptr;
574 get(LLVMContext &
C, ArrayRef<std::pair<unsigned, Attribute>> Attrs);
576 get(LLVMContext &
C, ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
580 LLVM_ABI static AttributeList
get(LLVMContext &
C, AttributeSet FnAttrs,
581 AttributeSet RetAttrs,
582 ArrayRef<AttributeSet> ArgAttrs);
585 explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
587 static AttributeList getImpl(LLVMContext &
C, ArrayRef<AttributeSet> AttrSets);
589 AttributeList setAttributesAtIndex(LLVMContext &
C,
unsigned Index,
590 AttributeSet Attrs)
const;
593 AttributeList() =
default;
601 ArrayRef<AttributeList> Attrs);
602 LLVM_ABI static AttributeList
get(LLVMContext &
C,
unsigned Index,
603 ArrayRef<Attribute::AttrKind> Kinds);
604 LLVM_ABI static AttributeList
get(LLVMContext &
C,
unsigned Index,
605 ArrayRef<Attribute::AttrKind> Kinds,
606 ArrayRef<uint64_t> Values);
607 LLVM_ABI static AttributeList
get(LLVMContext &
C,
unsigned Index,
608 ArrayRef<StringRef> Kind);
609 LLVM_ABI static AttributeList
get(LLVMContext &
C,
unsigned Index,
611 LLVM_ABI static AttributeList
get(LLVMContext &
C,
unsigned Index,
612 const AttrBuilder &
B);
617 [[nodiscard]]
LLVM_ABI AttributeList addAttributeAtIndex(
618 LLVMContext &
C,
unsigned Index, Attribute::AttrKind Kind)
const;
622 [[nodiscard]]
LLVM_ABI AttributeList
623 addAttributeAtIndex(LLVMContext &
C,
unsigned Index, StringRef Kind,
624 StringRef
Value = StringRef())
const;
628 [[nodiscard]]
LLVM_ABI AttributeList addAttributeAtIndex(LLVMContext &
C,
634 [[nodiscard]]
LLVM_ABI AttributeList addAttributesAtIndex(
635 LLVMContext &
C,
unsigned Index,
const AttrBuilder &
B)
const;
639 [[nodiscard]] AttributeList addFnAttribute(LLVMContext &
C,
640 Attribute::AttrKind Kind)
const {
641 return addAttributeAtIndex(
C, FunctionIndex, Kind);
646 [[nodiscard]] AttributeList addFnAttribute(LLVMContext &
C,
647 Attribute Attr)
const {
648 return addAttributeAtIndex(
C, FunctionIndex, Attr);
653 [[nodiscard]] AttributeList
654 addFnAttribute(LLVMContext &
C, StringRef Kind,
655 StringRef
Value = StringRef())
const {
656 return addAttributeAtIndex(
C, FunctionIndex, Kind,
Value);
661 [[nodiscard]] AttributeList addFnAttributes(LLVMContext &
C,
662 const AttrBuilder &
B)
const {
663 return addAttributesAtIndex(
C, FunctionIndex,
B);
668 [[nodiscard]] AttributeList addRetAttribute(LLVMContext &
C,
669 Attribute::AttrKind Kind)
const {
670 return addAttributeAtIndex(
C, ReturnIndex, Kind);
675 [[nodiscard]] AttributeList addRetAttribute(LLVMContext &
C,
676 Attribute Attr)
const {
677 return addAttributeAtIndex(
C, ReturnIndex, Attr);
682 [[nodiscard]] AttributeList addRetAttributes(LLVMContext &
C,
683 const AttrBuilder &
B)
const {
684 return addAttributesAtIndex(
C, ReturnIndex,
B);
689 [[nodiscard]] AttributeList
690 addParamAttribute(LLVMContext &
C,
unsigned ArgNo,
691 Attribute::AttrKind Kind)
const {
692 return addAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind);
697 [[nodiscard]] AttributeList
698 addParamAttribute(LLVMContext &
C,
unsigned ArgNo, StringRef Kind,
699 StringRef
Value = StringRef())
const {
700 return addAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind,
Value);
705 [[nodiscard]]
LLVM_ABI AttributeList addParamAttribute(
706 LLVMContext &
C, ArrayRef<unsigned> ArgNos, Attribute
A)
const;
710 [[nodiscard]] AttributeList addParamAttributes(LLVMContext &
C,
unsigned ArgNo,
711 const AttrBuilder &
B)
const {
712 return addAttributesAtIndex(
C, ArgNo + FirstArgIndex,
B);
717 [[nodiscard]]
LLVM_ABI AttributeList removeAttributeAtIndex(
718 LLVMContext &
C,
unsigned Index, Attribute::AttrKind Kind)
const;
722 [[nodiscard]]
LLVM_ABI AttributeList
723 removeAttributeAtIndex(LLVMContext &
C,
unsigned Index, StringRef Kind)
const;
724 [[nodiscard]] AttributeList removeAttribute(LLVMContext &
C,
unsigned Index,
725 StringRef Kind)
const {
726 return removeAttributeAtIndex(
C, Index, Kind);
731 [[nodiscard]]
LLVM_ABI AttributeList removeAttributesAtIndex(
732 LLVMContext &
C,
unsigned Index,
const AttributeMask &AttrsToRemove)
const;
736 [[nodiscard]]
LLVM_ABI AttributeList
737 removeAttributesAtIndex(LLVMContext &
C,
unsigned Index)
const;
741 [[nodiscard]] AttributeList
742 removeFnAttribute(LLVMContext &
C, Attribute::AttrKind Kind)
const {
743 return removeAttributeAtIndex(
C, FunctionIndex, Kind);
748 [[nodiscard]] AttributeList removeFnAttribute(LLVMContext &
C,
749 StringRef Kind)
const {
750 return removeAttributeAtIndex(
C, FunctionIndex, Kind);
755 [[nodiscard]] AttributeList
756 removeFnAttributes(LLVMContext &
C,
const AttributeMask &AttrsToRemove)
const {
757 return removeAttributesAtIndex(
C, FunctionIndex, AttrsToRemove);
762 [[nodiscard]] AttributeList removeFnAttributes(LLVMContext &
C)
const {
763 return removeAttributesAtIndex(
C, FunctionIndex);
768 [[nodiscard]] AttributeList
769 removeRetAttribute(LLVMContext &
C, Attribute::AttrKind Kind)
const {
770 return removeAttributeAtIndex(
C, ReturnIndex, Kind);
775 [[nodiscard]] AttributeList removeRetAttribute(LLVMContext &
C,
776 StringRef Kind)
const {
777 return removeAttributeAtIndex(
C, ReturnIndex, Kind);
782 [[nodiscard]] AttributeList
783 removeRetAttributes(LLVMContext &
C,
784 const AttributeMask &AttrsToRemove)
const {
785 return removeAttributesAtIndex(
C, ReturnIndex, AttrsToRemove);
790 [[nodiscard]] AttributeList
791 removeParamAttribute(LLVMContext &
C,
unsigned ArgNo,
792 Attribute::AttrKind Kind)
const {
793 return removeAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind);
798 [[nodiscard]] AttributeList
799 removeParamAttribute(LLVMContext &
C,
unsigned ArgNo, StringRef Kind)
const {
800 return removeAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind);
805 [[nodiscard]] AttributeList
806 removeParamAttributes(LLVMContext &
C,
unsigned ArgNo,
807 const AttributeMask &AttrsToRemove)
const {
808 return removeAttributesAtIndex(
C, ArgNo + FirstArgIndex, AttrsToRemove);
813 [[nodiscard]] AttributeList removeParamAttributes(LLVMContext &
C,
814 unsigned ArgNo)
const {
815 return removeAttributesAtIndex(
C, ArgNo + FirstArgIndex);
820 [[nodiscard]] AttributeList
821 replaceAttributeTypeAtIndex(LLVMContext &
C,
unsigned ArgNo,
822 Attribute::AttrKind Kind,
823 Type *ReplacementTy)
const {
824 Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
825 auto Attrs = removeAttributeAtIndex(
C, ArgNo, Kind);
826 return Attrs.addAttributeAtIndex(
C, ArgNo,
827 Attr.getWithNewType(
C, ReplacementTy));
832 [[nodiscard]]
LLVM_ABI AttributeList
833 addDereferenceableRetAttr(LLVMContext &
C, uint64_t Bytes)
const;
837 [[nodiscard]]
LLVM_ABI AttributeList addDereferenceableParamAttr(
838 LLVMContext &
C,
unsigned ArgNo, uint64_t Bytes)
const;
843 [[nodiscard]]
LLVM_ABI AttributeList addDereferenceableOrNullParamAttr(
844 LLVMContext &
C,
unsigned ArgNo, uint64_t Bytes)
const;
848 [[nodiscard]]
LLVM_ABI AttributeList
853 [[nodiscard]]
LLVM_ABI AttributeList
854 addAllocSizeParamAttr(LLVMContext &
C,
unsigned ArgNo,
unsigned ElemSizeArg,
855 const std::optional<unsigned> &NumElemsArg)
const;
860 [[nodiscard]]
LLVM_ABI std::optional<AttributeList>
861 intersectWith(LLVMContext &
C, AttributeList Other)
const;
872 LLVM_ABI AttributeSet getParamAttrs(
unsigned ArgNo)
const;
875 LLVM_ABI AttributeSet getRetAttrs()
const;
878 LLVM_ABI AttributeSet getFnAttrs()
const;
881 LLVM_ABI bool hasAttributeAtIndex(
unsigned Index,
882 Attribute::AttrKind Kind)
const;
885 LLVM_ABI bool hasAttributeAtIndex(
unsigned Index, StringRef Kind)
const;
888 LLVM_ABI bool hasAttributesAtIndex(
unsigned Index)
const;
891 bool hasParamAttr(
unsigned ArgNo, Attribute::AttrKind Kind)
const {
892 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
896 bool hasParamAttr(
unsigned ArgNo, StringRef Kind)
const {
897 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
901 bool hasParamAttrs(
unsigned ArgNo)
const {
902 return hasAttributesAtIndex(ArgNo + FirstArgIndex);
906 bool hasRetAttr(Attribute::AttrKind Kind)
const {
907 return hasAttributeAtIndex(ReturnIndex, Kind);
911 bool hasRetAttr(StringRef Kind)
const {
912 return hasAttributeAtIndex(ReturnIndex, Kind);
916 bool hasRetAttrs()
const {
return hasAttributesAtIndex(ReturnIndex); }
919 LLVM_ABI bool hasFnAttr(Attribute::AttrKind Kind)
const;
922 LLVM_ABI bool hasFnAttr(StringRef Kind)
const;
925 bool hasFnAttrs()
const {
return hasAttributesAtIndex(FunctionIndex); }
930 LLVM_ABI bool hasAttrSomewhere(Attribute::AttrKind Kind,
931 unsigned *Index =
nullptr)
const;
935 Attribute::AttrKind Kind)
const;
941 Attribute getParamAttr(
unsigned ArgNo, Attribute::AttrKind Kind)
const {
942 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
946 Attribute getParamAttr(
unsigned ArgNo, StringRef Kind)
const {
947 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
951 Attribute getFnAttr(Attribute::AttrKind Kind)
const {
952 return getAttributeAtIndex(FunctionIndex, Kind);
956 Attribute getFnAttr(StringRef Kind)
const {
957 return getAttributeAtIndex(FunctionIndex, Kind);
961 Attribute getRetAttr(Attribute::AttrKind Kind)
const {
962 return getAttributeAtIndex(ReturnIndex, Kind);
966 LLVM_ABI MaybeAlign getRetAlignment()
const;
969 LLVM_ABI MaybeAlign getParamAlignment(
unsigned ArgNo)
const;
972 LLVM_ABI MaybeAlign getParamStackAlignment(
unsigned ArgNo)
const;
978 LLVM_ABI Type *getParamStructRetType(
unsigned ArgNo)
const;
984 LLVM_ABI Type *getParamPreallocatedType(
unsigned ArgNo)
const;
987 LLVM_ABI Type *getParamInAllocaType(
unsigned ArgNo)
const;
990 LLVM_ABI Type *getParamElementType(
unsigned ArgNo)
const;
996 LLVM_ABI MaybeAlign getRetStackAlignment()
const;
1000 LLVM_ABI uint64_t getRetDereferenceableBytes()
const;
1003 LLVM_ABI uint64_t getParamDereferenceableBytes(
unsigned Index)
const;
1007 LLVM_ABI uint64_t getRetDereferenceableOrNullBytes()
const;
1010 LLVM_ABI DeadOnReturnInfo getDeadOnReturnInfo(
unsigned Index)
const;
1014 LLVM_ABI uint64_t getParamDereferenceableOrNullBytes(
unsigned ArgNo)
const;
1017 LLVM_ABI std::optional<ConstantRange> getParamRange(
unsigned ArgNo)
const;
1034 LLVM_ABI std::string getAsString(
unsigned Index,
1035 bool InAttrGrp =
false)
const;
1038 LLVM_ABI bool hasParentContext(LLVMContext &
C)
const;
1044 using iterator =
const AttributeSet *;
1049 LLVM_ABI unsigned getNumAttrSets()
const;
1054 struct index_iterator {
1055 unsigned NumAttrSets;
1056 index_iterator(
int NumAttrSets) : NumAttrSets(NumAttrSets) {}
1057 struct int_wrapper {
1058 int_wrapper(
unsigned i) : i(i) {}
1062 int_wrapper &operator++() {
1070 int_wrapper
begin() {
return int_wrapper(AttributeList::FunctionIndex); }
1072 int_wrapper
end() {
return int_wrapper(NumAttrSets - 1); }
1076 index_iterator indexes()
const {
return index_iterator(getNumAttrSets()); }
1079 bool operator==(
const AttributeList &
RHS)
const {
return pImpl ==
RHS.pImpl; }
1080 bool operator!=(
const AttributeList &
RHS)
const {
return pImpl !=
RHS.pImpl; }
1083 void *getRawPointer()
const {
1088 bool isEmpty()
const {
return pImpl ==
nullptr; }
1099 static AttributeList getEmptyKey() {
1100 auto Val =
static_cast<uintptr_t
>(-1);
1101 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1102 return AttributeList(
reinterpret_cast<AttributeListImpl *
>(Val));
1105 static AttributeList getTombstoneKey() {
1106 auto Val =
static_cast<uintptr_t
>(-2);
1107 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1108 return AttributeList(
reinterpret_cast<AttributeListImpl *
>(Val));
1111 static unsigned getHashValue(AttributeList AS) {
1112 return (
unsigned((uintptr_t)AS.pImpl) >> 4) ^
1113 (unsigned((uintptr_t)AS.pImpl) >> 9);
1129 SmallVector<Attribute, 8>
Attrs;
1132 AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1133 AttrBuilder(
const AttrBuilder &) =
delete;
1134 AttrBuilder(AttrBuilder &&) =
default;
1136 AttrBuilder(LLVMContext &Ctx,
const Attribute &
A) : Ctx(Ctx) {
1140 LLVM_ABI AttrBuilder(LLVMContext &Ctx, AttributeSet AS);
1145 LLVM_ABI AttrBuilder &addAttribute(Attribute::AttrKind Val);
1148 LLVM_ABI AttrBuilder &addAttribute(Attribute
A);
1151 LLVM_ABI AttrBuilder &addAttribute(StringRef
A, StringRef V = StringRef());
1154 LLVM_ABI AttrBuilder &removeAttribute(Attribute::AttrKind Val);
1157 LLVM_ABI AttrBuilder &removeAttribute(StringRef
A);
1160 AttrBuilder &removeAttribute(Attribute
A) {
1161 if (
A.isStringAttribute())
1162 return removeAttribute(
A.getKindAsString());
1164 return removeAttribute(
A.getKindAsEnum());
1176 LLVM_ABI bool overlaps(
const AttributeMask &AM)
const;
1186 bool hasAttributes()
const {
return !
Attrs.empty(); }
1203 getRawIntAttr(Attribute::AttrKind Kind)
const;
1207 return MaybeAlign(getRawIntAttr(Attribute::Alignment).value_or(0));
1211 MaybeAlign getStackAlignment()
const {
1212 return MaybeAlign(getRawIntAttr(Attribute::StackAlignment).value_or(0));
1217 uint64_t getDereferenceableBytes()
const {
1218 return getRawIntAttr(Attribute::Dereferenceable).value_or(0);
1223 uint64_t getDereferenceableOrNullBytes()
const {
1224 return getRawIntAttr(Attribute::DereferenceableOrNull).value_or(0);
1230 std::optional<uint64_t> Raw = getRawIntAttr(Attribute::NoFPClass);
1235 LLVM_ABI Type *getTypeAttr(Attribute::AttrKind Kind)
const;
1238 Type *getByValType()
const {
return getTypeAttr(Attribute::ByVal); }
1241 Type *getStructRetType()
const {
return getTypeAttr(Attribute::StructRet); }
1244 Type *getByRefType()
const {
return getTypeAttr(Attribute::ByRef); }
1247 Type *getPreallocatedType()
const {
1248 return getTypeAttr(Attribute::Preallocated);
1252 Type *getInAllocaType()
const {
return getTypeAttr(Attribute::InAlloca); }
1256 LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>>
1257 getAllocSizeArgs()
const;
1260 LLVM_ABI AttrBuilder &addRawIntAttr(Attribute::AttrKind Kind, uint64_t
Value);
1264 LLVM_ABI AttrBuilder &addAlignmentAttr(MaybeAlign Align);
1270 inline AttrBuilder &addAlignmentAttr(
unsigned Align) {
1271 return addAlignmentAttr(MaybeAlign(Align));
1276 LLVM_ABI AttrBuilder &addStackAlignmentAttr(MaybeAlign Align);
1282 inline AttrBuilder &addStackAlignmentAttr(
unsigned Align) {
1283 return addStackAlignmentAttr(MaybeAlign(Align));
1288 LLVM_ABI AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
1292 LLVM_ABI AttrBuilder &addDeadOnReturnAttr(DeadOnReturnInfo Info);
1296 LLVM_ABI AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
1300 addAllocSizeAttr(
unsigned ElemSizeArg,
1301 const std::optional<unsigned> &NumElemsArg);
1304 LLVM_ABI AttrBuilder &addVScaleRangeAttr(
unsigned MinValue,
1305 std::optional<unsigned> MaxValue);
1308 LLVM_ABI AttrBuilder &addTypeAttr(Attribute::AttrKind Kind,
Type *Ty);
1327 LLVM_ABI AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr);
1332 addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr);
1336 LLVM_ABI AttrBuilder &addUWTableAttr(UWTableKind Kind);
1339 LLVM_ABI AttrBuilder &addAllocKindAttr(AllocFnKind Kind);
1342 LLVM_ABI AttrBuilder &addMemoryAttr(MemoryEffects ME);
1345 LLVM_ABI AttrBuilder &addCapturesAttr(CaptureInfo CI);
1348 LLVM_ABI AttrBuilder &addNoFPClassAttr(FPClassTest NoFPClassMask);
1351 LLVM_ABI AttrBuilder &addConstantRangeAttr(Attribute::AttrKind Kind,
1352 const ConstantRange &CR);
1355 LLVM_ABI AttrBuilder &addRangeAttr(
const ConstantRange &CR);
1358 LLVM_ABI AttrBuilder &addConstantRangeListAttr(Attribute::AttrKind Kind,
1359 ArrayRef<ConstantRange> Val);
1362 LLVM_ABI AttrBuilder &addInitializesAttr(
const ConstantRangeList &CRL);
1367 LLVM_ABI AttrBuilder &addFromEquivalentMetadata(
const Instruction &
I);
1369 ArrayRef<Attribute> attrs()
const {
return Attrs; }
1372 bool operator!=(
const AttrBuilder &
B)
const {
return !(*
this ==
B); }
1375namespace AttributeFuncs {
1377enum AttributeSafetyKind : uint8_t {
1378 ASK_SAFE_TO_DROP = 1,
1379 ASK_UNSAFE_TO_DROP = 2,
1380 ASK_ALL = ASK_SAFE_TO_DROP | ASK_UNSAFE_TO_DROP,
1397 AttributeSafetyKind ASK = ASK_ALL);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static std::optional< ConstantRange > getRange(Value *V, const InstrInfoQuery &IIQ)
Helper method to get range from metadata or attribute.
static LoopDeletionResult merge(LoopDeletionResult A, LoopDeletionResult B)
static Align getFnStackAlignment(const TargetSubtargetInfo &STI, const Function &F)
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
II addRangeRetAttr(Range)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static FPClassTest getNoFPClass(const Instruction &I)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents a single, uniqued attribute.
This class represents a set of attributes that apply to the function, return type,...
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
This class represents a group of attributes that apply to one element: function, return type,...
This class holds the attributes for a particular argument, parameter, function, or return value.
LLVM_ABI AllocFnKind getAllocKind() const
bool hasAttributes() const
Return true if attributes exists in this set.
const Attribute * iterator
LLVM_ABI AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
LLVM_ABI Type * getInAllocaType() const
LLVM_ABI Type * getByValType() const
LLVM_ABI DeadOnReturnInfo getDeadOnReturnInfo() const
bool operator!=(const AttributeSet &O) const
LLVM_ABI AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
LLVM_ABI MemoryEffects getMemoryEffects() const
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
bool operator==(const AttributeSet &O) const
LLVM_ABI std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
LLVM_ABI Type * getStructRetType() const
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
LLVM_ABI unsigned getVScaleRangeMin() const
LLVM_ABI std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
LLVM_ABI UWTableKind getUWTableKind() const
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
LLVM_ABI iterator begin() const
LLVM_ABI iterator end() const
LLVM_ABI AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attributes from this set.
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
LLVM_ABI MaybeAlign getStackAlignment() const
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
LLVM_ABI Type * getPreallocatedType() const
LLVM_ABI uint64_t getDereferenceableBytes() const
LLVM_ABI MaybeAlign getAlignment() const
LLVM_ABI FPClassTest getNoFPClass() const
friend struct DenseMapInfo
AttributeSet(const AttributeSet &)=default
LLVM_ABI Type * getElementType() const
LLVM_ABI Type * getByRefType() const
LLVM_ABI CaptureInfo getCaptureInfo() const
AttributeSet()=default
AttributeSet is a trivially copyable value type.
static LLVM_ABI AttributeSet get(LLVMContext &C, const AttrBuilder &B)
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
LLVM_ABI unsigned getNumAttributes() const
Return the number of attributes in this set.
LLVM_ABI AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
static const unsigned NumTypeAttrKinds
LLVM_ABI bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
static LLVM_ABI Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
bool operator==(Attribute A) const
Equality and non-equality operators.
static LLVM_ABI Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
LLVM_ABI bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
static LLVM_ABI Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
LLVM_ABI const ConstantRange & getRange() const
Returns the value of the range attribute.
static LLVM_ABI bool intersectWithCustom(AttrKind Kind)
LLVM_ABI bool isIntAttribute() const
Return true if the attribute is an integer attribute.
static LLVM_ABI Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
LLVM_ABI uint64_t getValueAsInt() const
Return the attribute's value as an integer.
LLVM_ABI unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
LLVM_ABI AllocFnKind getAllocKind() const
LLVM_ABI bool isConstantRangeAttribute() const
Return true if the attribute is a ConstantRange attribute.
static LLVM_ABI Attribute getWithAllocKind(LLVMContext &Context, AllocFnKind Kind)
LLVM_ABI StringRef getKindAsString() const
Return the attribute's kind as a string.
static LLVM_ABI Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
static LLVM_ABI bool intersectWithMin(AttrKind Kind)
static LLVM_ABI Attribute getWithDeadOnReturnInfo(LLVMContext &Context, DeadOnReturnInfo DI)
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static LLVM_ABI bool canUseAsRetAttr(AttrKind Kind)
static bool isTypeAttrKind(AttrKind Kind)
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
static LLVM_ABI Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
LLVM_ABI std::pair< unsigned, std::optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute.
static LLVM_ABI Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
bool operator!=(Attribute A) const
LLVM_ABI FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
static LLVM_ABI Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
LLVM_ABI Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
LLVM_ABI bool getValueAsBool() const
Return the attribute's value as a boolean.
LLVM_ABI ArrayRef< ConstantRange > getInitializes() const
Returns the value of the initializes attribute.
LLVM_ABI const ConstantRange & getValueAsConstantRange() const
Return the attribute's value as a ConstantRange.
LLVM_ABI uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
static LLVM_ABI Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
LLVM_ABI MemoryEffects getMemoryEffects() const
Returns memory effects.
LLVM_ABI UWTableKind getUWTableKind() const
static LLVM_ABI Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
LLVM_ABI ArrayRef< ConstantRange > getValueAsConstantRangeList() const
Return the attribute's value as a ConstantRange array.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
static LLVM_ABI bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
bool hasKindAsEnum() const
Returns true if the attribute's kind can be represented as an enum (Enum, Integer,...
static LLVM_ABI StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
static LLVM_ABI bool canUseAsFnAttr(AttrKind Kind)
static LLVM_ABI bool intersectWithAnd(AttrKind Kind)
static LLVM_ABI Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ EndAttrKinds
Sentinel value useful for loops.
static bool isConstantRangeAttrKind(AttrKind Kind)
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
LLVM_ABI bool isTypeAttribute() const
Return true if the attribute is a type attribute.
static LLVM_ABI Attribute getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI)
static LLVM_ABI Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
static bool isIntAttrKind(AttrKind Kind)
static bool isConstantRangeListAttrKind(AttrKind Kind)
LLVM_ABI bool isConstantRangeListAttribute() const
Return true if the attribute is a ConstantRangeList attribute.
static LLVM_ABI Attribute getWithByValType(LLVMContext &Context, Type *Ty)
Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy)
For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy.
LLVM_ABI bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
static bool isEnumAttrKind(AttrKind Kind)
static LLVM_ABI Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
static LLVM_ABI bool canUseAsParamAttr(AttrKind Kind)
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM_ABI MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
static const unsigned NumIntAttrKinds
LLVM_ABI MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
LLVM_ABI CaptureInfo getCaptureInfo() const
Returns information from captures attribute.
static LLVM_ABI bool intersectMustPreserve(AttrKind Kind)
LLVM_ABI int cmpKind(Attribute A) const
Used to sort attribute by kind.
LLVM_ABI bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM_ABI DeadOnReturnInfo getDeadOnReturnInfo() const
Returns the number of dead_on_return bytes from the dead_on_return attribute, or std::nullopt if all ...
LLVM_ABI Type * getValueAsType() const
Return the attribute's value as a Type.
Represents which components of the pointer may be captured in which location.
This class represents a list of constant ranges.
This class represents a range of values.
static DeadOnReturnInfo createFromIntValue(uint64_t Data)
bool coversAllReachableMemory() const
uint64_t toIntValue() const
DeadOnReturnInfo(uint64_t DeadOnReturnBytes)
uint64_t getNumberOfDeadBytes() const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
This is an important class for using LLVM in a threaded context.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI AttributeList getAttributes(LLVMContext &C, ID id, FunctionType *FT)
Return the attributes for an intrinsic.
LLVM_ABI iterator begin() const
LLVM_ABI std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
@ LLVM_MARK_AS_BITMASK_ENUM
APInt operator*(APInt a, uint64_t RHS)
bool operator!=(uint64_t V1, const APInt &V2)
LLVM_ABI AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, AttributeSafetyKind ASK=ASK_ALL)
This class holds the attributes for a function, its return value, and its parameters.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Attribute unwrap(LLVMAttributeRef Attr)
LLVM_ABI void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
LLVMAttributeRef wrap(Attribute Attr)
LLVM_ABI bool areInlineCompatible(const Function &Caller, const Function &Callee)
LLVM_ABI void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
LLVM_ABI void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
LLVM_ABI bool areOutlineCompatible(const Function &A, const Function &B)
Checks if there are any incompatible function attributes between A and B.
LLVM_ABI AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static AttributeSet getTombstoneKey()
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
static AttributeSet getEmptyKey()
static unsigned getHashValue(AttributeSet AS)
An information struct used to provide DenseMap with the various necessary components for a given valu...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.