Home | History | Annotate | Download | only in IR

Lines Matching full:attribute

11 // \brief This file implements the Attribute, AttributeImpl, AttrBuilder,
30 // Attribute Construction Methods
33 Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
53 // Return the Attribute that we found or created.
54 return Attribute(PA);
57 Attribute Attribute::get(LLVMContext &Context, StringRef Kind, StringRef Val) {
73 // Return the Attribute that we found or created.
74 return Attribute(PA);
77 Attribute Attribute::getWithAlignment(LLVMContext &Context, uint64_t Align) {
83 Attribute Attribute::getWithStackAlignment(LLVMContext &Context,
91 // Attribute Accessor Methods
94 bool Attribute::isEnumAttribute() const {
98 bool Attribute::isAlignAttribute() const {
102 bool Attribute::isStringAttribute() const {
106 Attribute::AttrKind Attribute::getKindAsEnum() const {
109 "Invalid attribute type to get the kind as an enum!");
113 uint64_t Attribute::getValueAsInt() const {
116 "Expected the attribute to be an alignment attribute!");
120 StringRef Attribute::getKindAsString() const {
123 "Invalid attribute type to get the kind as a string!");
127 StringRef Attribute::getValueAsString() const {
130 "Invalid attribute type to get the value as a string!");
134 bool Attribute::hasAttribute(AttrKind Kind) const {
138 bool Attribute::hasAttribute(StringRef Kind) const {
143 /// This returns the alignment field of an attribute as a byte alignment value.
144 unsigned Attribute::getAlignment() const {
145 assert(hasAttribute(Attribute::Alignment) &&
146 "Trying to get alignment from non-alignment attribute!");
150 /// This returns the stack alignment field of an attribute as a byte alignment
152 unsigned Attribute::getStackAlignment() const {
153 assert(hasAttribute(Attribute::StackAlignment) &&
154 "Trying to get alignment from non-alignment attribute!");
158 std::string Attribute::getAsString(bool InAttrGrp) const {
161 if (hasAttribute(Attribute::SanitizeAddress))
163 if (hasAttribute(Attribute::AlwaysInline))
165 if (hasAttribute(Attribute::Builtin))
167 if (hasAttribute(Attribute::ByVal))
169 if (hasAttribute(Attribute::InlineHint))
171 if (hasAttribute(Attribute::InReg))
173 if (hasAttribute(Attribute::MinSize))
175 if (hasAttribute(Attribute::Naked))
177 if (hasAttribute(Attribute::Nest))
179 if (hasAttribute(Attribute::NoAlias))
181 if (hasAttribute(Attribute::NoBuiltin))
183 if (hasAttribute(Attribute::NoCapture))
185 if (hasAttribute(Attribute::NoDuplicate))
187 if (hasAttribute(Attribute::NoImplicitFloat))
189 if (hasAttribute(Attribute::NoInline))
191 if (hasAttribute(Attribute::NonLazyBind))
193 if (hasAttribute(Attribute::NoRedZone))
195 if (hasAttribute(Attribute::NoReturn))
197 if (hasAttribute(Attribute::NoUnwind))
199 if (hasAttribute(Attribute::OptimizeForSize))
201 if (hasAttribute(Attribute::ReadNone))
203 if (hasAttribute(Attribute::ReadOnly))
205 if (hasAttribute(Attribute::Returned))
207 if (hasAttribute(Attribute::ReturnsTwice))
209 if (hasAttribute(Attribute::SExt))
211 if (hasAttribute(Attribute::StackProtect))
213 if (hasAttribute(Attribute::StackProtectReq))
215 if (hasAttribute(Attribute::StackProtectStrong))
217 if (hasAttribute(Attribute::StructRet))
219 if (hasAttribute(Attribute::SanitizeThread))
221 if (hasAttribute(Attribute::SanitizeMemory))
223 if (hasAttribute(Attribute::UWTable))
225 if (hasAttribute(Attribute::ZExt))
227 if (hasAttribute(Attribute::Cold))
235 if (hasAttribute(Attribute::Alignment)) {
243 if (hasAttribute(Attribute::StackAlignment)) {
273 llvm_unreachable("Unknown attribute");
276 bool Attribute::operator<(Attribute A) const {
289 bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
299 Attribute::AttrKind AttributeImpl::getKindAsEnum() const {
320 // This sorts the attributes with Attribute::AttrKinds coming first (sorted
341 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
344 case Attribute::EndAttrKinds:
347 case Attribute::None: return 0;
348 case Attribute::ZExt: return 1 << 0;
349 case Attribute::SExt: return 1 << 1;
350 case Attribute::NoReturn: return 1 << 2;
351 case Attribute::InReg: return 1 << 3;
352 case Attribute::StructRet: return 1 << 4;
353 case Attribute::NoUnwind: return 1 << 5;
354 case Attribute::NoAlias: return 1 << 6;
355 case Attribute::ByVal: return 1 << 7;
356 case Attribute::Nest: return 1 << 8;
357 case Attribute::ReadNone: return 1 << 9;
358 case Attribute::ReadOnly: return 1 << 10;
359 case Attribute::NoInline: return 1 << 11;
360 case Attribute::AlwaysInline: return 1 << 12;
361 case Attribute::OptimizeForSize: return 1 << 13;
362 case Attribute::StackProtect: return 1 << 14;
363 case Attribute::StackProtectReq: return 1 << 15;
364 case Attribute::Alignment: return 31 << 16;
365 case Attribute::NoCapture: return 1 << 21;
366 case Attribute::NoRedZone: return 1 << 22;
367 case Attribute::NoImplicitFloat: return 1 << 23;
368 case Attribute::Naked: return 1 << 24;
369 case Attribute::InlineHint: return 1 << 25;
370 case Attribute::StackAlignment: return 7 << 26;
371 case Attribute::ReturnsTwice: return 1 << 29;
372 case Attribute::UWTable: return 1 << 30;
373 case Attribute::NonLazyBind: return 1U << 31;
374 case Attribute::SanitizeAddress: return 1ULL << 32;
375 case Attribute::MinSize: return 1ULL << 33;
376 case Attribute::NoDuplicate: return 1ULL << 34;
377 case Attribute::StackProtectStrong: return 1ULL << 35;
378 case Attribute::SanitizeThread: return 1ULL << 36;
379 case Attribute::SanitizeMemory: return 1ULL << 37;
380 case Attribute::NoBuiltin: return 1ULL << 38;
381 case Attribute::Returned: return 1ULL << 39;
382 case Attribute::Cold: return 1ULL << 40;
383 case Attribute::Builtin: return 1ULL << 41;
385 llvm_unreachable("Unsupported attribute type");
393 ArrayRef<Attribute> Attrs) {
401 SmallVector<Attribute, 8> SortedAttrs(Attrs.begin(), Attrs.end());
404 for (SmallVectorImpl<Attribute>::iterator I = SortedAttrs.begin(),
417 sizeof(Attribute) * SortedAttrs.size());
426 bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
440 Attribute AttributeSetNode::getAttribute(Attribute::AttrKind Kind) const {
444 return Attribute();
447 Attribute AttributeSetNode::getAttribute(StringRef Kind) const {
451 return Attribute();
456 if (I->hasAttribute(Attribute::Alignment))
463 if (I->hasAttribute(Attribute::StackAlignment))
490 Attribute Attr = *II;
495 Attribute::AttrKind Kind = Attr.getKindAsEnum();
497 Attribute::Alignment)
499 else if (Kind == Attribute::StackAlignment)
545 ArrayRef<std::pair<unsigned, Attribute> > Attrs){
554 assert(!Attrs[i].second.hasAttribute(Attribute::None) &&
555 "Pointless attribute!");
562 for (ArrayRef<std::pair<unsigned, Attribute> >::iterator I = Attrs.begin(),
565 SmallVector<Attribute, 4> AttrVec;
593 SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
594 for (Attribute::AttrKind Kind = Attribute::None;
595 Kind != Attribute::EndAttrKinds; Kind = Attribute::AttrKind(Kind + 1)) {
599 if (Kind == Attribute::Alignment)
600 Attrs.push_back(std::make_pair(Index, Attribute::
602 else if (Kind == Attribute::StackAlignment)
603 Attrs.push_back(std::make_pair(Index, Attribute::
606 Attrs.push_back(std::make_pair(Index, Attribute::get(C, Kind)));
612 Attrs.push_back(std::make_pair(Index, Attribute::get(C, I->first,I->second)));
618 ArrayRef<Attribute::AttrKind> Kind) {
619 SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
620 for (ArrayRef<Attribute::AttrKind>::iterator I = Kind.begin(),
622 Attrs.push_back(std::make_pair(Index, Attribute::get(C, *I)));
658 Attribute::AttrKind Attr) const {
691 // Add the attribute slots before the one we're trying to add.
705 // Now add the attribute into the correct slot. There may already be an
719 // Add the remaining attribute slots.
727 Attribute::AttrKind Attr) const {
740 assert(!Attrs.hasAttribute(Index, Attribute::Alignment) &&
744 // Add the attribute slots before the one we're trying to add.
758 // Now remove the attribute from the correct slot. There may already be an
770 // Add the remaining attribute slots.
811 bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
826 /// \brief Return true if the specified attribute is set for at least one
828 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
840 Attribute AttributeSet::getAttribute(unsigned Index,
841 Attribute::AttrKind Kind) const {
843 return ASN ? ASN->getAttribute(Kind) : Attribute();
846 Attribute AttributeSet::getAttribute(unsigned Index,
849 return ASN ? ASN->getAttribute(Kind) : Attribute();
872 // Loop through to find the attribute node we want.
882 return ArrayRef<Attribute>().begin();
888 return ArrayRef<Attribute>().end();
896 /// \brief Return the number of slots used in this attribute list. This is the
897 /// number of arguments that have an attribute set on them (including the
961 AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val) {
962 assert((unsigned)Val < Attribute::EndAttrKinds && "Attribute out of range!");
963 assert(Val != Attribute::Alignment && Val != Attribute::StackAlignment &&
964 "Adding alignment attribute without adding alignment value!");
969 AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) {
975 Attribute::AttrKind Kind = Attr.getKindAsEnum();
978 if (Kind == Attribute::Alignment)
980 else if (Kind == Attribute::StackAlignment)
990 AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
991 assert((unsigned)Val < Attribute::EndAttrKinds && "Attribute out of range!");
994 if (Val == Attribute::Alignment)
996 else if (Val == Attribute::StackAlignment)
1013 Attribute Attr = *I;
1015 Attribute::AttrKind Kind = I->getKindAsEnum();
1018 if (Kind == Attribute::Alignment)
1020 else if (Kind == Attribute::StackAlignment)
1023 assert(Attr.isStringAttribute() && "Invalid attribute type!");
1047 Attrs[Attribute::Alignment] = true;
1059 Attrs[Attribute::StackAlignment] = true;
1101 Attribute Attr = *I;
1106 assert(Attr.isStringAttribute() && "Invalid attribute kind!");
1134 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
1135 I = Attribute::AttrKind(I + 1)) {
1139 if (I == Attribute::Alignment)
1141 else if (I == Attribute::StackAlignment)
1158 // Attribute that only apply to integers.
1159 Incompatible.addAttribute(Attribute::SExt)
1160 .addAttribute(Attribute::ZExt);
1163 // Attribute that only apply to pointers.
1164 Incompatible.addAttribute(Attribute::ByVal)
1165 .addAttribute(Attribute::Nest)
1166 .addAttribute(Attribute::NoAlias)
1167 .addAttribute(Attribute::NoCapture)
1168 .addAttribute(Attribute::ReadNone)
1169 .addAttribute(Attribute::ReadOnly)
1170 .addAttribute(Attribute::StructRet);