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));
262 unsigned getNumAttributes()
const;
284 std::string
getAsString(
bool InAttrGrp =
false)
const;
290 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 300 auto Val =
static_cast<uintptr_t
>(-1);
301 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
302 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
306 auto Val =
static_cast<uintptr_t
>(-2);
307 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
308 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
312 return (
unsigned((uintptr_t)AS.SetNode) >> 4) ^
313 (
unsigned((uintptr_t)AS.SetNode) >> 9);
405 return addAttribute(C, ArgNo + FirstArgIndex, Kind);
413 return addAttribute(C, ArgNo + FirstArgIndex, Kind,
Value);
427 return addAttributes(C, ArgNo + FirstArgIndex, B);
448 unsigned Index)
const;
454 return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
462 return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
469 return removeAttributes(C, ArgNo + FirstArgIndex, AttrsToRemove);
475 unsigned ArgNo)
const {
476 return removeAttributes(C, ArgNo + FirstArgIndex);
483 uint64_t Bytes)
const;
488 LLVMContext &C,
unsigned ArgNo, uint64_t Bytes)
const {
489 return addDereferenceableAttr(C, ArgNo + FirstArgIndex, Bytes);
495 LLVMContext &C,
unsigned Index, uint64_t Bytes)
const;
501 LLVMContext &C,
unsigned ArgNo, uint64_t Bytes)
const {
502 return addDereferenceableOrNullAttr(C, ArgNo + FirstArgIndex, Bytes);
508 addAllocSizeAttr(
LLVMContext &C,
unsigned Index,
unsigned ElemSizeArg,
516 return addAllocSizeAttr(C, ArgNo + FirstArgIndex, ElemSizeArg, NumElemsArg);
546 bool hasAttributes(
unsigned Index)
const;
560 return hasAttributes(ArgNo + FirstArgIndex);
569 bool hasFnAttribute(
StringRef Kind)
const;
578 unsigned *Index =
nullptr)
const;
588 return getAttribute(ArgNo + FirstArgIndex, Kind);
593 return getAttribute(ArgNo + FirstArgIndex, Kind);
597 unsigned getRetAlignment()
const;
600 unsigned getParamAlignment(
unsigned ArgNo)
const;
625 std::pair<unsigned, Optional<unsigned>>
629 std::string
getAsString(
unsigned Index,
bool InAttrGrp =
false)
const;
640 unsigned getNumAttrSets()
const;
644 unsigned index_end()
const {
return getNumAttrSets() - 1; }
656 bool isEmpty()
const {
return pImpl ==
nullptr; }
666 auto Val =
static_cast<uintptr_t
>(-1);
667 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
668 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
672 auto Val =
static_cast<uintptr_t
>(-2);
673 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
674 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
678 return (
unsigned((uintptr_t)AS.pImpl) >> 4) ^
679 (
unsigned((uintptr_t)AS.pImpl) >> 9);
694 std::bitset<Attribute::EndAttrKinds>
Attrs;
695 std::map<std::string, std::string> TargetDepAttrs;
698 uint64_t DerefBytes = 0;
699 uint64_t DerefOrNullBytes = 0;
700 uint64_t AllocSizeArgs = 0;
753 bool hasAttributes()
const;
760 bool hasAlignmentAttr()
const;
786 AttrBuilder &addStackAlignmentAttr(
unsigned Align);
790 AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
794 AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
797 AttrBuilder &addAllocSizeAttr(
unsigned ElemSizeArg,
802 AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr);
806 bool empty()
const {
return Attrs.none(); }
809 using td_type = std::pair<std::string, std::string>;
827 bool td_empty()
const {
return TargetDepAttrs.empty(); }
831 return !(*
this ==
B);
835 namespace AttributeFuncs {
851 #endif // LLVM_IR_ATTRIBUTES_H
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()
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
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.
This class represents lattice values for constants.
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
LLVM_NODISCARD AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
static unsigned getHashValue(AttributeList AS)
return AArch64::GPR64RegClass contains(Reg)
static AttributeList getTombstoneKey()
bool areInlineCompatible(const Function &Caller, const Function &Callee)
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
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)
LLVM_NODISCARD 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 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
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
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
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.
LLVM_NODISCARD AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
bool operator!=(const AttrBuilder &B)
LLVM_NODISCARD AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
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...
LLVM_NODISCARD AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
LLVM_NODISCARD AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
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.
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
AttrBuilder(const Attribute &A)
LLVM_NODISCARD 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.
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.
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.
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
LLVM_NODISCARD 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.
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.
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...