Lines Matching refs:Attribute
11 // \brief This file implements the Attribute, AttributeImpl, AttrBuilder,
31 // Attribute Construction Methods
34 Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
54 // Return the Attribute that we found or created.
55 return Attribute(PA);
58 Attribute Attribute::get(LLVMContext &Context, StringRef Kind, StringRef Val) {
74 // Return the Attribute that we found or created.
75 return Attribute(PA);
78 Attribute Attribute::getWithAlignment(LLVMContext &Context, uint64_t Align) {
84 Attribute Attribute::getWithStackAlignment(LLVMContext &Context,
91 Attribute Attribute::getWithDereferenceableBytes(LLVMContext &Context,
97 Attribute Attribute::getWithDereferenceableOrNullBytes(LLVMContext &Context,
104 // Attribute Accessor Methods
107 bool Attribute::isEnumAttribute() const {
111 bool Attribute::isIntAttribute() const {
115 bool Attribute::isStringAttribute() const {
119 Attribute::AttrKind Attribute::getKindAsEnum() const {
122 "Invalid attribute type to get the kind as an enum!");
126 uint64_t Attribute::getValueAsInt() const {
129 "Expected the attribute to be an integer attribute!");
133 StringRef Attribute::getKindAsString() const {
136 "Invalid attribute type to get the kind as a string!");
140 StringRef Attribute::getValueAsString() const {
143 "Invalid attribute type to get the value as a string!");
147 bool Attribute::hasAttribute(AttrKind Kind) const {
151 bool Attribute::hasAttribute(StringRef Kind) const {
156 /// This returns the alignment field of an attribute as a byte alignment value.
157 unsigned Attribute::getAlignment() const {
158 assert(hasAttribute(Attribute::Alignment) &&
159 "Trying to get alignment from non-alignment attribute!");
163 /// This returns the stack alignment field of an attribute as a byte alignment
165 unsigned Attribute::getStackAlignment() const {
166 assert(hasAttribute(Attribute::StackAlignment) &&
167 "Trying to get alignment from non-alignment attribute!");
172 uint64_t Attribute::getDereferenceableBytes() const {
173 assert(hasAttribute(Attribute::Dereferenceable) &&
175 "non-dereferenceable attribute!");
179 uint64_t Attribute::getDereferenceableOrNullBytes() const {
180 assert(hasAttribute(Attribute::DereferenceableOrNull) &&
182 "non-dereferenceable attribute!");
186 std::string Attribute::getAsString(bool InAttrGrp) const {
189 if (hasAttribute(Attribute::SanitizeAddress))
191 if (hasAttribute(Attribute::AlwaysInline))
193 if (hasAttribute(Attribute::ArgMemOnly))
195 if (hasAttribute(Attribute::Builtin))
197 if (hasAttribute(Attribute::ByVal))
199 if (hasAttribute(Attribute::Convergent))
201 if (hasAttribute(Attribute::InaccessibleMemOnly))
203 if (hasAttribute(Attribute::InaccessibleMemOrArgMemOnly))
205 if (hasAttribute(Attribute::InAlloca))
207 if (hasAttribute(Attribute::InlineHint))
209 if (hasAttribute(Attribute::InReg))
211 if (hasAttribute(Attribute::JumpTable))
213 if (hasAttribute(Attribute::MinSize))
215 if (hasAttribute(Attribute::Naked))
217 if (hasAttribute(Attribute::Nest))
219 if (hasAttribute(Attribute::NoAlias))
221 if (hasAttribute(Attribute::NoBuiltin))
223 if (hasAttribute(Attribute::NoCapture))
225 if (hasAttribute(Attribute::NoDuplicate))
227 if (hasAttribute(Attribute::NoImplicitFloat))
229 if (hasAttribute(Attribute::NoInline))
231 if (hasAttribute(Attribute::NonLazyBind))
233 if (hasAttribute(Attribute::NonNull))
235 if (hasAttribute(Attribute::NoRedZone))
237 if (hasAttribute(Attribute::NoReturn))
239 if (hasAttribute(Attribute::NoRecurse))
241 if (hasAttribute(Attribute::NoUnwind))
243 if (hasAttribute(Attribute::OptimizeNone))
245 if (hasAttribute(Attribute::OptimizeForSize))
247 if (hasAttribute(Attribute::ReadNone))
249 if (hasAttribute(Attribute::ReadOnly))
251 if (hasAttribute(Attribute::Returned))
253 if (hasAttribute(Attribute::ReturnsTwice))
255 if (hasAttribute(Attribute::SExt))
257 if (hasAttribute(Attribute::StackProtect))
259 if (hasAttribute(Attribute::StackProtectReq))
261 if (hasAttribute(Attribute::StackProtectStrong))
263 if (hasAttribute(Attribute::SafeStack))
265 if (hasAttribute(Attribute::StructRet))
267 if (hasAttribute(Attribute::SanitizeThread))
269 if (hasAttribute(Attribute::SanitizeMemory))
271 if (hasAttribute(Attribute::UWTable))
273 if (hasAttribute(Attribute::ZExt))
275 if (hasAttribute(Attribute::Cold))
283 if (hasAttribute(Attribute::Alignment)) {
305 if (hasAttribute(Attribute::StackAlignment))
308 if (hasAttribute(Attribute::Dereferenceable))
311 if (hasAttribute(Attribute::DereferenceableOrNull))
330 llvm_unreachable("Unknown attribute");
333 bool Attribute::operator<(Attribute A) const {
350 bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
360 Attribute::AttrKind AttributeImpl::getKindAsEnum() const {
381 // This sorts the attributes with Attribute::AttrKinds coming first (sorted
402 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
405 case Attribute::EndAttrKinds:
408 case Attribute::None: return 0;
409 case Attribute::ZExt: return 1 << 0;
410 case Attribute::SExt: return 1 << 1;
411 case Attribute::NoReturn: return 1 << 2;
412 case Attribute::InReg: return 1 << 3;
413 case Attribute::StructRet: return 1 << 4;
414 case Attribute::NoUnwind: return 1 << 5;
415 case Attribute::NoAlias: return 1 << 6;
416 case Attribute::ByVal: return 1 << 7;
417 case Attribute::Nest: return 1 << 8;
418 case Attribute::ReadNone: return 1 << 9;
419 case Attribute::ReadOnly: return 1 << 10;
420 case Attribute::NoInline: return 1 << 11;
421 case Attribute::AlwaysInline: return 1 << 12;
422 case Attribute::OptimizeForSize: return 1 << 13;
423 case Attribute::StackProtect: return 1 << 14;
424 case Attribute::StackProtectReq: return 1 << 15;
425 case Attribute::Alignment: return 31 << 16;
426 case Attribute::NoCapture: return 1 << 21;
427 case Attribute::NoRedZone: return 1 << 22;
428 case Attribute::NoImplicitFloat: return 1 << 23;
429 case Attribute::Naked: return 1 << 24;
430 case Attribute::InlineHint: return 1 << 25;
431 case Attribute::StackAlignment: return 7 << 26;
432 case Attribute::ReturnsTwice: return 1 << 29;
433 case Attribute::UWTable: return 1 << 30;
434 case Attribute::NonLazyBind: return 1U << 31;
435 case Attribute::SanitizeAddress: return 1ULL << 32;
436 case Attribute::MinSize: return 1ULL << 33;
437 case Attribute::NoDuplicate: return 1ULL << 34;
438 case Attribute::StackProtectStrong: return 1ULL << 35;
439 case Attribute::SanitizeThread: return 1ULL << 36;
440 case Attribute::SanitizeMemory: return 1ULL << 37;
441 case Attribute::NoBuiltin: return 1ULL << 38;
442 case Attribute::Returned: return 1ULL << 39;
443 case Attribute::Cold: return 1ULL << 40;
444 case Attribute::Builtin: return 1ULL << 41;
445 case Attribute::OptimizeNone: return 1ULL << 42;
446 case Attribute::InAlloca: return 1ULL << 43;
447 case Attribute::NonNull: return 1ULL << 44;
448 case Attribute::JumpTable: return 1ULL << 45;
449 case Attribute::Convergent: return 1ULL << 46;
450 case Attribute::SafeStack: return 1ULL << 47;
451 case Attribute::NoRecurse: return 1ULL << 48;
452 case Attribute::InaccessibleMemOnly: return 1ULL << 49;
453 case Attribute::InaccessibleMemOrArgMemOnly: return 1ULL << 50;
454 case Attribute::Dereferenceable:
455 llvm_unreachable("dereferenceable attribute not supported in raw format");
457 case Attribute::DereferenceableOrNull:
458 llvm_unreachable("dereferenceable_or_null attribute not supported in raw "
461 case Attribute::ArgMemOnly:
462 llvm_unreachable("argmemonly attribute not supported in raw format");
465 llvm_unreachable("Unsupported attribute type");
473 ArrayRef<Attribute> Attrs) {
481 SmallVector<Attribute, 8> SortedAttrs(Attrs.begin(), Attrs.end());
484 for (Attribute Attr : SortedAttrs)
495 void *Mem = ::operator new(totalSizeToAlloc<Attribute>(SortedAttrs.size()));
504 bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
518 Attribute AttributeSetNode::getAttribute(Attribute::AttrKind Kind) const {
522 return Attribute();
525 Attribute AttributeSetNode::getAttribute(StringRef Kind) const {
529 return Attribute();
534 if (I->hasAttribute(Attribute::Alignment))
541 if (I->hasAttribute(Attribute::StackAlignment))
548 if (I->hasAttribute(Attribute::Dereferenceable))
555 if (I->hasAttribute(Attribute::DereferenceableOrNull))
582 Attribute Attr = *II;
587 Attribute::AttrKind Kind = Attr.getKindAsEnum();
589 if (Kind == Attribute::Alignment)
591 else if (Kind == Attribute::StackAlignment)
593 else if (Kind == Attribute::Dereferenceable)
638 ArrayRef<std::pair<unsigned, Attribute> > Attrs){
647 assert(!Attrs[i].second.hasAttribute(Attribute::None) &&
648 "Pointless attribute!");
655 for (ArrayRef<std::pair<unsigned, Attribute> >::iterator I = Attrs.begin(),
658 SmallVector<Attribute, 4> AttrVec;
687 SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
688 for (Attribute::AttrKind Kind = Attribute::None;
689 Kind != Attribute::EndAttrKinds; Kind = Attribute::AttrKind(Kind + 1)) {
693 Attribute Attr;
695 case Attribute::Alignment:
696 Attr = Attribute::getWithAlignment(C, B.getAlignment());
698 case Attribute::StackAlignment:
699 Attr = Attribute::getWithStackAlignment(C, B.getStackAlignment());
701 case Attribute::Dereferenceable:
702 Attr = Attribute::getWithDereferenceableBytes(
705 case Attribute::DereferenceableOrNull:
706 Attr = Attribute::getWithDereferenceableOrNullBytes(
710 Attr = Attribute::get(C, Kind);
718 std::make_pair(Index, Attribute::get(C, TDA.first, TDA.second)));
724 ArrayRef<Attribute::AttrKind> Kind) {
725 SmallVector<std::pair<unsigned, Attribute>, 8> Attrs;
726 for (Attribute::AttrKind K : Kind)
727 Attrs.push_back(std::make_pair(Index, Attribute::get(C, K)));
762 Attribute::AttrKind Attr) const {
783 Attribute A) const {
825 // Add the attribute slots before the one we're trying to add.
839 // Now add the attribute into the correct slot. There may already be an
853 // Add the remaining attribute slots.
861 Attribute::AttrKind Attr) const {
873 assert(!Attrs.hasAttribute(Index, Attribute::Alignment) &&
876 // Add the attribute slots before the one we're trying to add.
890 // Now remove the attribute from the correct slot. There may already be an
902 // Add the remaining attribute slots.
917 // Add the attribute slots before the one we're trying to add.
931 // Now remove the attribute from the correct slot. There may already be an
938 // Add the remaining attribute slots.
994 bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
1009 /// \brief Return true if the specified attribute is set for at least one
1011 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
1023 Attribute AttributeSet::getAttribute(unsigned Index,
1024 Attribute::AttrKind Kind) const {
1026 return ASN ? ASN->getAttribute(Kind) : Attribute();
1029 Attribute AttributeSet::getAttribute(unsigned Index,
1032 return ASN ? ASN->getAttribute(Kind) : Attribute();
1065 // Loop through to find the attribute node we want.
1075 return ArrayRef<Attribute>().begin();
1081 return ArrayRef<Attribute>().end();
1089 /// \brief Return the number of slots used in this attribute list. This is the
1090 /// number of arguments that have an attribute set on them (including the
1156 AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val) {
1157 assert((unsigned)Val < Attribute::EndAttrKinds && "Attribute out of range!");
1158 assert(Val != Attribute::Alignment && Val != Attribute::StackAlignment &&
1159 Val != Attribute::Dereferenceable &&
1160 "Adding integer attribute without adding a value!");
1165 AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) {
1171 Attribute::AttrKind Kind = Attr.getKindAsEnum();
1174 if (Kind == Attribute::Alignment)
1176 else if (Kind == Attribute::StackAlignment)
1178 else if (Kind == Attribute::Dereferenceable)
1180 else if (Kind == Attribute::DereferenceableOrNull)
1190 AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
1191 assert((unsigned)Val < Attribute::EndAttrKinds && "Attribute out of range!");
1194 if (Val == Attribute::Alignment)
1196 else if (Val == Attribute::StackAlignment)
1198 else if (Val == Attribute::Dereferenceable)
1200 else if (Val == Attribute::DereferenceableOrNull)
1217 Attribute Attr = *I;
1221 assert(Attr.isStringAttribute() && "Invalid attribute type!");
1242 Attrs[Attribute::Alignment] = true;
1254 Attrs[Attribute::StackAlignment] = true;
1262 Attrs[Attribute::Dereferenceable] = true;
1271 Attrs[Attribute::DereferenceableOrNull] = true;
1352 Attribute Attr = *I;
1357 assert(Attr.isStringAttribute() && "Invalid attribute kind!");
1386 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
1387 I = Attribute::AttrKind(I + 1)) {
1388 if (I == Attribute::Dereferenceable ||
1389 I == Attribute::DereferenceableOrNull ||
1390 I == Attribute::ArgMemOnly)
1395 if (I == Attribute::Alignment)
1397 else if (I == Attribute::StackAlignment)
1414 // Attribute that only apply to integers.
1415 Incompatible.addAttribute(Attribute::SExt)
1416 .addAttribute(Attribute::ZExt);
1419 // Attribute that only apply to pointers.
1420 Incompatible.addAttribute(Attribute::ByVal)
1421 .addAttribute(Attribute::Nest)
1422 .addAttribute(Attribute::NoAlias)
1423 .addAttribute(Attribute::NoCapture)
1424 .addAttribute(Attribute::NonNull)
1427 .addAttribute(Attribute::ReadNone)
1428 .addAttribute(Attribute::ReadOnly)
1429 .addAttribute(Attribute::StructRet)
1430 .addAttribute(Attribute::InAlloca);