LLVM  13.0.0git
Public Types | Public Member Functions | List of all members
llvm::AttrBuilder Class Reference

#include "llvm/IR/Attributes.h"

Public Types

using td_type = decltype(TargetDepAttrs)::value_type
 
using td_iterator = decltype(TargetDepAttrs)::iterator
 
using td_const_iterator = decltype(TargetDepAttrs)::const_iterator
 
using td_range = iterator_range< td_iterator >
 
using td_const_range = iterator_range< td_const_iterator >
 

Public Member Functions

 AttrBuilder ()=default
 
 AttrBuilder (const Attribute &A)
 
 AttrBuilder (AttributeList AS, unsigned Idx)
 
 AttrBuilder (AttributeSet AS)
 
void clear ()
 
AttrBuilderaddAttribute (Attribute::AttrKind Val)
 Add an attribute to the builder. More...
 
AttrBuilderaddAttribute (Attribute A)
 Add the Attribute object to the builder. More...
 
AttrBuilderaddAttribute (StringRef A, StringRef V=StringRef())
 Add the target-dependent attribute to the builder. More...
 
AttrBuilderremoveAttribute (Attribute::AttrKind Val)
 Remove an attribute from the builder. More...
 
AttrBuilderremoveAttributes (AttributeList A, uint64_t WithoutIndex)
 Remove the attributes from the builder. More...
 
AttrBuilderremoveAttribute (StringRef A)
 Remove the target-dependent attribute to the builder. More...
 
AttrBuildermerge (const AttrBuilder &B)
 Add the attributes from the builder. More...
 
AttrBuilderremove (const AttrBuilder &B)
 Remove the attributes from the builder. More...
 
bool overlaps (const AttrBuilder &B) const
 Return true if the builder has any attribute that's in the specified builder. More...
 
bool contains (Attribute::AttrKind A) const
 Return true if the builder has the specified attribute. More...
 
bool contains (StringRef A) const
 Return true if the builder has the specified target-dependent attribute. More...
 
bool hasAttributes () const
 Return true if the builder has IR-level attributes. More...
 
bool hasAttributes (AttributeList A, uint64_t Index) const
 Return true if the builder has any attribute that's in the specified attribute. More...
 
bool hasAlignmentAttr () const
 Return true if the builder has an alignment attribute. More...
 
MaybeAlign getAlignment () const
 Retrieve the alignment attribute, if it exists. More...
 
MaybeAlign getStackAlignment () const
 Retrieve the stack alignment attribute, if it exists. More...
 
uint64_t getDereferenceableBytes () const
 Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is returned otherwise). More...
 
uint64_t getDereferenceableOrNullBytes () const
 Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists (zero is returned otherwise). More...
 
TypegetByValType () const
 Retrieve the byval type. More...
 
TypegetStructRetType () const
 Retrieve the sret type. More...
 
TypegetByRefType () const
 Retrieve the byref type. More...
 
TypegetPreallocatedType () const
 Retrieve the preallocated type. More...
 
TypegetInAllocaType () const
 Retrieve the inalloca type. More...
 
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs () const
 Retrieve the allocsize args, if the allocsize attribute exists. More...
 
std::pair< unsigned, unsigned > getVScaleRangeArgs () const
 Retrieve the vscale_range args, if the vscale_range attribute exists. More...
 
AttrBuilderaddAlignmentAttr (MaybeAlign Align)
 This turns an alignment into the form used internally in Attribute. More...
 
AttrBuilderaddAlignmentAttr (unsigned Align)
 This turns an int alignment (which must be a power of 2) into the form used internally in Attribute. More...
 
AttrBuilderaddStackAlignmentAttr (MaybeAlign Align)
 This turns a stack alignment into the form used internally in Attribute. More...
 
AttrBuilderaddStackAlignmentAttr (unsigned Align)
 This turns an int stack alignment (which must be a power of 2) into the form used internally in Attribute. More...
 
AttrBuilderaddDereferenceableAttr (uint64_t Bytes)
 This turns the number of dereferenceable bytes into the form used internally in Attribute. More...
 
AttrBuilderaddDereferenceableOrNullAttr (uint64_t Bytes)
 This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute. More...
 
