LLVM  14.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
llvm::Attribute Class Reference

#include "llvm/IR/Attributes.h"

Collaboration diagram for llvm::Attribute:
Collaboration graph
[legend]

Public Types

enum  AttrKind { None, EndAttrKinds, EmptyKey, TombstoneKey }
 This enumeration lists the attributes that can be associated with parameters, function results, or the function itself. More...
 

Public Member Functions

 Attribute ()=default
 
Attribute getWithNewType (LLVMContext &Context, Type *ReplacementTy)
 For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy. More...
 
bool isEnumAttribute () const
 Return true if the attribute is an Attribute::AttrKind type. More...
 
bool isIntAttribute () const
 Return true if the attribute is an integer attribute. More...
 
bool isStringAttribute () const
 Return true if the attribute is a string (target-dependent) attribute. More...
 
bool isTypeAttribute () const
 Return true if the attribute is a type attribute. More...
 
bool isValid () const
 Return true if the attribute is any kind of attribute. More...
 
bool hasAttribute (AttrKind Val) const
 Return true if the attribute is present. More...
 
bool hasAttribute (StringRef Val) const
 Return true if the target-dependent attribute is present. More...
 
Attribute::AttrKind getKindAsEnum () const
 Return the attribute's kind as an enum (Attribute::AttrKind). More...
 
uint64_t getValueAsInt () const
 Return the attribute's value as an integer. More...
 
bool getValueAsBool () const
 Return the attribute's value as a boolean. More...
 
StringRef getKindAsString () const
 Return the attribute's kind as a string. More...
 
StringRef getValueAsString () const
 Return the attribute's value as a string. More...
 
TypegetValueAsType () const
 Return the attribute's value as a Type. More...
 
MaybeAlign getAlignment () const
 Returns the alignment field of an attribute as a byte alignment value. More...
 
MaybeAlign getStackAlignment () const
 Returns the stack alignment field of an attribute as a byte alignment value. More...
 
uint64_t getDereferenceableBytes () const
 Returns the number of dereferenceable bytes from the dereferenceable attribute. More...
 
uint64_t getDereferenceableOrNullBytes () const
 Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute. More...
 
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs () const
 Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known). More...
 
std::pair< unsigned, unsigned > getVScaleRangeArgs () const
 Returns the argument numbers for the vscale_range attribute (or pair(0, 0) if not known). More...
 
std::string getAsString (bool InAttrGrp=false) const
 The Attribute is converted to a string of equivalent mnemonic. More...
 
bool hasParentContext (LLVMContext &C) const
 Return true if this attribute belongs to the LLVMContext. More...
 
bool operator== (Attribute A) const
 Equality and non-equality operators. More...
 
bool operator!= (Attribute A) const
 
bool operator< (Attribute A) const
 Less-than operator. Useful for sorting the attributes list. More...
 
void Profile (FoldingSetNodeID &ID) const
 
void * getRawPointer () const
 Return a raw pointer that uniquely identifies this attribute. More...
 

Static Public Member Functions

static bool isEnumAttrKind (AttrKind Kind)
 
static bool isIntAttrKind (AttrKind Kind)
 
static bool isTypeAttrKind (AttrKind Kind)
 
static bool canUseAsFnAttr (AttrKind Kind)
 
static bool canUseAsParamAttr (AttrKind Kind)
 
static bool canUseAsRetAttr (AttrKind Kind)
 
