LLVM API Documentation

Public Types | Public Member Functions | Static Public Member Functions
llvm::Attribute Class Reference

#include <Attributes.h>

List of all members.

Public Types

enum  AttrKind {
  None, Alignment, AlwaysInline, Builtin,
  ByVal, InAlloca, 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.
bool isAlignAttribute () const
 Return true if the attribute is an alignment 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.
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)

Detailed Description

Definition at line 45 of file Attributes.h.


Member Enumeration Documentation

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.

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.

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.


Constructor & Destructor Documentation

llvm::Attribute::Attribute ( ) [inline]

Definition at line 119 of file Attributes.h.

Referenced by get().


Member Function Documentation

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

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 145 of file Attributes.cpp.

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

Referenced by llvm::AttrBuilder::addAttribute().

std::string Attribute::getAsString ( bool  InAttrGrp = false) 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 107 of file Attributes.cpp.

References llvm::AttributeImpl::getKindAsEnum(), isAlignAttribute(), isEnumAttribute(), and None.

Referenced by llvm::AttrBuilder::addAttribute(), llvm::AttributeSetImpl::Raw(), and WriteAttributeGroupTable().

Return the attribute's kind as a string. This requires the attribute to be a string attribute.

Definition at line 121 of file Attributes.cpp.

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

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

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 153 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 114 of file Attributes.cpp.

References llvm::AttributeImpl::getValueAsInt(), and isAlignAttribute().

Referenced by getAsString(), 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::getWithStackAlignment ( LLVMContext Context,
uint64_t  Align 
) [static]

Definition at line 84 of file Attributes.cpp.

References Align(), llvm::isPowerOf2_32(), and StackAlignment.

Return true if the target-dependent attribute is present.

Definition at line 139 of file Attributes.cpp.

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

Return true if the attribute is an alignment attribute.

Definition at line 99 of file Attributes.cpp.

References llvm::AttributeImpl::isAlignAttribute().

Referenced by getKindAsEnum(), getValueAsInt(), llvm::AttrBuilder::hasAttributes(), llvm::AttrBuilder::removeAttributes(), and WriteAttributeGroupTable().

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

Definition at line 185 of file Attributes.h.

bool Attribute::operator< ( Attribute  A) const

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

Definition at line 281 of file Attributes.cpp.

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

Equality and non-equality operators.

Definition at line 184 of file Attributes.h.

void llvm::Attribute::Profile ( FoldingSetNodeID ID) const [inline]

Definition at line 190 of file Attributes.h.

References llvm::FoldingSetNodeID::AddPointer().


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