AttrBuilderaddAllocSizeAttr (unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
 This turns one (or two) ints into the form used internally in Attribute. More...
 
AttrBuilderaddVScaleRangeAttr (unsigned MinValue, unsigned MaxValue)
 This turns two ints into the form used internally in Attribute. More...
 
AttrBuilderaddByValAttr (Type *Ty)
 This turns a byval type into the form used internally in Attribute. More...
 
AttrBuilderaddStructRetAttr (Type *Ty)
 This turns a sret type into the form used internally in Attribute. More...
 
AttrBuilderaddByRefAttr (Type *Ty)
 This turns a byref type into the form used internally in Attribute. More...
 
AttrBuilderaddPreallocatedAttr (Type *Ty)
 This turns a preallocated type into the form used internally in Attribute. More...
 
AttrBuilderaddInAllocaAttr (Type *Ty)
 This turns an inalloca type into the form used internally in Attribute. More...
 
AttrBuilderaddAllocSizeAttrFromRawRepr (uint64_t RawAllocSizeRepr)
 Add an allocsize attribute, using the representation returned by Attribute.getIntValue(). More...
 
AttrBuilderaddVScaleRangeAttrFromRawRepr (uint64_t RawVScaleRangeRepr)
 Add a vscale_range attribute, using the representation returned by Attribute.getIntValue(). More...
 
bool empty () const
 Return true if the builder contains no target-independent attributes. More...
 
td_iterator td_begin ()
 
td_iterator td_end ()
 
td_const_iterator td_begin () const
 
td_const_iterator td_end () const
 
td_range td_attrs ()
 
td_const_range td_attrs () const
 
bool td_empty () const
 
bool operator== (const AttrBuilder &B) const
 
bool operator!= (const AttrBuilder &B) const
 

Detailed Description

Definition at line 804 of file Attributes.h.

Member Typedef Documentation

◆ td_const_iterator

using llvm::AttrBuilder::td_const_iterator = decltype(TargetDepAttrs)::const_iterator

Definition at line 992 of file Attributes.h.

◆ td_const_range

Definition at line 994 of file Attributes.h.

◆ td_iterator

using llvm::AttrBuilder::td_iterator = decltype(TargetDepAttrs)::iterator

Definition at line 991 of file Attributes.h.

◆ td_range

Definition at line 993 of file Attributes.h.

◆ td_type

using llvm::AttrBuilder::td_type = decltype(TargetDepAttrs)::value_type

Definition at line 990 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttrBuilder() [1/4]

llvm::AttrBuilder::AttrBuilder ( )
default

◆ AttrBuilder() [2/4]

llvm::AttrBuilder::AttrBuilder ( const Attribute A)
inline

Definition at line 822 of file Attributes.h.

References addAttribute().

◆ AttrBuilder() [3/4]

AttrBuilder::AttrBuilder ( AttributeList  AS,
unsigned  Idx 
)

Definition at line 1727 of file Attributes.cpp.

References A, addAttribute(), llvm::AArch64CC::AL, and Index.

◆ AttrBuilder() [4/4]

AttrBuilder::AttrBuilder ( AttributeSet  AS)

Definition at line 1733 of file Attributes.cpp.

References A, and addAttribute().

Member Function Documentation

◆ addAlignmentAttr() [1/2]

AttrBuilder & AttrBuilder::addAlignmentAttr ( MaybeAlign  Align)

This turns an alignment into the form used internally in Attribute.

This call has no effect if Align is not set.

Definition at line 1842 of file Attributes.cpp.

References Align, assert(), Attrs, and llvm::Value::MaximumAlignment.

Referenced by addAlignmentAttr(), addFramePointerAttrs(), and llvm::AttributeFuncs::typeIncompatible().

◆ addAlignmentAttr() [2/2]

AttrBuilder& llvm::AttrBuilder::addAlignmentAttr ( unsigned  Align)
inline

This turns an int alignment (which must be a power of 2) into the form used internally in Attribute.

This call has no effect if Align is 0. Deprecated, use the version using a MaybeAlign.

Definition at line 931 of file Attributes.h.

References addAlignmentAttr().

◆ addAllocSizeAttr()

AttrBuilder & AttrBuilder::addAllocSizeAttr ( unsigned  ElemSizeArg,
const Optional< unsigned > &  NumElemsArg 
)

This turns one (or two) ints into the form used internally in Attribute.

Definition at line 1882 of file Attributes.cpp.

References addAllocSizeAttrFromRawRepr(), and packAllocSizeArgs().

◆ addAllocSizeAttrFromRawRepr()

AttrBuilder & AttrBuilder::addAllocSizeAttrFromRawRepr ( uint64_t  RawAllocSizeRepr)

Add an allocsize attribute, using the representation returned by Attribute.getIntValue().

Definition at line 1887 of file Attributes.cpp.

References assert(), and Attrs.

Referenced by addAllocSizeAttr().

◆ addAttribute() [1/3]

AttrBuilder & AttrBuilder::addAttribute ( Attribute  A)

◆ addAttribute() [2/3]

AttrBuilder& llvm::AttrBuilder::addAttribute ( Attribute::AttrKind  Val)
inline

◆ addAttribute() [3/3]

AttrBuilder & AttrBuilder::addAttribute ( StringRef  A,
StringRef  V = StringRef() 
)

Add the target-dependent attribute to the builder.

Definition at line 1787 of file Attributes.cpp.

References A.

◆ addByRefAttr()

AttrBuilder & AttrBuilder::addByRefAttr ( Type Ty)

This turns a byref type into the form used internally in Attribute.

Definition at line 1927 of file Attributes.cpp.

References Attrs.

Referenced by llvm::AttributeFuncs::typeIncompatible().

◆ addByValAttr()

AttrBuilder & AttrBuilder::addByValAttr ( Type Ty)

This turns a byval type into the form used internally in Attribute.

Definition at line 1915 of file Attributes.cpp.

References Attrs.

Referenced by llvm::promoteCall(), and llvm::AttributeFuncs::typeIncompatible().

◆ addDereferenceableAttr()

AttrBuilder & AttrBuilder::addDereferenceableAttr ( uint64_t  Bytes)

This turns the number of dereferenceable bytes into the form used internally in Attribute.

Definition at line 1865 of file Attributes.cpp.

References Attrs.

Referenced by addFramePointerAttrs(), IdentifyValidAttributes(), and llvm::AttributeFuncs::typeIncompatible().

◆ addDereferenceableOrNullAttr()

AttrBuilder & AttrBuilder::addDereferenceableOrNullAttr ( uint64_t  Bytes)

This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute.

Definition at line 1873 of file Attributes.cpp.

References Attrs.

Referenced by IdentifyValidAttributes(), and llvm::AttributeFuncs::typeIncompatible().

◆ addInAllocaAttr()

AttrBuilder & AttrBuilder::addInAllocaAttr ( Type Ty)

This turns an inalloca type into the form used internally in Attribute.

Definition at line 1939 of file Attributes.cpp.

References Attrs.

Referenced by llvm::AttributeFuncs::typeIncompatible().

◆ addPreallocatedAttr()

AttrBuilder & AttrBuilder::addPreallocatedAttr ( Type Ty)

This turns a preallocated type into the form used internally in Attribute.

Definition at line 1933 of file Attributes.cpp.

References Attrs.

Referenced by llvm::AttributeFuncs::typeIncompatible().

◆ addStackAlignmentAttr() [1/2]

AttrBuilder & AttrBuilder::addStackAlignmentAttr ( MaybeAlign  Align)

This turns a stack alignment into the form used internally in Attribute.

This call has no effect if Align is not set.

Definition at line 1853 of file Attributes.cpp.

References Align, assert(), and Attrs.

Referenced by addStackAlignmentAttr().

◆ addStackAlignmentAttr() [2/2]

AttrBuilder& llvm::AttrBuilder::addStackAlignmentAttr ( unsigned  Align)
inline

This turns an int stack alignment (which must be a power of 2) into the form used internally in Attribute.

This call has no effect if Align is 0. Deprecated, use the version using a MaybeAlign.

Definition at line 943 of file Attributes.h.

References addStackAlignmentAttr().

◆ addStructRetAttr()

AttrBuilder & AttrBuilder::addStructRetAttr ( Type Ty)

This turns a sret type into the form used internally in Attribute.

Definition at line 1921 of file Attributes.cpp.

References Attrs.

Referenced by llvm::AttributeFuncs::typeIncompatible().

◆ addVScaleRangeAttr()

AttrBuilder & AttrBuilder::addVScaleRangeAttr ( unsigned  MinValue,
unsigned  MaxValue 
)

This turns two ints into the form used internally in Attribute.

Definition at line 1898 of file Attributes.cpp.

References addVScaleRangeAttrFromRawRepr(), and packVScaleRangeArgs().

◆ addVScaleRangeAttrFromRawRepr()

AttrBuilder & AttrBuilder::addVScaleRangeAttrFromRawRepr ( uint64_t  RawVScaleRangeRepr)

Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().

Definition at line 1903 of file Attributes.cpp.

References Attrs.

Referenced by addVScaleRangeAttr().

◆ clear()

void AttrBuilder::clear ( )

Definition at line 1738 of file Attributes.cpp.

References Attrs, and llvm::Optional< T >::reset().

◆ contains() [1/2]

bool llvm::AttrBuilder::contains ( Attribute::AttrKind  A) const
inline

Return true if the builder has the specified attribute.

Definition at line 867 of file Attributes.h.

References assert(), and llvm::Attribute::EndAttrKinds.

Referenced by llvm::attributesPermitTailCall(), and hasAttributes().

◆ contains() [2/2]

bool AttrBuilder::contains ( StringRef  A) const

Return true if the builder has the specified target-dependent attribute.

Definition at line 2044 of file Attributes.cpp.

References A.

◆ empty()

bool llvm::AttrBuilder::empty ( ) const
inline

Return true if the builder contains no target-independent attributes.

Definition at line 987 of file Attributes.h.

Referenced by AddReturnAttributes().

◆ getAlignment()

MaybeAlign llvm::AttrBuilder::getAlignment ( ) const
inline

Retrieve the alignment attribute, if it exists.

Definition at line 887 of file Attributes.h.

◆ getAllocSizeArgs()

std::pair< unsigned, Optional< unsigned > > AttrBuilder::getAllocSizeArgs ( ) const

Retrieve the allocsize args, if the allocsize attribute exists.

If it doesn't exist, pair(0, 0) is returned.

Definition at line 1834 of file Attributes.cpp.

References unpackAllocSizeArgs().

◆ getByRefType()

Type* llvm::AttrBuilder::getByRefType ( ) const
inline

Retrieve the byref type.

Definition at line 907 of file Attributes.h.

◆ getByValType()

Type* llvm::AttrBuilder::getByValType ( ) const
inline

Retrieve the byval type.

Definition at line 901 of file Attributes.h.

Referenced by llvm::promoteCall().

◆ getDereferenceableBytes()

uint64_t llvm::AttrBuilder::getDereferenceableBytes ( ) const
inline

Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is returned otherwise).

