15#ifndef LLVM_IR_ATTRIBUTES_H
16#define LLVM_IR_ATTRIBUTES_H
23#include "llvm/Config/llvm-config.h"
72 assert(DeadBytes.has_value() &&
73 "This attribute does not specify a byte count. Did you forget to "
74 "check if the attribute covers all reachable memory?");
75 return DeadBytes.value();
81 if (
Data == std::numeric_limits<uint64_t>::max())
87 if (DeadBytes.has_value())
88 return DeadBytes.value();
89 return std::numeric_limits<uint64_t>::max();
93 return DeadBytes.has_value() && DeadBytes.value() == 0;
97 std::optional<uint64_t> DeadBytes;
129 #include "llvm/IR/Attributes.inc"
138 return Kind >= FirstEnumAttr && Kind <= LastEnumAttr;
141 return Kind >= FirstIntAttr && Kind <= LastIntAttr;
144 return Kind >= FirstTypeAttr && Kind <= LastTypeAttr;
147 return Kind >= FirstConstantRangeAttr && Kind <= LastConstantRangeAttr;
150 return Kind >= FirstConstantRangeListAttr &&
151 Kind <= LastConstantRangeListAttr;
201 const std::optional<unsigned> &NumElemsArg);
326 LLVM_ABI std::pair<unsigned, std::optional<unsigned>>
400 uint8_t AvailableAttrs[16] = {};
402 "Too many attributes");
406 return AvailableAttrs[Kind / 8] & (1 << (Kind % 8));
410 AvailableAttrs[Kind / 8] |= 1 << (Kind % 8);
446 friend AttributeListImpl;
471 bool operator==(
const AttributeSet &O)
const {
return SetNode == O.SetNode; }
472 bool operator!=(
const AttributeSet &O)
const {
return !(*
this == O); }
492 const AttrBuilder &
B)
const;
519 [[nodiscard]]
LLVM_ABI std::optional<AttributeSet>
530 return SetNode && SetNode->hasAttribute(Kind);
553 LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>>
571#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
587namespace hashing::detail {
593static_assert(std::has_unique_object_representations_v<Attribute> &&
594 std::has_unique_object_representations_v<AttributeSet>,
595 "hashing the bytes requires unique object representations");
608 enum AttrIndex :
unsigned {
615 friend class AttrBuilder;
619 template <
typename Ty,
typename Enable>
friend struct DenseMapInfo;
666 const AttrBuilder &
B);
706 return addAttributeAtIndex(
C, FunctionIndex, Kind);
712 Attribute Attr)
const {
713 return addAttributeAtIndex(
C, FunctionIndex, Attr);
718 [[nodiscard]] AttributeList
719 addFnAttribute(LLVMContext &
C, StringRef Kind,
720 StringRef
Value = StringRef())
const {
721 return addAttributeAtIndex(
C, FunctionIndex, Kind,
Value);
726 [[nodiscard]] AttributeList addFnAttributes(LLVMContext &
C,
727 const AttrBuilder &
B)
const {
728 return addAttributesAtIndex(
C, FunctionIndex,
B);
733 [[nodiscard]] AttributeList addRetAttribute(LLVMContext &
C,
734 Attribute::AttrKind Kind)
const {
735 return addAttributeAtIndex(
C, ReturnIndex, Kind);
740 [[nodiscard]] AttributeList addRetAttribute(LLVMContext &
C,
741 Attribute Attr)
const {
742 return addAttributeAtIndex(
C, ReturnIndex, Attr);
747 [[nodiscard]] AttributeList addRetAttributes(LLVMContext &
C,
748 const AttrBuilder &
B)
const {
749 return addAttributesAtIndex(
C, ReturnIndex,
B);
754 [[nodiscard]] AttributeList
755 maybeAddRetAttribute(LLVMContext &
C, Attribute::AttrKind Kind)
const {
756 if (Kind != Attribute::AttrKind::None)
757 return addAttributeAtIndex(
C, ReturnIndex, Kind);
763 [[nodiscard]] AttributeList
764 addParamAttribute(LLVMContext &
C,
unsigned ArgNo,
765 Attribute::AttrKind Kind)
const {
766 return addAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind);
771 [[nodiscard]] AttributeList
772 addParamAttribute(LLVMContext &
C,
unsigned ArgNo, StringRef Kind,
773 StringRef
Value = StringRef())
const {
774 return addAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind,
Value);
779 [[nodiscard]]
LLVM_ABI AttributeList addParamAttribute(
780 LLVMContext &
C, ArrayRef<unsigned> ArgNos, Attribute
A)
const;
784 [[nodiscard]] AttributeList addParamAttributes(LLVMContext &
C,
unsigned ArgNo,
785 const AttrBuilder &
B)
const {
786 return addAttributesAtIndex(
C, ArgNo + FirstArgIndex,
B);
791 [[nodiscard]] AttributeList
792 maybeAddParamAttribute(LLVMContext &
C,
unsigned ArgNo,
793 Attribute::AttrKind Kind)
const {
794 if (Kind != Attribute::AttrKind::None)
795 return addParamAttribute(
C, ArgNo, Kind);
801 [[nodiscard]]
LLVM_ABI AttributeList removeAttributeAtIndex(
802 LLVMContext &
C,
unsigned Index, Attribute::AttrKind Kind)
const;
806 [[nodiscard]]
LLVM_ABI AttributeList
807 removeAttributeAtIndex(LLVMContext &
C,
unsigned Index, StringRef Kind)
const;
808 [[nodiscard]] AttributeList removeAttribute(LLVMContext &
C,
unsigned Index,
809 StringRef Kind)
const {
810 return removeAttributeAtIndex(
C, Index, Kind);
815 [[nodiscard]]
LLVM_ABI AttributeList removeAttributesAtIndex(
816 LLVMContext &
C,
unsigned Index,
const AttributeMask &AttrsToRemove)
const;
820 [[nodiscard]]
LLVM_ABI AttributeList
821 removeAttributesAtIndex(LLVMContext &
C,
unsigned Index)
const;
825 [[nodiscard]] AttributeList
826 removeFnAttribute(LLVMContext &
C, Attribute::AttrKind Kind)
const {
827 return removeAttributeAtIndex(
C, FunctionIndex, Kind);
832 [[nodiscard]] AttributeList removeFnAttribute(LLVMContext &
C,
833 StringRef Kind)
const {
834 return removeAttributeAtIndex(
C, FunctionIndex, Kind);
839 [[nodiscard]] AttributeList
840 removeFnAttributes(LLVMContext &
C,
const AttributeMask &AttrsToRemove)
const {
841 return removeAttributesAtIndex(
C, FunctionIndex, AttrsToRemove);
846 [[nodiscard]] AttributeList removeFnAttributes(LLVMContext &
C)
const {
847 return removeAttributesAtIndex(
C, FunctionIndex);
852 [[nodiscard]] AttributeList
853 removeRetAttribute(LLVMContext &
C, Attribute::AttrKind Kind)
const {
854 return removeAttributeAtIndex(
C, ReturnIndex, Kind);
859 [[nodiscard]] AttributeList removeRetAttribute(LLVMContext &
C,
860 StringRef Kind)
const {
861 return removeAttributeAtIndex(
C, ReturnIndex, Kind);
866 [[nodiscard]] AttributeList
867 removeRetAttributes(LLVMContext &
C,
868 const AttributeMask &AttrsToRemove)
const {
869 return removeAttributesAtIndex(
C, ReturnIndex, AttrsToRemove);
874 [[nodiscard]] AttributeList
875 removeParamAttribute(LLVMContext &
C,
unsigned ArgNo,
876 Attribute::AttrKind Kind)
const {
877 return removeAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind);
882 [[nodiscard]] AttributeList
883 removeParamAttribute(LLVMContext &
C,
unsigned ArgNo, StringRef Kind)
const {
884 return removeAttributeAtIndex(
C, ArgNo + FirstArgIndex, Kind);
889 [[nodiscard]] AttributeList
890 removeParamAttributes(LLVMContext &
C,
unsigned ArgNo,
891 const AttributeMask &AttrsToRemove)
const {
892 return removeAttributesAtIndex(
C, ArgNo + FirstArgIndex, AttrsToRemove);
897 [[nodiscard]] AttributeList removeParamAttributes(LLVMContext &
C,
898 unsigned ArgNo)
const {
899 return removeAttributesAtIndex(
C, ArgNo + FirstArgIndex);
904 [[nodiscard]] AttributeList
905 replaceAttributeTypeAtIndex(LLVMContext &
C,
unsigned ArgNo,
906 Attribute::AttrKind Kind,
907 Type *ReplacementTy)
const {
908 Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
909 auto Attrs = removeAttributeAtIndex(
C, ArgNo, Kind);
910 return Attrs.addAttributeAtIndex(
C, ArgNo,
911 Attr.getWithNewType(
C, ReplacementTy));
916 [[nodiscard]]
LLVM_ABI AttributeList
917 addDereferenceableRetAttr(LLVMContext &
C,
uint64_t Bytes)
const;
921 [[nodiscard]]
LLVM_ABI AttributeList addDereferenceableParamAttr(
922 LLVMContext &
C,
unsigned ArgNo,
uint64_t Bytes)
const;
927 [[nodiscard]]
LLVM_ABI AttributeList addDereferenceableOrNullParamAttr(
928 LLVMContext &
C,
unsigned ArgNo,
uint64_t Bytes)
const;
932 [[nodiscard]]
LLVM_ABI AttributeList
937 [[nodiscard]]
LLVM_ABI AttributeList
938 addAllocSizeParamAttr(LLVMContext &
C,
unsigned ArgNo,
unsigned ElemSizeArg,
939 const std::optional<unsigned> &NumElemsArg)
const;
944 [[nodiscard]]
LLVM_ABI std::optional<AttributeList>
945 intersectWith(LLVMContext &
C, AttributeList Other)
const;
956 LLVM_ABI AttributeSet getParamAttrs(
unsigned ArgNo)
const;
959 LLVM_ABI AttributeSet getRetAttrs()
const;
962 LLVM_ABI AttributeSet getFnAttrs()
const;
965 LLVM_ABI bool hasAttributeAtIndex(
unsigned Index,
966 Attribute::AttrKind Kind)
const;
969 LLVM_ABI bool hasAttributeAtIndex(
unsigned Index, StringRef Kind)
const;
972 LLVM_ABI bool hasAttributesAtIndex(
unsigned Index)
const;
975 bool hasParamAttr(
unsigned ArgNo, Attribute::AttrKind Kind)
const {
976 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
980 bool hasParamAttr(
unsigned ArgNo, StringRef Kind)
const {
981 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
985 bool hasParamAttrs(
unsigned ArgNo)
const {
986 return hasAttributesAtIndex(ArgNo + FirstArgIndex);
990 bool hasRetAttr(Attribute::AttrKind Kind)
const {
991 return hasAttributeAtIndex(ReturnIndex, Kind);
995 bool hasRetAttr(StringRef Kind)
const {
996 return hasAttributeAtIndex(ReturnIndex, Kind);
1000 bool hasRetAttrs()
const {
return hasAttributesAtIndex(ReturnIndex); }
1003 bool hasFnAttr(Attribute::AttrKind Kind)
const {
1008 LLVM_ABI bool hasFnAttr(StringRef Kind)
const;
1011 bool hasFnAttrs()
const {
return hasAttributesAtIndex(FunctionIndex); }
1016 LLVM_ABI bool hasAttrSomewhere(Attribute::AttrKind Kind,
1017 unsigned *Index =
nullptr)
const;
1021 Attribute::AttrKind Kind)
const;
1027 Attribute getParamAttr(
unsigned ArgNo, Attribute::AttrKind Kind)
const {
1028 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
1032 Attribute getParamAttr(
unsigned ArgNo, StringRef Kind)
const {
1033 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
1037 Attribute getFnAttr(Attribute::AttrKind Kind)
const {
1038 return getAttributeAtIndex(FunctionIndex, Kind);
1042 Attribute getFnAttr(StringRef Kind)
const {
1043 return getAttributeAtIndex(FunctionIndex, Kind);
1047 Attribute getRetAttr(Attribute::AttrKind Kind)
const {
1048 return getAttributeAtIndex(ReturnIndex, Kind);
1052 LLVM_ABI MaybeAlign getRetAlignment()
const;
1055 LLVM_ABI MaybeAlign getParamAlignment(
unsigned ArgNo)
const;
1058 LLVM_ABI MaybeAlign getParamStackAlignment(
unsigned ArgNo)
const;
1061 LLVM_ABI Type *getParamByValType(
unsigned ArgNo)
const;
1064 LLVM_ABI Type *getParamStructRetType(
unsigned ArgNo)
const;
1067 LLVM_ABI Type *getParamByRefType(
unsigned ArgNo)
const;
1070 LLVM_ABI Type *getParamPreallocatedType(
unsigned ArgNo)
const;
1073 LLVM_ABI Type *getParamInAllocaType(
unsigned ArgNo)
const;
1076 LLVM_ABI Type *getParamElementType(
unsigned ArgNo)
const;
1082 LLVM_ABI MaybeAlign getRetStackAlignment()
const;
1096 LLVM_ABI DeadOnReturnInfo getDeadOnReturnInfo(
unsigned Index)
const;
1100 LLVM_ABI uint64_t getParamDereferenceableOrNullBytes(
unsigned ArgNo)
const;
1103 LLVM_ABI std::optional<ConstantRange> getParamRange(
unsigned ArgNo)
const;
1120 LLVM_ABI std::string getAsString(
unsigned Index,
1121 bool InAttrGrp =
false)
const;
1124 LLVM_ABI bool hasParentContext(LLVMContext &
C)
const;
1130 using iterator =
const AttributeSet *;
1135 LLVM_ABI unsigned getNumAttrSets()
const;
1140 struct index_iterator {
1141 unsigned NumAttrSets;
1142 index_iterator(
int NumAttrSets) : NumAttrSets(NumAttrSets) {}
1143 struct int_wrapper {
1144 int_wrapper(
unsigned i) : i(i) {}
1148 int_wrapper &operator++() {
1156 int_wrapper
begin() {
return int_wrapper(AttributeList::FunctionIndex); }
1158 int_wrapper
end() {
return int_wrapper(NumAttrSets - 1); }
1162 index_iterator indexes()
const {
return index_iterator(getNumAttrSets()); }
1165 bool operator==(
const AttributeList &
RHS)
const {
return pImpl ==
RHS.pImpl; }
1166 bool operator!=(
const AttributeList &
RHS)
const {
return pImpl !=
RHS.pImpl; }
1169 void *getRawPointer()
const {
1174 bool isEmpty()
const {
return pImpl ==
nullptr; }
1185 static unsigned getHashValue(AttributeList AS) {
1186 return DenseMapInfo<const void *>::getHashValue(AS.pImpl);
1202 SmallVector<Attribute, 8>
Attrs;
1205 AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1206 AttrBuilder(
const AttrBuilder &) =
delete;
1207 AttrBuilder(AttrBuilder &&) =
default;
1209 AttrBuilder(LLVMContext &Ctx,
const Attribute &
A) : Ctx(Ctx) {
1213 LLVM_ABI AttrBuilder(LLVMContext &Ctx, AttributeSet AS);
1218 LLVM_ABI AttrBuilder &addAttribute(Attribute::AttrKind Val);
1221 LLVM_ABI AttrBuilder &addAttribute(Attribute
A);
1224 LLVM_ABI AttrBuilder &addAttribute(StringRef
A, StringRef
V = StringRef());
1227 LLVM_ABI AttrBuilder &removeAttribute(Attribute::AttrKind Val);
1230 LLVM_ABI AttrBuilder &removeAttribute(StringRef
A);
1233 AttrBuilder &removeAttribute(Attribute
A) {
1234 if (
A.isStringAttribute())
1235 return removeAttribute(
A.getKindAsString());
1237 return removeAttribute(
A.getKindAsEnum());
1249 LLVM_ABI bool overlaps(
const AttributeMask &AM)
const;
1259 bool hasAttributes()
const {
return !
Attrs.empty(); }
1276 getRawIntAttr(Attribute::AttrKind Kind)
const;
1280 return MaybeAlign(getRawIntAttr(Attribute::Alignment).value_or(0));
1285 return MaybeAlign(getRawIntAttr(Attribute::StackAlignment).value_or(0));
1290 uint64_t getDereferenceableBytes()
const {
1291 return getRawIntAttr(Attribute::Dereferenceable).value_or(0);
1296 uint64_t getDereferenceableOrNullBytes()
const {
1297 return getRawIntAttr(Attribute::DereferenceableOrNull).value_or(0);
1303 std::optional<uint64_t> Raw = getRawIntAttr(Attribute::NoFPClass);
1308 LLVM_ABI Type *getTypeAttr(Attribute::AttrKind Kind)
const;
1314 Type *getStructRetType()
const {
return getTypeAttr(Attribute::StructRet); }
1317 Type *getByRefType()
const {
return getTypeAttr(Attribute::ByRef); }
1320 Type *getPreallocatedType()
const {
1321 return getTypeAttr(Attribute::Preallocated);
1325 Type *getInAllocaType()
const {
return getTypeAttr(Attribute::InAlloca); }
1329 LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>>
1330 getAllocSizeArgs()
const;
1337 LLVM_ABI AttrBuilder &addAlignmentAttr(MaybeAlign Align);
1343 inline AttrBuilder &addAlignmentAttr(
unsigned Align) {
1344 return addAlignmentAttr(MaybeAlign(Align));
1349 LLVM_ABI AttrBuilder &addStackAlignmentAttr(MaybeAlign Align);
1355 inline AttrBuilder &addStackAlignmentAttr(
unsigned Align) {
1356 return addStackAlignmentAttr(MaybeAlign(Align));
1365 LLVM_ABI AttrBuilder &addDeadOnReturnAttr(DeadOnReturnInfo Info);
1373 addAllocSizeAttr(
unsigned ElemSizeArg,
1374 const std::optional<unsigned> &NumElemsArg);
1377 LLVM_ABI AttrBuilder &addVScaleRangeAttr(
unsigned MinValue,
1378 std::optional<unsigned> MaxValue);
1381 LLVM_ABI AttrBuilder &addTypeAttr(Attribute::AttrKind Kind,
Type *Ty);
1400 LLVM_ABI AttrBuilder &addAllocSizeAttrFromRawRepr(
uint64_t RawAllocSizeRepr);
1405 addVScaleRangeAttrFromRawRepr(
uint64_t RawVScaleRangeRepr);
1409 LLVM_ABI AttrBuilder &addUWTableAttr(UWTableKind Kind);
1412 LLVM_ABI AttrBuilder &addAllocKindAttr(AllocFnKind Kind);
1415 LLVM_ABI AttrBuilder &addMemoryAttr(MemoryEffects ME);
1418 LLVM_ABI AttrBuilder &addCapturesAttr(CaptureInfo CI);
1421 LLVM_ABI AttrBuilder &addDenormalFPEnvAttr(DenormalFPEnv
Mode);
1424 LLVM_ABI AttrBuilder &addNoFPClassAttr(FPClassTest NoFPClassMask);
1427 LLVM_ABI AttrBuilder &addConstantRangeAttr(Attribute::AttrKind Kind,
1428 const ConstantRange &CR);
1431 LLVM_ABI AttrBuilder &addRangeAttr(
const ConstantRange &CR);
1434 LLVM_ABI AttrBuilder &addConstantRangeListAttr(Attribute::AttrKind Kind,
1435 ArrayRef<ConstantRange> Val);
1438 LLVM_ABI AttrBuilder &addInitializesAttr(
const ConstantRangeList &CRL);
1443 LLVM_ABI AttrBuilder &addFromEquivalentMetadata(
const Instruction &
I);
1445 ArrayRef<Attribute> attrs()
const {
return Attrs; }
1448 bool operator!=(
const AttrBuilder &
B)
const {
return !(*
this ==
B); }
1451namespace AttributeFuncs {
1453enum AttributeSafetyKind : uint8_t {
1454 ASK_SAFE_TO_DROP = 1,
1455 ASK_UNSAFE_TO_DROP = 2,
1456 ASK_ALL = ASK_SAFE_TO_DROP | ASK_UNSAFE_TO_DROP,
1473 AttributeSafetyKind ASK = ASK_ALL);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static DenormalFPEnv getDenormalFPEnv(AttributeSet FnAttrs)
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 cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static FPClassTest getNoFPClass(const Instruction &I)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
A bitset with a bit for each enum attribute kind.
void addAttribute(Attribute::AttrKind Kind)
bool hasAttribute(Attribute::AttrKind Kind) const
This class represents a single, uniqued attribute.
The enum function attributes available in an AttributeListImpl, so that AttributeList can query them ...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has an enum attribute of the given kind.
AttributeBitSet AvailableFunctionAttrs
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...
The enum attributes available in an AttributeSetNode, so that AttributeSet can query them inline.
bool hasAttribute(Attribute::AttrKind Kind) const
AttributeBitSet AvailableAttrs
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
bool operator==(const AttributeSet &O) const
LLVM_ABI std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
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 addSortedAttributes(LLVMContext &C, ArrayRef< Attribute > Attrs) const
Add attributes to the attribute set, replacing attributes of the same kind.
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)
static LLVM_ABI bool isABIAttr(AttrKind Kind)
Whether this is an ABI attribute (for returns or arguments).
bool operator==(Attribute A) const
Equality and non-equality operators.
static LLVM_ABI Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
static const unsigned NumEnumAttrKinds
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.
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)
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
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
@ EndAttrKinds
Sentinel value useful for loops.
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
This is an important class for using LLVM in a threaded context.
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.
LLVM_ABI AttributeList getAttributes(LLVMContext &C, ID id, FunctionType *FT)
Return the attributes for an intrinsic.
Align getStackAlignment(ABI TargetABI)
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_ABI AttributeMask getPoisonGeneratingAttributes()
Get param/return attributes which make an invalid value poison, e.g., nonnull, where null becomes poi...
RelativeUniformCounterPtr Values
@ Unknown
Not known to have no common set bits.
@ 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.
LLVM_ABI AttributeSet dropRetOnlyCaptureComponents(LLVMContext &C, AttributeSet ParamAttrs, Type *RetTy)
Adjust the parameter attributes ParamAttrs for a function or call site whose return type becomes RetT...
LLVM_ABI bool isStrictFPInlineCompatible(const Function &Caller, const Function &Callee)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
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.
Represents the full denormal controls for a function, including the default mode and the f32 specific...
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
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.
Trait to indicate whether a type's bits can be hashed directly.