LLVM 24.0.0git
llvm::AttributeSet Class Reference

This class holds the attributes for a particular argument, parameter, function, or return value. More...

#include "llvm/IR/Attributes.h"

Public Types

using iterator = const Attribute *

Public Member Functions

 AttributeSet ()=default
 AttributeSet is a trivially copyable value type.
 AttributeSet (const AttributeSet &)=default
 ~AttributeSet ()=default
bool operator== (const AttributeSet &O) const
bool operator!= (const AttributeSet &O) const
LLVM_ABI AttributeSet addAttribute (LLVMContext &C, Attribute::AttrKind Kind) const
 Add an argument attribute.
LLVM_ABI AttributeSet addAttribute (LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
 Add a target-dependent attribute.
LLVM_ABI AttributeSet addAttributes (LLVMContext &C, AttributeSet AS) const
 Add attributes to the attribute set.
LLVM_ABI AttributeSet addAttributes (LLVMContext &C, const AttrBuilder &B) const
 Add attributes to the attribute set.
LLVM_ABI AttributeSet addSortedAttributes (LLVMContext &C, ArrayRef< Attribute > Attrs) const
 Add attributes to the attribute set, replacing attributes of the same kind.
LLVM_ABI AttributeSet removeAttribute (LLVMContext &C, Attribute::AttrKind Kind) const
 Remove the specified attribute from this set.
LLVM_ABI AttributeSet removeAttribute (LLVMContext &C, StringRef Kind) const
 Remove the specified attribute from this set.
LLVM_ABI AttributeSet removeAttributes (LLVMContext &C, const AttributeMask &AttrsToRemove) const
 Remove the specified attributes from this set.
LLVM_ABI std::optional< AttributeSet > intersectWith (LLVMContext &C, AttributeSet Other) const
 Try to intersect this AttributeSet with Other.
LLVM_ABI unsigned getNumAttributes () const
 Return the number of attributes in this set.
bool hasAttributes () const
 Return true if attributes exists in this set.
bool hasAttribute (Attribute::AttrKind Kind) const
 Return true if the attribute exists in this set.
LLVM_ABI bool hasAttribute (StringRef Kind) const
 Return true if the attribute exists in this set.
LLVM_ABI Attribute getAttribute (Attribute::AttrKind Kind) const
 Return the attribute object.
LLVM_ABI Attribute getAttribute (StringRef Kind) const
 Return the target-dependent attribute object.
LLVM_ABI MaybeAlign getAlignment () const
LLVM_ABI MaybeAlign getStackAlignment () const
LLVM_ABI uint64_t getDereferenceableBytes () const
LLVM_ABI DeadOnReturnInfo getDeadOnReturnInfo () const
LLVM_ABI uint64_t getDereferenceableOrNullBytes () const
LLVM_ABI Type * getByValType () const
LLVM_ABI Type * getStructRetType () const
LLVM_ABI Type * getByRefType () const
LLVM_ABI Type * getPreallocatedType () const
LLVM_ABI Type * getInAllocaType () const
LLVM_ABI Type * getElementType () const
LLVM_ABI std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs () const
LLVM_ABI unsigned getVScaleRangeMin () const
LLVM_ABI std::optional< unsigned > getVScaleRangeMax () const
LLVM_ABI UWTableKind getUWTableKind () const
LLVM_ABI AllocFnKind getAllocKind () const
LLVM_ABI MemoryEffects getMemoryEffects () const
LLVM_ABI CaptureInfo getCaptureInfo () const
LLVM_ABI FPClassTest getNoFPClass () const
LLVM_ABI std::string getAsString (bool InAttrGrp=false) const
LLVM_ABI bool hasParentContext (LLVMContext &C) const
 Return true if this attribute set belongs to the LLVMContext.
LLVM_ABI iterator begin () const
LLVM_ABI iterator end () const
void dump () const

Static Public Member Functions

static LLVM_ABI AttributeSet get (LLVMContext &C, const AttrBuilder &B)
static LLVM_ABI AttributeSet get (LLVMContext &C, ArrayRef< Attribute > Attrs)

Friends

template<typename Ty, typename Enable>
struct DenseMapInfo

Detailed Description

This class holds the attributes for a particular argument, parameter, function, or return value.

It is an immutable value type that is cheap to copy. Adding and removing enum attributes is intended to be fast, but adding and removing string or integer attributes involves a FoldingSet lookup.

Definition at line 448 of file Attributes.h.

Member Typedef Documentation

◆ iterator

Definition at line 570 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttributeSet() [1/2]

llvm::AttributeSet::AttributeSet ( )
default

AttributeSet is a trivially copyable value type.

Referenced by addSortedAttributes(), get(), and get().

◆ AttributeSet() [2/2]

llvm::AttributeSet::AttributeSet ( const AttributeSet & )
default

◆ ~AttributeSet()

llvm::AttributeSet::~AttributeSet ( )
default

References B(), C(), and LLVM_ABI.

Member Function Documentation

◆ addAttribute() [1/2]

AttributeSet AttributeSet::addAttribute ( LLVMContext & C,
Attribute::AttrKind Kind ) const
nodiscard

Add an argument attribute.

Returns a new set because attribute sets are immutable.

Definition at line 977 of file Attributes.cpp.

References addAttributes(), B(), C(), get(), and hasAttribute().

Referenced by llvm::OpenMPIRBuilder::addAttributes(), and llvm::RTLIB::RuntimeLibcallsInfo::getDefaultFunctionTy().

◆ addAttribute() [2/2]

AttributeSet AttributeSet::addAttribute ( LLVMContext & C,
StringRef Kind,
StringRef Value = StringRef() ) const
nodiscard

Add a target-dependent attribute.

Returns a new set because attribute sets are immutable.

Definition at line 985 of file Attributes.cpp.

References addAttributes(), B(), C(), and get().

◆ addAttributes() [1/2]

AttributeSet AttributeSet::addAttributes ( LLVMContext & C,
AttributeSet AS ) const
nodiscard

Add attributes to the attribute set.

Returns a new set because attribute sets are immutable.

Definition at line 992 of file Attributes.cpp.

References B(), C(), get(), and hasAttributes().

Referenced by addAttribute(), addAttribute(), llvm::OpenMPIRBuilder::addAttributes(), and llvm::RTLIB::RuntimeLibcallsInfo::getDefaultFunctionTy().

◆ addAttributes() [2/2]

AttributeSet AttributeSet::addAttributes ( LLVMContext & C,
const AttrBuilder & B ) const

Add attributes to the attribute set.

Returns a new set because attribute sets are immutable.

Definition at line 1005 of file Attributes.cpp.

References B(), C(), get(), and hasAttributes().

◆ addSortedAttributes()

AttributeSet AttributeSet::addSortedAttributes ( LLVMContext & C,
ArrayRef< Attribute > Attrs ) const
nodiscard

Add attributes to the attribute set, replacing attributes of the same kind.

Attrs must be sorted like an attribute set, with at most one attribute of each kind. Returns a new set because attribute sets are immutable.

Definition at line 2455 of file Attributes.cpp.

References llvm::ArrayRef(), assert(), AttributeSet(), begin(), C(), end(), llvm::AttributeSetNode::getSorted(), isSortedAndUnique(), and mergeSortedAttrs().

Referenced by llvm::RTLIB::RuntimeLibcallsInfo::getDefaultFunctionTy().

◆ begin()

AttributeSet::iterator AttributeSet::begin ( ) const

Definition at line 1283 of file Attributes.cpp.

References getNode().

Referenced by addSortedAttributes(), and intersectWith().

◆ dump()

LLVM_DUMP_METHOD void AttributeSet::dump ( ) const

Definition at line 1292 of file Attributes.cpp.

References llvm::dbgs(), getAsString(), and LLVM_DUMP_METHOD.

◆ end()

AttributeSet::iterator AttributeSet::end ( ) const

Definition at line 1287 of file Attributes.cpp.

References getNode().

Referenced by addSortedAttributes(), and intersectWith().

◆ get() [1/2]

AttributeSet AttributeSet::get ( LLVMContext & C,
ArrayRef< Attribute > Attrs )
static

Definition at line 973 of file Attributes.cpp.

References AttributeSet(), C(), and llvm::AttributeSetNode::get().

◆ get() [2/2]

◆ getAlignment()

MaybeAlign AttributeSet::getAlignment ( ) const

Definition at line 1192 of file Attributes.cpp.

References getNode().

◆ getAllocKind()

AllocFnKind AttributeSet::getAllocKind ( ) const

Definition at line 1257 of file Attributes.cpp.

References getNode(), and llvm::Unknown.

◆ getAllocSizeArgs()

std::optional< std::pair< unsigned, std::optional< unsigned > > > AttributeSet::getAllocSizeArgs ( ) const

Definition at line 1239 of file Attributes.cpp.

References getNode().

◆ getAsString()

std::string AttributeSet::getAsString ( bool InAttrGrp = false) const

◆ getAttribute() [1/2]

◆ getAttribute() [2/2]

Attribute AttributeSet::getAttribute ( StringRef Kind) const

Return the target-dependent attribute object.

Definition at line 1188 of file Attributes.cpp.

References llvm::Attribute, and getNode().

◆ getByRefType()

Type * AttributeSet::getByRefType ( ) const

Definition at line 1212 of file Attributes.cpp.

References getNode().

◆ getByValType()

Type * AttributeSet::getByValType ( ) const

Definition at line 1216 of file Attributes.cpp.

References getNode().

◆ getCaptureInfo()

◆ getDeadOnReturnInfo()

DeadOnReturnInfo AttributeSet::getDeadOnReturnInfo ( ) const

Definition at line 1204 of file Attributes.cpp.

References getNode().

◆ getDereferenceableBytes()

uint64_t AttributeSet::getDereferenceableBytes ( ) const

Definition at line 1200 of file Attributes.cpp.

References getNode().

◆ getDereferenceableOrNullBytes()

uint64_t AttributeSet::getDereferenceableOrNullBytes ( ) const

Definition at line 1208 of file Attributes.cpp.

References getNode().

◆ getElementType()

Type * AttributeSet::getElementType ( ) const

Definition at line 1233 of file Attributes.cpp.

References getNode().

◆ getInAllocaType()

Type * AttributeSet::getInAllocaType ( ) const

Definition at line 1229 of file Attributes.cpp.

References getNode().

◆ getMemoryEffects()

◆ getNoFPClass()

FPClassTest AttributeSet::getNoFPClass ( ) const

Definition at line 1269 of file Attributes.cpp.

References llvm::fcNone, and getNode().

◆ getNumAttributes()

unsigned AttributeSet::getNumAttributes ( ) const

Return the number of attributes in this set.

Definition at line 1175 of file Attributes.cpp.

References getNode().

◆ getPreallocatedType()

Type * AttributeSet::getPreallocatedType ( ) const

Definition at line 1224 of file Attributes.cpp.

References getNode().

◆ getStackAlignment()

MaybeAlign AttributeSet::getStackAlignment ( ) const

Definition at line 1196 of file Attributes.cpp.

References getNode().

◆ getStructRetType()

Type * AttributeSet::getStructRetType ( ) const

Definition at line 1220 of file Attributes.cpp.

References getNode().

◆ getUWTableKind()

UWTableKind AttributeSet::getUWTableKind ( ) const

Definition at line 1253 of file Attributes.cpp.

References getNode(), and llvm::None.

◆ getVScaleRangeMax()

std::optional< unsigned > AttributeSet::getVScaleRangeMax ( ) const

Definition at line 1249 of file Attributes.cpp.

References getNode().

◆ getVScaleRangeMin()

unsigned AttributeSet::getVScaleRangeMin ( ) const

Definition at line 1245 of file Attributes.cpp.

References getNode().

◆ hasAttribute() [1/2]

◆ hasAttribute() [2/2]

bool AttributeSet::hasAttribute ( StringRef Kind) const

Return true if the attribute exists in this set.

Definition at line 1180 of file Attributes.cpp.

References getNode().

◆ hasAttributes()

bool llvm::AttributeSet::hasAttributes ( ) const
inline

◆ hasParentContext()

bool AttributeSet::hasParentContext ( LLVMContext & C) const

Return true if this attribute set belongs to the LLVMContext.

Definition at line 1277 of file Attributes.cpp.

References assert(), C(), getNode(), and hasAttributes().

◆ intersectWith()

◆ operator!=()

bool llvm::AttributeSet::operator!= ( const AttributeSet & O) const
inline

Definition at line 475 of file Attributes.h.

◆ operator==()

bool llvm::AttributeSet::operator== ( const AttributeSet & O) const
inline

Definition at line 474 of file Attributes.h.

◆ removeAttribute() [1/2]

AttributeSet AttributeSet::removeAttribute ( LLVMContext & C,
Attribute::AttrKind Kind ) const
nodiscard

Remove the specified attribute from this set.

Returns a new set because attribute sets are immutable.

Definition at line 1018 of file Attributes.cpp.

References B(), C(), get(), and hasAttribute().

◆ removeAttribute() [2/2]

AttributeSet AttributeSet::removeAttribute ( LLVMContext & C,
StringRef Kind ) const
nodiscard

Remove the specified attribute from this set.

Returns a new set because attribute sets are immutable.

Definition at line 1026 of file Attributes.cpp.

References B(), C(), get(), and hasAttribute().

◆ removeAttributes()

AttributeSet AttributeSet::removeAttributes ( LLVMContext & C,
const AttributeMask & AttrsToRemove ) const
nodiscard

Remove the specified attributes from this set.

Returns a new set because attribute sets are immutable.

Definition at line 1034 of file Attributes.cpp.

References A(), B(), C(), get(), and llvm::none_of().

Referenced by moveFunctionAdaptingType().

◆ DenseMapInfo

template<typename Ty, typename Enable>
friend struct DenseMapInfo
friend

Definition at line 450 of file Attributes.h.

References DenseMapInfo, and LLVM_ABI.

Referenced by DenseMapInfo.


The documentation for this class was generated from the following files: