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

#include "llvm/IR/Attributes.h"

Public Member Functions

 AttrBuilder (LLVMContext &Ctx)
 
 AttrBuilder (const AttrBuilder &)=delete
 
 AttrBuilder (AttrBuilder &&)=default
 
 AttrBuilder (LLVMContext &Ctx, const Attribute &A)
 
 AttrBuilder (LLVMContext &Ctx, 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...
 
AttrBuilderremoveAttribute (StringRef A)
 Remove the target-dependent attribute from the builder. More...
 
AttrBuilderremoveAttribute (Attribute A)
 Remove the target-dependent attribute from the builder. More...
 
AttrBuildermerge (const AttrBuilder &B)
 Add the attributes from the builder. More...
 
AttrBuilderremove (const AttributeMask &AM)
 Remove the attributes from the builder. More...
 
bool overlaps (const AttributeMask &AM) 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 hasAlignmentAttr () const
 Return true if the builder has an alignment attribute. More...
 
Attribute getAttribute (Attribute::AttrKind Kind) const
 Return Attribute with the given Kind. More...
 
Attribute getAttribute (StringRef Kind) const
 Return Attribute with the given Kind. More...
 
uint64_t getRawIntAttr (Attribute::AttrKind Kind) const
 Return raw (possibly packed/encoded) value of integer attribute or 0 if not set. 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...
 
TypegetTypeAttr (Attribute::AttrKind Kind) const
 Retrieve type for the given type attribute. 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...
 
unsigned getVScaleRangeMin () const
 Retrieve the minimum value of 'vscale_range'. More...
 
Optional< unsigned > getVScaleRangeMax () const
 Retrieve the maximum value of 'vscale_range' or None when unknown. More...
 
AttrBuilderaddRawIntAttr (Attribute::AttrKind Kind, uint64_t Value)
 Add integer attribute with raw value (packed/encoded if necessary). 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, Optional< unsigned > MaxValue)
 This turns two ints into the form used internally in Attribute. More...
 
AttrBuilderaddTypeAttr (Attribute::AttrKind Kind, Type *Ty)
 Add a type attribute with the given type. 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...
 
AttrBuilderaddUWTableAttr (UWTableKind Kind)
 This turns the unwind table kind into the form used internally in Attribute. More...
 
ArrayRef< Attributeattrs () const
 
bool operator== (const AttrBuilder &B) const
 
bool operator!= (const AttrBuilder &B) const
 

Detailed Description

Definition at line 1005 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttrBuilder() [1/5]

llvm::AttrBuilder::AttrBuilder ( LLVMContext Ctx)
inline

Definition at line 1010 of file Attributes.h.

◆ AttrBuilder() [2/5]

llvm::AttrBuilder::AttrBuilder ( const AttrBuilder )
delete

◆ AttrBuilder() [3/5]

llvm::AttrBuilder::AttrBuilder ( AttrBuilder &&  )
default

◆ AttrBuilder() [4/5]

llvm::AttrBuilder::AttrBuilder ( LLVMContext Ctx,
const Attribute A 
)
inline

Definition at line 1014 of file Attributes.h.

References addAttribute().

◆ AttrBuilder() [5/5]

AttrBuilder::AttrBuilder ( LLVMContext Ctx,
AttributeSet  AS 
)

Definition at line 1532 of file Attributes.cpp.

References llvm::append_range(), assert(), Attrs, and llvm::is_sorted().

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

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

Referenced by addAlignmentAttr(), and addFramePointerAttrs().

◆ 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 1144 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 1663 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 1668 of file Attributes.cpp.

References addRawIntAttr(), and assert().

Referenced by addAllocSizeAttr().

◆ addAttribute() [1/3]

AttrBuilder & AttrBuilder::addAttribute ( Attribute  A)

◆ addAttribute() [2/3]

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

◆ addAttribute() [3/3]

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

Add the target-dependent attribute to the builder.

Definition at line 1590 of file Attributes.cpp.

References addAttributeImpl(), and llvm::Attribute::get().

◆ addByRefAttr()

AttrBuilder & AttrBuilder::addByRefAttr ( Type Ty)

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

Definition at line 1711 of file Attributes.cpp.

References addTypeAttr().

◆ addByValAttr()

AttrBuilder & AttrBuilder::addByValAttr ( Type Ty)

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

Definition at line 1703 of file Attributes.cpp.

References addTypeAttr().

Referenced by llvm::promoteCall().