static Attribute get (LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
 Return a uniquified Attribute object. More...
 
static Attribute get (LLVMContext &Context, StringRef Kind, StringRef Val=StringRef())
 
static Attribute get (LLVMContext &Context, AttrKind Kind, Type *Ty)
 
static Attribute getWithAlignment (LLVMContext &Context, Align Alignment)
 Return a uniquified Attribute object that has the specific alignment set. More...
 
static Attribute getWithStackAlignment (LLVMContext &Context, Align Alignment)
 
static Attribute getWithDereferenceableBytes (LLVMContext &Context, uint64_t Bytes)
 
static Attribute getWithDereferenceableOrNullBytes (LLVMContext &Context, uint64_t Bytes)
 
static Attribute getWithAllocSizeArgs (LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
 
static Attribute getWithVScaleRangeArgs (LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
 
static Attribute getWithByValType (LLVMContext &Context, Type *Ty)
 
static Attribute getWithStructRetType (LLVMContext &Context, Type *Ty)
 
static Attribute getWithByRefType (LLVMContext &Context, Type *Ty)
 
static Attribute getWithPreallocatedType (LLVMContext &Context, Type *Ty)
 
static Attribute getWithInAllocaType (LLVMContext &Context, Type *Ty)
 
static Attribute::AttrKind getAttrKindFromName (StringRef AttrName)
 
static StringRef getNameFromAttrKind (Attribute::AttrKind AttrKind)
 
static bool isExistingAttribute (StringRef Name)
 Return true if the provided string matches the IR name of an attribute. More...
 
static Attribute fromRawPointer (void *RawPtr)
 Get an attribute from a raw pointer created by getRawPointer. More...
 

Static Public Attributes

static const unsigned NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1
 
static const unsigned NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1
 

Detailed Description

Definition at line 52 of file Attributes.h.

Member Enumeration Documentation

◆ AttrKind

This enumeration lists the attributes that can be associated with parameters, function results, or the function itself.

Note: The ‘uwtable’ attribute is about the ABI or the user mandating an entry in the unwind table. The ‘nounwind’ attribute is about an exception passing by the function.

In a theoretical system that uses tables for profiling and SjLj for exceptions, they would be fully independent. In a normal system that uses tables for both, the semantics are:

nil = Needs an entry because an exception might pass by. nounwind = No need for an entry uwtable = Needs an entry because the ABI says so and because an exception might pass by. uwtable + nounwind = Needs an entry because the ABI says so.

Enumerator
None 

No attributes have been set.

EndAttrKinds 

Sentinal value useful for loops.

EmptyKey 

Use as Empty key for DenseMap of AttrKind.

TombstoneKey 

Use as Tombstone key for DenseMap of AttrKind.

Definition at line 71 of file Attributes.h.

Constructor & Destructor Documentation

◆ Attribute()

llvm::Attribute::Attribute ( )
default

Referenced by fromRawPointer(), and get().

Member Function Documentation

◆ canUseAsFnAttr()

bool Attribute::canUseAsFnAttr ( AttrKind  Kind)
static

Definition at line 505 of file Attributes.cpp.

References FnAttr, and hasAttributeProperty().

Referenced by forceAttributes().

◆ canUseAsParamAttr()

bool Attribute::canUseAsParamAttr ( AttrKind  Kind)
static

Definition at line 509 of file Attributes.cpp.

References hasAttributeProperty(), and ParamAttr.

◆ canUseAsRetAttr()

bool Attribute::canUseAsRetAttr ( AttrKind  Kind)
static

Definition at line 513 of file Attributes.cpp.

References hasAttributeProperty(), and RetAttr.

◆ fromRawPointer()

static Attribute llvm::Attribute::fromRawPointer ( void *  RawPtr)
inlinestatic

Get an attribute from a raw pointer created by getRawPointer.

Definition at line 246 of file Attributes.h.

References Attribute().

Referenced by llvm::unwrap().

◆ get() [1/3]

Attribute Attribute::get ( LLVMContext Context,
Attribute::AttrKind  Kind,
Type Ty 
)
static

◆ get() [2/3]

Attribute Attribute::get ( LLVMContext Context,
Attribute::AttrKind  Kind,
uint64_t  Val = 0 
)
static

◆ get() [3/3]

Attribute Attribute::get ( LLVMContext Context,
StringRef  Kind,
StringRef  Val = StringRef() 
)
static

◆ getAlignment()

MaybeAlign Attribute::getAlignment ( ) const

Returns the alignment field of an attribute as a byte alignment value.

Definition at line 325 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().

Referenced by llvm::FunctionComparator::cmpOperations().

◆ getAllocSizeArgs()

std::pair< unsigned, Optional< unsigned > > Attribute::getAllocSizeArgs ( ) const

Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known).

Definition at line 351 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsInt(), hasAttribute(), and unpackAllocSizeArgs().

Referenced by getAllocationSize(), and getAsString().

◆ getAsString()

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

◆ getAttrKindFromName()

Attribute::AttrKind Attribute::getAttrKindFromName ( StringRef  AttrName)
static

◆ getDereferenceableBytes()

uint64_t Attribute::getDereferenceableBytes ( ) const

Returns the number of dereferenceable bytes from the dereferenceable attribute.

Definition at line 337 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().

Referenced by tryToMoveFreeBeforeNullTest().

◆ getDereferenceableOrNullBytes()

uint64_t Attribute::getDereferenceableOrNullBytes ( ) const

Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.

Definition at line 344 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().

◆ getKindAsEnum()

Attribute::AttrKind Attribute::getKindAsEnum ( ) const

Return the attribute's kind as an enum (Attribute::AttrKind).

This requires the attribute to be an enum, integer, or type attribute.

Definition at line 273 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getKindAsEnum(), isEnumAttribute(), isIntAttribute(), isTypeAttribute(), and None.

Referenced by llvm::AttrBuilder::addAttribute(), addIfNotExistent(), getAsString(), getWithNewType(), LLVMGetEnumAttributeKind(), and AAMemoryBehaviorImpl::manifest().

◆ getKindAsString()

StringRef Attribute::getKindAsString ( ) const

Return the attribute's kind as a string.

This requires the attribute to be a string attribute.

Definition at line 294 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getKindAsString(), and isStringAttribute().

Referenced by llvm::AttrBuilder::addAttribute(), addIfNotExistent(), getAsString(), and LLVMGetStringAttributeKind().

◆ getNameFromAttrKind()

StringRef Attribute::getNameFromAttrKind ( Attribute::AttrKind  AttrKind)
static

Definition at line 231 of file Attributes.cpp.

References llvm_unreachable, and None.

Referenced by getAsString(), and llvm::hasAttributeInAssume().

◆ getRawPointer()

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

Return a raw pointer that uniquely identifies this attribute.

Definition at line 241 of file Attributes.h.

Referenced by llvm::wrap().

◆ getStackAlignment()

MaybeAlign Attribute::getStackAlignment ( ) const

Returns the stack alignment field of an attribute as a byte alignment value.

Definition at line 331 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().

◆ getValueAsBool()

bool Attribute::getValueAsBool ( ) const

Return the attribute's value as a boolean.

This requires that the attribute be a string attribute.

Definition at line 287 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsBool(), and isStringAttribute().

Referenced by llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), llvm::TargetLoweringBase::areJTsAllowed(), hasUnsafeFPMath(), llvm::AMDGPULibCalls::isUnsafeMath(), and SwitchToLookupTable().

◆ getValueAsInt()

uint64_t Attribute::getValueAsInt ( ) const

Return the attribute's value as an integer.

This requires that the attribute be an integer attribute.

Definition at line 280 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsInt(), and isIntAttribute().

Referenced by llvm::AttrBuilder::addAttribute(), getAsString(), and isEqualOrWorse().

◆ getValueAsString()

StringRef Attribute::getValueAsString ( ) const

Return the attribute's value as a string.

This requires the attribute to be a string attribute.

Definition at line 301 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsString(), and isStringAttribute().

Referenced by llvm::AttrBuilder::addAttribute(), adjustCallerStackProbeSize(), adjustMinLegalVectorWidth(), foldFPToIntToFP(), llvm::Function::getDenormalMode(), getDeoptLowering(), llvm::AMDGPUTargetMachine::getFeatureString(), llvm::AMDGPUTargetMachine::getGPUName(), llvm::SystemZTargetLowering::getStackProbeSize(), llvm::PPCTargetLowering::getStackProbeSize(), llvm::X86TargetLowering::getStackProbeSize(), llvm::X86TargetLowering::getStackProbeSymbolName(), llvm::RISCVTargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::SystemZTargetMachine::getSubtargetImpl(), llvm::WebAssemblyTargetMachine::getSubtargetImpl(), llvm::X86TargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::M68kTargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), llvm::VFABI::getVectorVariantNames(), llvm::SystemZTargetLowering::hasInlineStackProbe(), llvm::PPCTargetLowering::hasInlineStackProbe(), llvm::X86TargetLowering::hasInlineStackProbe(), isThumbFunction(), LLVMGetStringAttributeValue(), llvm::CallLowering::lowerCall(), llvm::RISCVTargetLowering::LowerFormalArguments(), llvm::RISCVTargetLowering::LowerReturn(), llvm::parseStatepointDirectivesFromAttrs(), llvm::StackProtector::runOnFunction(), llvm::SITargetLowering::shouldExpandAtomicRMWInIR(), and simplifyNvvmIntrinsic().

