16 #ifndef LLVM_IR_ATTRIBUTES_H 17 #define LLVM_IR_ATTRIBUTES_H 25 #include "llvm/Config/llvm-config.h" 38 class AttributeListImpl;
39 class AttributeSetNode;
40 template<
typename T>
struct DenseMapInfo;
74 #include "llvm/IR/Attributes.inc" 104 unsigned ElemSizeArg,
165 std::string
getAsString(
bool InAttrGrp =
false)
const;
185 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
258 unsigned getNumAttributes()
const;
280 std::string
getAsString(
bool InAttrGrp =
false)
const;
286 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 296 auto Val =
static_cast<uintptr_t
>(-1);
297 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
298 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
302 auto 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);
399 return addAttribute(C, ArgNo + FirstArgIndex, Kind);
407 return addAttribute(C, ArgNo + FirstArgIndex, Kind,
Value);
419 return addAttributes(C, ArgNo + FirstArgIndex, B);
445 return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
452 return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
459 return removeAttributes(C, ArgNo + FirstArgIndex, AttrsToRemove);
465 return removeAttributes(C, ArgNo + FirstArgIndex);
471 uint64_t Bytes)
const;
476 uint64_t Bytes)
const {
477 return addDereferenceableAttr(C, ArgNo + FirstArgIndex, Bytes);
483 uint64_t Bytes)
const;
490 uint64_t Bytes)
const {
491 return addDereferenceableOrNullAttr(C, ArgNo + FirstArgIndex, Bytes);
497 unsigned ElemSizeArg,
503 unsigned ElemSizeArg,
505 return addAllocSizeAttr(C, ArgNo + FirstArgIndex, ElemSizeArg, NumElemsArg);
535 bool hasAttributes(
unsigned Index)
const;
549 return hasAttributes(ArgNo + FirstArgIndex);
558 bool hasFnAttribute(
StringRef Kind)
const;
567 unsigned *Index =
nullptr)
const;
586 unsigned getRetAlignment()
const;
589 unsigned getParamAlignment(
unsigned ArgNo)
const;
614 std::pair<unsigned, Optional<unsigned>>
618 std::string
getAsString(
unsigned Index,
bool InAttrGrp =
false)
const;
629 unsigned getNumAttrSets()
const;
633 unsigned index_end()
const {
return getNumAttrSets() - 1; }
645 bool isEmpty()
const {
return pImpl ==
nullptr; }
655 auto Val =
static_cast<uintptr_t
>(-1);
656 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
657 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
661 auto Val =
static_cast<uintptr_t
>(-2);
662 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
663 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
667 return (
unsigned((uintptr_t)AS.pImpl) >> 4) ^
668 (
unsigned((uintptr_t)AS.pImpl) >> 9);
683 std::bitset<Attribute::EndAttrKinds>
Attrs;
684 std::map<std::string, std::string> TargetDepAttrs;
685 uint64_t Alignment = 0;
686 uint64_t StackAlignment = 0;
687 uint64_t DerefBytes = 0;
688 uint64_t DerefOrNullBytes = 0;
689 uint64_t AllocSizeArgs = 0;
742 bool hasAttributes()
const;
749 bool hasAlignmentAttr()
const;
775 AttrBuilder &addStackAlignmentAttr(
unsigned Align);
779 AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
783 AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
786 AttrBuilder &addAllocSizeAttr(
unsigned ElemSizeArg,
791 AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr);
795 bool empty()
const {
return Attrs.none(); }
798 using td_type = std::pair<std::string, std::string>;
816 bool td_empty()
const {
return TargetDepAttrs.empty(); }
820 return !(*
this ==
B);
824 namespace AttributeFuncs {
840 #endif // LLVM_IR_ATTRIBUTES_H AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
const_iterator end(StringRef path)
Get end iterator over path.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
static AttributeSet getEmptyKey()
StringRef getKindAsString() const
Return the attribute's kind as a string.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Compute iterated dominance frontiers using a linear time algorithm.
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute...
unsigned getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static unsigned getHashValue(AttributeSet AS)
bool operator!=(const AttributeList &RHS) const
td_const_iterator td_end() const
unsigned index_end() const
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.
static unsigned getHashValue(AttributeList AS)
return AArch64::GPR64RegClass contains(Reg)
static AttributeList getTombstoneKey()
bool areInlineCompatible(const Function &Caller, const Function &Callee)
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
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.
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Attribute unwrap(LLVMAttributeRef Attr)
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
No attributes have been set.
bool operator!=(const AttributeSet &O) const
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
uint64_t getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
static AttributeSet getTombstoneKey()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known).
td_const_range td_attrs() const
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
amdgpu Simplify well known AMD library false Value * Callee
static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align)
bool operator==(const AttributeSet &O) const
static xmlAttrPtr getAttribute(xmlNodePtr Node, const unsigned char *AttributeName)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
void Profile(FoldingSetNodeID &ID) const
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
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.
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
bool operator!=(const AttrBuilder &B)
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
bool operator==(Attribute A) const
Equality and non-equality operators.
Sentinal value useful for loops.
bool hasParamAttr(unsigned ArgNo, StringRef Kind) const
Return true if the attribute exists for the given argument.
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
static AttributeList getEmptyKey()
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
AttrBuilder(const Attribute &A)
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 removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
static void clear(coro::Shape &Shape)
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
unsigned getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
LLVMAttributeRef wrap(Attribute Attr)
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
static bool isEqual(AttributeList LHS, AttributeList RHS)
bool empty() const
Return true if the builder contains no target-independent attributes.
StringRef getValueAsString() const
Return the attribute's value as a string.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
std::pair< std::string, std::string > td_type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasAttributes() const
Return true if attributes exists in this set.
LLVM Value Representation.
bool operator!=(Attribute A) const
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
StringRef - Represent a constant reference to a string, i.e.
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
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)
bool isEmpty() const
Return true if there are no attributes.
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
td_const_iterator td_begin() const
unsigned index_begin() const
Use these to iterate over the valid attribute indices.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...