LLVM
15.0.0git
|
#include "llvm/IR/Attributes.h"
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... | |
Type * | getValueAsType () 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... | |
unsigned | getVScaleRangeMin () const |
Returns the minimum value for the vscale_range attribute. More... | |
Optional< unsigned > | getVScaleRangeMax () const |
Returns the maximum value for the vscale_range attribute or None when unknown. More... | |
UWTableKind | getUWTableKind () const |
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 Attributes | |
static const unsigned | NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1 |
static const unsigned | NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1 |
Definition at line 52 of file Attributes.h.
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 | |
TombstoneKey |
Definition at line 71 of file Attributes.h.
|
default |
Referenced by fromRawPointer(), and get().
|
static |
Definition at line 513 of file Attributes.cpp.
References FnAttr, and hasAttributeProperty().
Referenced by forceAttributes().
|
static |
Definition at line 517 of file Attributes.cpp.
References hasAttributeProperty(), and ParamAttr.
|
static |
Definition at line 521 of file Attributes.cpp.
References hasAttributeProperty(), and RetAttr.
|
inlinestatic |
Get an attribute from a raw pointer created by getRawPointer.
Definition at line 253 of file Attributes.h.
References Attribute().
Referenced by llvm::unwrap().
|
static |
Definition at line 143 of file Attributes.cpp.
References llvm::LLVMContextImpl::Alloc, assert(), Attribute(), llvm::LLVMContextImpl::AttrsSet, Context, isTypeAttrKind(), and llvm::LLVMContext::pImpl.
|
static |
Return a uniquified Attribute object.
Definition at line 91 of file Attributes.cpp.
References llvm::LLVMContextImpl::Alloc, assert(), Attribute(), llvm::LLVMContextImpl::AttrsSet, Context, isEnumAttrKind(), isIntAttrKind(), and llvm::LLVMContext::pImpl.
Referenced by llvm::AttrBuilder::addAttribute(), llvm::AttributeList::addAttributeAtIndex(), llvm::AttrBuilder::addRawIntAttr(), llvm::AttrBuilder::addTypeAttr(), CreateGCStatepointCallCommon(), CreateGCStatepointInvokeCommon(), llvm::IRBuilderBase::CreatePreserveArrayAccessIndex(), llvm::IRBuilderBase::CreatePreserveStructAccessIndex(), llvm::ARMTargetLowering::emitLoadLinked(), llvm::AArch64TargetLowering::emitLoadLinked(), llvm::ARMTargetLowering::emitStoreConditional(), llvm::AArch64TargetLowering::emitStoreConditional(), llvm::AttributeList::get(), llvm::IRAttribute< Attribute::Returned, AbstractAttribute >::getDeducedAttributes(), getWithAlignment(), getWithAllocSizeArgs(), getWithByRefType(), getWithByValType(), getWithDereferenceableBytes(), getWithDereferenceableOrNullBytes(), getWithInAllocaType(), getWithNewType(), getWithPreallocatedType(), getWithStackAlignment(), getWithStructRetType(), getWithUWTableKind(), getWithVScaleRangeArgs(), LLVMAddTargetDependentFunctionAttr(), LLVMCreateEnumAttribute(), LLVMCreateStringAttribute(), LLVMCreateTypeAttribute(), processCallSite(), llvm::codegen::setFunctionAttributes(), llvm::setInlineRemark(), and llvm::VFABI::setVectorVariantNames().
|
static |
Definition at line 120 of file Attributes.cpp.
References llvm::LLVMContextImpl::Alloc, llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), Attribute(), llvm::LLVMContextImpl::AttrsSet, Context, llvm::StringRef::empty(), llvm::LLVMContext::pImpl, and llvm::StringAttributeImpl::totalSizeToAlloc().
MaybeAlign Attribute::getAlignment | ( | ) | const |
Returns the alignment field of an attribute as a byte alignment value.
Definition at line 329 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
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 355 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), hasAttribute(), and unpackAllocSizeArgs().
Referenced by getAllocationSize(), and 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 379 of file Attributes.cpp.
References llvm::Default, llvm::raw_ostream::flush(), getAllocSizeArgs(), getKindAsEnum(), getKindAsString(), getNameFromAttrKind(), getUWTableKind(), getValueAsInt(), llvm::AttributeImpl::getValueAsString(), getValueAsType(), llvm::Optional< T >::getValueOr(), getVScaleRangeMax(), getVScaleRangeMin(), hasAttribute(), isEnumAttribute(), isStringAttribute(), isTypeAttribute(), llvm_unreachable, llvm::None, llvm::Type::print(), llvm::StringRef::str(), and llvm::Sync.
|
static |
Definition at line 226 of file Attributes.cpp.
References llvm::StringSwitch< T, R >::Default(), and None.
Referenced by llvm::fillMapFromAssume(), forceAttributes(), llvm::getKnowledgeFromBundle(), llvm::hasAttributeInAssume(), and LLVMGetEnumAttributeKindForName().
uint64_t Attribute::getDereferenceableBytes | ( | ) | const |
Returns the number of dereferenceable bytes from the dereferenceable attribute.
Definition at line 341 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
Referenced by tryToMoveFreeBeforeNullTest().
uint64_t Attribute::getDereferenceableOrNullBytes | ( | ) | const |
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
Definition at line 348 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
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 277 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getKindAsEnum(), isEnumAttribute(), isIntAttribute(), isTypeAttribute(), and None.
Referenced by llvm::AttrBuilder::addAttribute(), addIfNotExistent(), getAsString(), getWithNewType(), LLVMGetEnumAttributeKind(), and AttributeComparator::operator()().
StringRef Attribute::getKindAsString | ( | ) | const |
Return the attribute's kind as a string.
This requires the attribute to be a string attribute.
Definition at line 298 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getKindAsString(), and isStringAttribute().
Referenced by llvm::AttrBuilder::addAttribute(), addIfNotExistent(), getAsString(), LLVMGetStringAttributeKind(), and AttributeComparator::operator()().
|
static |
Definition at line 235 of file Attributes.cpp.
References llvm_unreachable, and None.
Referenced by getAsString(), and llvm::hasAttributeInAssume().
|
inline |
Return a raw pointer that uniquely identifies this attribute.
Definition at line 248 of file Attributes.h.
Referenced by llvm::wrap().
MaybeAlign Attribute::getStackAlignment | ( | ) | const |
Returns the stack alignment field of an attribute as a byte alignment value.
Definition at line 335 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
UWTableKind Attribute::getUWTableKind | ( | ) | const |
Definition at line 373 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
Referenced by getAsString().
bool Attribute::getValueAsBool | ( | ) | const |
Return the attribute's value as a boolean.
This requires that the attribute be a string attribute.
Definition at line 291 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().
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 284 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), and isIntAttribute().
Referenced by getAsString(), and isEqualOrWorse().
StringRef Attribute::getValueAsString | ( | ) | const |
Return the attribute's value as a string.
This requires the attribute to be a string attribute.
Definition at line 305 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsString(), and isStringAttribute().
Referenced by adjustCallerStackProbeSize(), adjustMinLegalVectorWidth(), llvm::Function::getDenormalMode(), getDeoptLowering(), llvm::AMDGPUTargetMachine::getFeatureString(), llvm::AMDGPUTargetMachine::getGPUName(), llvm::SystemZTargetLowering::getStackProbeSize(), llvm::PPCTargetLowering::getStackProbeSize(), llvm::X86TargetLowering::getStackProbeSize(), llvm::X86TargetLowering::getStackProbeSymbolName(), llvm::getStringFnAttrAsInt(), llvm::LoongArchTargetMachine::getSubtargetImpl(), llvm::RISCVTargetMachine::getSubtargetImpl(), llvm::CSKYTargetMachine::getSubtargetImpl(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::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(), simplifyNvvmIntrinsic(), and llvm::AttributeFuncs::updateMinLegalVectorWidthAttr().
Type * Attribute::getValueAsType | ( | ) | const |
Return the attribute's value as a Type.
This requires the attribute to be a type attribute.
Definition at line 312 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsType(), and isTypeAttribute().
Referenced by getAsString().
Optional< unsigned > Attribute::getVScaleRangeMax | ( | ) | const |
Returns the maximum value for the vscale_range attribute or None when unknown.
Definition at line 367 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), hasAttribute(), and unpackVScaleRangeArgs().
Referenced by getAsString(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::InstCombinerImpl::visitSExt(), llvm::InstCombinerImpl::visitTrunc(), and llvm::InstCombinerImpl::visitZExt().
unsigned Attribute::getVScaleRangeMin | ( | ) | const |
Returns the minimum value for the vscale_range attribute.
Definition at line 361 of file Attributes.cpp.
References assert(), llvm::AttributeImpl::getValueAsInt(), hasAttribute(), and unpackVScaleRangeArgs().
Referenced by getAsString(), and llvm::AArch64TargetMachine::getSubtargetImpl().
|
static |
Return a uniquified Attribute object that has the specific alignment set.
Definition at line 165 of file Attributes.cpp.
References A, assert(), Context, get(), and llvm::Value::MaximumAlignment.
Referenced by llvm::MatrixBuilder::CreateColumnMajorLoad(), llvm::MatrixBuilder::CreateColumnMajorStore(), llvm::IRBuilderBase::CreateElementUnorderedAtomicMemMove(), LLVMSetInstrParamAlignment(), LLVMSetParamAlignment(), llvm::MemIntrinsicBase< AnyMemIntrinsic >::setDestAlignment(), and llvm::MemTransferBase< AnyMemIntrinsic >::setSourceAlignment().
|
static |
Definition at line 213 of file Attributes.cpp.
References assert(), Context, get(), and packAllocSizeArgs().
Referenced by setAllocSize().
|
static |
Definition at line 195 of file Attributes.cpp.
|
static |
Definition at line 187 of file Attributes.cpp.
References Context, and get().
Referenced by LLVMCreateEnumAttribute().
|
static |
Definition at line 175 of file Attributes.cpp.
References assert(), Context, and get().
Referenced by annotateDereferenceableBytes().
|
static |
Definition at line 181 of file Attributes.cpp.
|
static |
Definition at line 203 of file Attributes.cpp.
|
inline |
For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy
.
Definition at line 138 of file Attributes.h.
References assert(), Context, get(), getKindAsEnum(), and isTypeAttribute().
Referenced by llvm::AttributeList::replaceAttributeTypeAtIndex().
|
static |
Definition at line 199 of file Attributes.cpp.
|
static |
|
static |
Definition at line 191 of file Attributes.cpp.
References Context, and get().
Referenced by LLVMCreateEnumAttribute().
|
static |
Definition at line 207 of file Attributes.cpp.
References Context, and get().
Referenced by llvm::Function::setUWTableKind().
|
static |
Definition at line 220 of file Attributes.cpp.
References Context, get(), and packVScaleRangeArgs().
bool Attribute::hasAttribute | ( | AttrKind | Val | ) | const |
Return true if the attribute is present.
Definition at line 320 of file Attributes.cpp.
References llvm::AttributeImpl::hasAttribute(), and None.
Referenced by getAlignment(), getAllocSizeArgs(), getAsString(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), getStackAlignment(), getUWTableKind(), getVScaleRangeMax(), getVScaleRangeMin(), and llvm::isStatepointDirectiveAttr().
bool Attribute::hasAttribute | ( | StringRef | Val | ) | const |
Return true if the target-dependent attribute is present.
Definition at line 324 of file Attributes.cpp.
References llvm::AttributeImpl::hasAttribute(), and isStringAttribute().
bool Attribute::hasParentContext | ( | LLVMContext & | C | ) | const |
Return true if this attribute belongs to the LLVMContext.
Definition at line 477 of file Attributes.cpp.
References assert(), isValid(), and llvm::AttributeImpl::Profile().
bool Attribute::isEnumAttribute | ( | ) | const |
Return true if the attribute is an Attribute::AttrKind type.
Definition at line 261 of file Attributes.cpp.
References llvm::AttributeImpl::isEnumAttribute().
Referenced by addIfNotExistent(), getAsString(), and getKindAsEnum().
|
inlinestatic |
Definition at line 84 of file Attributes.h.
Referenced by get().
|
static |
Return true if the provided string matches the IR name of an attribute.
example: "noalias" return true but not "NoAlias"
Definition at line 249 of file Attributes.cpp.
References llvm::StringSwitch< T, R >::Default().
Referenced by llvm::hasAttributeInAssume().
bool Attribute::isIntAttribute | ( | ) | const |
Return true if the attribute is an integer attribute.
Definition at line 265 of file Attributes.cpp.
References llvm::AttributeImpl::isIntAttribute().
Referenced by addIfNotExistent(), getKindAsEnum(), getValueAsInt(), and isEqualOrWorse().
|
inlinestatic |
Definition at line 87 of file Attributes.h.
Referenced by get(), llvm::AttrBuilder::getRawIntAttr(), llvm::hasAttributeInAssume(), and llvm::IntAttributeImpl::IntAttributeImpl().
bool Attribute::isStringAttribute | ( | ) | const |
Return true if the attribute is a string (target-dependent) attribute.
Definition at line 269 of file Attributes.cpp.
References llvm::AttributeImpl::isStringAttribute().
Referenced by llvm::AttrBuilder::addAttribute(), addIfNotExistent(), getAsString(), getKindAsString(), getValueAsBool(), getValueAsString(), hasAttribute(), LLVMIsStringAttribute(), AttributeComparator::operator()(), llvm::parseStatepointDirectivesFromAttrs(), and llvm::StackProtector::runOnFunction().
bool Attribute::isTypeAttribute | ( | ) | const |
Return true if the attribute is a type attribute.
Definition at line 273 of file Attributes.cpp.
References llvm::AttributeImpl::isTypeAttribute().
Referenced by getAsString(), getKindAsEnum(), getValueAsType(), getWithNewType(), and LLVMIsTypeAttribute().
|
inlinestatic |
Definition at line 90 of file Attributes.h.
Referenced by get(), and llvm::AttrBuilder::getTypeAttr().
|
inline |
Return true if the attribute is any kind of attribute.
Definition at line 169 of file Attributes.h.
Referenced by adjustCallerStackProbeSize(), adjustMinLegalVectorWidth(), llvm::AttrBuilder::contains(), llvm::AMDGPUTargetMachine::getFeatureString(), llvm::CallBase::getFnAttr(), llvm::AMDGPUTargetMachine::getGPUName(), getParameterABIAttributes(), llvm::RISCVTargetMachine::getSubtargetImpl(), llvm::LoongArchTargetMachine::getSubtargetImpl(), llvm::CSKYTargetMachine::getSubtargetImpl(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::SystemZTargetMachine::getSubtargetImpl(), llvm::WebAssemblyTargetMachine::getSubtargetImpl(), llvm::X86TargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::M68kTargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), hasParentContext(), isThumbFunction(), tryToMoveFreeBeforeNullTest(), and llvm::AttributeFuncs::updateMinLegalVectorWidthAttr().
|
inline |
Definition at line 240 of file Attributes.h.
bool Attribute::operator< | ( | Attribute | A | ) | const |
Less-than operator. Useful for sorting the attributes list.
Definition at line 485 of file Attributes.cpp.
References A.
|
inline |
Equality and non-equality operators.
Definition at line 239 of file Attributes.h.
void Attribute::Profile | ( | FoldingSetNodeID & | ID | ) | const |
Definition at line 492 of file Attributes.cpp.
|
static |
Definition at line 81 of file Attributes.h.
|
static |
Definition at line 82 of file Attributes.h.