◆ getValueAsType()

Type * Attribute::getValueAsType ( ) const

Return the attribute's value as a Type.

This requires the attribute to be a type attribute.

Definition at line 308 of file Attributes.cpp.

References assert(), llvm::AttributeImpl::getValueAsType(), and isTypeAttribute().

Referenced by llvm::AttrBuilder::addAttribute(), and getAsString().

◆ getVScaleRangeArgs()

std::pair< unsigned, unsigned > Attribute::getVScaleRangeArgs ( ) const

◆ getWithAlignment()

Attribute Attribute::getWithAlignment ( LLVMContext Context,
Align  Alignment 
)
static

◆ getWithAllocSizeArgs()

Attribute Attribute::getWithAllocSizeArgs ( LLVMContext Context,
unsigned  ElemSizeArg,
const Optional< unsigned > &  NumElemsArg 
)
static

Definition at line 209 of file Attributes.cpp.

References assert(), Context, get(), and packAllocSizeArgs().

◆ getWithByRefType()

Attribute Attribute::getWithByRefType ( LLVMContext Context,
Type Ty 
)
static

Definition at line 196 of file Attributes.cpp.

References Context, and get().

◆ getWithByValType()

Attribute Attribute::getWithByValType ( LLVMContext Context,
Type Ty 
)
static

