LLVM API Documentation
#include <Attributes.h>
Public Types | |
enum | AttrKind { None, Alignment, AlwaysInline, Builtin, ByVal, InAlloca, Cold, InlineHint, InReg, JumpTable, MinSize, Naked, Nest, NoAlias, NoBuiltin, NoCapture, NoDuplicate, NoImplicitFloat, NoInline, NonLazyBind, NonNull, Dereferenceable, 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. | |
bool | isIntAttribute () const |
Return true if the attribute is an integer attribute. | |
bool | isStringAttribute () const |
Return true if the attribute is a string (target-dependent) attribute. | |
bool | hasAttribute (AttrKind Val) const |
Return true if the attribute is present. | |
bool | hasAttribute (StringRef Val) const |
Return true if the target-dependent attribute is present. | |
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. | |
uint64_t | getValueAsInt () const |
Return the attribute's value as an integer. This requires that the attribute be an alignment attribute. | |
StringRef | getKindAsString () const |
Return the attribute's kind as a string. This requires the attribute to be a string attribute. | |
StringRef | getValueAsString () const |
Return the attribute's value as a string. This requires the attribute to be a string attribute. | |
unsigned | getAlignment () const |
Returns the alignment field of an attribute as a byte alignment value. | |
unsigned | getStackAlignment () const |
Returns the stack alignment field of an attribute as a byte alignment value. | |
uint64_t | getDereferenceableBytes () const |
Returns the number of dereferenceable bytes from the dereferenceable attribute (or zero if unknown). | |
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. | |
bool | operator== (Attribute A) const |
Equality and non-equality operators. | |
bool | operator!= (Attribute A) const |
bool | operator< (Attribute A) const |
Less-than operator. Useful for sorting the attributes list. | |
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. | |
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. | |
static Attribute | getWithStackAlignment (LLVMContext &Context, uint64_t Align) |
static Attribute | getWithDereferenceableBytes (LLVMContext &Context, uint64_t Bytes) |
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.
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. |
InAlloca |
Pass structure in an alloca. |
Cold |
Marks function as being in a cold path. |
InlineHint |
Source said inlining was desirable. |
InReg |
Force argument to be passed in register. |
JumpTable |
Build jump-instruction tables and replace refs. |
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 |
NonNull |
Pointer is known to be not null. |
Dereferenceable |
Pointer is known to be dereferenceable. |
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.
llvm::Attribute::Attribute | ( | ) | [inline] |
Definition at line 122 of file Attributes.h.
Referenced by get().
Attribute Attribute::get | ( | LLVMContext & | Context, |
Attribute::AttrKind | Kind, | ||
uint64_t | Val = 0 |
||
) | [static] |
Return a uniquified Attribute object.
Definition at line 34 of file Attributes.cpp.
References llvm::FoldingSetNodeID::AddInteger(), Attribute(), llvm::LLVMContextImpl::AttrsSet, llvm::FoldingSet< T >::FindNodeOrInsertPos(), llvm::FoldingSetImpl::InsertNode(), and llvm::LLVMContext::pImpl.
Referenced by llvm::AttributeSet::get().
Attribute Attribute::get | ( | LLVMContext & | Context, |
StringRef | Kind, | ||
StringRef | Val = StringRef() |
||
) | [static] |
Definition at line 58 of file Attributes.cpp.
References llvm::FoldingSetNodeID::AddString(), Attribute(), llvm::LLVMContextImpl::AttrsSet, llvm::StringRef::empty(), llvm::FoldingSet< T >::FindNodeOrInsertPos(), llvm::FoldingSetImpl::InsertNode(), 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 151 of file Attributes.cpp.
References Alignment, llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
Referenced by llvm::AttrBuilder::addAttribute().
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 173 of file Attributes.cpp.
References Alignment, AlwaysInline, Builtin, ByVal, Cold, Dereferenceable, llvm::StringRef::empty(), getKindAsString(), getValueAsInt(), llvm::AttributeImpl::getValueAsString(), hasAttribute(), InAlloca, InlineHint, InReg, isStringAttribute(), JumpTable, llvm_unreachable, MinSize, Naked, Nest, NoAlias, NoBuiltin, NoCapture, NoDuplicate, NoImplicitFloat, NoInline, NonLazyBind, NonNull, 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().
uint64_t Attribute::getDereferenceableBytes | ( | ) | const |
Returns the number of dereferenceable bytes from the dereferenceable attribute (or zero if unknown).
This returns the number of dereferenceable bytes.
Definition at line 166 of file Attributes.cpp.
References Dereferenceable, llvm::AttributeImpl::getValueAsInt(), and hasAttribute().
Referenced by llvm::AttrBuilder::addAttribute().
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 113 of file Attributes.cpp.
References llvm::AttributeImpl::getKindAsEnum(), isEnumAttribute(), isIntAttribute(), 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 127 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 159 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 120 of file Attributes.cpp.
References llvm::AttributeImpl::getValueAsInt(), and isIntAttribute().
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 134 of file Attributes.cpp.
References llvm::AttributeImpl::getValueAsString(), and isStringAttribute().
Referenced by llvm::AttrBuilder::addAttribute(), llvm::NVPTXTargetLowering::allowFMA(), llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), llvm::ARMBaseRegisterInfo::getCalleeSavedRegs(), LowerInterruptReturn(), llvm::StackProtector::runOnFunction(), and WriteAttributeGroupTable().
Attribute Attribute::getWithAlignment | ( | LLVMContext & | Context, |
uint64_t | Align | ||
) | [static] |
Return a uniquified Attribute object that has the specific alignment set.
Definition at line 78 of file Attributes.cpp.
References Align(), Alignment, and llvm::isPowerOf2_32().
Attribute Attribute::getWithDereferenceableBytes | ( | LLVMContext & | Context, |
uint64_t | Bytes | ||
) | [static] |
Definition at line 91 of file Attributes.cpp.
References Dereferenceable.
Referenced by llvm::AttributeSet::get().
Attribute Attribute::getWithStackAlignment | ( | LLVMContext & | Context, |
uint64_t | Align | ||
) | [static] |
Definition at line 84 of file Attributes.cpp.
References Align(), llvm::isPowerOf2_32(), and StackAlignment.
bool Attribute::hasAttribute | ( | AttrKind | Val | ) | const |
Return true if the attribute is present.
Definition at line 141 of file Attributes.cpp.
References llvm::AttributeImpl::hasAttribute(), and None.
Referenced by getAlignment(), getAsString(), getDereferenceableBytes(), and getStackAlignment().
bool Attribute::hasAttribute | ( | StringRef | Val | ) | const |
Return true if the target-dependent attribute is present.
Definition at line 145 of file Attributes.cpp.
References llvm::AttributeImpl::hasAttribute(), and isStringAttribute().
bool Attribute::isEnumAttribute | ( | ) | const |
Return true if the attribute is an Attribute::AttrKind type.
Definition at line 101 of file Attributes.cpp.
References llvm::AttributeImpl::isEnumAttribute().
Referenced by getKindAsEnum(), llvm::AttrBuilder::hasAttributes(), llvm::AttrBuilder::removeAttributes(), and WriteAttributeGroupTable().
bool Attribute::isIntAttribute | ( | ) | const |
Return true if the attribute is an integer attribute.
Definition at line 105 of file Attributes.cpp.
References llvm::AttributeImpl::isIntAttribute().
Referenced by getKindAsEnum(), getValueAsInt(), 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 109 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 194 of file Attributes.h.
Less-than operator. Useful for sorting the attributes list.
Definition at line 313 of file Attributes.cpp.
Equality and non-equality operators.
Definition at line 193 of file Attributes.h.
void llvm::Attribute::Profile | ( | FoldingSetNodeID & | ID | ) | const [inline] |
Definition at line 199 of file Attributes.h.
References llvm::FoldingSetNodeID::AddPointer().