LLVM: llvm::Attribute Class Reference (original) (raw)
Functions, function parameters, and return types can have attributes to indicate how they should be treated by optimizations and code generation. More...
#include "[llvm/IR/Attributes.h](Attributes%5F8h%5Fsource.html)"
| 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. | |
| LLVM_ABI bool | isEnumAttribute () const |
| Return true if the attribute is an Attribute::AttrKind type. | |
| LLVM_ABI bool | isIntAttribute () const |
| Return true if the attribute is an integer attribute. | |
| LLVM_ABI bool | isStringAttribute () const |
| Return true if the attribute is a string (target-dependent) attribute. | |
| LLVM_ABI bool | isTypeAttribute () const |
| Return true if the attribute is a type attribute. | |
| LLVM_ABI bool | isConstantRangeAttribute () const |
| Return true if the attribute is a ConstantRange attribute. | |
| LLVM_ABI bool | isConstantRangeListAttribute () const |
| Return true if the attribute is a ConstantRangeList attribute. | |
| bool | isValid () const |
| Return true if the attribute is any kind of attribute. | |
| LLVM_ABI bool | hasAttribute (AttrKind Val) const |
| Return true if the attribute is present. | |
| LLVM_ABI bool | hasAttribute (StringRef Val) const |
| Return true if the target-dependent attribute is present. | |
| bool | hasKindAsEnum () const |
| Returns true if the attribute's kind can be represented as an enum (Enum, Integer, Type, ConstantRange, or ConstantRangeList attribute). | |
| LLVM_ABI Attribute::AttrKind | getKindAsEnum () const |
| Return the attribute's kind as an enum (Attribute::AttrKind). | |
| LLVM_ABI uint64_t | getValueAsInt () const |
| Return the attribute's value as an integer. | |
| LLVM_ABI bool | getValueAsBool () const |
| Return the attribute's value as a boolean. | |
| LLVM_ABI StringRef | getKindAsString () const |
| Return the attribute's kind as a string. | |
| LLVM_ABI StringRef | getValueAsString () const |
| Return the attribute's value as a string. | |
| LLVM_ABI Type * | getValueAsType () const |
| Return the attribute's value as a Type. | |
| LLVM_ABI const ConstantRange & | getValueAsConstantRange () const |
| Return the attribute's value as a ConstantRange. | |
| LLVM_ABI ArrayRef< ConstantRange > | getValueAsConstantRangeList () const |
| Return the attribute's value as a ConstantRange array. | |
| LLVM_ABI MaybeAlign | getAlignment () const |
| Returns the alignment field of an attribute as a byte alignment value. | |
| LLVM_ABI MaybeAlign | getStackAlignment () const |
| Returns the stack alignment field of an attribute as a byte alignment value. | |
| LLVM_ABI uint64_t | getDereferenceableBytes () const |
| Returns the number of dereferenceable bytes from the dereferenceable attribute. | |
| LLVM_ABI uint64_t | getDereferenceableOrNullBytes () const |
| Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute. | |
| LLVM_ABI std::pair< unsigned, std::optional< unsigned > > | getAllocSizeArgs () const |
| Returns the argument numbers for the allocsize attribute. | |
| LLVM_ABI unsigned | getVScaleRangeMin () const |
| Returns the minimum value for the vscale_range attribute. | |
| LLVM_ABI std::optional< unsigned > | getVScaleRangeMax () const |
| Returns the maximum value for the vscale_range attribute or std::nullopt when unknown. | |
| LLVM_ABI UWTableKind | getUWTableKind () const |
| LLVM_ABI AllocFnKind | getAllocKind () const |
| LLVM_ABI MemoryEffects | getMemoryEffects () const |
| Returns memory effects. | |
| LLVM_ABI CaptureInfo | getCaptureInfo () const |
| Returns information from captures attribute. | |
| LLVM_ABI FPClassTest | getNoFPClass () const |
| Return the FPClassTest for nofpclass. | |
| LLVM_ABI const ConstantRange & | getRange () const |
| Returns the value of the range attribute. | |
| LLVM_ABI ArrayRef< ConstantRange > | getInitializes () const |
| Returns the value of the initializes attribute. | |
| LLVM_ABI std::string | getAsString (bool InAttrGrp=false) const |
| The Attribute is converted to a string of equivalent mnemonic. | |
| LLVM_ABI bool | hasParentContext (LLVMContext &C) const |
| Return true if this attribute belongs to the LLVMContext. | |
| bool | operator== (Attribute A) const |
| Equality and non-equality operators. | |
| bool | operator!= (Attribute A) const |
| LLVM_ABI int | cmpKind (Attribute A) const |
| Used to sort attribute by kind. | |
| LLVM_ABI bool | operator< (Attribute A) const |
| Less-than operator. Useful for sorting the attributes list. | |
| LLVM_ABI void | Profile (FoldingSetNodeID &ID) const |
| void * | getRawPointer () const |
| Return a raw pointer that uniquely identifies this attribute. |
Functions, function parameters, and return types can have attributes to indicate how they should be treated by optimizations and code generation.
This class represents one of those attributes. It's light-weight and should be passed around by-value.
Definition at line 69 of file Attributes.h.
◆ 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 | Sentinel 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 88 of file Attributes.h.
| llvm::Attribute::Attribute ( ) | default |
|---|
◆ canUseAsFnAttr()
| bool Attribute::canUseAsFnAttr ( AttrKind Kind) | static |
|---|
◆ canUseAsParamAttr()
| bool Attribute::canUseAsParamAttr ( AttrKind Kind) | static |
|---|
◆ canUseAsRetAttr()
| bool Attribute::canUseAsRetAttr ( AttrKind Kind) | static |
|---|
◆ cmpKind()
◆ fromRawPointer()
| Attribute llvm::Attribute::fromRawPointer ( void * RawPtr) | inlinestatic |
|---|
◆ get() [1/5]
◆ get() [2/5]
◆ get() [3/5]
◆ get() [4/5]
Return a uniquified Attribute object.
Definition at line 95 of file Attributes.cpp.
References assert(), Attribute(), get(), isEnumAttrKind(), and isIntAttrKind().
Referenced by llvm::memprof::addAmbiguousAttribute(), addAssumptionsImpl(), llvm::memprof::CallStackTrie::addSingleAllocTypeAttribute(), CreateGCStatepointCallCommon(), CreateGCStatepointInvokeCommon(), llvm::IRBuilderBase::CreatePreserveArrayAccessIndex(), llvm::IRBuilderBase::CreatePreserveStructAccessIndex(), llvm::AArch64TargetLowering::emitLoadLinked(), llvm::ARMTargetLowering::emitLoadLinked(), llvm::AArch64TargetLowering::emitStoreConditional(), llvm::ARMTargetLowering::emitStoreConditional(), emitTPIDR2Save(), get(), llvm::Attributor::getAttrsFromAssumes(), llvm::IRAttribute< AK, BaseType, AAType >::getDeducedAttributes(), getWithAlignment(), getWithAllocKind(), getWithAllocSizeArgs(), getWithByRefType(), getWithByValType(), getWithCaptureInfo(), getWithDereferenceableBytes(), getWithDereferenceableOrNullBytes(), getWithInAllocaType(), getWithMemoryEffects(), getWithNewType(), getWithNoFPClass(), getWithPreallocatedType(), getWithStackAlignment(), getWithStructRetType(), getWithUWTableKind(), getWithVScaleRangeArgs(), llvm::Attributor::hasAttr(), llvm::inferAttribute(), inferInitializes(), insertCall(), llvm::AANoSync::isImpliedByIR(), llvm::AANoUndef::isImpliedByIR(), llvm::AAWillReturn::isImpliedByIR(), LLVMAddTargetDependentFunctionAttr(), LLVMCreateConstantRangeAttribute(), LLVMCreateEnumAttribute(), LLVMCreateStringAttribute(), LLVMCreateTypeAttribute(), LLVMDIBuilderGetOrCreateArray(), LLVMDIBuilderGetOrCreateTypeArray(), processCallSite(), llvm::InlinerPass::run(), setAllocKind(), llvm::codegen::setFunctionAttributes(), llvm::setInlineRemark(), setParamElementType(), setParamReadNone(), setParamReadOnly(), setParamWriteOnly(), llvm::VFABI::setVectorVariantNames(), and upgradeSingleNVVMAnnotation().
◆ get() [5/5]
◆ getAlignment()
◆ getAllocKind()
◆ getAllocSizeArgs()
| std::pair< unsigned, std::optional< unsigned > > Attribute::getAllocSizeArgs | ( | ) | const |
|---|
◆ getAsString()
| std::string Attribute::getAsString | ( | bool | InAttrGrp = false | ) | const |
|---|
The Attribute is converted to a string of equivalent mnemonic.
This is, presumably, for writing out the mnemonics for the assembly writer.
Definition at line 536 of file Attributes.cpp.
References llvm::Aligned, llvm::Alloc, llvm::ArgMem, assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::Default, llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::ErrnoMem, llvm::First, llvm::raw_ostream::flush(), llvm::Free, getAllocKind(), getAllocSizeArgs(), llvm::ConstantRange::getBitWidth(), getCaptureInfo(), getInitializes(), getKindAsEnum(), getKindAsString(), llvm::ConstantRange::getLower(), getMemoryEffects(), llvm::MemoryEffectsBase< LocationEnum >::getModRef(), getModRefStr(), getNameFromAttrKind(), getNoFPClass(), llvm::ConstantRange::getUpper(), getUWTableKind(), getValueAsConstantRange(), getValueAsInt(), getValueAsType(), getVScaleRangeMax(), getVScaleRangeMin(), hasAttribute(), llvm::InaccessibleMem, isEnumAttribute(), isStringAttribute(), isTypeAttribute(), llvm::join(), llvm_unreachable, llvm::MemoryEffectsBase< IRMemLocation >::locations(), llvm::NoModRef, llvm::None, llvm::Other, llvm::ConstantRangeList::print(), llvm::Type::print(), llvm::printEscapedString(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Realloc, llvm::StringRef::str(), llvm::TargetMem0, llvm::TargetMem1, llvm::Uninitialized, llvm::Unknown, and llvm::Zeroed.
Referenced by LLVMGetAsString().
◆ getAttrKindFromName()
| Attribute::AttrKind Attribute::getAttrKindFromName ( StringRef AttrName) | static |
|---|
◆ getCaptureInfo()
◆ getDereferenceableBytes()
| uint64_t Attribute::getDereferenceableBytes | ( | ) | const |
|---|
◆ getDereferenceableOrNullBytes()
| uint64_t Attribute::getDereferenceableOrNullBytes | ( | ) | const |
|---|
◆ getInitializes()
◆ getKindAsEnum()
| Attribute::AttrKind Attribute::getKindAsEnum | ( | ) | const |
|---|
◆ getKindAsString()
| StringRef Attribute::getKindAsString | ( | ) | const |
|---|
◆ getMemoryEffects()
◆ getNameFromAttrKind()
| StringRef Attribute::getNameFromAttrKind ( Attribute::AttrKind AttrKind) | static |
|---|
◆ getNoFPClass()
◆ getRange()
◆ getRawPointer()
| void * llvm::Attribute::getRawPointer ( ) const | inline |
|---|
◆ getStackAlignment()
◆ getUWTableKind()
◆ getValueAsBool()
| bool Attribute::getValueAsBool | ( | ) | const |
|---|
◆ getValueAsConstantRange()
◆ getValueAsConstantRangeList()
◆ getValueAsInt()
| uint64_t Attribute::getValueAsInt | ( | ) | const |
|---|
◆ 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 400 of file Attributes.cpp.
References assert(), and isStringAttribute().
Referenced by llvm::memprof::addAmbiguousAttribute(), addIfNotExistent(), adjustCallerStackProbeSize(), adjustMinLegalVectorWidth(), collectMetadataInfo(), llvm::GCNTargetMachine::createMachineScheduler(), llvm::TargetOptions::DisableFramePointerElim(), llvm::SystemZELFFrameLowering::emitPrologue(), expandProtectedFieldPtr(), llvm::TargetOptions::FramePointerIsReserved(), llvm::getAllocationFamily(), llvm::AMDGPUTargetMachine::getFeatureString(), llvm::AMDGPUTargetMachine::getGPUName(), llvm::RISCVMachineFunctionInfo::getInterruptStackKind(), llvm::X86TargetLowering::getStackProbeSymbolName(), llvm::getStringFnAttrAsInt(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::CSKYTargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::LoongArchTargetMachine::getSubtargetImpl(), llvm::M68kTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::RISCVTargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::SystemZTargetMachine::getSubtargetImpl(), llvm::WebAssemblyTargetMachine::getSubtargetImpl(), llvm::X86TargetMachine::getSubtargetImpl(), llvm::XtensaTargetMachine::getSubtargetImpl(), llvm::VFABI::getVectorVariantNames(), llvm::PPCTargetLowering::hasInlineStackProbe(), llvm::RISCVTargetLowering::hasInlineStackProbe(), llvm::SystemZTargetLowering::hasInlineStackProbe(), llvm::X86TargetLowering::hasInlineStackProbe(), isThumbFunction(), LLVMGetStringAttributeValue(), llvm::RISCVTargetLowering::LowerFormalArguments(), llvm::RISCVTargetLowering::LowerReturn(), optimizeModularFormat(), llvm::GCNSubtarget::overridePostRASchedPolicy(), llvm::parseStatepointDirectivesFromAttrs(), llvm::memprof::removeAnyExistingAmbiguousAttribute(), and llvm::updateMinLegalVectorWidthAttr().
◆ getValueAsType()
| Type * Attribute::getValueAsType | ( | ) | const |
|---|
◆ getVScaleRangeMax()
| std::optional< unsigned > Attribute::getVScaleRangeMax | ( | ) | const |
|---|
◆ getVScaleRangeMin()
| unsigned Attribute::getVScaleRangeMin | ( | ) | const |
|---|
◆ getWithAlignment()
Return a uniquified Attribute object that has the specific alignment set.
Definition at line 234 of file Attributes.cpp.
References A(), assert(), get(), and llvm::Value::MaximumAlignment.
Referenced by adjustByValArgAlignment(), llvm::MatrixBuilder::CreateColumnMajorLoad(), llvm::MatrixBuilder::CreateColumnMajorStore(), llvm::IRBuilderBase::CreateElementUnorderedAtomicMemMove(), llvm::IRBuilderBase::CreateMaskedCompressStore(), llvm::IRBuilderBase::CreateMaskedExpandLoad(), llvm::IRBuilderBase::CreateMaskedGather(), llvm::IRBuilderBase::CreateMaskedLoad(), llvm::IRBuilderBase::CreateMaskedScatter(), llvm::IRBuilderBase::CreateMaskedStore(), createNVVMInternalAddrspaceWrap(), llvm::IRBuilderBase::CreateThreadLocalAddress(), llvm::VPInterleaveEVLRecipe::execute(), llvm::VPWidenLoadEVLRecipe::execute(), llvm::VPWidenStoreEVLRecipe::execute(), llvm::ARMTTIImpl::instCombineIntrinsic(), LLVMSetInstrParamAlignment(), LLVMSetParamAlignment(), lowerKernelArguments(), llvm::MemIntrinsicBase< Derived >::setDestAlignment(), llvm::MemIntrinsicBase< Derived >::setDestAlignment(), llvm::MemTransferBase< BaseCL >::setSourceAlignment(), llvm::MemTransferBase< BaseCL >::setSourceAlignment(), tryToImproveAlign(), and llvm::InstCombinerImpl::visitCallInst().
◆ getWithAllocKind()
◆ getWithAllocSizeArgs()
◆ getWithByRefType()
◆ getWithByValType()
◆ getWithCaptureInfo()
◆ getWithDereferenceableBytes()
◆ getWithDereferenceableOrNullBytes()
◆ getWithInAllocaType()
◆ getWithMemoryEffects()
◆ getWithNewType()
◆ getWithNoFPClass()
◆ getWithPreallocatedType()
◆ getWithStackAlignment()
◆ getWithStructRetType()
◆ getWithUWTableKind()
◆ getWithVScaleRangeArgs()
◆ hasAttribute() [1/2]
| bool Attribute::hasAttribute | ( | AttrKind | Val | ) | const |
|---|
Return true if the attribute is present.
Definition at line 426 of file Attributes.cpp.
References None.
Referenced by getAlignment(), getAllocKind(), getAllocSizeArgs(), getAsString(), getCaptureInfo(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), getInitializes(), getMemoryEffects(), getNoFPClass(), getRange(), getStackAlignment(), getUWTableKind(), getVScaleRangeMax(), getVScaleRangeMin(), and llvm::isStatepointDirectiveAttr().
◆ hasAttribute() [2/2]
◆ hasKindAsEnum()
| bool llvm::Attribute::hasKindAsEnum ( ) const | inline |
|---|
◆ hasParentContext()
◆ intersectMustPreserve()
| bool Attribute::intersectMustPreserve ( AttrKind Kind) | static |
|---|
◆ intersectWithAnd()
| bool Attribute::intersectWithAnd ( AttrKind Kind) | static |
|---|
◆ intersectWithCustom()
| bool Attribute::intersectWithCustom ( AttrKind Kind) | static |
|---|
◆ intersectWithMin()
| bool Attribute::intersectWithMin ( AttrKind Kind) | static |
|---|
◆ isConstantRangeAttribute()
| bool Attribute::isConstantRangeAttribute | ( | ) | const |
|---|
◆ isConstantRangeAttrKind()
| bool llvm::Attribute::isConstantRangeAttrKind ( AttrKind Kind) | inlinestatic |
|---|
◆ isConstantRangeListAttribute()
| bool Attribute::isConstantRangeListAttribute | ( | ) | const |
|---|
◆ isConstantRangeListAttrKind()
| bool llvm::Attribute::isConstantRangeListAttrKind ( AttrKind Kind) | inlinestatic |
|---|
◆ isEnumAttribute()
| bool Attribute::isEnumAttribute | ( | ) | const |
|---|
◆ isEnumAttrKind()
| bool llvm::Attribute::isEnumAttrKind ( AttrKind Kind) | inlinestatic |
|---|
◆ isExistingAttribute()
◆ isIntAttribute()
| bool Attribute::isIntAttribute | ( | ) | const |
|---|
◆ isIntAttrKind()
| bool llvm::Attribute::isIntAttrKind ( AttrKind Kind) | inlinestatic |
|---|
◆ isStringAttribute()
| bool Attribute::isStringAttribute | ( | ) | const |
|---|
Return true if the attribute is a string (target-dependent) attribute.
Definition at line 356 of file Attributes.cpp.
Referenced by addIfNotExistent(), getAsString(), getKindAsString(), getValueAsBool(), getValueAsString(), hasAttribute(), hasKindAsEnum(), LLVMIsStringAttribute(), AttributeComparator::operator()(), AttributeComparator::operator()(), AttributeComparator::operator()(), and llvm::parseStatepointDirectivesFromAttrs().
◆ isTypeAttribute()
| bool Attribute::isTypeAttribute | ( | ) | const |
|---|
◆ isTypeAttrKind()
| bool llvm::Attribute::isTypeAttrKind ( AttrKind Kind) | inlinestatic |
|---|
◆ isValid()
| bool llvm::Attribute::isValid ( ) const | inline |
|---|
Return true if the attribute is any kind of attribute.
Definition at line 223 of file Attributes.h.
Referenced by addNoUndefAttrs(), AddParamAndFnBasicAttributes(), AddReturnAttributes(), adjustCallerStackProbeSize(), adjustMinLegalVectorWidth(), collectMetadataInfo(), llvm::GCNTargetMachine::createMachineScheduler(), llvm::TargetOptions::DisableFramePointerElim(), expandProtectedFieldPtr(), llvm::GCNTTIImpl::fpenvIEEEMode(), llvm::TargetOptions::FramePointerIsReserved(), llvm::getAllocationFamily(), getAllocFnKind(), llvm::AMDGPUTargetMachine::getFeatureString(), llvm::CallBase::getFnAttr(), llvm::AMDGPUTargetMachine::getGPUName(), getParameterABIAttributes(), llvm::CallBase::getRange(), llvm::getStringFnAttrAsInt(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::CSKYTargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::LoongArchTargetMachine::getSubtargetImpl(), llvm::M68kTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::RISCVTargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::SystemZTargetMachine::getSubtargetImpl(), llvm::WebAssemblyTargetMachine::getSubtargetImpl(), llvm::X86TargetMachine::getSubtargetImpl(), llvm::XtensaTargetMachine::getSubtargetImpl(), llvm::getVScaleRange(), hasParentContext(), llvm::inferAttribute(), llvm::AttributeSet::intersectWith(), isThumbFunction(), llvm::SPIRVCallLowering::lowerCall(), llvm::SPIRVCallLowering::lowerReturn(), llvm::GCNSubtarget::overridePostRASchedPolicy(), runImpl(), llvm::simplifyBinaryIntrinsic(), tryToMoveFreeBeforeNullTest(), llvm::typeIncompatible(), and llvm::updateMinLegalVectorWidthAttr().
◆ operator!=()
◆ operator<()
Less-than operator. Useful for sorting the attributes list.
Definition at line 755 of file Attributes.cpp.
References A().
◆ operator==()
Equality and non-equality operators.
Definition at line 323 of file Attributes.h.
References A().
◆ Profile()
◆ NumIntAttrKinds
| const unsigned llvm::Attribute::NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1 | static |
|---|
◆ NumTypeAttrKinds
| const unsigned llvm::Attribute::NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1 | static |
|---|
The documentation for this class was generated from the following files:
- include/llvm/IR/Attributes.h
- lib/IR/Attributes.cpp