◆ addDereferenceableAttr()

AttrBuilder & AttrBuilder::addDereferenceableAttr ( uint64_t  Bytes)

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

Definition at line 1650 of file Attributes.cpp.

References addRawIntAttr().

Referenced by addFramePointerAttrs(), and IdentifyValidAttributes().

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

References addRawIntAttr().

Referenced by IdentifyValidAttributes().

◆ addInAllocaAttr()

AttrBuilder & AttrBuilder::addInAllocaAttr ( Type Ty)

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

Definition at line 1719 of file Attributes.cpp.

References addTypeAttr().

Referenced by llvm::promoteCall().

◆ addPreallocatedAttr()

AttrBuilder & AttrBuilder::addPreallocatedAttr ( Type Ty)

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

Definition at line 1715 of file Attributes.cpp.

References addTypeAttr().

◆ addRawIntAttr()

AttrBuilder & AttrBuilder::addRawIntAttr ( Attribute::AttrKind  Kind,
uint64_t  Value 
)

Add integer attribute with raw value (packed/encoded if necessary).

Definition at line 1616 of file Attributes.cpp.

References addAttribute(), and llvm::Attribute::get().

Referenced by addAlignmentAttr(), addAllocSizeAttrFromRawRepr(), addDereferenceableAttr(), addDereferenceableOrNullAttr(), addStackAlignmentAttr(), addUWTableAttr(), and addVScaleRangeAttrFromRawRepr().

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

References addRawIntAttr(), assert(), and llvm::Align::value().

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

References addTypeAttr().

◆ addTypeAttr()

AttrBuilder & AttrBuilder::addTypeAttr ( Attribute::AttrKind  Kind,
Type Ty 
)

Add a type attribute with the given type.

Definition at line 1699 of file Attributes.cpp.

References addAttribute(), and llvm::Attribute::get().

Referenced by addByRefAttr(), addByValAttr(), addInAllocaAttr(), addPreallocatedAttr(), and addStructRetAttr().

◆ addUWTableAttr()

AttrBuilder & AttrBuilder::addUWTableAttr ( UWTableKind  Kind)

This turns the unwind table kind into the form used internally in Attribute.

Definition at line 1687 of file Attributes.cpp.

References addRawIntAttr(), and llvm::None.

◆ addVScaleRangeAttr()

AttrBuilder & AttrBuilder::addVScaleRangeAttr ( unsigned  MinValue,
Optional< unsigned >  MaxValue 
)

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

Definition at line 1674 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 1679 of file Attributes.cpp.

References addRawIntAttr().

Referenced by addVScaleRangeAttr().

◆ attrs()

ArrayRef<Attribute> llvm::AttrBuilder::attrs ( ) const
inline

Definition at line 1206 of file Attributes.h.

◆ clear()

void AttrBuilder::clear ( )

Definition at line 1537 of file Attributes.cpp.

References Attrs.

◆ contains() [1/2]

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

Return true if the builder has the specified attribute.

Definition at line 1755 of file Attributes.cpp.

References getAttribute(), and llvm::Attribute::isValid().

Referenced by llvm::attributesPermitTailCall().

◆ contains() [2/2]

bool AttrBuilder::contains ( StringRef  A) const

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

Definition at line 1759 of file Attributes.cpp.

References getAttribute(), and llvm::Attribute::isValid().

◆ getAlignment()

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

Retrieve the alignment attribute, if it exists.

Definition at line 1082 of file Attributes.h.

References getRawIntAttr().

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

References getRawIntAttr(), and unpackAllocSizeArgs().

◆ getAttribute() [1/2]

Attribute AttrBuilder::getAttribute ( Attribute::AttrKind  Kind) const

Return Attribute with the given Kind.

The returned attribute will be invalid if the Kind is not present in the builder.

Definition at line 1740 of file Attributes.cpp.

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

Referenced by contains(), getRawIntAttr(), and getTypeAttr().

◆ getAttribute() [2/2]

Attribute AttrBuilder::getAttribute ( StringRef  Kind) const

Return Attribute with the given Kind.

The returned attribute will be invalid if the Kind is not present in the builder.

Definition at line 1748 of file Attributes.cpp.

References llvm::lower_bound().

◆ getByRefType()

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

Retrieve the byref type.

Definition at line 1113 of file Attributes.h.

References getTypeAttr().

◆ getByValType()

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

Retrieve the byval type.

Definition at line 1107 of file Attributes.h.