Definition at line 894 of file Attributes.h.

◆ getDereferenceableOrNullBytes()

uint64_t llvm::AttrBuilder::getDereferenceableOrNullBytes ( ) const
inline

Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists (zero is returned otherwise).

Definition at line 898 of file Attributes.h.

◆ getInAllocaType()

Type* llvm::AttrBuilder::getInAllocaType ( ) const
inline

Retrieve the inalloca type.

Definition at line 913 of file Attributes.h.

◆ getPreallocatedType()

Type* llvm::AttrBuilder::getPreallocatedType ( ) const
inline

Retrieve the preallocated type.

Definition at line 910 of file Attributes.h.

◆ getStackAlignment()

MaybeAlign llvm::AttrBuilder::getStackAlignment ( ) const
inline

Retrieve the stack alignment attribute, if it exists.

Definition at line 890 of file Attributes.h.

◆ getStructRetType()

Type* llvm::AttrBuilder::getStructRetType ( ) const
inline

Retrieve the sret type.

Definition at line 904 of file Attributes.h.

◆ getVScaleRangeArgs()

std::pair< unsigned, unsigned > AttrBuilder::getVScaleRangeArgs ( ) const

Retrieve the vscale_range args, if the vscale_range attribute exists.

If it doesn't exist, pair(0, 0) is returned.

