LLVM  4.0.0
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::AttributeSet Class Reference

#include <Attributes.h>

Public Types

enum  AttrIndex : unsigned { ReturnIndex = 0U, FunctionIndex = ~0U }
 
typedef ArrayRef< Attribute >
::iterator 
iterator
 

Public Member Functions

 AttributeSet ()
 
AttributeSet addAttribute (LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
 Add an attribute to the attribute set at the given index. More...
 
AttributeSet addAttribute (LLVMContext &C, unsigned Index, StringRef Kind, StringRef Value=StringRef()) const
 Add an attribute to the attribute set at the given index. More...
 
AttributeSet addAttribute (LLVMContext &C, ArrayRef< unsigned > Indices, Attribute A) const
 Add an attribute to the attribute set at the given indices. More...
 
AttributeSet addAttributes (LLVMContext &C, unsigned Index, AttributeSet Attrs) const
 Add attributes to the attribute set at the given index. More...
 
AttributeSet removeAttribute (LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
 Remove the specified attribute at the specified index from this attribute list. More...
 
AttributeSet removeAttribute (LLVMContext &C, unsigned Index, StringRef Kind) const
 Remove the specified attribute at the specified index from this attribute list. More...
 
AttributeSet removeAttributes (LLVMContext &C, unsigned Index, AttributeSet Attrs) const
 Remove the specified attributes at the specified index from this attribute list. More...
 
AttributeSet removeAttributes (LLVMContext &C, unsigned Index, const AttrBuilder &Attrs) const
 Remove the specified attributes at the specified index from this attribute list. More...
 
AttributeSet addDereferenceableAttr (LLVMContext &C, unsigned Index, uint64_t Bytes) const
 Add the dereferenceable attribute to the attribute set at the given index. More...
 
AttributeSet addDereferenceableOrNullAttr (LLVMContext &C, unsigned Index, uint64_t Bytes) const
 Add the dereferenceable_or_null attribute to the attribute set at the given index. More...
 
AttributeSet addAllocSizeAttr (LLVMContext &C, unsigned Index, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
 Add the allocsize attribute to the attribute set at the given index. More...
 
LLVMContextgetContext () const
 Retrieve the LLVM context. More...
 
AttributeSet getParamAttributes (unsigned Index) const
 The attributes for the specified index are returned. More...
 
AttributeSet getRetAttributes () const
 The attributes for the ret value are returned. More...
 
AttributeSet getFnAttributes () const
 The function attributes are returned. More...
 
bool hasAttribute (unsigned Index, Attribute::AttrKind Kind) const
 Return true if the attribute exists at the given index. More...
 
bool hasAttribute (unsigned Index, StringRef Kind) const
 Return true if the attribute exists at the given index. More...
 
bool hasAttributes (unsigned Index) const
 Return true if attribute exists at the given index. More...
 
bool hasFnAttribute (Attribute::AttrKind Kind) const
 Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but may be faster. More...
 
bool hasFnAttribute (StringRef Kind) const
 Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but may be faster. More...
 
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. More...
 
Attribute getAttribute (unsigned Index, Attribute::AttrKind Kind) const
 Return the attribute object that exists at the given index. More...
 
Attribute getAttribute (unsigned Index, StringRef Kind) const
 Return the attribute object that exists at the given index. More...
 
unsigned getParamAlignment (unsigned Index) const
 Return the alignment for the specified function parameter. More...
 
unsigned getStackAlignment (unsigned Index) const
 Get the stack alignment. More...
 
uint64_t getDereferenceableBytes (unsigned Index) const
 Get the number of dereferenceable bytes (or zero if unknown). More...
 
uint64_t getDereferenceableOrNullBytes (unsigned Index) const
 Get the number of dereferenceable_or_null bytes (or zero if unknown). More...
 
std::pair< unsigned, Optional
< unsigned > > 
getAllocSizeArgs (unsigned Index) const
 Get the allocsize argument numbers (or pair(0, 0) if unknown). More...
 
std::string getAsString (unsigned Index, bool InAttrGrp=false) const
 Return the attributes at the index as a string. More...
 
iterator begin (unsigned Slot) const
 
iterator end (unsigned Slot) const
 
bool operator== (const AttributeSet &RHS) const
 operator==/!= - Provide equality predicates. More...
 
bool operator!= (const AttributeSet &RHS) const
 
void * getRawPointer () const
 Return a raw pointer that uniquely identifies this attribute list. More...
 
bool isEmpty () const
 Return true if there are no attributes. More...
 
unsigned getNumSlots () const
 Return the number of slots used in this attribute list. More...
 
unsigned getSlotIndex (unsigned Slot) const
 Return the index for the given slot. More...
 
AttributeSet getSlotAttributes (unsigned Slot) const
 Return the attributes at the given slot. More...
 
void dump () const
 

Static Public Member Functions

static AttributeSet get (LLVMContext &C, ArrayRef< AttributeSet > Attrs)
 Return an AttributeSet with the specified parameters in it. More...
 
static AttributeSet get (LLVMContext &C, unsigned Index, ArrayRef< Attribute::AttrKind > Kinds)
 
static AttributeSet get (LLVMContext &C, unsigned Index, ArrayRef< StringRef > Kind)
 
static AttributeSet get (LLVMContext &C, unsigned Index, const AttrBuilder &B)
 

Friends

class AttrBuilder
 
class AttributeSetImpl
 
class AttributeSetNode
 
template<typename Ty >
struct DenseMapInfo
 

Detailed Description

Definition at line 203 of file Attributes.h.

Member Typedef Documentation

Definition at line 377 of file Attributes.h.

Member Enumeration Documentation

Enumerator
ReturnIndex 
FunctionIndex 

Definition at line 205 of file Attributes.h.

Constructor & Destructor Documentation

llvm::AttributeSet::AttributeSet ( )
inline

Member Function Documentation

AttributeSet AttributeSet::addAllocSizeAttr ( LLVMContext C,
unsigned  Index,
unsigned  ElemSizeArg,
const Optional< unsigned > &  NumElemsArg 
)

Add the allocsize attribute to the attribute set at the given index.

Because attribute sets are immutable, this returns a new set.

Definition at line 952 of file Attributes.cpp.

References llvm::AttrBuilder::addAllocSizeAttr(), addAttributes(), and B.

AttributeSet AttributeSet::addAttribute ( LLVMContext C,
unsigned  Index,
Attribute::AttrKind  Kind 
) const

Add an attribute to the attribute set at the given index.

Because attribute sets are immutable, this returns a new set.

Definition at line 753 of file Attributes.cpp.

References addAttributes(), and hasAttribute().

Referenced by llvm::Function::addAttribute(), llvm::CallInst::addAttribute(), llvm::InvokeInst::addAttribute(), fixupFPReturnAndCall(), processCallSite(), and removeUseSoftFloat().

AttributeSet AttributeSet::addAttribute ( LLVMContext C,
unsigned  Index,
StringRef  Kind,
StringRef  Value = StringRef() 
) const

Add an attribute to the attribute set at the given index.

Because attribute sets are immutable, this returns a new set.

Definition at line 759 of file Attributes.cpp.

References llvm::AttrBuilder::addAttribute(), addAttributes(), and B.

AttributeSet AttributeSet::addAttribute ( LLVMContext C,
ArrayRef< unsigned Indices,
Attribute  A 
) const

Add an attribute to the attribute set at the given indices.

Because attribute sets are immutable, this returns a new set.

Definition at line 766 of file Attributes.cpp.

References llvm::AttrBuilder::addAttribute(), B, llvm::ArrayRef< T >::begin(), C, E, llvm::SmallVectorImpl< T >::emplace_back(), llvm::ArrayRef< T >::end(), getSlotAttributes(), getSlotIndex(), and I.

AttributeSet AttributeSet::addAttributes ( LLVMContext C,
unsigned  Index,
AttributeSet  Attrs 
) const
AttributeSet AttributeSet::addDereferenceableAttr ( LLVMContext C,
unsigned  Index,
uint64_t  Bytes 
) const

Add the dereferenceable attribute to the attribute set at the given index.

Because attribute sets are immutable, this returns a new set.

Definition at line 936 of file Attributes.cpp.

References addAttributes(), llvm::AttrBuilder::addDereferenceableAttr(), and B.

Referenced by llvm::Function::addDereferenceableAttr(), llvm::CallInst::addDereferenceableAttr(), and llvm::InvokeInst::addDereferenceableAttr().

AttributeSet AttributeSet::addDereferenceableOrNullAttr ( LLVMContext C,
unsigned  Index,
uint64_t  Bytes 
) const

Add the dereferenceable_or_null attribute to the attribute set at the given index.

Because attribute sets are immutable, this returns a new set.

Definition at line 943 of file Attributes.cpp.

References addAttributes(), llvm::AttrBuilder::addDereferenceableOrNullAttr(), and B.

Referenced by llvm::Function::addDereferenceableOrNullAttr(), llvm::CallInst::addDereferenceableOrNullAttr(), and llvm::InvokeInst::addDereferenceableOrNullAttr().

AttributeSet::iterator AttributeSet::begin ( unsigned  Slot) const
LLVM_DUMP_METHOD void AttributeSet::dump ( ) const

Definition at line 1118 of file Attributes.cpp.

References llvm::dbgs(), getAsString(), getNumSlots(), getSlotIndex(), and i.

AttributeSet::iterator AttributeSet::end ( unsigned  Slot) const
AttributeSet AttributeSet::get ( LLVMContext C,
ArrayRef< AttributeSet Attrs 
)
static
AttributeSet AttributeSet::get ( LLVMContext C,
unsigned  Index,
ArrayRef< Attribute::AttrKind Kinds 
)
static
AttributeSet AttributeSet::get ( LLVMContext C,
unsigned  Index,
ArrayRef< StringRef Kind 
)
static
AttributeSet AttributeSet::get ( LLVMContext C,
unsigned  Index,
const AttrBuilder B 
)
static
std::pair< unsigned, Optional< unsigned > > AttributeSet::getAllocSizeArgs ( unsigned  Index) const

Get the allocsize argument numbers (or pair(0, 0) if unknown).

Definition at line 1065 of file Attributes.cpp.

References llvm::AttributeSetNode::getAllocSizeArgs(), and llvm::Intrinsic::getAttributes().

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

Return the attributes at the index as a string.

Definition at line 1070 of file Attributes.cpp.

References llvm::AttributeSetNode::getAsString(), and llvm::Intrinsic::getAttributes().

Referenced by dump().

Attribute AttributeSet::getAttribute ( unsigned  Index,
Attribute::AttrKind  Kind 
) const
Attribute AttributeSet::getAttribute ( unsigned  Index,
StringRef  Kind 
) const

Return the attribute object that exists at the given index.

Definition at line 1038 of file Attributes.cpp.

References llvm::AttributeSetNode::getAttribute(), and llvm::Intrinsic::getAttributes().

LLVMContext & AttributeSet::getContext ( ) const

Retrieve the LLVM context.

Definition at line 964 of file Attributes.cpp.

Referenced by legalizeCallAttributes().

uint64_t AttributeSet::getDereferenceableBytes ( unsigned  Index) const

Get the number of dereferenceable bytes (or zero if unknown).

Definition at line 1054 of file Attributes.cpp.

References llvm::Intrinsic::getAttributes(), and llvm::AttributeSetNode::getDereferenceableBytes().

Referenced by llvm::Function::getDereferenceableBytes(), and llvm::CallInst::getDereferenceableBytes().

uint64_t AttributeSet::getDereferenceableOrNullBytes ( unsigned  Index) const

Get the number of dereferenceable_or_null bytes (or zero if unknown).

Definition at line 1059 of file Attributes.cpp.

References llvm::Intrinsic::getAttributes(), and llvm::AttributeSetNode::getDereferenceableOrNullBytes().

Referenced by llvm::Function::getDereferenceableOrNullBytes(), and llvm::CallInst::getDereferenceableOrNullBytes().

AttributeSet AttributeSet::getFnAttributes ( ) const

The function attributes are returned.

Definition at line 985 of file Attributes.cpp.

References AttributeSet(), FunctionIndex, llvm::Intrinsic::getAttributes(), and hasAttributes().

Referenced by llvm::CloneFunctionInto(), DoPromotion(), and makeStatepointExplicitImpl().

unsigned AttributeSet::getNumSlots ( ) const

Return the number of slots used in this attribute list.

This is the number of arguments that have an attribute set on them (including the function itself).

Definition at line 1102 of file Attributes.cpp.

Referenced by llvm::Argument::addAttr(), llvm::CloneFunctionInto(), dump(), getSlotAttributes(), getSlotIndex(), llvm::AttrBuilder::hasAttributes(), isEmpty(), legalizeCallAttributes(), llvm::Argument::removeAttr(), llvm::AttrBuilder::removeAttributes(), and StripNest().

unsigned AttributeSet::getParamAlignment ( unsigned  Index) const

Return the alignment for the specified function parameter.

Definition at line 1044 of file Attributes.cpp.

References llvm::AttributeSetNode::getAlignment(), and llvm::Intrinsic::getAttributes().

Referenced by addAttributes(), llvm::Function::getParamAlignment(), llvm::CallInst::getParamAlignment(), and getParameterABIAttributes().

AttributeSet AttributeSet::getParamAttributes ( unsigned  Index) const

The attributes for the specified index are returned.

Definition at line 968 of file Attributes.cpp.

References AttributeSet(), llvm::Intrinsic::getAttributes(), and hasAttributes().

Referenced by llvm::CloneFunctionInto(), and DoPromotion().

void* llvm::AttributeSet::getRawPointer ( ) const
inline

Return a raw pointer that uniquely identifies this attribute list.

Definition at line 395 of file Attributes.h.

AttributeSet AttributeSet::getRetAttributes ( ) const

The attributes for the ret value are returned.

Definition at line 976 of file Attributes.cpp.

References AttributeSet(), llvm::Intrinsic::getAttributes(), hasAttributes(), and ReturnIndex.

Referenced by llvm::CloneFunctionInto(), DoPromotion(), and makeStatepointExplicitImpl().

AttributeSet AttributeSet::getSlotAttributes ( unsigned  Slot) const

Return the attributes at the given slot.

Definition at line 1112 of file Attributes.cpp.

References assert(), and getNumSlots().

Referenced by addAttribute(), addAttributes(), removeAttributes(), and StripNest().

unsigned AttributeSet::getSlotIndex ( unsigned  Slot) const
unsigned AttributeSet::getStackAlignment ( unsigned  Index) const

Get the stack alignment.

Definition at line 1049 of file Attributes.cpp.

References llvm::Intrinsic::getAttributes(), and llvm::AttributeSetNode::getStackAlignment().

Referenced by llvm::Function::getFnStackAlignment().

bool AttributeSet::hasAttribute ( unsigned  Index,
Attribute::AttrKind  Kind 
) const
bool AttributeSet::hasAttribute ( unsigned  Index,
StringRef  Kind 
) const

Return true if the attribute exists at the given index.

Definition at line 999 of file Attributes.cpp.

References llvm::Intrinsic::getAttributes(), and llvm::AttributeSetNode::hasAttribute().

bool AttributeSet::hasAttributes ( unsigned  Index) const

Return true if attribute exists at the given index.

Definition at line 1004 of file Attributes.cpp.

References llvm::Intrinsic::getAttributes(), and llvm::AttributeSetNode::hasAttributes().

Referenced by DoPromotion(), getFnAttributes(), getParamAttributes(), and getRetAttributes().

bool AttributeSet::hasAttrSomewhere ( Attribute::AttrKind  Kind,
unsigned Index = nullptr 
) const
bool AttributeSet::hasFnAttribute ( Attribute::AttrKind  Kind) const

Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but may be faster.

Definition at line 1009 of file Attributes.cpp.

Referenced by llvm::Function::hasFnAttribute().

bool AttributeSet::hasFnAttribute ( StringRef  Kind) const

Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but may be faster.

Definition at line 1013 of file Attributes.cpp.

References FunctionIndex, and hasAttribute().

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

Return true if there are no attributes.

Definition at line 400 of file Attributes.h.

References getNumSlots().

Referenced by llvm::ValueEnumerator::getAttributeGroupID(), and llvm::ValueEnumerator::getAttributeID().

bool llvm::AttributeSet::operator!= ( const AttributeSet RHS) const
inline

Definition at line 386 of file Attributes.h.

bool llvm::AttributeSet::operator== ( const AttributeSet RHS) const
inline

operator==/!= - Provide equality predicates.

Definition at line 383 of file Attributes.h.

AttributeSet AttributeSet::removeAttribute ( LLVMContext C,
unsigned  Index,
Attribute::AttrKind  Kind 
) const

Remove the specified attribute at the specified index from this attribute list.

Because attribute lists are immutable, this returns the new list.

Definition at line 845 of file Attributes.cpp.

References hasAttribute(), and removeAttributes().

Referenced by PromoteArguments(), llvm::Function::removeAttribute(), llvm::CallInst::removeAttribute(), llvm::InvokeInst::removeAttribute(), llvm::Function::removeFnAttr(), and StripNest().

AttributeSet AttributeSet::removeAttribute ( LLVMContext C,
unsigned  Index,
StringRef  Kind 
) const

Remove the specified attribute at the specified index from this attribute list.

Because attribute lists are immutable, this returns the new list.

Definition at line 851 of file Attributes.cpp.

References hasAttribute(), and removeAttributes().

AttributeSet AttributeSet::removeAttributes ( LLVMContext C,
unsigned  Index,
AttributeSet  Attrs 
) const

Remove the specified attributes at the specified index from this attribute list.

Because attribute lists are immutable, this returns the new list.

Definition at line 857 of file Attributes.cpp.

References assert(), AttributeSet(), B, C, E, llvm::AttributeSetImpl::getNumSlots(), llvm::AttributeSetImpl::getSlotAttributes(), getSlotAttributes(), getSlotIndex(), hasAttribute(), I, and llvm::AttrBuilder::removeAttributes().

Referenced by removeAttribute(), and llvm::Function::removeAttributes().

AttributeSet AttributeSet::removeAttributes ( LLVMContext C,
unsigned  Index,
const AttrBuilder Attrs 
) const

Remove the specified attributes at the specified index from this attribute list.

Because attribute lists are immutable, this returns the new list.

Definition at line 900 of file Attributes.cpp.

References assert(), AttributeSet(), B, C, E, getSlotAttributes(), getSlotIndex(), llvm::AttrBuilder::hasAlignmentAttr(), I, and llvm::AttrBuilder::remove().

Friends And Related Function Documentation

friend class AttrBuilder
friend

Definition at line 211 of file Attributes.h.

friend class AttributeSetImpl
friend

Definition at line 212 of file Attributes.h.

friend class AttributeSetNode
friend

Definition at line 213 of file Attributes.h.

template<typename Ty >
friend struct DenseMapInfo
friend

Definition at line 214 of file Attributes.h.


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