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);
962 if (!
B.hasAttributes())
967 return get(
C, Merged);
974 B.removeAttribute(Kind);
982 B.removeAttribute(Kind);
990 if (!
B.overlaps(Attrs))
997std::optional<AttributeSet>
1004 auto ItBegin0 =
begin();
1005 auto ItEnd0 =
end();
1006 auto ItBegin1 =
Other.begin();
1007 auto ItEnd1 =
Other.end();
1009 while (ItBegin0 != ItEnd0 || ItBegin1 != ItEnd1) {
1014 if (ItBegin1 == ItEnd1)
1015 Attr0 = *ItBegin0++;
1016 else if (ItBegin0 == ItEnd0)
1017 Attr0 = *ItBegin1++;
1019 int Cmp = ItBegin0->cmpKind(*ItBegin1);
1021 Attr0 = *ItBegin0++;
1022 Attr1 = *ItBegin1++;
1024 Attr0 = *ItBegin0++;
1026 Attr0 = *ItBegin1++;
1028 assert(Attr0.
isValid() &&
"Iteration should always yield a valid attr");
1030 auto IntersectEq = [&]() {
1043 return std::nullopt;
1052 return std::nullopt;
1058 "Iterator picked up two different attributes in the same iteration");
1063 "Invalid attr type of intersectAnd");
1071 "Invalid attr type of intersectMin");
1079 case Attribute::Alignment:
1086 case Attribute::Memory:
1090 case Attribute::Captures:
1094 case Attribute::NoFPClass:
1098 case Attribute::Range: {
1114 return std::nullopt;
1118 if (Kind == Attribute::ByVal &&
1120 Other.getAttribute(Attribute::Alignment))
1121 return std::nullopt;
1124 return get(
C, Intersected);
1148 return SetNode ? SetNode->
getAlignment() : std::nullopt;
1172 return SetNode ? SetNode->
getAttributeType(Attribute::StructRet) :
nullptr;
1176 return SetNode ? SetNode->
getAttributeType(Attribute::Preallocated) :
nullptr;
1184 return SetNode ? SetNode->
getAttributeType(Attribute::ElementType) :
nullptr;
1187std::optional<std::pair<unsigned, std::optional<unsigned>>>
1191 return std::nullopt;
1223 return SetNode ? SetNode->
getAsString(InAttrGrp) :
"";
1231 return C.pImpl->AttrsSetNodes.FindNodeOrInsertPos(
ID, Unused) == SetNode;
1235 return SetNode ? SetNode->
begin() :
nullptr;
1239 return SetNode ? SetNode->
end() :
nullptr;
1242#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1255 : NumAttrs(Attrs.
size()) {
1259 for (
const auto &
I : *
this) {
1260 if (
I.isStringAttribute())
1261 StringAttrs.insert({
I.getKindAsString(),
I });
1263 AvailableAttrs.addAttribute(
I.getKindAsEnum());
1271 return getSorted(
C, SortedAttrs);
1276 if (SortedAttrs.
empty())
1284 for (
const auto &Attr : SortedAttrs)
1295 void *Mem = ::operator
new(totalSizeToAlloc<Attribute>(SortedAttrs.size()));
1305 return getSorted(
C,
B.attrs());
1309 return StringAttrs.count(Kind);
1312std::optional<Attribute>
1316 return std::nullopt;
1321 std::lower_bound(
begin(),
end() - StringAttrs.size(), Kind,
1323 return A.getKindAsEnum() < Kind;
1325 assert(
I !=
end() &&
I->hasAttribute(Kind) &&
"Presence check failed?");
1330 if (
auto A = findEnumAttribute(Kind))
1336 return StringAttrs.lookup(Kind);
1340 if (
auto A = findEnumAttribute(Attribute::Alignment))
1341 return A->getAlignment();
1342 return std::nullopt;
1346 if (
auto A = findEnumAttribute(Attribute::StackAlignment))
1347 return A->getStackAlignment();
1348 return std::nullopt;
1352 if (
auto A = findEnumAttribute(Kind))
1353 return A->getValueAsType();
1358 if (
auto A = findEnumAttribute(Attribute::Dereferenceable))
1359 return A->getDereferenceableBytes();
1364 if (
auto A = findEnumAttribute(Attribute::DereferenceableOrNull))
1365 return A->getDereferenceableOrNullBytes();
1369std::optional<std::pair<unsigned, std::optional<unsigned>>>
1371 if (
auto A = findEnumAttribute(Attribute::AllocSize))
1372 return A->getAllocSizeArgs();
1373 return std::nullopt;
1377 if (
auto A = findEnumAttribute(Attribute::VScaleRange))
1378 return A->getVScaleRangeMin();
1383 if (
auto A = findEnumAttribute(Attribute::VScaleRange))
1384 return A->getVScaleRangeMax();
1385 return std::nullopt;
1389 if (
auto A = findEnumAttribute(Attribute::UWTable))
1390 return A->getUWTableKind();
1395 if (
auto A = findEnumAttribute(Attribute::AllocKind))
1396 return A->getAllocKind();
1401 if (
auto A = findEnumAttribute(Attribute::Memory))
1402 return A->getMemoryEffects();
1407 if (
auto A = findEnumAttribute(Attribute::Captures))
1408 return A->getCaptureInfo();
1413 if (
auto A = findEnumAttribute(Attribute::NoFPClass))
1414 return A->getNoFPClass();
1423 Str +=
I->getAsString(InAttrGrp);
1439 : NumAttrSets(Sets.
size()) {
1440 assert(!Sets.
empty() &&
"pointless AttributeListImpl");
1448 if (!
I.isStringAttribute())
1451 for (
const auto &Set : Sets)
1452 for (
const auto &
I : Set)
1453 if (!
I.isStringAttribute())
1463 for (
const auto &Set : Sets)
1464 ID.AddPointer(Set.SetNode);
1468 unsigned *Index)
const {
1473 for (
unsigned I = 0, E = NumAttrSets;
I != E; ++
I) {
1474 if (
begin()[
I].hasAttribute(Kind)) {
1485#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1497 assert(!AttrSets.
empty() &&
"pointless AttributeListImpl");
1505 pImpl->
AttrsLists.FindNodeOrInsertPos(
ID, InsertPoint);
1512 AttributeListImpl::totalSizeToAlloc<AttributeSet>(AttrSets.
size()),
1515 pImpl->
AttrsLists.InsertNode(PA, InsertPoint);
1524 ArrayRef<std::pair<unsigned, Attribute>> Attrs) {
1530 "Misordered Attributes list!");
1532 [](
const std::pair<unsigned, Attribute> &Pair) {
1533 return Pair.second.isValid();
1535 "Pointless attribute!");
1541 E = Attrs.end();
I != E; ) {
1542 unsigned Index =
I->first;
1544 while (
I != E &&
I->first == Index) {
1552 return get(
C, AttrPairVec);
1557 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs) {
1563 "Misordered Attributes list!");
1565 [](
const std::pair<unsigned, AttributeSet> &Pair) {
1566 return !Pair.second.hasAttributes();
1568 "Pointless attribute!");
1570 unsigned MaxIndex = Attrs.back().first;
1574 MaxIndex = Attrs[Attrs.size() - 2].first;
1577 for (
const auto &Pair : Attrs)
1580 return getImpl(
C, AttrVec);
1589 unsigned NumSets = 0;
1590 for (
size_t I = ArgAttrs.
size();
I != 0; --
I) {
1591 if (ArgAttrs[
I - 1].hasAttributes()) {
1621 return getImpl(
C, AttrSets);
1626 if (!Attrs.hasAttributes())
1630 AttrSets[Index] = Attrs;
1631 return getImpl(
C, AttrSets);
1642 for (
const auto K : Kinds)
1644 return get(
C, Attrs);
1650 assert(Kinds.
size() == Values.
size() &&
"Mismatched attribute values.");
1652 auto VI = Values.
begin();
1653 for (
const auto K : Kinds)
1655 return get(
C, Attrs);
1661 for (
const auto &K : Kinds)
1663 return get(
C, Attrs);
1670 if (Attrs.size() == 1)
1673 unsigned MaxSize = 0;
1674 for (
const auto &
List : Attrs)
1675 MaxSize = std::max(MaxSize,
List.getNumAttrSets());
1682 for (
unsigned I = 0;
I < MaxSize; ++
I) {
1684 for (
const auto &
List : Attrs)
1689 return getImpl(
C, NewAttrSets);
1696 if (Attrs.hasAttribute(Kind))
1708 B.addAttribute(Kind,
Value);
1724 if (Index >= AttrSets.
size())
1725 AttrSets.resize(Index + 1);
1726 AttrSets[Index] = Attrs;
1729 while (!AttrSets.
empty() && !AttrSets.
back().hasAttributes())
1730 AttrSets.pop_back();
1731 if (AttrSets.
empty())
1733 return AttributeList::getImpl(
C, AttrSets);
1739 if (!
B.hasAttributes())
1757 if (MaxIndex >= AttrSets.
size())
1758 AttrSets.
resize(MaxIndex + 1);
1760 for (
unsigned ArgNo : ArgNos) {
1767 return getImpl(
C, AttrSets);
1775 if (Attrs == NewAttrs)
1777 return setAttributesAtIndex(
C, Index, NewAttrs);
1785 if (Attrs == NewAttrs)
1787 return setAttributesAtIndex(
C, Index, NewAttrs);
1793 AttributeSet NewAttrs = Attrs.removeAttributes(
C, AttrsToRemove);
1795 if (Attrs == NewAttrs)
1797 return setAttributesAtIndex(
C, Index, NewAttrs);
1802 unsigned WithoutIndex)
const {
1807 return setAttributesAtIndex(
C, WithoutIndex,
AttributeSet());
1813 B.addDereferenceableAttr(Bytes);
1821 B.addDereferenceableAttr(Bytes);
1829 B.addDereferenceableOrNullAttr(Bytes);
1842 const std::optional<unsigned> &NumElemsArg)
const {
1844 B.addAllocSizeAttr(ElemSizeArg, NumElemsArg);
1848std::optional<AttributeList>
1857 for (
unsigned Idx : IndexIt) {
1858 auto IntersectedAS =
1862 return std::nullopt;
1863 if (!IntersectedAS->hasAttributes())
1865 IntersectedAttrs.
push_back(std::make_pair(
Idx, *IntersectedAS));
1902 return pImpl && pImpl->hasFnAttribute(Kind);
1910 unsigned *Index)
const {
1911 return pImpl && pImpl->hasAttrSomewhere(Attr, Index);
1985std::optional<ConstantRange>
1988 if (RangeAttr.isValid())
1990 return std::nullopt;
2021 return pImpl->begin()[Index];
2025 assert(!
isEmpty() &&
"an empty attribute list has no parent context");
2029 return C.pImpl->AttrsLists.FindNodeOrInsertPos(
ID, Unused) == pImpl;
2033 return pImpl ? pImpl->begin() :
nullptr;
2037 return pImpl ? pImpl->end() :
nullptr;
2045 return pImpl ? pImpl->NumAttrSets : 0;
2049 O <<
"AttributeList[\n";
2051 for (
unsigned i :
indexes()) {
2071#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2114template <
typename K>
2118 if (It != Attrs.end() && It->hasAttribute(Kind))
2121 Attrs.insert(It, Attr);
2145 if (It != Attrs.end() && It->hasAttribute(Val))
2152 if (It != Attrs.end() && It->hasAttribute(
A))
2157std::optional<uint64_t>
2162 return A.getValueAsInt();
2163 return std::nullopt;
2171std::optional<std::pair<unsigned, std::optional<unsigned>>>
2175 return A.getAllocSizeArgs();
2176 return std::nullopt;
2192 assert(*
Align <= 0x100 &&
"Alignment too large.");
2197 if (Bytes == 0)
return *
this;
2206 return addRawIntAttr(Attribute::DereferenceableOrNull, Bytes);
2211 const std::optional<unsigned> &NumElems) {
2217 assert(RawArgs &&
"Invalid allocsize arguments -- given allocsize(0, 0)");
2222 std::optional<unsigned> MaxValue) {
2262 return A.isValid() ?
A.getValueAsType() :
nullptr;
2312 if (
I.hasMetadata(LLVMContext::MD_nonnull))
2315 if (
I.hasMetadata(LLVMContext::MD_noundef))
2318 if (
const MDNode *
Align =
I.getMetadata(LLVMContext::MD_align)) {
2323 if (
const MDNode *Dereferenceable =
2324 I.getMetadata(LLVMContext::MD_dereferenceable)) {
2326 mdconst::extract<ConstantInt>(Dereferenceable->getOperand(0));
2330 if (
const MDNode *DereferenceableOrNull =
2331 I.getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
2333 mdconst::extract<ConstantInt>(DereferenceableOrNull->getOperand(0));
2337 if (
const MDNode *
Range =
I.getMetadata(LLVMContext::MD_range))
2345 for (
const auto &
I :
B.attrs())
2363 if (It != Attrs.end() && It->hasAttribute(
A))
2370 if (It != Attrs.end() && It->hasAttribute(
A))
2379 return std::nullopt;
2391 return Attrs ==
B.Attrs;
2471 return Incompatible;
2505 DenormalMode CallerModeF32 = Caller.getDenormalModeF32Raw();
2506 DenormalMode CalleeModeF32 = Callee.getDenormalModeF32Raw();
2508 CallerModeF32 = CallerMode;
2510 CalleeModeF32 = CalleeMode;
2520 return !Callee.getAttributes().hasFnAttr(Attribute::StrictFP) ||
2521 Caller.getAttributes().hasFnAttr(Attribute::StrictFP);
2524template<
typename AttrClass>
2526 return Caller.getFnAttribute(AttrClass::getKind()) ==
2527 Callee.getFnAttribute(AttrClass::getKind());
2532 return Caller.getFnAttribute(AttrName) == Callee.getFnAttribute(AttrName);
2540template<
typename AttrClass>
2542 if (AttrClass::isSet(Caller, AttrClass::getKind()) &&
2543 !AttrClass::isSet(Callee, AttrClass::getKind()))
2544 AttrClass::set(Caller, AttrClass::getKind(),
false);
2552template<
typename AttrClass>
2554 if (!AttrClass::isSet(Caller, AttrClass::getKind()) &&
2555 AttrClass::isSet(Callee, AttrClass::getKind()))
2556 AttrClass::set(Caller, AttrClass::getKind(),
true);
2565 if (!Caller.hasStackProtectorFnAttr())
2576 if (Callee.hasFnAttribute(Attribute::StackProtectReq)) {
2577 Caller.removeFnAttrs(OldSSPAttr);
2578 Caller.addFnAttr(Attribute::StackProtectReq);
2579 }
else if (Callee.hasFnAttribute(Attribute::StackProtectStrong) &&
2580 !Caller.hasFnAttribute(Attribute::StackProtectReq)) {
2581 Caller.removeFnAttrs(OldSSPAttr);
2582 Caller.addFnAttr(Attribute::StackProtectStrong);
2583 }
else if (Callee.hasFnAttribute(Attribute::StackProtect) &&
2584 !Caller.hasFnAttribute(Attribute::StackProtectReq) &&
2585 !Caller.hasFnAttribute(Attribute::StackProtectStrong))
2586 Caller.addFnAttr(Attribute::StackProtect);
2592 if (!Caller.hasFnAttribute(
"probe-stack") &&
2593 Callee.hasFnAttribute(
"probe-stack")) {
2594 Caller.addFnAttr(Callee.getFnAttribute(
"probe-stack"));
2603 Attribute CalleeAttr = Callee.getFnAttribute(
"stack-probe-size");
2605 Attribute CallerAttr = Caller.getFnAttribute(
"stack-probe-size");
2607 uint64_t CallerStackProbeSize, CalleeStackProbeSize;
2611 if (CallerStackProbeSize > CalleeStackProbeSize) {
2612 Caller.addFnAttr(CalleeAttr);
2615 Caller.addFnAttr(CalleeAttr);
2631 Attribute CallerAttr = Caller.getFnAttribute(
"min-legal-vector-width");
2633 Attribute CalleeAttr = Callee.getFnAttribute(
"min-legal-vector-width");
2635 uint64_t CallerVectorWidth, CalleeVectorWidth;
2638 if (CallerVectorWidth < CalleeVectorWidth)
2639 Caller.addFnAttr(CalleeAttr);
2643 Caller.removeFnAttr(
"min-legal-vector-width");
2652 if (Callee.nullPointerIsDefined() && !Caller.nullPointerIsDefined()) {
2653 Caller.addFnAttr(Attribute::NullPointerIsValid);
2676 return A.getValueAsString() ==
"true";
2681 Fn.
addFnAttr(Kind, Val ?
"true" :
"false");
2685#define GET_ATTR_NAMES
2686#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
2687 struct ENUM_NAME##Attr : EnumAttr { \
2688 static enum Attribute::AttrKind getKind() { \
2689 return llvm::Attribute::ENUM_NAME; \
2692#define ATTRIBUTE_STRBOOL(ENUM_NAME, DISPLAY_NAME) \
2693 struct ENUM_NAME##Attr : StrBoolAttr { \
2694 static StringRef getKind() { return #DISPLAY_NAME; } \
2696#include "llvm/IR/Attributes.inc"
2698#define GET_ATTR_COMPAT_FUNC
2699#include "llvm/IR/Attributes.inc"
2703 return hasCompatibleFnAttrs(Caller, Callee);
2708 return hasCompatibleFnAttrs(
A,
B);
2713 mergeFnAttrs(Caller, Callee);
2726 mergeFnAttrs(
Base, ToMerge);
2735 if (Width > OldWidth)
2736 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::...