25#include "llvm/Config/llvm-config.h"
62 const std::optional<unsigned> &NumElemsArg) {
64 "Attempting to pack a reserved value");
70static std::pair<unsigned, std::optional<unsigned>>
72 unsigned NumElems = Num & std::numeric_limits<unsigned>::max();
73 unsigned ElemSizeArg = Num >> 32;
75 std::optional<unsigned> NumElemsArg;
77 NumElemsArg = NumElems;
78 return std::make_pair(ElemSizeArg, NumElemsArg);
82 std::optional<unsigned> MaxValue) {
83 return uint64_t(MinValue) << 32 | MaxValue.value_or(0);
86static std::pair<unsigned, std::optional<unsigned>>
88 unsigned MaxValue =
Value & std::numeric_limits<unsigned>::max();
89 unsigned MinValue =
Value >> 32;
91 return std::make_pair(MinValue,
92 MaxValue > 0 ? MaxValue : std::optional<unsigned>());
99 "Not an enum or int attribute");
107 assert(Val == 0 &&
"Value must be zero for enum attributes");
119 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
130 if (!Val.
empty())
ID.AddString(Val);
142 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
164 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
174 "Not a ConstantRange attribute");
190 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
200 "Not a ConstantRangeList attribute");
204 ID.AddInteger(Val.
size());
205 for (
auto &CR : Val) {
206 CR.getLower().Profile(
ID);
207 CR.getUpper().Profile(
ID);
225 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
240 assert(
A <= 0x100 &&
"Alignment too large.");
246 assert(Bytes &&
"Bytes must be non-zero.");
252 assert(Bytes &&
"Bytes must be non-zero.");
253 return get(
Context, DereferenceableOrNull, Bytes);
297 const std::optional<unsigned> &NumElemsArg) {
298 assert(!(ElemSizeArg == 0 && NumElemsArg == 0) &&
299 "Invalid allocsize arguments -- given allocsize(0, 0)");
315#define GET_ATTR_NAMES
316#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
317 .Case(#DISPLAY_NAME, Attribute::ENUM_NAME)
318#include "llvm/IR/Attributes.inc"
324#define GET_ATTR_NAMES
325#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
326 case Attribute::ENUM_NAME: \
327 return #DISPLAY_NAME;
328#include "llvm/IR/Attributes.inc"
338#define GET_ATTR_NAMES
339#define ATTRIBUTE_ALL(ENUM_NAME, DISPLAY_NAME) .Case(#DISPLAY_NAME, true)
340#include "llvm/IR/Attributes.inc"
373 if (!pImpl)
return None;
375 "Invalid attribute type to get the kind as an enum!");
380 if (!pImpl)
return 0;
382 "Expected the attribute to be an integer attribute!");
387 if (!pImpl)
return false;
389 "Expected the attribute to be a string attribute!");
394 if (!pImpl)
return {};
396 "Invalid attribute type to get the kind as a string!");
401 if (!pImpl)
return {};
403 "Invalid attribute type to get the value as a string!");
408 if (!pImpl)
return {};
410 "Invalid attribute type to get the value as a type!");
416 "Invalid attribute type to get the value as a ConstantRange!");
422 "Invalid attribute type to get the value as a ConstantRangeList!");
437 "Trying to get alignment from non-alignment attribute!");
443 "Trying to get alignment from non-alignment attribute!");
449 "Trying to get dereferenceable bytes from "
450 "non-dereferenceable attribute!");
456 "Trying to get dereferenceable bytes from "
457 "non-dereferenceable attribute!");
461std::pair<unsigned, std::optional<unsigned>>
464 "Trying to get allocsize args from non-allocsize attribute");
470 "Trying to get vscale args from non-vscale attribute");
476 "Trying to get vscale args from non-vscale attribute");
482 "Trying to get unwind table kind from non-uwtable attribute");
488 "Trying to get allockind value from non-allockind attribute");
494 "Can only call getMemoryEffects() on memory attribute");
500 "Can only call getCaptureInfo() on captures attribute");
506 "Can only call getNoFPClass() on nofpclass attribute");
512 "Trying to get range args from non-range attribute");
518 "Trying to get initializes attr from non-ConstantRangeList attribute");
537 if (!pImpl)
return {};
562 auto AttrWithBytesToString = [&](
const char *
Name) {
569 return AttrWithBytesToString(
"alignstack");
572 return AttrWithBytesToString(
"dereferenceable");
575 return AttrWithBytesToString(
"dereferenceable_or_null");
579 std::optional<unsigned> NumElems;
583 ?
"allocsize(" +
Twine(ElemSize) +
"," +
Twine(*NumElems) +
")"
584 :
"allocsize(" +
Twine(ElemSize) +
")")
591 return (
"vscale_range(" +
Twine(MinValue) +
"," +
592 Twine(MaxValue.value_or(0)) +
")")
617 return (
"allockind(\"" +
652 OS <<
"inaccessiblemem: ";
675 std::string Result =
"nofpclass";
697 OS <<
"initializes(";
719 if (!AttrVal.empty()) {
721 printEscapedString(AttrVal,
OS);
732 assert(
isValid() &&
"invalid Attribute doesn't refer to any context");
736 return C.pImpl->AttrsSet.FindNodeOrInsertPos(
ID, Unused) == pImpl;
740 if (!pImpl && !
A.pImpl)
746 return pImpl->
cmp(*
A.pImpl,
true);
750 if (!pImpl && !
A.pImpl)
return false;
751 if (!pImpl)
return true;
752 if (!
A.pImpl)
return false;
753 return *pImpl < *
A.pImpl;
757 ID.AddPointer(pImpl);
771#define GET_ATTR_PROP_TABLE
772#include "llvm/IR/Attributes.inc"
775 unsigned Index = Kind - 1;
776 assert(Index < std::size(AttrPropTable) &&
"Invalid attribute kind");
777 return AttrPropTable[Index];
799 assert((Prop == AttributeProperty::IntersectPreserve ||
800 Prop == AttributeProperty::IntersectAnd ||
801 Prop == AttributeProperty::IntersectMin ||
802 Prop == AttributeProperty::IntersectCustom) &&
803 "Unknown intersect property");
805 AttributeProperty::IntersectPropertyMask) == Prop;
869 ->getConstantRangeValue();
875 ->getConstantRangeListValue();
897 "Unclear how to compare range list");
914 return cmp(AI,
false) < 0;
933 B.addAttribute(Kind);
940 B.addAttribute(Kind,
Value);
961 B.removeAttribute(Kind);
969 B.removeAttribute(Kind);
977 if (!
B.overlaps(Attrs))
984std::optional<AttributeSet>
991 auto ItBegin0 =
begin();
993 auto ItBegin1 =
Other.begin();
994 auto ItEnd1 =
Other.end();
996 while (ItBegin0 != ItEnd0 || ItBegin1 != ItEnd1) {
1001 if (ItBegin1 == ItEnd1)
1002 Attr0 = *ItBegin0++;
1003 else if (ItBegin0 == ItEnd0)
1004 Attr0 = *ItBegin1++;
1006 int Cmp = ItBegin0->cmpKind(*ItBegin1);
1008 Attr0 = *ItBegin0++;
1009 Attr1 = *ItBegin1++;
1011 Attr0 = *ItBegin0++;
1013 Attr0 = *ItBegin1++;
1015 assert(Attr0.
isValid() &&
"Iteration should always yield a valid attr");
1017 auto IntersectEq = [&]() {
1030 return std::nullopt;
1039 return std::nullopt;
1045 "Iterator picked up two different attributes in the same iteration");
1050 "Invalid attr type of intersectAnd");
1058 "Invalid attr type of intersectMin");
1066 case Attribute::Alignment:
1073 case Attribute::Memory:
1077 case Attribute::Captures:
1081 case Attribute::NoFPClass:
1085 case Attribute::Range: {
1101 return std::nullopt;
1105 if (Kind == Attribute::ByVal &&
1107 Other.getAttribute(Attribute::Alignment))
1108 return std::nullopt;
1111 return get(
C, Intersected);
1135 return SetNode ? SetNode->
getAlignment() : std::nullopt;
1159 return SetNode ? SetNode->
getAttributeType(Attribute::StructRet) :
nullptr;
1163 return SetNode ? SetNode->
getAttributeType(Attribute::Preallocated) :
nullptr;
1171 return SetNode ? SetNode->
getAttributeType(Attribute::ElementType) :
nullptr;
1174std::optional<std::pair<unsigned, std::optional<unsigned>>>
1178 return std::nullopt;
1210 return SetNode ? SetNode->
getAsString(InAttrGrp) :
"";
1218 return C.pImpl->AttrsSetNodes.FindNodeOrInsertPos(
ID, Unused) == SetNode;
1222 return SetNode ? SetNode->
begin() :
nullptr;
1226 return SetNode ? SetNode->
end() :
nullptr;
1229#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1242 : NumAttrs(Attrs.
size()) {
1246 for (
const auto &
I : *
this) {
1247 if (
I.isStringAttribute())
1248 StringAttrs.insert({
I.getKindAsString(),
I });
1250 AvailableAttrs.addAttribute(
I.getKindAsEnum());
1258 return getSorted(
C, SortedAttrs);
1263 if (SortedAttrs.
empty())
1271 for (
const auto &Attr : SortedAttrs)
1282 void *Mem = ::operator
new(totalSizeToAlloc<Attribute>(SortedAttrs.size()));
1292 return getSorted(
C,
B.attrs());
1296 return StringAttrs.count(Kind);
1299std::optional<Attribute>
1303 return std::nullopt;
1308 std::lower_bound(
begin(),
end() - StringAttrs.size(), Kind,
1310 return A.getKindAsEnum() < Kind;
1312 assert(
I !=
end() &&
I->hasAttribute(Kind) &&
"Presence check failed?");
1317 if (
auto A = findEnumAttribute(Kind))
1323 return StringAttrs.lookup(Kind);
1327 if (
auto A = findEnumAttribute(Attribute::Alignment))
1328 return A->getAlignment();
1329 return std::nullopt;
1333 if (
auto A = findEnumAttribute(Attribute::StackAlignment))
1334 return A->getStackAlignment();
1335 return std::nullopt;
1339 if (
auto A = findEnumAttribute(Kind))
1340 return A->getValueAsType();
1345 if (
auto A = findEnumAttribute(Attribute::Dereferenceable))
1346 return A->getDereferenceableBytes();
1351 if (
auto A = findEnumAttribute(Attribute::DereferenceableOrNull))
1352 return A->getDereferenceableOrNullBytes();
1356std::optional<std::pair<unsigned, std::optional<unsigned>>>
1358 if (
auto A = findEnumAttribute(Attribute::AllocSize))
1359 return A->getAllocSizeArgs();
1360 return std::nullopt;
1364 if (
auto A = findEnumAttribute(Attribute::VScaleRange))
1365 return A->getVScaleRangeMin();
1370 if (
auto A = findEnumAttribute(Attribute::VScaleRange))
1371 return A->getVScaleRangeMax();
1372 return std::nullopt;
1376 if (
auto A = findEnumAttribute(Attribute::UWTable))
1377 return A->getUWTableKind();
1382 if (
auto A = findEnumAttribute(Attribute::AllocKind))
1383 return A->getAllocKind();
1388 if (
auto A = findEnumAttribute(Attribute::Memory))
1389 return A->getMemoryEffects();
1394 if (
auto A = findEnumAttribute(Attribute::Captures))
1395 return A->getCaptureInfo();
1400 if (
auto A = findEnumAttribute(Attribute::NoFPClass))
1401 return A->getNoFPClass();
1410 Str +=
I->getAsString(InAttrGrp);
1426 : NumAttrSets(Sets.
size()) {
1427 assert(!Sets.
empty() &&
"pointless AttributeListImpl");
1435 if (!
I.isStringAttribute())
1438 for (
const auto &Set : Sets)
1439 for (
const auto &
I : Set)
1440 if (!
I.isStringAttribute())
1450 for (
const auto &Set : Sets)
1451 ID.AddPointer(Set.SetNode);
1455 unsigned *Index)
const {
1460 for (
unsigned I = 0, E = NumAttrSets;
I != E; ++
I) {
1461 if (
begin()[
I].hasAttribute(Kind)) {
1472#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1484 assert(!AttrSets.
empty() &&
"pointless AttributeListImpl");
1492 pImpl->
AttrsLists.FindNodeOrInsertPos(
ID, InsertPoint);
1499 AttributeListImpl::totalSizeToAlloc<AttributeSet>(AttrSets.
size()),
1502 pImpl->
AttrsLists.InsertNode(PA, InsertPoint);
1511 ArrayRef<std::pair<unsigned, Attribute>> Attrs) {
1517 "Misordered Attributes list!");
1519 [](
const std::pair<unsigned, Attribute> &Pair) {
1520 return Pair.second.isValid();
1522 "Pointless attribute!");
1528 E = Attrs.end();
I != E; ) {
1529 unsigned Index =
I->first;
1531 while (
I != E &&
I->first == Index) {
1539 return get(
C, AttrPairVec);
1544 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs) {
1550 "Misordered Attributes list!");
1552 [](
const std::pair<unsigned, AttributeSet> &Pair) {
1553 return !Pair.second.hasAttributes();
1555 "Pointless attribute!");
1557 unsigned MaxIndex = Attrs.back().first;
1561 MaxIndex = Attrs[Attrs.size() - 2].first;
1564 for (
const auto &Pair : Attrs)
1567 return getImpl(
C, AttrVec);
1576 unsigned NumSets = 0;
1577 for (
size_t I = ArgAttrs.
size();
I != 0; --
I) {
1578 if (ArgAttrs[
I - 1].hasAttributes()) {
1608 return getImpl(
C, AttrSets);
1613 if (!Attrs.hasAttributes())
1617 AttrSets[Index] = Attrs;
1618 return getImpl(
C, AttrSets);
1629 for (
const auto K : Kinds)
1631 return get(
C, Attrs);
1637 assert(Kinds.
size() == Values.
size() &&
"Mismatched attribute values.");
1639 auto VI = Values.
begin();
1640 for (
const auto K : Kinds)
1642 return get(
C, Attrs);
1648 for (
const auto &K : Kinds)
1650 return get(
C, Attrs);
1657 if (Attrs.size() == 1)
1660 unsigned MaxSize = 0;
1661 for (
const auto &
List : Attrs)
1662 MaxSize = std::max(MaxSize,
List.getNumAttrSets());
1669 for (
unsigned I = 0;
I < MaxSize; ++
I) {
1671 for (
const auto &
List : Attrs)
1676 return getImpl(
C, NewAttrSets);
1683 if (Attrs.hasAttribute(Kind))
1695 B.addAttribute(Kind,
Value);
1711 if (Index >= AttrSets.
size())
1712 AttrSets.resize(Index + 1);
1713 AttrSets[Index] = Attrs;
1716 while (!AttrSets.
empty() && !AttrSets.
back().hasAttributes())
1717 AttrSets.pop_back();
1718 if (AttrSets.
empty())
1720 return AttributeList::getImpl(
C, AttrSets);
1726 if (!
B.hasAttributes())
1744 if (MaxIndex >= AttrSets.
size())
1745 AttrSets.
resize(MaxIndex + 1);
1747 for (
unsigned ArgNo : ArgNos) {
1754 return getImpl(
C, AttrSets);
1762 if (Attrs == NewAttrs)
1764 return setAttributesAtIndex(
C, Index, NewAttrs);
1772 if (Attrs == NewAttrs)
1774 return setAttributesAtIndex(
C, Index, NewAttrs);
1780 AttributeSet NewAttrs = Attrs.removeAttributes(
C, AttrsToRemove);
1782 if (Attrs == NewAttrs)
1784 return setAttributesAtIndex(
C, Index, NewAttrs);
1789 unsigned WithoutIndex)
const {
1794 return setAttributesAtIndex(
C, WithoutIndex,
AttributeSet());
1800 B.addDereferenceableAttr(Bytes);
1808 B.addDereferenceableAttr(Bytes);
1816 B.addDereferenceableOrNullAttr(Bytes);
1829 const std::optional<unsigned> &NumElemsArg)
const {
1831 B.addAllocSizeAttr(ElemSizeArg, NumElemsArg);
1835std::optional<AttributeList>
1844 for (
unsigned Idx : IndexIt) {
1845 auto IntersectedAS =
1849 return std::nullopt;
1850 if (!IntersectedAS->hasAttributes())
1852 IntersectedAttrs.
push_back(std::make_pair(
Idx, *IntersectedAS));
1889 return pImpl && pImpl->hasFnAttribute(Kind);
1897 unsigned *Index)
const {
1898 return pImpl && pImpl->hasAttrSomewhere(Attr, Index);
1972std::optional<ConstantRange>
1975 if (RangeAttr.isValid())
1977 return std::nullopt;
2008 return pImpl->begin()[Index];
2012 assert(!
isEmpty() &&
"an empty attribute list has no parent context");
2016 return C.pImpl->AttrsLists.FindNodeOrInsertPos(
ID, Unused) == pImpl;
2020 return pImpl ? pImpl->begin() :
nullptr;
2024 return pImpl ? pImpl->end() :
nullptr;
2032 return pImpl ? pImpl->NumAttrSets : 0;
2036 O <<
"AttributeList[\n";
2038 for (
unsigned i :
indexes()) {
2058#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2101template <
typename K>
2105 if (It != Attrs.end() && It->hasAttribute(Kind))
2108 Attrs.insert(It, Attr);
2132 if (It != Attrs.end() && It->hasAttribute(Val))
2139 if (It != Attrs.end() && It->hasAttribute(
A))
2144std::optional<uint64_t>
2149 return A.getValueAsInt();
2150 return std::nullopt;
2158std::optional<std::pair<unsigned, std::optional<unsigned>>>
2162 return A.getAllocSizeArgs();
2163 return std::nullopt;
2179 assert(*
Align <= 0x100 &&
"Alignment too large.");
2184 if (Bytes == 0)
return *
this;
2193 return addRawIntAttr(Attribute::DereferenceableOrNull, Bytes);
2198 const std::optional<unsigned> &NumElems) {
2204 assert(RawArgs &&
"Invalid allocsize arguments -- given allocsize(0, 0)");
2209 std::optional<unsigned> MaxValue) {
2249 return A.isValid() ?
A.getValueAsType() :
nullptr;
2299 if (
I.hasMetadata(LLVMContext::MD_nonnull))
2302 if (
I.hasMetadata(LLVMContext::MD_noundef))
2305 if (
const MDNode *
Align =
I.getMetadata(LLVMContext::MD_align)) {
2310 if (
const MDNode *Dereferenceable =
2311 I.getMetadata(LLVMContext::MD_dereferenceable)) {
2313 mdconst::extract<ConstantInt>(Dereferenceable->getOperand(0));
2317 if (
const MDNode *DereferenceableOrNull =
2318 I.getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
2320 mdconst::extract<ConstantInt>(DereferenceableOrNull->getOperand(0));
2324 if (
const MDNode *
Range =
I.getMetadata(LLVMContext::MD_range))
2332 for (
const auto &
I :
B.attrs())
2350 if (It != Attrs.end() && It->hasAttribute(
A))
2357 if (It != Attrs.end() && It->hasAttribute(
A))
2366 return std::nullopt;
2378 return Attrs ==
B.Attrs;
2458 return Incompatible;
2492 DenormalMode CallerModeF32 = Caller.getDenormalModeF32Raw();
2493 DenormalMode CalleeModeF32 = Callee.getDenormalModeF32Raw();
2495 CallerModeF32 = CallerMode;
2497 CalleeModeF32 = CalleeMode;
2507 return !Callee.getAttributes().hasFnAttr(Attribute::StrictFP) ||
2508 Caller.getAttributes().hasFnAttr(Attribute::StrictFP);
2511template<
typename AttrClass>
2513 return Caller.getFnAttribute(AttrClass::getKind()) ==
2514 Callee.getFnAttribute(AttrClass::getKind());
2519 return Caller.getFnAttribute(AttrName) == Callee.getFnAttribute(AttrName);
2527template<
typename AttrClass>
2529 if (AttrClass::isSet(Caller, AttrClass::getKind()) &&
2530 !AttrClass::isSet(Callee, AttrClass::getKind()))
2531 AttrClass::set(Caller, AttrClass::getKind(),
false);
2539template<
typename AttrClass>
2541 if (!AttrClass::isSet(Caller, AttrClass::getKind()) &&
2542 AttrClass::isSet(Callee, AttrClass::getKind()))
2543 AttrClass::set(Caller, AttrClass::getKind(),
true);
2552 if (!Caller.hasStackProtectorFnAttr())
2563 if (Callee.hasFnAttribute(Attribute::StackProtectReq)) {
2564 Caller.removeFnAttrs(OldSSPAttr);
2565 Caller.addFnAttr(Attribute::StackProtectReq);
2566 }
else if (Callee.hasFnAttribute(Attribute::StackProtectStrong) &&
2567 !Caller.hasFnAttribute(Attribute::StackProtectReq)) {
2568 Caller.removeFnAttrs(OldSSPAttr);
2569 Caller.addFnAttr(Attribute::StackProtectStrong);
2570 }
else if (Callee.hasFnAttribute(Attribute::StackProtect) &&
2571 !Caller.hasFnAttribute(Attribute::StackProtectReq) &&
2572 !Caller.hasFnAttribute(Attribute::StackProtectStrong))
2573 Caller.addFnAttr(Attribute::StackProtect);
2579 if (!Caller.hasFnAttribute(
"probe-stack") &&
2580 Callee.hasFnAttribute(
"probe-stack")) {
2581 Caller.addFnAttr(Callee.getFnAttribute(
"probe-stack"));
2590 Attribute CalleeAttr = Callee.getFnAttribute(
"stack-probe-size");
2592 Attribute CallerAttr = Caller.getFnAttribute(
"stack-probe-size");
2594 uint64_t CallerStackProbeSize, CalleeStackProbeSize;
2598 if (CallerStackProbeSize > CalleeStackProbeSize) {
2599 Caller.addFnAttr(CalleeAttr);
2602 Caller.addFnAttr(CalleeAttr);
2618 Attribute CallerAttr = Caller.getFnAttribute(
"min-legal-vector-width");
2620 Attribute CalleeAttr = Callee.getFnAttribute(
"min-legal-vector-width");
2622 uint64_t CallerVectorWidth, CalleeVectorWidth;
2625 if (CallerVectorWidth < CalleeVectorWidth)
2626 Caller.addFnAttr(CalleeAttr);
2630 Caller.removeFnAttr(
"min-legal-vector-width");
2639 if (Callee.nullPointerIsDefined() && !Caller.nullPointerIsDefined()) {
2640 Caller.addFnAttr(Attribute::NullPointerIsValid);
2663 return A.getValueAsString() ==
"true";
2668 Fn.
addFnAttr(Kind, Val ?
"true" :
"false");
2672#define GET_ATTR_NAMES
2673#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
2674 struct ENUM_NAME##Attr : EnumAttr { \
2675 static enum Attribute::AttrKind getKind() { \
2676 return llvm::Attribute::ENUM_NAME; \
2679#define ATTRIBUTE_STRBOOL(ENUM_NAME, DISPLAY_NAME) \
2680 struct ENUM_NAME##Attr : StrBoolAttr { \
2681 static StringRef getKind() { return #DISPLAY_NAME; } \
2683#include "llvm/IR/Attributes.inc"
2685#define GET_ATTR_COMPAT_FUNC
2686#include "llvm/IR/Attributes.inc"
2690 return hasCompatibleFnAttrs(Caller, Callee);
2695 return hasCompatibleFnAttrs(
A,
B);
2700 mergeFnAttrs(Caller, Callee);
2713 mergeFnAttrs(
Base, ToMerge);
2722 if (Width > OldWidth)
2723 Fn.
addFnAttr(
"min-legal-vector-width", llvm::utostr(Width));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines various helper methods and classes used by LLVMContextImpl for creating and managin...
static void addAttributeImpl(SmallVectorImpl< Attribute > &Attrs, K Kind, Attribute Attr)
static void setAND(Function &Caller, const Function &Callee)
Compute the logical AND of the attributes of the caller and the callee.
static void adjustCallerStackProbes(Function &Caller, const Function &Callee)
If the inlined function required stack probes, then ensure that the calling function has those too.
static std::pair< unsigned, std::optional< unsigned > > unpackVScaleRangeArgs(uint64_t Value)
static void adjustMinLegalVectorWidth(Function &Caller, const Function &Callee)
If the inlined function defines a min legal vector width, then ensure the calling function has the sa...
static void adjustCallerStackProbeSize(Function &Caller, const Function &Callee)
If the inlined function defines the size of guard region on the stack, then ensure that the calling f...
static void adjustCallerSSPLevel(Function &Caller, const Function &Callee)
If the inlined function had a higher stack protection level than the calling function,...
static bool checkStrictFP(const Function &Caller, const Function &Callee)
static uint64_t packAllocSizeArgs(unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
static uint64_t packVScaleRangeArgs(unsigned MinValue, std::optional< unsigned > MaxValue)
static bool hasIntersectProperty(Attribute::AttrKind Kind, AttributeProperty Prop)
static unsigned attrIdxToArrayIdx(unsigned Index)
Map from AttributeList index to the internal array index.
static bool denormModeCompatible(DenormalMode CallerMode, DenormalMode CalleeMode)
Callees with dynamic denormal modes are compatible with any caller mode.
static void adjustNullPointerValidAttr(Function &Caller, const Function &Callee)
If the inlined function has null_pointer_is_valid attribute, set this attribute in the caller post in...
static const unsigned AllocSizeNumElemsNotPresent
static std::pair< unsigned, std::optional< unsigned > > unpackAllocSizeArgs(uint64_t Num)
static bool checkDenormMode(const Function &Caller, const Function &Callee)
static unsigned getAttributeProperties(Attribute::AttrKind Kind)
static void setOR(Function &Caller, const Function &Callee)
Compute the logical OR of the attributes of the caller and the callee.
static bool hasAttributeProperty(Attribute::AttrKind Kind, AttributeProperty Prop)
static const char * getModRefStr(ModRefInfo MR)
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines a hash set that can be used to remove duplication of nodes in a graph.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
LLVM_ABI void Profile(FoldingSetNodeID &id) const
Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & back() const
back - Get the last element.
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
LLVM_ABI AttrBuilder & addStructRetAttr(Type *Ty)
This turns a sret type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr)
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
LLVM_ABI std::optional< uint64_t > getRawIntAttr(Attribute::AttrKind Kind) const
Return raw (possibly packed/encoded) value of integer attribute or std::nullopt if not set.
LLVM_ABI AttrBuilder & addAllocKindAttr(AllocFnKind Kind)
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return Attribute with the given Kind.
LLVM_ABI AttrBuilder & addByRefAttr(Type *Ty)
This turns a byref type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addNoFPClassAttr(FPClassTest NoFPClassMask)
LLVM_ABI AttrBuilder & addCapturesAttr(CaptureInfo CI)
Add captures attribute.
LLVM_ABI bool overlaps(const AttributeMask &AM) const
Return true if the builder has any attribute that's in the specified builder.
LLVM_ABI AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
LLVM_ABI AttrBuilder & addVScaleRangeAttr(unsigned MinValue, std::optional< unsigned > MaxValue)
This turns two ints into the form used internally in Attribute.
AttrBuilder(LLVMContext &Ctx)
LLVM_ABI AttrBuilder & addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value)
Add integer attribute with raw value (packed/encoded if necessary).
LLVM_ABI AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
LLVM_ABI AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addInitializesAttr(const ConstantRangeList &CRL)
Add initializes attribute.
LLVM_ABI bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
LLVM_ABI AttrBuilder & addMemoryAttr(MemoryEffects ME)
Add memory effect attribute.
LLVM_ABI AttrBuilder & addConstantRangeListAttr(Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)
Add a ConstantRangeList attribute with the given ranges.
LLVM_ABI AttrBuilder & addConstantRangeAttr(Attribute::AttrKind Kind, const ConstantRange &CR)
Add a ConstantRange attribute with the given range.
LLVM_ABI AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
LLVM_ABI AttrBuilder & addPreallocatedAttr(Type *Ty)
This turns a preallocated type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addInAllocaAttr(Type *Ty)
This turns an inalloca type into the form used internally in Attribute.
LLVM_ABI AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
LLVM_ABI bool operator==(const AttrBuilder &B) const
LLVM_ABI Type * getTypeAttr(Attribute::AttrKind Kind) const
Retrieve type for the given type attribute.
LLVM_ABI AttrBuilder & remove(const AttributeMask &AM)
Remove the attributes from the builder.
LLVM_ABI AttrBuilder & addFromEquivalentMetadata(const Instruction &I)
Add 0 or more parameter attributes which are equivalent to metadata attached to I.
LLVM_ABI std::optional< ConstantRange > getRange() const
Retrieve the range if the attribute exists (std::nullopt is returned otherwise).
LLVM_ABI AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addTypeAttr(Attribute::AttrKind Kind, Type *Ty)
Add a type attribute with the given type.
LLVM_ABI std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
Retrieve the allocsize args, or std::nullopt if the attribute does not exist.
LLVM_ABI AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
LLVM_ABI AttrBuilder & addRangeAttr(const ConstantRange &CR)
Add range attribute.
LLVM_ABI AttrBuilder & addUWTableAttr(UWTableKind Kind)
This turns the unwind table kind into the form used internally in Attribute.
void addAttribute(Attribute::AttrKind Kind)
bool hasAttribute(Attribute::AttrKind Kind) const
int cmp(const AttributeImpl &AI, bool KindOnly) const
Used to sort attributes.
bool isConstantRangeAttribute() const
bool hasAttribute(Attribute::AttrKind A) const
void Profile(FoldingSetNodeID &ID) const
Type * getValueAsType() const
Attribute::AttrKind getKindAsEnum() const
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
uint64_t getValueAsInt() const
bool isIntAttribute() const
bool isTypeAttribute() const
bool getValueAsBool() const
StringRef getKindAsString() const
StringRef getValueAsString() const
bool isEnumAttribute() const
ArrayRef< ConstantRange > getValueAsConstantRangeList() const
bool isConstantRangeListAttribute() const
bool isStringAttribute() const
const ConstantRange & getValueAsConstantRange() const
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value.
void Profile(FoldingSetNodeID &ID) const
AttributeListImpl(ArrayRef< AttributeSet > Sets)
friend class AttributeList
LLVM_ABI bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
LLVM_ABI Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
LLVM_ABI AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
LLVM_ABI AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
LLVM_ABI AttributeList addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const
Add the range attribute to the attribute set at the return value index.
LLVM_ABI bool hasAttributesAtIndex(unsigned Index) const
Return true if attribute exists at the given index.
friend class AttributeListImpl
LLVM_ABI AttributeSet getFnAttrs() const
The function attributes are returned.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
LLVM_ABI AttributeList removeAttributesAtIndex(LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
friend class AttributeSet
LLVM_ABI iterator begin() const
LLVM_ABI MaybeAlign getRetStackAlignment() const
Get the stack alignment of the return value.
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
LLVM_ABI void print(raw_ostream &O) const
LLVM_ABI AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
static LLVM_ABI AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
LLVM_ABI AllocFnKind getAllocKind() const
bool isEmpty() const
Return true if there are no attributes.
LLVM_ABI AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
LLVM_ABI bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
LLVM_ABI uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
LLVM_ABI MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
LLVM_ABI bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value.
LLVM_ABI iterator end() const
LLVM_ABI Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
LLVM_ABI unsigned getNumAttrSets() const
LLVM_ABI FPClassTest getRetNoFPClass() const
Get the disallowed floating-point classes of the return value.
LLVM_ABI std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
LLVM_ABI UWTableKind getUWTableKind() const
Get the unwind table kind requested for the function.
LLVM_ABI MaybeAlign getRetAlignment() const
Return the alignment of the return value.
LLVM_ABI Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
LLVM_ABI Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
LLVM_ABI Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute list belongs to the LLVMContext.
const AttributeSet * iterator
LLVM_ABI MaybeAlign getFnStackAlignment() const
Get the stack alignment of the function.
LLVM_ABI AttributeList addAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
LLVM_ABI Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
LLVM_ABI MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
LLVM_ABI uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
LLVM_ABI AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg) const
Add the allocsize attribute to the attribute set at the given arg index.
LLVM_ABI uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
LLVM_ABI AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
LLVM_ABI AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
LLVM_ABI FPClassTest getParamNoFPClass(unsigned ArgNo) const
Get the disallowed floating-point classes of the argument value.
LLVM_ABI std::optional< AttributeList > intersectWith(LLVMContext &C, AttributeList Other) const
Try to intersect this AttributeList with Other.
LLVM_ABI Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
LLVM_ABI AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
LLVM_ABI AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
LLVM_ABI std::optional< ConstantRange > getParamRange(unsigned ArgNo) const
Get range (or std::nullopt if unknown) of an arg.
LLVM_ABI uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
LLVM_ABI void dump() const
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
LLVM_ABI MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
AttributeMask & addAttribute(Attribute::AttrKind Val)
Add an attribute to the mask.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
MaybeAlign getStackAlignment() const
uint64_t getDereferenceableOrNullBytes() const
std::optional< unsigned > getVScaleRangeMax() const
bool hasAttribute(Attribute::AttrKind Kind) const
Type * getAttributeType(Attribute::AttrKind Kind) const
AllocFnKind getAllocKind() const
CaptureInfo getCaptureInfo() const
unsigned getVScaleRangeMin() const
MaybeAlign getAlignment() const
MemoryEffects getMemoryEffects() const
UWTableKind getUWTableKind() const
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
uint64_t getDereferenceableBytes() const
unsigned getNumAttributes() const
Return the number of attributes this AttributeList contains.
void Profile(FoldingSetNodeID &ID) const
std::string getAsString(bool InAttrGrp) const
static AttributeSetNode * get(LLVMContext &C, const AttrBuilder &B)
FPClassTest getNoFPClass() const
Attribute getAttribute(Attribute::AttrKind Kind) const
LLVM_ABI AllocFnKind getAllocKind() const
bool hasAttributes() const
Return true if attributes exists in this set.
LLVM_ABI AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
LLVM_ABI Type * getInAllocaType() const
LLVM_ABI Type * getByValType() const
LLVM_ABI AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
LLVM_ABI MemoryEffects getMemoryEffects() const
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
LLVM_ABI std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
LLVM_ABI Type * getStructRetType() const
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
LLVM_ABI unsigned getVScaleRangeMin() const
LLVM_ABI std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
LLVM_ABI UWTableKind getUWTableKind() const
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
LLVM_ABI iterator begin() const
LLVM_ABI iterator end() const
LLVM_ABI AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attributes from this set.
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
LLVM_ABI MaybeAlign getStackAlignment() const
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
LLVM_ABI Type * getPreallocatedType() const
LLVM_ABI uint64_t getDereferenceableBytes() const
LLVM_ABI MaybeAlign getAlignment() const
LLVM_ABI FPClassTest getNoFPClass() const
LLVM_ABI Type * getElementType() const
LLVM_ABI Type * getByRefType() const
LLVM_ABI CaptureInfo getCaptureInfo() const
AttributeSet()=default
AttributeSet is a trivially copyable value type.
static LLVM_ABI AttributeSet get(LLVMContext &C, const AttrBuilder &B)
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
LLVM_ABI unsigned getNumAttributes() const
Return the number of attributes in this set.
LLVM_ABI AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
LLVM_ABI bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
static LLVM_ABI Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
static LLVM_ABI Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
LLVM_ABI bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
static LLVM_ABI Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
LLVM_ABI const ConstantRange & getRange() const
Returns the value of the range attribute.
static LLVM_ABI bool intersectWithCustom(AttrKind Kind)
LLVM_ABI bool isIntAttribute() const
Return true if the attribute is an integer attribute.
static LLVM_ABI Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
LLVM_ABI uint64_t getValueAsInt() const
Return the attribute's value as an integer.
LLVM_ABI unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
LLVM_ABI AllocFnKind getAllocKind() const
LLVM_ABI bool isConstantRangeAttribute() const
Return true if the attribute is a ConstantRange attribute.
static LLVM_ABI Attribute getWithAllocKind(LLVMContext &Context, AllocFnKind Kind)
LLVM_ABI StringRef getKindAsString() const
Return the attribute's kind as a string.
static LLVM_ABI Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
static LLVM_ABI bool intersectWithMin(AttrKind Kind)
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static LLVM_ABI bool canUseAsRetAttr(AttrKind Kind)
static bool isTypeAttrKind(AttrKind Kind)
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
static LLVM_ABI Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
LLVM_ABI std::pair< unsigned, std::optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute.
static LLVM_ABI Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
LLVM_ABI FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
static LLVM_ABI Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
LLVM_ABI Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
LLVM_ABI bool getValueAsBool() const
Return the attribute's value as a boolean.
LLVM_ABI ArrayRef< ConstantRange > getInitializes() const
Returns the value of the initializes attribute.
LLVM_ABI const ConstantRange & getValueAsConstantRange() const
Return the attribute's value as a ConstantRange.
LLVM_ABI uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
static LLVM_ABI Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
LLVM_ABI MemoryEffects getMemoryEffects() const
Returns memory effects.
LLVM_ABI void Profile(FoldingSetNodeID &ID) const
LLVM_ABI UWTableKind getUWTableKind() const
static LLVM_ABI Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
LLVM_ABI ArrayRef< ConstantRange > getValueAsConstantRangeList() const
Return the attribute's value as a ConstantRange array.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
static LLVM_ABI bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
bool hasKindAsEnum() const
Returns true if the attribute's kind can be represented as an enum (Enum, Integer,...
static LLVM_ABI StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
static LLVM_ABI bool canUseAsFnAttr(AttrKind Kind)
static LLVM_ABI bool intersectWithAnd(AttrKind Kind)
static LLVM_ABI Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
@ EndAttrKinds
Sentinel value useful for loops.
static bool isConstantRangeAttrKind(AttrKind Kind)
LLVM_ABI bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
LLVM_ABI bool isTypeAttribute() const
Return true if the attribute is a type attribute.
static LLVM_ABI Attribute getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI)
static LLVM_ABI Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
static bool isIntAttrKind(AttrKind Kind)
static bool isConstantRangeListAttrKind(AttrKind Kind)
LLVM_ABI bool isConstantRangeListAttribute() const
Return true if the attribute is a ConstantRangeList attribute.
static LLVM_ABI Attribute getWithByValType(LLVMContext &Context, Type *Ty)
LLVM_ABI bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
static bool isEnumAttrKind(AttrKind Kind)
static LLVM_ABI Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
static LLVM_ABI bool canUseAsParamAttr(AttrKind Kind)
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM_ABI MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
LLVM_ABI MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
LLVM_ABI CaptureInfo getCaptureInfo() const
Returns information from captures attribute.
static LLVM_ABI bool intersectMustPreserve(AttrKind Kind)
LLVM_ABI int cmpKind(Attribute A) const
Used to sort attribute by kind.
LLVM_ABI bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM_ABI Type * getValueAsType() const
Return the attribute's value as a Type.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Represents which components of the pointer may be captured in which location.
static CaptureInfo createFromIntValue(uint32_t Data)
static CaptureInfo all()
Create CaptureInfo that may capture all components of the pointer.
uint32_t toIntValue() const
Convert CaptureInfo into an encoded integer value (used by captures attribute).
This is the shared class of boolean and integer constants.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static size_t totalSizeToAlloc(ArrayRef< ConstantRange > Val)
This class represents a list of constant ranges.
ArrayRef< ConstantRange > rangesRef() const
LLVM_ABI void print(raw_ostream &OS) const
Print out the ranges to a stream.
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
LLVM_ABI bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
const APInt & getUpper() const
Return the upper value for this range.
LLVM_ABI ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
static bool isSupportedFloatingPointType(Type *Ty)
Returns true if Ty is a supported floating-point type for phi, select, or call FPMathOperators.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
FoldingSet< AttributeImpl > AttrsSet
FoldingSet< AttributeSetNode > AttrsSetNodes
FoldingSet< AttributeListImpl > AttrsLists
SpecificBumpPtrAllocator< ConstantRangeAttributeImpl > ConstantRangeAttributeAlloc
std::vector< ConstantRangeListAttributeImpl * > ConstantRangeListAttributes
This is an important class for using LLVM in a threaded context.
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
static MemoryEffectsBase createFromIntValue(uint32_t Data)
Create MemoryEffectsBase from an encoded integer value (used by memory attribute).
static auto locations()
Returns iterator over all supported location kinds.
uint32_t toIntValue() const
Convert MemoryEffectsBase into an encoded integer value (used by memory attribute).
static MemoryEffectsBase unknown()
Create MemoryEffectsBase that can read and write any memory.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static size_t totalSizeToAlloc(StringRef Kind, StringRef Val)
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
int compare(StringRef RHS) const
compare - Compare two strings; the result is negative, zero, or positive if this string is lexicograp...
A switch()-like statement whose cases are string literals.
const T * getTrailingObjects() const
Returns a pointer to the trailing object array of the given type (which must be one of those specifie...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isPointerTy() const
True if this is an instance of PointerType.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
bool isVoidTy() const
Return true if this is 'void'.
LLVM Value Representation.
static constexpr uint64_t MaximumAlignment
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
This class provides various memory handling functions that manipulate MemoryBlock instances.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI bool areInlineCompatible(const Function &Caller, const Function &Callee)
LLVM_ABI AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
LLVM_ABI bool isNoFPClassCompatibleType(Type *Ty)
Returns true if this is a type legal for the 'nofpclass' attribute.
LLVM_ABI bool areOutlineCompatible(const Function &A, const Function &B)
Checks if there are any incompatible function attributes between A and B.
LLVM_ABI void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
LLVM_ABI void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
LLVM_ABI AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
LLVM_ABI void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
LLVM_ABI ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
@ None
No unwind table requested.
void sort(IteratorTy Start, IteratorTy End)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
@ Ref
The access may reference the value stored in memory.
@ ModRef
The access may reference and may modify the value stored in memory.
@ Mod
The access may modify the value stored in memory.
@ NoModRef
The access neither references nor modifies the value stored in memory.
@ ArgMem
Access to memory via argument pointers.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
OutputIt copy(R &&Range, OutputIt Out)
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Attribute comparator that only compares attribute keys.
bool operator()(Attribute A0, StringRef Kind) const
bool operator()(Attribute A0, Attribute A1) const
bool operator()(Attribute A0, Attribute::AttrKind Kind) const
static void set(Function &Fn, Attribute::AttrKind Kind, bool Val)
static bool isSet(const Function &Fn, Attribute::AttrKind Kind)
static bool isSet(const Function &Fn, StringRef Kind)
static void set(Function &Fn, StringRef Kind, bool Val)
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind Input
Denormal treatment kind for floating point instruction inputs in the default floating-point environme...
@ Dynamic
Denormals have unknown treatment.
static constexpr DenormalMode getInvalid()
DenormalModeKind Output
Denormal flushing mode for floating point instruction results in the default floating point environme...
static constexpr DenormalMode getDynamic()
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
Function object to check whether the first component of a container supported by std::get (like std::...