51 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
71 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
79 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
80 assert(Align <= 0x40000000 &&
"Alignment too large.");
86 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
87 assert(Align <= 0x100 &&
"Alignment too large.");
93 assert(Bytes &&
"Bytes must be non-zero.");
99 assert(Bytes &&
"Bytes must be non-zero.");
120 if (!pImpl)
return None;
122 "Invalid attribute type to get the kind as an enum!");
127 if (!pImpl)
return 0;
129 "Expected the attribute to be an integer attribute!");
136 "Invalid attribute type to get the kind as a string!");
143 "Invalid attribute type to get the value as a string!");
159 "Trying to get alignment from non-alignment attribute!");
167 "Trying to get alignment from non-alignment attribute!");
174 "Trying to get dereferenceable bytes from "
175 "non-dereferenceable attribute!");
181 "Trying to get dereferenceable bytes from "
182 "non-dereferenceable attribute!");
187 if (!pImpl)
return "";
190 return "sanitize_address";
192 return "alwaysinline";
222 return "noduplicate";
224 return "noimplicitfloat";
228 return "nonlazybind";
248 return "returns_twice";
262 return "sanitize_thread";
264 return "sanitize_memory";
280 Result += (InAttrGrp) ?
"=" :
" ";
285 auto AttrWithBytesToString = [&](
const char *
Name) {
300 return AttrWithBytesToString(
"alignstack");
303 return AttrWithBytesToString(
"dereferenceable");
306 return AttrWithBytesToString(
"dereferenceable_or_null");
318 if (Val.
empty())
return Result;
320 Result += (
"=\"" + Val +
Twine(
'"')).str();
328 if (!pImpl && !A.pImpl)
return false;
329 if (!pImpl)
return true;
330 if (!A.pImpl)
return false;
331 return *pImpl < *A.pImpl;
340 void EnumAttributeImpl::anchor() {}
341 void IntAttributeImpl::anchor() {}
342 void StringAttributeImpl::anchor() {}
476 E = SortedAttrs.end();
I != E; ++
I)
499 if (
I->hasAttribute(Kind))
506 if (
I->hasAttribute(Kind))
513 if (
I->hasAttribute(Kind))
520 if (
I->hasAttribute(Kind))
528 return I->getAlignment();
535 return I->getStackAlignment();
542 return I->getDereferenceableBytes();
549 return I->getDereferenceableOrNullBytes();
558 Str +=
I->getAsString(InAttrGrp);
574 IE = ASN->
end(); II !=
IE; ++II) {
599 AttributeSet(const_cast<AttributeSetImpl *>(
this)).dump();
608 ArrayRef<std::pair<unsigned, AttributeSetNode*> > Attrs) {
621 sizeof(std::pair<unsigned, AttributeSetNode *>) *
624 pImpl->
AttrsLists.InsertNode(PA, InsertPoint);
632 ArrayRef<std::pair<unsigned, Attribute> > Attrs){
638 for (
unsigned i = 0, e = Attrs.size(); i != e; ++i) {
639 assert((!i || Attrs[i-1].first <= Attrs[i].first) &&
640 "Misordered Attributes list!");
642 "Pointless attribute!");
650 E = Attrs.end();
I != E; ) {
651 unsigned Index =
I->first;
653 while (
I != E &&
I->first == Index) {
658 AttrPairVec.
push_back(std::make_pair(Index,
662 return getImpl(C, AttrPairVec);
672 return getImpl(C, Attrs);
710 return get(
C, Attrs);
717 E = Kind.
end();
I != E; ++
I)
719 return get(
C, Attrs);
724 if (Attrs.
size() == 1)
return Attrs[0];
734 for (
unsigned I = 1, E = Attrs.
size();
I != E; ++
I) {
738 ANVI = AttrNodeVec.
begin(), ANVE;
740 *AI = AS->getNode(0),
743 ANVE = AttrNodeVec.
end();
744 while (ANVI != ANVE && ANVI->first <= AI->first)
746 ANVI = AttrNodeVec.
insert(ANVI, *AI) + 1;
750 return getImpl(C, AttrNodeVec);
756 return addAttributes(C, Index, AttributeSet::get(C, Index, Attr));
763 return addAttributes(C, Index, AttributeSet::get(C, Index, B));
770 return addAttributes(C, Index, AttributeSet::get(C, Index, B));
775 if (!pImpl)
return Attrs;
776 if (!Attrs.pImpl)
return *
this;
783 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
784 "Attempt to change alignment!");
789 uint64_t NumAttrs = pImpl->getNumAttributes();
791 uint64_t LastIndex = 0;
792 for (
unsigned I = 0, E = NumAttrs;
I != E; ++
I) {
808 IE = Attrs.pImpl->
end(
I); II !=
IE; ++II)
813 AttrSet.
push_back(AttributeSet::get(C, Index, B));
816 for (
unsigned I = LastIndex, E = NumAttrs;
I < E; ++
I)
819 return get(
C, AttrSet);
831 if (!Attrs.pImpl)
return *
this;
836 "Attempt to change alignment!");
840 uint64_t NumAttrs = pImpl->getNumAttributes();
842 uint64_t LastIndex = 0;
843 for (
unsigned I = 0, E = NumAttrs;
I != E; ++
I) {
862 AttrSet.push_back(AttributeSet::get(C, Index, B));
865 for (
unsigned I = LastIndex, E = NumAttrs;
I < E; ++
I)
868 return get(
C, AttrSet);
881 uint64_t NumAttrs = pImpl->getNumAttributes();
883 uint64_t LastIndex = 0;
884 for (
unsigned I = 0, E = NumAttrs;
I != E; ++
I) {
898 AttrSet.push_back(AttributeSet::get(C, Index, B));
901 for (
unsigned I = LastIndex, E = NumAttrs;
I < E; ++
I)
904 return get(
C, AttrSet);
908 uint64_t Bytes)
const {
911 return addAttributes(C, Index, AttributeSet::get(C, Index, B));
916 uint64_t Bytes)
const {
919 return addAttributes(C, Index, AttributeSet::get(C, Index, B));
927 return pImpl->getContext();
932 AttributeSet::get(pImpl->getContext(),
940 AttributeSet::get(pImpl->getContext(),
949 AttributeSet::get(pImpl->getContext(),
974 if (!pImpl)
return false;
976 for (
unsigned I = 0, E = pImpl->getNumAttributes();
I != E; ++
I)
978 IE = pImpl->end(
I); II !=
IE; ++II)
979 if (II->hasAttribute(Attr))
1018 bool InAttrGrp)
const {
1020 return ASN ? ASN->
getAsString(InAttrGrp) : std::string(
"");
1025 if (!pImpl)
return nullptr;
1028 for (
unsigned I = 0, E = pImpl->getNumAttributes();
I != E; ++
I)
1029 if (pImpl->getSlotIndex(
I) == Index)
1030 return pImpl->getSlotNode(
I);
1038 return pImpl->begin(Slot);
1044 return pImpl->end(Slot);
1055 return pImpl ? pImpl->getNumAttributes() : 0;
1059 assert(pImpl && Slot < pImpl->getNumAttributes() &&
1060 "Slot # out of range!");
1061 return pImpl->getSlotIndex(Slot);
1065 assert(pImpl && Slot < pImpl->getNumAttributes() &&
1066 "Slot # out of range!");
1067 return pImpl->getSlotAttributes(Slot);
1072 return pImpl ? pImpl->Raw(Index) : 0;
1078 for (
unsigned i = 0, e =
getNumSlots(); i < e; ++i) {
1096 : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
1097 DerefOrNullBytes(0) {
1105 IE = pImpl->
end(
I); II !=
IE; ++II)
1114 Alignment = StackAlignment = DerefBytes = DerefOrNullBytes = 0;
1121 "Adding integer attribute without adding a value!");
1147 TargetDepAttrs[
A] = V;
1162 DerefOrNullBytes = 0;
1168 unsigned Slot = ~0U;
1175 assert(Slot != ~0U &&
"Couldn't find index in AttributeSet!");
1181 Attrs[
Kind] =
false;
1190 DerefOrNullBytes = 0;
1193 std::map<std::string, std::string>::iterator
1195 if (Iter != TargetDepAttrs.end())
1196 TargetDepAttrs.erase(Iter);
1204 std::map<std::string, std::string>::iterator
I = TargetDepAttrs.find(A);
1205 if (I != TargetDepAttrs.end())
1206 TargetDepAttrs.erase(I);
1211 if (Align == 0)
return *
this;
1213 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
1214 assert(Align <= 0x40000000 &&
"Alignment too large.");
1223 if (Align == 0)
return *
this;
1225 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
1226 assert(Align <= 0x100 &&
"Alignment too large.");
1229 StackAlignment =
Align;
1234 if (Bytes == 0)
return *
this;
1246 DerefOrNullBytes = Bytes;
1253 Alignment = B.Alignment;
1255 if (!StackAlignment)
1256 StackAlignment = B.StackAlignment;
1259 DerefBytes = B.DerefBytes;
1261 if (!DerefOrNullBytes)
1262 DerefOrNullBytes = B.DerefOrNullBytes;
1267 TargetDepAttrs[
I.first] =
I.second;
1277 if (B.StackAlignment)
1283 if (B.DerefOrNullBytes)
1284 DerefOrNullBytes = 0;
1289 TargetDepAttrs.erase(
I.first);
1296 if ((Attrs & B.Attrs).any())
1308 return TargetDepAttrs.find(A) != TargetDepAttrs.end();
1312 return !Attrs.none() || !TargetDepAttrs.empty();
1316 unsigned Slot = ~0U;
1323 assert(Slot != ~0U &&
"Couldn't find the index!");
1329 if (Attrs[
I->getKindAsEnum()])
1333 return TargetDepAttrs.find(Attr.
getKindAsString())!=TargetDepAttrs.end();
1341 return Alignment != 0;
1345 if (Attrs != B.Attrs)
1349 E = TargetDepAttrs.end();
I != E; ++
I)
1350 if (B.TargetDepAttrs.find(
I->first) == B.TargetDepAttrs.end())
1353 return Alignment == B.Alignment && StackAlignment == B.StackAlignment &&
1354 DerefBytes == B.DerefBytes;
1359 if (!Val)
return *
this;
1371 Alignment = 1ULL << ((A >> 16) - 1);
1373 StackAlignment = 1ULL << ((A >> 26)-1);
1407 return Incompatible;
void push_back(const T &Elt)
uint64_t getDereferenceableBytes() const
std::string getAsString(bool InAttrGrp) const
FoldingSet< AttributeImpl > AttrsSet
Alignment of stack for function (3 bits) stored as log2 of alignment with +1 bias 0 means unaligned (...
AttributeSet getParamAttributes(unsigned Index) const
The attributes for the specified index are returned.
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
Sign extended before/after call.
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
Force argument to be passed in register.
Function is called early and/or often, so lazy binding isn't worthwhile.
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
Nested function static chain.
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
std::pair< unsigned, AttributeSetNode * > IndexAttrPair
Source said inlining was desirable.
AttributeSet getSlotAttributes(unsigned Slot) const
Retrieve the attributes for the given "slot" in the AttrNode list.
iterator begin(unsigned Slot) const
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
unsigned getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
void Profile(FoldingSetNodeID &ID) const
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
bool hasAlignmentAttr() const
Return true if the builder has an alignment attribute.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
AttrBuilder & addRawValue(uint64_t Val)
Add the raw value to the internal representation.
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
bool hasAttributes() const
StringRef getKindAsString() const
Return the attribute's kind as a string.
AttributeSet removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Remove the specified attribute at the specified index from this attribute list.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
FoldingSet< AttributeSetImpl > AttrsLists
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
This file contains the simple types necessary to represent the attributes associated with functions a...
Attribute::AttrKind getKindAsEnum() const
No attributes have been set.
void AddInteger(signed I)
AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
Function must be in a unwind table.
Function does not access memory.
Hidden pointer to structure to return.
friend class AttributeSet
Function creates no aliases of pointer.
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static std::string utostr(uint64_t X, bool isNeg=false)
unsigned getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
iterator end(unsigned Slot) const
AttrBuilder & remove(const AttrBuilder &B)
Remove the attributes from the builder.
size_t size() const
size - Get the array size.
Considered to not alias after call.
StringRef getKindAsString() const
static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
std::pair< std::string, std::string > td_type
bool hasAttribute(Attribute::AttrKind Kind) const
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute (or zero if unknown)...
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
bool operator==(const AttrBuilder &B)
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
iterator begin(unsigned Slot) const
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
bool isStringAttribute() const
AttributeSet getSlotAttributes(unsigned Slot) const
Return the attributes at the given slot.
unsigned getSlotIndex(unsigned Slot) const
Get the index of the given "slot" in the AttrNodes list.
Return value is always equal to this argument.
unsigned getAlignment() const
Pass structure in an alloca.
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
uint64_t Raw(unsigned Index) const
This file defines various helper methods and classes used by LLVMContextImpl for creating and managin...
Zero extended before/after call.
bool overlaps(const AttrBuilder &B) const
Return true if the builder has any attribute that's in the specified builder.
Function doesn't unwind stack.
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
bool empty() const
empty - Check if the array is empty.
Marks function as being in a cold path.
Sentinal value useful for loops.
Mark the function as not returning.
StringRef getValueAsString() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute (or ze...
bool isIntAttribute() const
Call cannot be duplicated.
LLVMContextImpl *const pImpl
Pointer is known to be not null.
bool hasAttribute(Attribute::AttrKind A) const
LLVMContext & getContext() const
Retrieve the LLVM context.
uint64_t getValueAsInt() const
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static uint64_t getAttrMask(Attribute::AttrKind Val)
Callee is recognized as a builtin, despite nobuiltin attribute on its declaration.
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
iterator end(unsigned Slot) const
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
AttributeSetNode * getSlotNode(unsigned Slot) const
Retrieve the attribute set node for the given "slot" in the AttrNode list.
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Log2_32 - This function returns the floor log base 2 of the specified value, -1 if the value is zero...
Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias 0 means unaligned (different...
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list.
friend class AttributeSetImpl
Function must not be optimized.
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
Function only reads from memory.
static AttributeSetNode * get(LLVMContext &C, ArrayRef< Attribute > Attrs)
std::map< std::string, std::string >::const_iterator td_const_iterator
unsigned getStackAlignment() const
iterator insert(iterator I, T &&Elt)
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index.
bool hasAttrSomewhere(Attribute::AttrKind Attr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
AttrBuilder typeIncompatible(const Type *Ty)
Which attributes cannot be applied to a type.
Callee isn't recognized as a builtin.
ArrayRef< Attribute >::iterator iterator
bool isEnumAttribute() const
void AddString(StringRef String)
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
uint64_t getDereferenceableOrNullBytes() const
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
Funciton can access memory only using pointers based on its arguments.
AttrBuilder & removeAttributes(AttributeSet A, uint64_t Index)
Remove the attributes from the builder.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
StringRef getValueAsString() const
Return the attribute's value as a string.
Function can return twice.
const ARM::ArchExtKind Kind
unsigned getNumAttributes() const
Return the number of attributes this AttributeSet contains.
Pointer is known to be dereferenceable.
LLVM Value Representation.
uint64_t Raw(unsigned Index) const
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Disable implicit floating point insts.
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
FoldingSet< AttributeSetNode > AttrsSetNodes
C - The default llvm calling convention, compatible with C.
bool isPowerOf2_32(uint32_t Value)
isPowerOf2_32 - This function returns true if the argument is a power of two > 0. ...
StringRef - Represent a constant reference to a string, i.e.
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
Attribute getAttribute(Attribute::AttrKind Kind) const
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index.
Can only be moved to control-equivalent blocks.
Stack protection required.
Build jump-instruction tables and replace refs.
Pointer is either null or dereferenceable.
uint64_t getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
bool empty() const
empty - Check if the string is empty.
AttributeSet getFnAttributes() const
The function attributes are returned.
Function must be optimized for size first.