15 #ifndef LLVM_IR_ATTRIBUTES_H 16 #define LLVM_IR_ATTRIBUTES_H 24 #include "llvm/Config/llvm-config.h" 38 class AttributeListImpl;
39 class AttributeSetNode;
40 template<
typename T>
struct DenseMapInfo;
74 #include "llvm/IR/Attributes.inc" 105 unsigned ElemSizeArg,
174 std::string
getAsString(
bool InAttrGrp =
false)
const;
194 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
271 unsigned getNumAttributes()
const;
292 Type *getByValType()
const;
294 std::string
getAsString(
bool InAttrGrp =
false)
const;
300 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 310 auto Val =
static_cast<uintptr_t
>(-1);
311 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
312 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
316 auto Val =
static_cast<uintptr_t
>(-2);
317 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
318 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
322 return (
unsigned((uintptr_t)AS.SetNode) >> 4) ^
323 (
unsigned((uintptr_t)AS.SetNode) >> 9);
415 return addAttribute(C, ArgNo + FirstArgIndex, Kind);
423 return addAttribute(C, ArgNo + FirstArgIndex, Kind,
Value);
437 return addAttributes(C, ArgNo + FirstArgIndex, B);
458 unsigned Index)
const;
464 return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
472 return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
479 return removeAttributes(C, ArgNo + FirstArgIndex, AttrsToRemove);
485 unsigned ArgNo)
const {
486 return removeAttributes(C, ArgNo + FirstArgIndex);
493 uint64_t Bytes)
const;
498 LLVMContext &C,
unsigned ArgNo, uint64_t Bytes)
const {
499 return addDereferenceableAttr(C, ArgNo + FirstArgIndex, Bytes);
505 LLVMContext &C,
unsigned Index, uint64_t Bytes)
const;
511 LLVMContext &C,
unsigned ArgNo, uint64_t Bytes)
const {
512 return addDereferenceableOrNullAttr(C, ArgNo + FirstArgIndex, Bytes);
518 addAllocSizeAttr(
LLVMContext &C,
unsigned Index,
unsigned ElemSizeArg,
526 return addAllocSizeAttr(C, ArgNo + FirstArgIndex, ElemSizeArg, NumElemsArg);
556 bool hasAttributes(
unsigned Index)
const;
570 return hasAttributes(ArgNo + FirstArgIndex);
579 bool hasFnAttribute(
StringRef Kind)
const;
588 unsigned *Index =
nullptr)
const;
610 MaybeAlign getParamAlignment(
unsigned ArgNo)
const;
613 Type *getParamByValType(
unsigned ArgNo)
const;
638 std::pair<unsigned, Optional<unsigned>>
642 std::string
getAsString(
unsigned Index,
bool InAttrGrp =
false)
const;
653 unsigned getNumAttrSets()
const;
657 unsigned index_end()
const {
return getNumAttrSets() - 1; }
669 bool isEmpty()
const {
return pImpl ==
nullptr; }
679 auto Val =
static_cast<uintptr_t
>(-1);
680 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
681 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
685 auto Val =
static_cast<uintptr_t
>(-2);
686 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
687 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
691 return (
unsigned((uintptr_t)AS.pImpl) >> 4) ^
692 (
unsigned((uintptr_t)AS.pImpl) >> 9);
707 std::bitset<Attribute::EndAttrKinds>
Attrs;
708 std::map<std::string, std::string, std::less<>> TargetDepAttrs;
711 uint64_t DerefBytes = 0;
712 uint64_t DerefOrNullBytes = 0;
713 uint64_t AllocSizeArgs = 0;
714 Type *ByValType =
nullptr;
767 bool hasAttributes()
const;
774 bool hasAlignmentAttr()
const;
818 return addStackAlignmentAttr(
MaybeAlign(Align));
823 AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
827 AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
830 AttrBuilder &addAllocSizeAttr(
unsigned ElemSizeArg,
838 AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr);
842 bool empty()
const {
return Attrs.none(); }
845 using td_type = std::pair<std::string, std::string>;
863 bool td_empty()
const {
return TargetDepAttrs.empty(); }
867 return !(*
this ==
B);
871 namespace AttributeFuncs {
887 #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.
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.
MaybeAlign getAlignment() const
Retrieve the alignment attribute, if it exists.
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...
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
Type * getByValType() const
Retrieve the byval type.
unsigned index_end() const
MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
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.
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)
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
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.
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
bool operator!=(const AttributeSet &O) const
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
static AttributeSet getTombstoneKey()
Type * getValueAsType() const
Return the attribute's value as a Type.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
MaybeAlign getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
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.
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) 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
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.
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.
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
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...
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
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.
amdgpu Simplify well known AMD library false FunctionCallee Callee
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.
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")
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
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...