16 #ifndef LLVM_IR_ATTRIBUTES_H
17 #define LLVM_IR_ATTRIBUTES_H
34 class AttributeSetImpl;
35 class AttributeSetNode;
37 template<
typename T>
struct DenseMapInfo;
71 #include "llvm/IR/Attributes.gen"
100 unsigned ElemSizeArg,
161 std::string
getAsString(
bool InAttrGrp =
false)
const;
181 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
298 uint64_t Bytes)
const;
304 uint64_t Bytes)
const;
309 unsigned ElemSizeArg,
349 unsigned *Index =
nullptr)
const;
371 std::pair<unsigned, Optional<unsigned>>
375 std::string
getAsString(
unsigned Index,
bool InAttrGrp =
false)
const;
384 return pImpl == RHS.pImpl;
387 return pImpl != RHS.pImpl;
423 uintptr_t Val =
static_cast<uintptr_t
>(-1);
424 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
425 return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
428 uintptr_t Val =
static_cast<uintptr_t
>(-2);
429 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
430 return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
433 return (
unsigned((uintptr_t)AS.pImpl) >> 4) ^
434 (
unsigned((uintptr_t)AS.pImpl) >> 9);
446 std::bitset<Attribute::EndAttrKinds> Attrs;
447 std::map<std::string, std::string> TargetDepAttrs;
449 uint64_t StackAlignment;
451 uint64_t DerefOrNullBytes;
452 uint64_t AllocSizeArgs;
456 : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
457 DerefOrNullBytes(0), AllocSizeArgs(0) {}
459 : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
460 DerefOrNullBytes(0), AllocSizeArgs(0) {
559 bool empty()
const {
return Attrs.none(); }
562 typedef std::pair<std::string, std::string>
td_type;
579 bool td_empty()
const {
return TargetDepAttrs.empty(); }
583 return !(*
this ==
B);
587 namespace AttributeFuncs {
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
static AttributeSet getEmptyKey()
AttributeSet addAllocSizeAttr(LLVMContext &C, unsigned Index, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Add the allocsize attribute to the attribute set at the given index.
AttributeSet getParamAttributes(unsigned Index) const
The attributes for the specified index are returned.
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
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)
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...
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
iterator begin(unsigned Slot) const
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
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.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given 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.
bool areInlineCompatible(const Function &Caller, const Function &Callee)
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
StringRef getKindAsString() const
Return the attribute's kind as a string.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
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.
AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
td_const_range td_attrs() const
td_const_iterator td_begin() const
std::map< std::string, std::string >::iterator td_iterator
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
static AttributeSet getTombstoneKey()
llvm::iterator_range< td_const_iterator > td_const_range
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs(unsigned Index) const
Get the allocsize argument numbers (or pair(0, 0) if unknown).
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.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
std::pair< std::string, std::string > td_type
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
bool operator==(const AttrBuilder &B)
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.
AttributeSet getSlotAttributes(unsigned Slot) const
Return the attributes at the given slot.
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Retrieve the allocsize args, if the allocsize attribute exists.
bool operator!=(const AttrBuilder &B)
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
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.
Sentinal value useful for loops.
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but may be faster.
LLVMContext & getContext() const
Retrieve the LLVM context.
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
iterator end(unsigned Slot) const
void Profile(FoldingSetNodeID &ID) const
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)
llvm::iterator_range< td_iterator > td_range
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list.
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
A range adaptor for a pair of iterators.
std::map< std::string, std::string >::const_iterator td_const_iterator
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
AttributeSet removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
bool operator==(const AttributeSet &RHS) const
operator==/!= - Provide equality predicates.
LLVMAttributeRef wrap(Attribute Attr)
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
ArrayRef< Attribute >::iterator iterator
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
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...
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
AttrBuilder & removeAttributes(AttributeSet A, uint64_t Index)
Remove the attributes from the builder.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
StringRef getValueAsString() const
Return the attribute's value as a string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool hasAttributes() const
Return true if the builder has IR-level attributes.
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...
StringRef - Represent a constant reference to a string, i.e.
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!=(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)
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
td_const_iterator td_end() const
bool isEmpty() const
Return true if there are no attributes.
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...
AttributeSet getFnAttributes() const
The function attributes are returned.
bool operator!=(const AttributeSet &RHS) const