Definition at line 1838 of file Attributes.cpp.

References unpackVScaleRangeArgs().

◆ hasAlignmentAttr()

bool AttrBuilder::hasAlignmentAttr ( ) const

Return true if the builder has an alignment attribute.

Definition at line 2068 of file Attributes.cpp.

◆ hasAttributes() [1/2]

bool AttrBuilder::hasAttributes ( ) const

Return true if the builder has IR-level attributes.

Definition at line 2048 of file Attributes.cpp.

References Attrs.

◆ hasAttributes() [2/2]

bool AttrBuilder::hasAttributes ( AttributeList  A,
uint64_t  Index 
) const

Return true if the builder has any attribute that's in the specified attribute.

Definition at line 2052 of file Attributes.cpp.

References llvm::AArch64CC::AL, assert(), contains(), and Index.

◆ merge()

AttrBuilder & AttrBuilder::merge ( const AttrBuilder B)

Add the attributes from the builder.

Definition at line 1945 of file Attributes.cpp.

References Attrs, B, and I.

Referenced by llvm::AttributeList::addAttributes(), and llvm::AttributeList::get().

◆ operator!=()

bool llvm::AttrBuilder::operator!= ( const AttrBuilder B) const
inline

Definition at line 1011 of file Attributes.h.

References B.

