LLVM API Documentation
#include <Attributes.h>
Public Types | |
enum | AttrKind { None, Alignment, AlwaysInline, Builtin, ByVal, Cold, InlineHint, InReg, MinSize, Naked, Nest, NoAlias, NoBuiltin, NoCapture, NoDuplicate, NoImplicitFloat, NoInline, NonLazyBind, NoRedZone, NoReturn, NoUnwind, OptimizeForSize, OptimizeNone, ReadNone, ReadOnly, Returned, ReturnsTwice, SExt, StackAlignment, StackProtect, StackProtectReq, StackProtectStrong, StructRet, SanitizeAddress, SanitizeThread, SanitizeMemory, UWTable, ZExt, EndAttrKinds } |
Public Member Functions | |
Attribute () | |
bool | isEnumAttribute () const |
Return true if the attribute is an Attribute::AttrKind type. More... | |
bool | isAlignAttribute () const |
Return true if the attribute is an alignment attribute. More... | |
bool | isStringAttribute () const |
Return true if the attribute is a string (target-dependent) 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). This requires the attribute to be an enum or alignment attribute. More... | |
uint64_t | getValueAsInt () const |
Return the attribute's value as an integer. This requires that the attribute be an alignment attribute. More... | |
StringRef | getKindAsString () const |
Return the attribute's kind as a string. This requires the attribute to be a string attribute. More... | |
StringRef | getValueAsString () const |
Return the attribute's value as a string. This requires the attribute to be a string attribute. More... | |
unsigned | getAlignment () const |
Returns the alignment field of an attribute as a byte alignment value. More... | |
unsigned | getStackAlignment () const |
Returns the stack alignment field of an attribute as a byte alignment value. More... | |
std::string | 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. 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 |
Static Public Member Functions | |
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 | getWithAlignment (LLVMContext &Context, uint64_t Align) |
Return a uniquified Attribute object that has the specific alignment set. More... | |
static Attribute | getWithStackAlignment (LLVMContext &Context, uint64_t Align) |
Definition at line 45 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. |
Alignment |
Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias 0 means unaligned (different from align(1)) |
AlwaysInline |
inline=always |
Builtin |
Callee is recognized as a builtin, despite nobuiltin attribute on its declaration. |
ByVal |
Pass structure by value. |
Cold |
Marks function as being in a cold path. |
InlineHint |
Source said inlining was desirable. |
InReg |
Force argument to be passed in register. |
MinSize |
Function must be optimized for size first. |
Naked |
Naked function. |
Nest |
Nested function static chain. |
NoAlias |
Considered to not alias after call. |
NoBuiltin |
Callee isn't recognized as a builtin. |
NoCapture |
Function creates no aliases of pointer. |
NoDuplicate |
Call cannot be duplicated. |
NoImplicitFloat |
Disable implicit floating point insts. |
NoInline |
inline=never |
NonLazyBind |
Function is called early and/or often, so lazy binding isn't worthwhile |
NoRedZone |
Disable redzone. |
NoReturn |
Mark the function as not returning. |
NoUnwind |
Function doesn't unwind stack. |
OptimizeForSize |
opt_size |
OptimizeNone |
Function must not be optimized. |
ReadNone |
Function does not access memory. |
ReadOnly |
Function only reads from memory. |
Returned |
Return value is always equal to this argument. |
ReturnsTwice |
Function can return twice. |
SExt |
Sign extended before/after call. |
StackAlignment |
Alignment of stack for function (3 bits) stored as log2 of alignment with +1 bias 0 means unaligned (different from alignstack=(1)) |
StackProtect |
Stack protection. |
StackProtectReq |
Stack protection required. |
StackProtectStrong |
Strong Stack protection. |
StructRet |
Hidden pointer to structure to return. |
SanitizeAddress |
AddressSanitizer is on. |
SanitizeThread |
ThreadSanitizer is on. |
SanitizeMemory |
MemorySanitizer is on. |
UWTable |
Function must be in a unwind table. |
ZExt |
Zero extended before/after call. |
EndAttrKinds |
Sentinal value useful for loops. |
Definition at line 64 of file Attributes.h.
|
inline |
Definition at line 118 of file Attributes.h.
Referenced by get().
|
static |
Return a uniquified Attribute object.
Definition at line 33 of file Attributes.cpp.
References llvm::FoldingSetNodeID::AddInteger(), Attribute(), llvm::LLVMContextImpl::AttrsSet, and llvm::LLVMContext::pImpl.
Referenced by llvm::AttributeSet::get().
|
static |
Definition at line 57 of file Attributes.cpp.
References llvm::FoldingSetNodeID::AddString(), Attribute(), llvm::LLVMContextImpl::AttrsSet, llvm::StringRef::empty(), and llvm::LLVMContext::pImpl.
unsigned Attribute::getAlignment | ( | ) | const |
Returns the alignment field of an attribute as a byte alignment value.
This returns the alignment field of an attribute as a byte alignment value.
Definition at line 144 of file Attributes.cpp.
References Alignment, llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
Referenced by llvm::AttrBuilder::addAttribute().
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 158 of file Attributes.cpp.
References Alignment, AlwaysInline, Builtin, ByVal, Cold, llvm::StringRef::empty(), getKindAsString(), getValueAsInt(), llvm::AttributeImpl::getValueAsString(), hasAttribute(), InlineHint, InReg, isStringAttribute(), llvm_unreachable, MinSize, Naked, Nest, NoAlias, NoBuiltin, NoCapture, NoDuplicate, NoImplicitFloat, NoInline, NonLazyBind, NoRedZone, NoReturn, NoUnwind, OptimizeForSize, OptimizeNone, ReadNone, ReadOnly, Returned, ReturnsTwice, SanitizeAddress, SanitizeMemory, SanitizeThread, SExt, StackAlignment, StackProtect, StackProtectReq, StackProtectStrong, llvm::StringRef::str(), StructRet, llvm::utostr(), UWTable, and ZExt.
Referenced by llvm::AssemblyWriter::printFunction().
Attribute::AttrKind Attribute::getKindAsEnum | ( | ) | const |
Return the attribute's kind as an enum (Attribute::AttrKind). This requires the attribute to be an enum or alignment attribute.
Definition at line 106 of file Attributes.cpp.
References llvm::AttributeImpl::getKindAsEnum(), isAlignAttribute(), isEnumAttribute(), and None.
Referenced by llvm::AttrBuilder::addAttribute(), llvm::AttributeSetImpl::Raw(), and WriteAttributeGroupTable().
StringRef Attribute::getKindAsString | ( | ) | const |
Return the attribute's kind as a string. This requires the attribute to be a string attribute.
Definition at line 120 of file Attributes.cpp.
References llvm::AttributeImpl::getKindAsString(), and isStringAttribute().
Referenced by llvm::AttrBuilder::addAttribute(), getAsString(), llvm::AttrBuilder::hasAttributes(), llvm::AttrBuilder::removeAttributes(), and WriteAttributeGroupTable().
unsigned Attribute::getStackAlignment | ( | ) | const |
Returns the stack alignment field of an attribute as a byte alignment value.
This returns the stack alignment field of an attribute as a byte alignment value.
Definition at line 152 of file Attributes.cpp.
References llvm::AttributeImpl::getValueAsInt(), hasAttribute(), and StackAlignment.
Referenced by llvm::AttrBuilder::addAttribute().
uint64_t Attribute::getValueAsInt | ( | ) | const |
Return the attribute's value as an integer. This requires that the attribute be an alignment attribute.
Definition at line 113 of file Attributes.cpp.
References llvm::AttributeImpl::getValueAsInt(), and isAlignAttribute().
Referenced by getAsString(), and WriteAttributeGroupTable().
StringRef Attribute::getValueAsString | ( | ) | const |
Return the attribute's value as a string. This requires the attribute to be a string attribute.
Definition at line 127 of file Attributes.cpp.
References llvm::AttributeImpl::getValueAsString(), and isStringAttribute().
Referenced by llvm::AttrBuilder::addAttribute(), llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), llvm::ARMBaseRegisterInfo::getCalleeSavedRegs(), LowerInterruptReturn(), llvm::PPCSubtarget::resetSubtargetFeatures(), llvm::X86Subtarget::resetSubtargetFeatures(), llvm::ARMSubtarget::resetSubtargetFeatures(), llvm::StackProtector::runOnFunction(), and WriteAttributeGroupTable().
|
static |
Return a uniquified Attribute object that has the specific alignment set.
Definition at line 77 of file Attributes.cpp.
References Align(), Alignment, and llvm::isPowerOf2_32().
|
static |
Definition at line 83 of file Attributes.cpp.
References Align(), llvm::isPowerOf2_32(), and StackAlignment.
Return true if the attribute is present.
Definition at line 134 of file Attributes.cpp.
References llvm::AttributeImpl::hasAttribute(), and None.
Referenced by getAlignment(), getAsString(), getStackAlignment(), llvm::PPCSubtarget::resetSubtargetFeatures(), llvm::X86Subtarget::resetSubtargetFeatures(), and llvm::ARMSubtarget::resetSubtargetFeatures().
Return true if the target-dependent attribute is present.
Definition at line 138 of file Attributes.cpp.
References llvm::AttributeImpl::hasAttribute(), and isStringAttribute().
bool Attribute::isAlignAttribute | ( | ) | const |
Return true if the attribute is an alignment attribute.
Definition at line 98 of file Attributes.cpp.
References llvm::AttributeImpl::isAlignAttribute().
Referenced by getKindAsEnum(), getValueAsInt(), llvm::AttrBuilder::hasAttributes(), llvm::AttrBuilder::removeAttributes(), and WriteAttributeGroupTable().
bool Attribute::isEnumAttribute | ( | ) | const |
Return true if the attribute is an Attribute::AttrKind type.
Definition at line 94 of file Attributes.cpp.
References llvm::AttributeImpl::isEnumAttribute().
Referenced by getKindAsEnum(), llvm::AttrBuilder::hasAttributes(), llvm::AttrBuilder::removeAttributes(), and WriteAttributeGroupTable().
bool Attribute::isStringAttribute | ( | ) | const |
Return true if the attribute is a string (target-dependent) attribute.
Definition at line 102 of file Attributes.cpp.
References llvm::AttributeImpl::isStringAttribute().
Referenced by llvm::AttrBuilder::addAttribute(), llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), getAsString(), getKindAsString(), getValueAsString(), hasAttribute(), llvm::AttrBuilder::hasAttributes(), llvm::AssemblyWriter::printFunction(), llvm::AttributeSetImpl::Raw(), llvm::AttrBuilder::removeAttributes(), and llvm::StackProtector::runOnFunction().
Definition at line 184 of file Attributes.h.
Less-than operator. Useful for sorting the attributes list.
Definition at line 278 of file Attributes.cpp.
Equality and non-equality operators.
Definition at line 183 of file Attributes.h.
|
inline |
Definition at line 189 of file Attributes.h.
References llvm::FoldingSetNodeID::AddPointer().