50 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
70 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
78 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
79 assert(Align <= 0x40000000 &&
"Alignment too large.");
85 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
86 assert(Align <= 0x100 &&
"Alignment too large.");
107 if (!pImpl)
return None;
109 "Invalid attribute type to get the kind as an enum!");
114 if (!pImpl)
return 0;
116 "Expected the attribute to be an alignment attribute!");
123 "Invalid attribute type to get the kind as a string!");
130 "Invalid attribute type to get the value as a string!");
146 "Trying to get alignment from non-alignment attribute!");
154 "Trying to get alignment from non-alignment attribute!");
159 if (!pImpl)
return "";
162 return "sanitize_address";
164 return "alwaysinline";
186 return "noduplicate";
188 return "noimplicitfloat";
192 return "nonlazybind";
210 return "returns_twice";
222 return "sanitize_thread";
224 return "sanitize_memory";
240 Result += (InAttrGrp) ?
"=" :
" ";
247 Result +=
"alignstack";
269 if (Val.
empty())
return Result;
271 Result +=
"=\"" + Val.
str() +
'"';
279 if (!pImpl && !A.pImpl)
return false;
280 if (!pImpl)
return true;
281 if (!A.pImpl)
return false;
282 return *pImpl < *A.pImpl;
291 void EnumAttributeImpl::anchor() {}
292 void AlignAttributeImpl::anchor() {}
293 void StringAttributeImpl::anchor() {}
412 E = SortedAttrs.end();
I != E; ++
I)
435 if (
I->hasAttribute(Kind))
442 if (
I->hasAttribute(Kind))
449 if (
I->hasAttribute(Kind))
456 if (
I->hasAttribute(Kind))
464 return I->getAlignment();
471 return I->getStackAlignment();
480 Str +=
I->getAsString(InAttrGrp);
496 IE = ASN->
end(); II !=
IE; ++II) {
519 AttributeSet(const_cast<AttributeSetImpl *>(
this)).dump();
528 ArrayRef<std::pair<unsigned, AttributeSetNode*> > Attrs) {
541 sizeof(std::pair<unsigned, AttributeSetNode *>) *
544 pImpl->
AttrsLists.InsertNode(PA, InsertPoint);
552 ArrayRef<std::pair<unsigned, Attribute> > Attrs){
558 for (
unsigned i = 0, e = Attrs.size(); i != e; ++i) {
559 assert((!i || Attrs[i-1].first <= Attrs[i].first) &&
560 "Misordered Attributes list!");
562 "Pointless attribute!");
570 E = Attrs.end();
I != E; ) {
571 unsigned Index =
I->first;
573 while (
I != E &&
I->first == Index) {
578 AttrPairVec.
push_back(std::make_pair(Index,
582 return getImpl(C, AttrPairVec);
592 return getImpl(C, Attrs);
621 return get(
C, Attrs);
628 E = Kind.
end();
I != E; ++
I)
630 return get(
C, Attrs);
635 if (Attrs.
size() == 1)
return Attrs[0];
645 for (
unsigned I = 1, E = Attrs.
size();
I != E; ++
I) {
649 ANVI = AttrNodeVec.
begin(), ANVE;
650 for (
const AttributeSetImpl::IndexAttrPair
651 *AI = AS->getNode(0),
654 ANVE = AttrNodeVec.
end();
655 while (ANVI != ANVE && ANVI->first <= AI->first)
657 ANVI = AttrNodeVec.
insert(ANVI, *AI) + 1;
661 return getImpl(C, AttrNodeVec);
667 return addAttributes(C, Index, AttributeSet::get(C, Index, Attr));
674 return addAttributes(C, Index, AttributeSet::get(C, Index, B));
681 return addAttributes(C, Index, AttributeSet::get(C, Index, B));
686 if (!pImpl)
return Attrs;
687 if (!Attrs.pImpl)
return *
this;
694 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
695 "Attempt to change alignment!");
700 uint64_t NumAttrs = pImpl->getNumAttributes();
702 uint64_t LastIndex = 0;
703 for (
unsigned I = 0, E = NumAttrs;
I != E; ++
I) {
719 IE = Attrs.pImpl->
end(
I); II !=
IE; ++II)
724 AttrSet.
push_back(AttributeSet::get(C, Index, B));
727 for (
unsigned I = LastIndex, E = NumAttrs;
I < E; ++
I)
730 return get(
C, AttrSet);
742 if (!Attrs.pImpl)
return *
this;
748 "Attempt to change alignment!");
753 uint64_t NumAttrs = pImpl->getNumAttributes();
755 uint64_t LastIndex = 0;
756 for (
unsigned I = 0, E = NumAttrs;
I != E; ++
I) {
775 AttrSet.push_back(AttributeSet::get(C, Index, B));
778 for (
unsigned I = LastIndex, E = NumAttrs;
I < E; ++
I)
781 return get(
C, AttrSet);
789 return pImpl->getContext();
794 AttributeSet::get(pImpl->getContext(),
802 AttributeSet::get(pImpl->getContext(),
804 std::make_pair(ReturnIndex,
811 AttributeSet::get(pImpl->getContext(),
813 std::make_pair(FunctionIndex,
836 if (pImpl == 0)
return false;
838 for (
unsigned I = 0, E = pImpl->getNumAttributes();
I != E; ++
I)
840 IE = pImpl->end(
I); II !=
IE; ++II)
841 if (II->hasAttribute(Attr))
870 bool InAttrGrp)
const {
872 return ASN ? ASN->
getAsString(InAttrGrp) : std::string(
"");
877 if (!pImpl)
return 0;
880 for (
unsigned I = 0, E = pImpl->getNumAttributes();
I != E; ++
I)
881 if (pImpl->getSlotIndex(
I) == Index)
882 return pImpl->getSlotNode(
I);
890 return pImpl->begin(Slot);
896 return pImpl->end(Slot);
907 return pImpl ? pImpl->getNumAttributes() : 0;
911 assert(pImpl && Slot < pImpl->getNumAttributes() &&
912 "Slot # out of range!");
913 return pImpl->getSlotIndex(Slot);
917 assert(pImpl && Slot < pImpl->getNumAttributes() &&
918 "Slot # out of range!");
919 return pImpl->getSlotAttributes(Slot);
924 return pImpl ? pImpl->Raw(Index) : 0;
930 for (
unsigned i = 0, e =
getNumSlots(); i < e; ++i) {
948 : Attrs(0), Alignment(0), StackAlignment(0) {
965 Alignment = StackAlignment = 0;
971 "Adding alignment attribute without adding alignment value!");
993 TargetDepAttrs[
A] = V;
1010 unsigned Slot = ~0U;
1017 assert(Slot != ~0U &&
"Couldn't find index in AttributeSet!");
1023 Attrs[
Kind] =
false;
1031 std::map<std::string, std::string>::iterator
1033 if (Iter != TargetDepAttrs.end())
1034 TargetDepAttrs.erase(Iter);
1042 std::map<std::string, std::string>::iterator
I = TargetDepAttrs.find(A);
1043 if (I != TargetDepAttrs.end())
1044 TargetDepAttrs.erase(I);
1049 if (Align == 0)
return *
this;
1051 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
1052 assert(Align <= 0x40000000 &&
"Alignment too large.");
1061 if (Align == 0)
return *
this;
1063 assert(
isPowerOf2_32(Align) &&
"Alignment must be a power of two.");
1064 assert(Align <= 0x100 &&
"Alignment too large.");
1067 StackAlignment =
Align;
1074 Alignment = B.Alignment;
1076 if (!StackAlignment)
1077 StackAlignment = B.StackAlignment;
1082 E = B.TargetDepAttrs.end();
I != E; ++
I)
1083 TargetDepAttrs[
I->first] =
I->second;
1089 return TargetDepAttrs.find(A) != TargetDepAttrs.end();
1093 return !Attrs.none() || !TargetDepAttrs.empty();
1097 unsigned Slot = ~0U;
1104 assert(Slot != ~0U &&
"Couldn't find the index!");
1110 if (Attrs[
I->getKindAsEnum()])
1114 return TargetDepAttrs.find(Attr.
getKindAsString())!=TargetDepAttrs.end();
1122 return Alignment != 0;
1126 if (Attrs != B.Attrs)
1130 E = TargetDepAttrs.end();
I != E; ++
I)
1131 if (B.TargetDepAttrs.find(
I->first) == B.TargetDepAttrs.end())
1134 return Alignment == B.Alignment && StackAlignment == B.StackAlignment;
1139 if (!Val)
return *
this;
1147 Alignment = 1ULL << ((A >> 16) - 1);
1149 StackAlignment = 1ULL << ((A >> 26)-1);
1179 return AttributeSet::get(Ty->
getContext(), Index, Incompatible);
void push_back(const T &Elt)
std::string getAsString(bool InAttrGrp) const
FoldingSet< AttributeImpl > AttrsSet
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.
Nested function static chain.
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
uint64_t getValueAsInt() const
Return the attribute's value as an integer. This requires that the attribute be an alignment attribut...
Source said inlining was desirable.
iterator insert(iterator I, const T &Elt)
AttributeSet getSlotAttributes(unsigned Slot) const
Retrieve the attributes for the given "slot" in the AttrNode list. Slot is an index into the AttrNode...
iterator begin(unsigned Slot) const
std::string str() const
str - Get the contents as an std::string.
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. This requires the attribute to be a string attribute...
AttributeSet removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Remove the specified attribute at the specified index from this attribute list. Since attribute lists...
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic. This is, presumably, for writing out the mnemonics for the assembly writer.
#define llvm_unreachable(msg)
FoldingSet< AttributeSetImpl > AttrsLists
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)
Function must be in a unwind table.
ID
LLVM Calling Convention Representation.
AttributeSet typeIncompatible(Type *Ty, uint64_t Index)
Which attributes cannot be applied to a type.
Function does not access memory.
Hidden pointer to structure to return.
friend class AttributeSet
Function creates no aliases of pointer.
std::map< std::string, std::string >::iterator td_iterator
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
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
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)
bool isAlignAttribute() const
Return true if the attribute is an alignment attribute.
bool hasAttribute(Attribute::AttrKind Kind) const
unsigned getNumSlots() const
Return the number of slots used in this attribute list. This is the number of arguments that have an ...
bool operator==(const AttrBuilder &B)
void array_pod_sort(IteratorTy Start, IteratorTy End)
iterator begin(unsigned Slot) const
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. This index is the index of the return...
Return value is always equal to this argument.
unsigned getAlignment() const
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.
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)
Call cannot be duplicated.
LLVMContextImpl *const pImpl
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.
bool isAlignAttribute() const
static uint64_t getAttrMask(Attribute::AttrKind Val)
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind). This requires the attribute to be an en...
iterator end(unsigned Slot) const
AttributeSetNode * getSlotNode(unsigned Slot) const
Retrieve the attribute set node for the given "slot" in the AttrNode list.
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
unsigned Log2_32(uint32_t Value)
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list. Since attribute list...
friend class AttributeSetImpl
Function must not be optimized.
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
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
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. Since attribute sets are immutable...
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.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
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.
AttributeSet getAttributes(LLVMContext &C, ID id)
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. This requires the attribute to be a string attribute...
Function can return twice.
unsigned getNumAttributes() const
Return the number of attributes this AttributeSet contains.
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
bool isPowerOf2_32(uint32_t Value)
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. Since attribute sets are immutable, this returns a new set.
Stack protection required.
uint64_t getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
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.