16 #ifndef LLVM_IR_ATTRIBUTES_H
17 #define LLVM_IR_ATTRIBUTES_H
37 class AttributeListImpl;
39 class AttributeSetNode;
40 template<
typename T>
struct DenseMapInfo;
74 #include "llvm/IR/Attributes.gen"
93 StringRef Val = StringRef());
104 unsigned ElemSizeArg,
105 const Optional<unsigned> &NumElemsArg);
165 std::string
getAsString(
bool InAttrGrp =
false)
const;
185 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
280 std::string
getAsString(
bool InAttrGrp =
false)
const;
286 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
296 uintptr_t Val =
static_cast<uintptr_t
>(-1);
297 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
298 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
302 uintptr_t Val =
static_cast<uintptr_t
>(-2);
303 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
304 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
308 return (
unsigned((uintptr_t)AS.SetNode) >> 4) ^
309 (
unsigned((uintptr_t)AS.SetNode) >> 9);
472 uint64_t Bytes)
const;
477 uint64_t Bytes)
const {
484 uint64_t Bytes)
const;
491 uint64_t Bytes)
const {
498 unsigned ElemSizeArg,
504 unsigned ElemSizeArg,
568 unsigned *Index =
nullptr)
const;
615 std::pair<unsigned, Optional<unsigned>>
619 std::string
getAsString(
unsigned Index,
bool InAttrGrp =
false)
const;
646 bool isEmpty()
const {
return pImpl ==
nullptr; }
656 uintptr_t Val =
static_cast<uintptr_t
>(-1);
657 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
658 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
662 uintptr_t Val =
static_cast<uintptr_t
>(-2);
663 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
664 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
668 return (
unsigned((uintptr_t)AS.pImpl) >> 4) ^
669 (
unsigned((uintptr_t)AS.pImpl) >> 9);
684 std::bitset<Attribute::EndAttrKinds> Attrs;
685 std::map<std::string, std::string> TargetDepAttrs;
686 uint64_t Alignment = 0;
687 uint64_t StackAlignment = 0;
688 uint64_t DerefBytes = 0;
689 uint64_t DerefOrNullBytes = 0;
690 uint64_t AllocSizeArgs = 0;
794 bool empty()
const {
return Attrs.none(); }
797 using td_type = std::pair<std::string, std::string>;
814 bool td_empty()
const {
return TargetDepAttrs.empty(); }
818 return !(*
this ==
B);
822 namespace AttributeFuncs {
838 #endif // LLVM_IR_ATTRIBUTES_H
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
static AttributeSet getEmptyKey()
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
unsigned getStackAlignment() const
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static unsigned getHashValue(AttributeSet AS)
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
unsigned getRetAlignment() const
Return the alignment of the return value.
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
unsigned getAlignment() const
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
unsigned getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Add the allocsize attribute to the attribute set at the given arg index.
bool hasAlignmentAttr() const
Return true if the builder has an alignment attribute.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
static unsigned getHashValue(AttributeList AS)
static AttributeList getTombstoneKey()
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
bool areInlineCompatible(const Function &Caller, const Function &Callee)
StringRef getKindAsString() const
Return the attribute's kind as a string.
AttributeSet getParamAttributes(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute...
Attribute unwrap(LLVMAttributeRef Attr)
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known).
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
No attributes have been set.
AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
td_const_range td_attrs() const
td_const_iterator td_begin() const
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
uint64_t getDereferenceableBytes() const
static AttributeSet getTombstoneKey()
unsigned getNumAttributes() const
Return the number of attributes in this set.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
bool operator==(const AttrBuilder &B)
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
std::map< std::string, std::string >::iterator td_iterator
std::map< std::string, std::string >::const_iterator td_const_iterator
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
unsigned index_end() const
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Retrieve the allocsize args, if the allocsize attribute exists.
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
AttributeList addAllocSizeAttr(LLVMContext &C, unsigned Index, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Add the allocsize attribute to the attribute set at the given index.
bool operator!=(const AttrBuilder &B)
bool overlaps(const AttrBuilder &B) const
Return true if the builder has any attribute that's in the specified builder.
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
bool operator==(Attribute A) const
Equality and non-equality operators.
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Sentinal value useful for loops.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
unsigned index_begin() const
Use these to iterate over the valid attribute indices.
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute...
AttributeList removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
AttributeList addAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
iterator_range< td_const_iterator > td_const_range
unsigned getNumAttrSets() const
bool operator==(const AttributeSet &O)
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs(unsigned Index) const
Get the allocsize argument numbers (or pair(0, 0) if unknown).
static AttributeList getEmptyKey()
bool isEmpty() const
Return true if there are no attributes.
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
std::string getAsString(bool InAttrGrp=false) const
AttrBuilder & removeAttributes(AttributeList A, uint64_t WithoutIndex)
Remove the attributes from the builder.
bool hasAttributes() const
Return true if attributes exists in this set.
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
void Profile(FoldingSetNodeID &ID) const
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
bool empty() const
Return true if the builder contains no target-independent attributes.
AttrBuilder(const Attribute &A)
bool operator!=(const AttributeList &RHS) const
iterator_range< td_iterator > td_range
AttributeSet getFnAttributes() const
The function attributes are returned.
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
A range adaptor for a pair of iterators.
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
AttributeList removeAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
LLVMAttributeRef wrap(Attribute Attr)
static bool isEqual(AttributeList LHS, AttributeList RHS)
bool hasParamAttr(unsigned ArgNo, StringRef Kind) const
Return true if the attribute exists for the given argument.
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
AttributeSet()=default
AttributeSet is a trivially copyable value type.
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
StringRef getValueAsString() const
Return the attribute's value as a string.
std::pair< std::string, std::string > td_type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
uint64_t getDereferenceableOrNullBytes() const
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
LLVM Value Representation.
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
LLVMContext & getContext() const
Retrieve the LLVM context.
StringRef - Represent a constant reference to a string, i.e.
AttributeSet removeAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes from this set.
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...
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
bool operator!=(const AttributeSet &O)
bool operator!=(Attribute A) const
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoImpl.
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
td_const_iterator td_end() const
uint64_t getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...