Definition at line 188 of file Attributes.cpp.

References Context, and get().

Referenced by LLVMCreateEnumAttribute(), and llvm::UpgradeFunctionAttributes().

◆ getWithDereferenceableBytes()

Attribute Attribute::getWithDereferenceableBytes ( LLVMContext Context,
uint64_t  Bytes 
)
static

◆ getWithDereferenceableOrNullBytes()

Attribute Attribute::getWithDereferenceableOrNullBytes ( LLVMContext Context,
uint64_t  Bytes 
)
static

Definition at line 182 of file Attributes.cpp.

References assert(), Context, and get().

Referenced by AADereferenceableImpl::getDeducedAttributes().

◆ getWithInAllocaType()

Attribute Attribute::getWithInAllocaType ( LLVMContext Context,
Type Ty 
)
static

Definition at line 204 of file Attributes.cpp.

References Context, and get().

◆ getWithNewType()

Attribute llvm::Attribute::getWithNewType ( LLVMContext Context,
Type ReplacementTy 
)
inline

For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy.

Definition at line 137 of file Attributes.h.

References assert(), Context, get(), getKindAsEnum(), and isTypeAttribute().

Referenced by llvm::AttributeList::replaceAttributeTypeAtIndex().

◆ getWithPreallocatedType()

Attribute Attribute::getWithPreallocatedType ( LLVMContext Context,
Type Ty 
)
static

Definition at line 200 of file Attributes.cpp.

References Context, and get().

◆ getWithStackAlignment()

Attribute Attribute::getWithStackAlignment ( LLVMContext Context,
Align  Alignment 
)
static

Definition at line 171 of file Attributes.cpp.

References A, assert(), Context, and get().

◆ getWithStructRetType()

Attribute Attribute::getWithStructRetType ( LLVMContext Context,
Type Ty 
)
static

Definition at line 192 of file Attributes.cpp.

References Context, and get().

Referenced by LLVMCreateEnumAttribute().

◆ getWithVScaleRangeArgs()

Attribute Attribute::getWithVScaleRangeArgs ( LLVMContext Context,
unsigned  MinValue,
unsigned  MaxValue 
)
static