◆ operator==()

bool AttrBuilder::operator== ( const AttrBuilder B) const

Definition at line 2072 of file Attributes.cpp.

References Attrs, and B.

◆ overlaps()

bool AttrBuilder::overlaps ( const AttrBuilder B) const

Return true if the builder has any attribute that's in the specified builder.

Definition at line 2031 of file Attributes.cpp.

References Attrs, B, I, and td_attrs().

◆ remove()

AttrBuilder & AttrBuilder::remove ( const AttrBuilder B)

Remove the attributes from the builder.

Definition at line 1988 of file Attributes.cpp.

References Attrs, B, I, and llvm::Optional< T >::reset().

Referenced by legalizeCallAttributes(), llvm::promoteCall(), and removeAttributes().

◆ removeAttribute() [1/2]

AttrBuilder & AttrBuilder::removeAttribute ( Attribute::AttrKind  Val)

Remove an attribute from the builder.

Definition at line 1792 of file Attributes.cpp.

References assert(), Attrs, llvm::Attribute::EndAttrKinds, and llvm::Optional< T >::reset().

Referenced by llvm::attributesPermitTailCall(), and legalizeCallAttributes().

◆ removeAttribute() [2/2]

AttrBuilder & AttrBuilder::removeAttribute ( StringRef  A)

Remove the target-dependent attribute to the builder.

Definition at line 1827 of file Attributes.cpp.

References A, and I.

◆ removeAttributes()

AttrBuilder & AttrBuilder::removeAttributes ( AttributeList  A,
uint64_t  WithoutIndex 
)

Remove the attributes from the builder.

Definition at line 1822 of file Attributes.cpp.

References A, Index, and remove().

◆ td_attrs() [1/2]

td_range llvm::AttrBuilder::td_attrs ( )
inline

Definition at line 1002 of file Attributes.h.

References td_begin(), and td_end().

Referenced by overlaps().

◆ td_attrs() [2/2]

td_const_range llvm::AttrBuilder::td_attrs ( ) const
inline

Definition at line 1004 of file Attributes.h.

References td_begin(), and td_end().

◆ td_begin() [1/2]

td_iterator llvm::AttrBuilder::td_begin ( )
inline

Definition at line 996 of file Attributes.h.

Referenced by td_attrs().

◆ td_begin() [2/2]

td_const_iterator llvm::AttrBuilder::td_begin ( ) const
inline

Definition at line 999 of file Attributes.h.

◆ td_empty()

bool llvm::AttrBuilder::td_empty ( ) const
inline

Definition at line 1008 of file Attributes.h.

◆ td_end() [1/2]

td_iterator llvm::AttrBuilder::td_end ( )
inline

Definition at line 997 of file Attributes.h.

Referenced by td_attrs().

◆ td_end() [2/2]

td_const_iterator llvm::AttrBuilder::td_end ( ) const
inline

Definition at line 1000 of file Attributes.h.


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