References getTypeAttr().

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 1093 of file Attributes.h.

References getRawIntAttr().

◆ 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 1099 of file Attributes.h.

References getRawIntAttr().

◆ getInAllocaType()

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

Retrieve the inalloca type.

Definition at line 1121 of file Attributes.h.

References getTypeAttr().

Referenced by llvm::promoteCall().

◆ getPreallocatedType()

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

Retrieve the preallocated type.

Definition at line 1116 of file Attributes.h.

References getTypeAttr().

◆ getRawIntAttr()

uint64_t AttrBuilder::getRawIntAttr ( Attribute::AttrKind  Kind) const

Return raw (possibly packed/encoded) value of integer attribute or 0 if not set.

Definition at line 1610 of file Attributes.cpp.

References assert(), getAttribute(), and llvm::Attribute::isIntAttrKind().

Referenced by getAlignment(), getAllocSizeArgs(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), getStackAlignment(), getVScaleRangeMax(), getVScaleRangeMin(), and hasAlignmentAttr().

◆ getStackAlignment()

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

Retrieve the stack alignment attribute, if it exists.

Definition at line 1087 of file Attributes.h.

References getRawIntAttr().

◆ getStructRetType()

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

Retrieve the sret type.

Definition at line 1110 of file Attributes.h.

References getTypeAttr().

◆ getTypeAttr()

Type * AttrBuilder::getTypeAttr ( Attribute::AttrKind  Kind) const

Retrieve type for the given type attribute.

Definition at line 1693 of file Attributes.cpp.

References assert(), getAttribute(), and llvm::Attribute::isTypeAttrKind().

Referenced by getByRefType(), getByValType(), getInAllocaType(), getPreallocatedType(), and getStructRetType().

◆ getVScaleRangeMax()

Optional< unsigned > AttrBuilder::getVScaleRangeMax ( ) const

Retrieve the maximum value of 'vscale_range' or None when unknown.

Definition at line 1629 of file Attributes.cpp.

References getRawIntAttr(), and unpackVScaleRangeArgs().

◆ getVScaleRangeMin()

unsigned AttrBuilder::getVScaleRangeMin ( ) const

Retrieve the minimum value of 'vscale_range'.

Definition at line 1625 of file Attributes.cpp.

References getRawIntAttr(), and unpackVScaleRangeArgs().

◆ hasAlignmentAttr()

bool AttrBuilder::hasAlignmentAttr ( ) const

Return true if the builder has an alignment attribute.

Definition at line 1763 of file Attributes.cpp.

References getRawIntAttr().

◆ hasAttributes()

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

Return true if the builder has IR-level attributes.

Definition at line 1064 of file Attributes.h.

Referenced by AddReturnAttributes(), and isLibCallInTailPosition().

◆ merge()

AttrBuilder & AttrBuilder::merge ( const AttrBuilder B)

Add the attributes from the builder.

Attributes in the passed builder overwrite attributes in this builder if they have the same key.

Definition at line 1723 of file Attributes.cpp.

References addAttribute(), B, and I.

Referenced by llvm::AttributeList::get().

◆ operator!=()

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

Definition at line 1209 of file Attributes.h.

References B.

◆ operator==()

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

Definition at line 1767 of file Attributes.cpp.

References B.

◆ overlaps()

bool AttrBuilder::overlaps ( const AttributeMask AM) const

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

Definition at line 1736 of file Attributes.cpp.

References llvm::any_of(), and llvm::AttributeMask::contains().

◆ remove()

AttrBuilder & AttrBuilder::remove ( const AttributeMask AM)

Remove the attributes from the builder.

Definition at line 1731 of file Attributes.cpp.

References llvm::AttributeMask::contains(), and llvm::erase_if().

Referenced by llvm::promoteCall().

◆ removeAttribute() [1/3]

AttrBuilder& llvm::AttrBuilder::removeAttribute ( Attribute  A)
inline

Remove the target-dependent attribute from the builder.

Definition at line 1038 of file Attributes.h.

References removeAttribute().

◆ removeAttribute() [2/3]

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

Remove an attribute from the builder.

Definition at line 1595 of file Attributes.cpp.

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

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

◆ removeAttribute() [3/3]

AttrBuilder & AttrBuilder::removeAttribute ( StringRef  A)

Remove the target-dependent attribute from the builder.

Definition at line 1603 of file Attributes.cpp.

References llvm::lower_bound().


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