LLVM 20.0.0git
|
#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 () |
AttrBuilder & | addAttribute (Attribute::AttrKind Val) |
Add an attribute to the builder. | |
AttrBuilder & | addAttribute (Attribute A) |
Add the Attribute object to the builder. | |
AttrBuilder & | addAttribute (StringRef A, StringRef V=StringRef()) |
Add the target-dependent attribute to the builder. | |
AttrBuilder & | removeAttribute (Attribute::AttrKind Val) |
Remove an attribute from the builder. | |
AttrBuilder & | removeAttribute (StringRef A) |
Remove the target-dependent attribute from the builder. | |
AttrBuilder & | removeAttribute (Attribute A) |
Remove the target-dependent attribute from the builder. | |
AttrBuilder & | merge (const AttrBuilder &B) |
Add the attributes from the builder. | |
AttrBuilder & | remove (const AttributeMask &AM) |
Remove the attributes from the builder. | |
bool | overlaps (const AttributeMask &AM) const |
Return true if the builder has any attribute that's in the specified builder. | |
bool | contains (Attribute::AttrKind A) const |
Return true if the builder has the specified attribute. | |
bool | contains (StringRef A) const |
Return true if the builder has the specified target-dependent attribute. | |
bool | hasAttributes () const |
Return true if the builder has IR-level attributes. | |
Attribute | getAttribute (Attribute::AttrKind Kind) const |
Return Attribute with the given Kind. | |
Attribute | getAttribute (StringRef Kind) const |
Return Attribute with the given Kind. | |
std::optional< ConstantRange > | getRange () const |
Retrieve the range if the attribute exists (std::nullopt is returned otherwise). | |
std::optional< uint64_t > | getRawIntAttr (Attribute::AttrKind Kind) const |
Return raw (possibly packed/encoded) value of integer attribute or std::nullopt if not set. | |
MaybeAlign | getAlignment () const |
Retrieve the alignment attribute, if it exists. | |
MaybeAlign | getStackAlignment () const |
Retrieve the stack alignment attribute, if it exists. | |
uint64_t | getDereferenceableBytes () const |
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is returned otherwise). | |
uint64_t | getDereferenceableOrNullBytes () const |
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists (zero is returned otherwise). | |
Type * | getTypeAttr (Attribute::AttrKind Kind) const |
Retrieve type for the given type attribute. | |
Type * | getByValType () const |
Retrieve the byval type. | |
Type * | getStructRetType () const |
Retrieve the sret type. | |
Type * | getByRefType () const |
Retrieve the byref type. | |
Type * | getPreallocatedType () const |
Retrieve the preallocated type. | |
Type * | getInAllocaType () const |
Retrieve the inalloca type. | |
std::optional< std::pair< unsigned, std::optional< unsigned > > > | getAllocSizeArgs () const |
Retrieve the allocsize args, or std::nullopt if the attribute does not exist. | |
AttrBuilder & | addRawIntAttr (Attribute::AttrKind Kind, uint64_t Value) |
Add integer attribute with raw value (packed/encoded if necessary). | |
AttrBuilder & | addAlignmentAttr (MaybeAlign Align) |
This turns an alignment into the form used internally in Attribute. | |
AttrBuilder & | addAlignmentAttr (unsigned Align) |
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute. | |
AttrBuilder & | addStackAlignmentAttr (MaybeAlign Align) |
This turns a stack alignment into the form used internally in Attribute. | |
AttrBuilder & | addStackAlignmentAttr (unsigned Align) |
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attribute. | |
AttrBuilder & | addDereferenceableAttr (uint64_t Bytes) |
This turns the number of dereferenceable bytes into the form used internally in Attribute. | |
AttrBuilder & | addDereferenceableOrNullAttr (uint64_t Bytes) |
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute. | |
AttrBuilder & | addAllocSizeAttr (unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg) |
This turns one (or two) ints into the form used internally in Attribute. | |
AttrBuilder & | addVScaleRangeAttr (unsigned MinValue, std::optional< unsigned > MaxValue) |
This turns two ints into the form used internally in Attribute. | |
AttrBuilder & | addTypeAttr (Attribute::AttrKind Kind, Type *Ty) |
Add a type attribute with the given type. | |
AttrBuilder & | addByValAttr (Type *Ty) |
This turns a byval type into the form used internally in Attribute. | |
AttrBuilder & | addStructRetAttr (Type *Ty) |
This turns a sret type into the form used internally in Attribute. | |
AttrBuilder & | addByRefAttr (Type *Ty) |
This turns a byref type into the form used internally in Attribute. | |
AttrBuilder & | addPreallocatedAttr (Type *Ty) |
This turns a preallocated type into the form used internally in Attribute. | |
AttrBuilder & | addInAllocaAttr (Type *Ty) |
This turns an inalloca type into the form used internally in Attribute. | |
AttrBuilder & | addAllocSizeAttrFromRawRepr (uint64_t RawAllocSizeRepr) |
Add an allocsize attribute, using the representation returned by Attribute.getIntValue(). | |
AttrBuilder & | addVScaleRangeAttrFromRawRepr (uint64_t RawVScaleRangeRepr) |
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue(). | |
AttrBuilder & | addUWTableAttr (UWTableKind Kind) |
This turns the unwind table kind into the form used internally in Attribute. | |
AttrBuilder & | addAllocKindAttr (AllocFnKind Kind) |
AttrBuilder & | addMemoryAttr (MemoryEffects ME) |
Add memory effect attribute. | |
AttrBuilder & | addCapturesAttr (CaptureInfo CI) |
Add captures attribute. | |
AttrBuilder & | addNoFPClassAttr (FPClassTest NoFPClassMask) |
AttrBuilder & | addConstantRangeAttr (Attribute::AttrKind Kind, const ConstantRange &CR) |
Add a ConstantRange attribute with the given range. | |
AttrBuilder & | addRangeAttr (const ConstantRange &CR) |
Add range attribute. | |
AttrBuilder & | addConstantRangeListAttr (Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val) |
Add a ConstantRangeList attribute with the given ranges. | |
AttrBuilder & | addInitializesAttr (const ConstantRangeList &CRL) |
Add initializes attribute. | |
ArrayRef< Attribute > | attrs () const |
bool | operator== (const AttrBuilder &B) const |
bool | operator!= (const AttrBuilder &B) const |
Definition at line 1064 of file Attributes.h.
|
inline |
Definition at line 1069 of file Attributes.h.
|
delete |
|
default |
|
inline |
Definition at line 1073 of file Attributes.h.
References A, and addAttribute().
AttrBuilder::AttrBuilder | ( | LLVMContext & | Ctx, |
AttributeSet | AS | ||
) |
Definition at line 2055 of file Attributes.cpp.
References llvm::append_range(), assert(), and llvm::is_sorted().
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 2155 of file Attributes.cpp.
References addRawIntAttr(), assert(), llvm::Value::MaximumAlignment, and llvm::Align::value().
Referenced by addAlignmentAttr(), addFramePointerAttrs(), IdentifyValidPoisonGeneratingAttributes(), and llvm::AttributeSet::intersectWith().
|
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 1199 of file Attributes.h.
References addAlignmentAttr().
AttrBuilder & AttrBuilder::addAllocKindAttr | ( | AllocFnKind | Kind | ) |
Definition at line 2231 of file Attributes.cpp.
References addRawIntAttr().
AttrBuilder & AttrBuilder::addAllocSizeAttr | ( | unsigned | ElemSizeArg, |
const std::optional< unsigned > & | NumElemsArg | ||
) |
This turns one (or two) ints into the form used internally in Attribute.
Definition at line 2186 of file Attributes.cpp.
References addAllocSizeAttrFromRawRepr(), and packAllocSizeArgs().
AttrBuilder & AttrBuilder::addAllocSizeAttrFromRawRepr | ( | uint64_t | RawAllocSizeRepr | ) |
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
Definition at line 2191 of file Attributes.cpp.
References addRawIntAttr(), and assert().
Referenced by addAllocSizeAttr().
AttrBuilder & AttrBuilder::addAttribute | ( | Attribute | A | ) |
Add the Attribute object to the builder.
Definition at line 2100 of file Attributes.cpp.
References addAttributeImpl(), llvm::Attribute::getKindAsEnum(), llvm::Attribute::getKindAsString(), and llvm::Attribute::isStringAttribute().
AttrBuilder & AttrBuilder::addAttribute | ( | Attribute::AttrKind | Val | ) |
Add an attribute to the builder.
Definition at line 2108 of file Attributes.cpp.
References addAttributeImpl(), and llvm::Attribute::get().
Referenced by addAsyncContextAttrs(), addConstantRangeAttr(), addConstantRangeListAttr(), addFramePointerAttrs(), addRawIntAttr(), addSwiftSelfAttrs(), addTypeAttr(), AttrBuilder(), llvm::OpenMPIRBuilder::createReductionsGPU(), llvm::AtomicInfo::EmitAtomicLibcall(), IdentifyValidPoisonGeneratingAttributes(), IdentifyValidUBGeneratingAttributes(), llvm::AttributeSet::intersectWith(), merge(), and llvm::codegen::setFunctionAttributes().
AttrBuilder & AttrBuilder::addAttribute | ( | StringRef | A, |
StringRef | V = StringRef() |
||
) |
Add the target-dependent attribute to the builder.
Definition at line 2113 of file Attributes.cpp.
References A, addAttributeImpl(), and llvm::Attribute::get().
AttrBuilder & AttrBuilder::addByRefAttr | ( | Type * | Ty | ) |
This turns a byref type into the form used internally in Attribute.
Definition at line 2253 of file Attributes.cpp.
References addTypeAttr().
AttrBuilder & AttrBuilder::addByValAttr | ( | Type * | Ty | ) |
This turns a byval type into the form used internally in Attribute.
Definition at line 2245 of file Attributes.cpp.
References addTypeAttr().
Referenced by llvm::promoteCall().
AttrBuilder & AttrBuilder::addCapturesAttr | ( | CaptureInfo | CI | ) |
Add captures attribute.
Definition at line 2220 of file Attributes.cpp.
References addRawIntAttr(), and llvm::CaptureInfo::toIntValue().
Referenced by llvm::AttributeSet::intersectWith().
AttrBuilder & AttrBuilder::addConstantRangeAttr | ( | Attribute::AttrKind | Kind, |
const ConstantRange & | CR | ||
) |
Add a ConstantRange attribute with the given range.
Definition at line 2265 of file Attributes.cpp.
References addAttribute(), llvm::Attribute::get(), and llvm::ConstantRange::isFullSet().
Referenced by addRangeAttr().
AttrBuilder & AttrBuilder::addConstantRangeListAttr | ( | Attribute::AttrKind | Kind, |
ArrayRef< ConstantRange > | Val | ||
) |
Add a ConstantRangeList attribute with the given ranges.
Definition at line 2278 of file Attributes.cpp.
References addAttribute(), and llvm::Attribute::get().
Referenced by addInitializesAttr().
AttrBuilder & AttrBuilder::addDereferenceableAttr | ( | uint64_t | Bytes | ) |
This turns the number of dereferenceable bytes into the form used internally in Attribute.
Definition at line 2172 of file Attributes.cpp.
References addRawIntAttr().
Referenced by addFramePointerAttrs(), and IdentifyValidUBGeneratingAttributes().
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 2178 of file Attributes.cpp.
References addRawIntAttr().
Referenced by IdentifyValidUBGeneratingAttributes().
AttrBuilder & AttrBuilder::addInAllocaAttr | ( | Type * | Ty | ) |
This turns an inalloca type into the form used internally in Attribute.
Definition at line 2261 of file Attributes.cpp.
References addTypeAttr().
Referenced by llvm::promoteCall().
AttrBuilder & AttrBuilder::addInitializesAttr | ( | const ConstantRangeList & | CRL | ) |
Add initializes attribute.
Definition at line 2283 of file Attributes.cpp.
References addConstantRangeListAttr(), and llvm::ConstantRangeList::rangesRef().
AttrBuilder & AttrBuilder::addMemoryAttr | ( | MemoryEffects | ME | ) |
Add memory effect attribute.
Definition at line 2216 of file Attributes.cpp.
References addRawIntAttr(), and llvm::MemoryEffectsBase< LocationEnum >::toIntValue().
Referenced by llvm::AttributeSet::intersectWith().
AttrBuilder & AttrBuilder::addNoFPClassAttr | ( | FPClassTest | NoFPClassMask | ) |
Definition at line 2224 of file Attributes.cpp.
References addRawIntAttr(), and llvm::fcNone.
Referenced by llvm::AttributeSet::intersectWith().
AttrBuilder & AttrBuilder::addPreallocatedAttr | ( | Type * | Ty | ) |
This turns a preallocated type into the form used internally in Attribute.
Definition at line 2257 of file Attributes.cpp.
References addTypeAttr().
AttrBuilder & AttrBuilder::addRangeAttr | ( | const ConstantRange & | CR | ) |
Add range attribute.
Definition at line 2273 of file Attributes.cpp.
References addConstantRangeAttr().
Referenced by AddReturnAttributes(), IdentifyValidPoisonGeneratingAttributes(), and llvm::AttributeSet::intersectWith().
AttrBuilder & AttrBuilder::addRawIntAttr | ( | Attribute::AttrKind | Kind, |
uint64_t | Value | ||
) |
Add integer attribute with raw value (packed/encoded if necessary).
Definition at line 2142 of file Attributes.cpp.
References addAttribute(), and llvm::Attribute::get().
Referenced by addAlignmentAttr(), addAllocKindAttr(), addAllocSizeAttrFromRawRepr(), addCapturesAttr(), addDereferenceableAttr(), addDereferenceableOrNullAttr(), addMemoryAttr(), addNoFPClassAttr(), addStackAlignmentAttr(), addUWTableAttr(), addVScaleRangeAttrFromRawRepr(), and llvm::AttributeSet::intersectWith().
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 2163 of file Attributes.cpp.
References addRawIntAttr(), assert(), and llvm::Align::value().
Referenced by addStackAlignmentAttr().
|
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 1211 of file Attributes.h.
References addStackAlignmentAttr().
AttrBuilder & AttrBuilder::addStructRetAttr | ( | Type * | Ty | ) |
This turns a sret type into the form used internally in Attribute.
Definition at line 2249 of file Attributes.cpp.
References addTypeAttr().
AttrBuilder & AttrBuilder::addTypeAttr | ( | Attribute::AttrKind | Kind, |
Type * | Ty | ||
) |
Add a type attribute with the given type.
Definition at line 2241 of file Attributes.cpp.
References addAttribute(), and llvm::Attribute::get().
Referenced by addByRefAttr(), addByValAttr(), addInAllocaAttr(), addPreallocatedAttr(), and addStructRetAttr().
AttrBuilder & AttrBuilder::addUWTableAttr | ( | UWTableKind | Kind | ) |
This turns the unwind table kind into the form used internally in Attribute.
Definition at line 2210 of file Attributes.cpp.
References addRawIntAttr(), and llvm::None.
AttrBuilder & AttrBuilder::addVScaleRangeAttr | ( | unsigned | MinValue, |
std::optional< unsigned > | MaxValue | ||
) |
This turns two ints into the form used internally in Attribute.
Definition at line 2197 of file Attributes.cpp.
References addVScaleRangeAttrFromRawRepr(), and packVScaleRangeArgs().
AttrBuilder & AttrBuilder::addVScaleRangeAttrFromRawRepr | ( | uint64_t | RawVScaleRangeRepr | ) |
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
Definition at line 2202 of file Attributes.cpp.
References addRawIntAttr().
Referenced by addVScaleRangeAttr().
Definition at line 1287 of file Attributes.h.
void AttrBuilder::clear | ( | ) |
Definition at line 2060 of file Attributes.cpp.
bool AttrBuilder::contains | ( | Attribute::AttrKind | A | ) | const |
Return true if the builder has the specified attribute.
Definition at line 2326 of file Attributes.cpp.
References A, getAttribute(), and llvm::Attribute::isValid().
Referenced by llvm::attributesPermitTailCall(), and llvm::TargetLowering::isInTailCallPosition().
Return true if the builder has the specified target-dependent attribute.
Definition at line 2330 of file Attributes.cpp.
References A, getAttribute(), and llvm::Attribute::isValid().
|
inline |
Retrieve the alignment attribute, if it exists.
Definition at line 1142 of file Attributes.h.
References getRawIntAttr().
Referenced by AddReturnAttributes().
std::optional< std::pair< unsigned, std::optional< unsigned > > > AttrBuilder::getAllocSizeArgs | ( | ) | const |
Retrieve the allocsize args, or std::nullopt if the attribute does not exist.
Definition at line 2148 of file Attributes.cpp.
References A, and getAttribute().
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 2304 of file Attributes.cpp.
References A, assert(), llvm::Attribute::EndAttrKinds, and llvm::lower_bound().
Referenced by AddReturnAttributes(), contains(), getAllocSizeArgs(), getRange(), getRawIntAttr(), and getTypeAttr().
Return Attribute with the given Kind.
The returned attribute will be invalid if the Kind is not present in the builder.
Definition at line 2312 of file Attributes.cpp.
References A, and llvm::lower_bound().
|
inline |
|
inline |
Retrieve the byval type.
Definition at line 1167 of file Attributes.h.
References getTypeAttr().
Referenced by llvm::promoteCall().
|
inline |
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is returned otherwise).
Definition at line 1153 of file Attributes.h.
References getRawIntAttr().
Referenced by AddReturnAttributes().
|
inline |
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists (zero is returned otherwise).
Definition at line 1159 of file Attributes.h.
References getRawIntAttr().
Referenced by AddReturnAttributes().
|
inline |
Retrieve the inalloca type.
Definition at line 1181 of file Attributes.h.
References getTypeAttr().
Referenced by llvm::promoteCall().
|
inline |
Retrieve the preallocated type.
Definition at line 1176 of file Attributes.h.
References getTypeAttr().
std::optional< ConstantRange > AttrBuilder::getRange | ( | ) | const |
Retrieve the range if the attribute exists (std::nullopt is returned otherwise).
Definition at line 2319 of file Attributes.cpp.
References getAttribute(), llvm::Attribute::getRange(), and llvm::Attribute::isValid().
std::optional< uint64_t > AttrBuilder::getRawIntAttr | ( | Attribute::AttrKind | Kind | ) | const |
Return raw (possibly packed/encoded) value of integer attribute or std::nullopt if not set.
Definition at line 2134 of file Attributes.cpp.
References A, assert(), getAttribute(), and llvm::Attribute::isIntAttrKind().
Referenced by getAlignment(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), and getStackAlignment().
|
inline |
Retrieve the stack alignment attribute, if it exists.
Definition at line 1147 of file Attributes.h.
References getRawIntAttr().
|
inline |
Type * AttrBuilder::getTypeAttr | ( | Attribute::AttrKind | Kind | ) | const |
Retrieve type for the given type attribute.
Definition at line 2235 of file Attributes.cpp.
References A, assert(), getAttribute(), and llvm::Attribute::isTypeAttrKind().
Referenced by getByRefType(), getByValType(), getInAllocaType(), getPreallocatedType(), and getStructRetType().
|
inline |
Return true if the builder has IR-level attributes.
Definition at line 1123 of file Attributes.h.
Referenced by AddReturnAttributes(), llvm::TargetLowering::isInTailCallPosition(), and isLibCallInTailPosition().
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 2287 of file Attributes.cpp.
References addAttribute(), B, and I.
Referenced by llvm::AttributeList::get().
|
inline |
Definition at line 1290 of file Attributes.h.
References B.
bool AttrBuilder::operator== | ( | const AttrBuilder & | B | ) | const |
Definition at line 2334 of file Attributes.cpp.
References B.
bool AttrBuilder::overlaps | ( | const AttributeMask & | AM | ) | const |
Return true if the builder has any attribute that's in the specified builder.
Definition at line 2300 of file Attributes.cpp.
References A, llvm::any_of(), and llvm::AttributeMask::contains().
AttrBuilder & AttrBuilder::remove | ( | const AttributeMask & | AM | ) |
Remove the attributes from the builder.
Definition at line 2295 of file Attributes.cpp.
References A, llvm::AttributeMask::contains(), and llvm::erase_if().
Referenced by llvm::promoteCall().
|
inline |
Remove the target-dependent attribute from the builder.
Definition at line 1097 of file Attributes.h.
References A, and removeAttribute().
AttrBuilder & AttrBuilder::removeAttribute | ( | Attribute::AttrKind | Val | ) |
Remove an attribute from the builder.
Definition at line 2118 of file Attributes.cpp.
References assert(), llvm::Attribute::EndAttrKinds, and llvm::lower_bound().
Referenced by AddReturnAttributes(), llvm::attributesPermitTailCall(), llvm::OpenMPIRBuilder::createReductionsGPU(), llvm::TargetLowering::isInTailCallPosition(), isLibCallInTailPosition(), legalizeCallAttributes(), and removeAttribute().
AttrBuilder & AttrBuilder::removeAttribute | ( | StringRef | A | ) |
Remove the target-dependent attribute from the builder.
Definition at line 2126 of file Attributes.cpp.
References A, and llvm::lower_bound().