Definition at line 216 of file Attributes.cpp.

References Context, get(), and packVScaleRangeArgs().

◆ hasAttribute() [1/2]

bool Attribute::hasAttribute ( AttrKind  Val) const

◆ hasAttribute() [2/2]

bool Attribute::hasAttribute ( StringRef  Val) const

Return true if the target-dependent attribute is present.

Definition at line 320 of file Attributes.cpp.

References llvm::AttributeImpl::hasAttribute(), and isStringAttribute().

◆ hasParentContext()

bool Attribute::hasParentContext ( LLVMContext C) const

Return true if this attribute belongs to the LLVMContext.

Definition at line 469 of file Attributes.cpp.

References assert(), isValid(), and llvm::AttributeImpl::Profile().

◆ isEnumAttribute()

bool Attribute::isEnumAttribute ( ) const

Return true if the attribute is an Attribute::AttrKind type.

Definition at line 257 of file Attributes.cpp.

References llvm::AttributeImpl::isEnumAttribute().

Referenced by addIfNotExistent(), getAsString(), and getKindAsEnum().

◆ isEnumAttrKind()

static bool llvm::Attribute::isEnumAttrKind ( AttrKind  Kind)
inlinestatic

Definition at line 84 of file Attributes.h.

Referenced by llvm::AttrBuilder::addAttribute(), and get().

◆ isExistingAttribute()

bool Attribute::isExistingAttribute ( StringRef  Name)
static

Return true if the provided string matches the IR name of an attribute.

example: "noalias" return true but not "NoAlias"

Definition at line 245 of file Attributes.cpp.

References llvm::StringSwitch< T, R >::Default().

Referenced by llvm::hasAttributeInAssume().

◆ isIntAttribute()

bool Attribute::isIntAttribute ( ) const

Return true if the attribute is an integer attribute.

Definition at line 261 of file Attributes.cpp.

References llvm::AttributeImpl::isIntAttribute().

Referenced by addIfNotExistent(), getKindAsEnum(), getValueAsInt(), and isEqualOrWorse().

◆ isIntAttrKind()

static bool llvm::Attribute::isIntAttrKind ( AttrKind  Kind)
inlinestatic

◆ isStringAttribute()

bool Attribute::isStringAttribute ( ) const

◆ isTypeAttribute()

bool Attribute::isTypeAttribute ( ) const

Return true if the attribute is a type attribute.

Definition at line 269 of file Attributes.cpp.

References llvm::AttributeImpl::isTypeAttribute().

Referenced by getAsString(), getKindAsEnum(), getValueAsType(), getWithNewType(), and LLVMIsTypeAttribute().

◆ isTypeAttrKind()

static bool llvm::Attribute::isTypeAttrKind ( AttrKind  Kind)
inlinestatic

Definition at line 90 of file Attributes.h.

Referenced by get(), and llvm::AttributeSetNode::get().

◆ isValid()

bool llvm::Attribute::isValid ( ) const
inline

◆ operator!=()

bool llvm::Attribute::operator!= ( Attribute  A) const
inline

Definition at line 233 of file Attributes.h.

◆ operator<()

bool Attribute::operator< ( Attribute  A) const

Less-than operator. Useful for sorting the attributes list.

Definition at line 477 of file Attributes.cpp.

References A.

◆ operator==()

bool llvm::Attribute::operator== ( Attribute  A) const
inline

Equality and non-equality operators.

Definition at line 232 of file Attributes.h.

◆ Profile()

void Attribute::Profile ( FoldingSetNodeID ID) const

Definition at line 484 of file Attributes.cpp.

Member Data Documentation

◆ NumIntAttrKinds

const unsigned llvm::Attribute::NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1
static

Definition at line 81 of file Attributes.h.

Referenced by llvm::AttrBuilder::merge(), and llvm::AttrBuilder::remove().

◆ NumTypeAttrKinds

const unsigned llvm::Attribute::NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1
static

Definition at line 82 of file Attributes.h.

Referenced by llvm::AttrBuilder::merge(), and llvm::AttrBuilder::remove().


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