1 //===- llvm/Attributes.h - Container for Attributes -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file contains the simple types necessary to represent the
12 /// attributes associated with functions and their calls.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_IR_ATTRIBUTES_H
17 #define LLVM_IR_ATTRIBUTES_H
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/FoldingSet.h"
21 #include "llvm/ADT/iterator_range.h"
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/PointerLikeTypeTraits.h"
25 #include "llvm-c/Types.h"
37 class AttributeListImpl;
38 class AttributeSetNode;
39 template<typename T> struct DenseMapInfo;
44 //===----------------------------------------------------------------------===//
46 /// \brief Functions, function parameters, and return types can have attributes
47 /// to indicate how they should be treated by optimizations and code
48 /// generation. This class represents one of those attributes. It's light-weight
49 /// and should be passed around by-value.
52 /// This enumeration lists the attributes that can be associated with
53 /// parameters, function results, or the function itself.
55 /// Note: The `uwtable' attribute is about the ABI or the user mandating an
56 /// entry in the unwind table. The `nounwind' attribute is about an exception
57 /// passing by the function.
59 /// In a theoretical system that uses tables for profiling and SjLj for
60 /// exceptions, they would be fully independent. In a normal system that uses
61 /// tables for both, the semantics are:
63 /// nil = Needs an entry because an exception might pass by.
64 /// nounwind = No need for an entry
65 /// uwtable = Needs an entry because the ABI says so and because
66 /// an exception might pass by.
67 /// uwtable + nounwind = Needs an entry because the ABI says so.
70 // IR-Level Attributes
71 None, ///< No attributes have been set
73 #include "llvm/IR/Attributes.gen"
74 EndAttrKinds ///< Sentinal value useful for loops
78 AttributeImpl *pImpl = nullptr;
80 Attribute(AttributeImpl *A) : pImpl(A) {}
83 Attribute() = default;
85 //===--------------------------------------------------------------------===//
86 // Attribute Construction
87 //===--------------------------------------------------------------------===//
89 /// \brief Return a uniquified Attribute object.
90 static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
91 static Attribute get(LLVMContext &Context, StringRef Kind,
92 StringRef Val = StringRef());
94 /// \brief Return a uniquified Attribute object that has the specific
96 static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align);
97 static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align);
98 static Attribute getWithDereferenceableBytes(LLVMContext &Context,
100 static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context,
102 static Attribute getWithAllocSizeArgs(LLVMContext &Context,
103 unsigned ElemSizeArg,
104 const Optional<unsigned> &NumElemsArg);
106 //===--------------------------------------------------------------------===//
107 // Attribute Accessors
108 //===--------------------------------------------------------------------===//
110 /// \brief Return true if the attribute is an Attribute::AttrKind type.
111 bool isEnumAttribute() const;
113 /// \brief Return true if the attribute is an integer attribute.
114 bool isIntAttribute() const;
116 /// \brief Return true if the attribute is a string (target-dependent)
118 bool isStringAttribute() const;
120 /// \brief Return true if the attribute is present.
121 bool hasAttribute(AttrKind Val) const;
123 /// \brief Return true if the target-dependent attribute is present.
124 bool hasAttribute(StringRef Val) const;
126 /// \brief Return the attribute's kind as an enum (Attribute::AttrKind). This
127 /// requires the attribute to be an enum or integer attribute.
128 Attribute::AttrKind getKindAsEnum() const;
130 /// \brief Return the attribute's value as an integer. This requires that the
131 /// attribute be an integer attribute.
132 uint64_t getValueAsInt() const;
134 /// \brief Return the attribute's kind as a string. This requires the
135 /// attribute to be a string attribute.
136 StringRef getKindAsString() const;
138 /// \brief Return the attribute's value as a string. This requires the
139 /// attribute to be a string attribute.
140 StringRef getValueAsString() const;
142 /// \brief Returns the alignment field of an attribute as a byte alignment
144 unsigned getAlignment() const;
146 /// \brief Returns the stack alignment field of an attribute as a byte
148 unsigned getStackAlignment() const;
150 /// \brief Returns the number of dereferenceable bytes from the
151 /// dereferenceable attribute.
152 uint64_t getDereferenceableBytes() const;
154 /// \brief Returns the number of dereferenceable_or_null bytes from the
155 /// dereferenceable_or_null attribute.
156 uint64_t getDereferenceableOrNullBytes() const;
158 /// Returns the argument numbers for the allocsize attribute (or pair(0, 0)
160 std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
162 /// \brief The Attribute is converted to a string of equivalent mnemonic. This
163 /// is, presumably, for writing out the mnemonics for the assembly writer.
164 std::string getAsString(bool InAttrGrp = false) const;
166 /// \brief Equality and non-equality operators.
167 bool operator==(Attribute A) const { return pImpl == A.pImpl; }
168 bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
170 /// \brief Less-than operator. Useful for sorting the attributes list.
171 bool operator<(Attribute A) const;
173 void Profile(FoldingSetNodeID &ID) const {
174 ID.AddPointer(pImpl);
177 /// \brief Return a raw pointer that uniquely identifies this attribute.
178 void *getRawPointer() const {
182 /// \brief Get an attribute from a raw pointer created by getRawPointer.
183 static Attribute fromRawPointer(void *RawPtr) {
184 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
188 // Specialized opaque value conversions.
189 inline LLVMAttributeRef wrap(Attribute Attr) {
190 return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
193 // Specialized opaque value conversions.
194 inline Attribute unwrap(LLVMAttributeRef Attr) {
195 return Attribute::fromRawPointer(Attr);
198 //===----------------------------------------------------------------------===//
200 /// This class holds the attributes for a particular argument, parameter,
201 /// function, or return value. It is an immutable value type that is cheap to
202 /// copy. Adding and removing enum attributes is intended to be fast, but adding
203 /// and removing string or integer attributes involves a FoldingSet lookup.
205 // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
206 // This will allow an efficient implementation of addAttribute and
207 // removeAttribute for enum attrs.
209 /// Private implementation pointer.
210 AttributeSetNode *SetNode = nullptr;
212 friend AttributeListImpl;
213 template <typename Ty> friend struct DenseMapInfo;
216 explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
219 /// AttributeSet is a trivially copyable value type.
220 AttributeSet() = default;
221 AttributeSet(const AttributeSet &) = default;
222 ~AttributeSet() = default;
224 static AttributeSet get(LLVMContext &C, const AttrBuilder &B);
225 static AttributeSet get(LLVMContext &C, ArrayRef<Attribute> Attrs);
227 bool operator==(const AttributeSet &O) { return SetNode == O.SetNode; }
228 bool operator!=(const AttributeSet &O) { return !(*this == O); }
230 unsigned getNumAttributes() const;
232 bool hasAttributes() const { return SetNode != nullptr; }
234 bool hasAttribute(Attribute::AttrKind Kind) const;
235 bool hasAttribute(StringRef Kind) const;
237 Attribute getAttribute(Attribute::AttrKind Kind) const;
238 Attribute getAttribute(StringRef Kind) const;
240 unsigned getAlignment() const;
241 unsigned getStackAlignment() const;
242 uint64_t getDereferenceableBytes() const;
243 uint64_t getDereferenceableOrNullBytes() const;
244 std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
245 std::string getAsString(bool InAttrGrp = false) const;
247 typedef const Attribute *iterator;
248 iterator begin() const;
249 iterator end() const;
252 //===----------------------------------------------------------------------===//
254 /// \brief Provide DenseMapInfo for AttributeSet.
255 template <> struct DenseMapInfo<AttributeSet> {
256 static inline AttributeSet getEmptyKey() {
257 uintptr_t Val = static_cast<uintptr_t>(-1);
258 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
259 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
262 static inline AttributeSet getTombstoneKey() {
263 uintptr_t Val = static_cast<uintptr_t>(-2);
264 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
265 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
268 static unsigned getHashValue(AttributeSet AS) {
269 return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
270 (unsigned((uintptr_t)AS.SetNode) >> 9);
273 static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
276 //===----------------------------------------------------------------------===//
278 /// \brief This class holds the attributes for a function, its return value, and
279 /// its parameters. You access the attributes for each of them via an index into
280 /// the AttributeList object. The function attributes are at index
281 /// `AttributeList::FunctionIndex', the return value is at index
282 /// `AttributeList::ReturnIndex', and the attributes for the parameters start at
284 class AttributeList {
286 enum AttrIndex : unsigned {
292 friend class AttrBuilder;
293 friend class AttributeListImpl;
294 friend class AttributeSet;
295 friend class AttributeSetNode;
297 template <typename Ty> friend struct DenseMapInfo;
299 /// \brief The attributes that we are managing. This can be null to represent
300 /// the empty attributes list.
301 AttributeListImpl *pImpl = nullptr;
304 /// \brief Create an AttributeList with the specified parameters in it.
305 static AttributeList get(LLVMContext &C,
306 ArrayRef<std::pair<unsigned, Attribute>> Attrs);
308 get(LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
310 /// \brief Create an AttributeList from attribute sets for a function, its
311 /// return value, and all of its arguments.
312 static AttributeList get(LLVMContext &C, AttributeSet FnAttrs,
313 AttributeSet RetAttrs,
314 ArrayRef<AttributeSet> ArgAttrs);
317 getImpl(LLVMContext &C,
318 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
321 explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
324 AttributeList() = default;
326 //===--------------------------------------------------------------------===//
327 // AttributeList Construction and Mutation
328 //===--------------------------------------------------------------------===//
330 /// \brief Return an AttributeList with the specified parameters in it.
331 static AttributeList get(LLVMContext &C, ArrayRef<AttributeList> Attrs);
332 static AttributeList get(LLVMContext &C, unsigned Index,
333 ArrayRef<Attribute::AttrKind> Kinds);
334 static AttributeList get(LLVMContext &C, unsigned Index,
335 ArrayRef<StringRef> Kind);
336 static AttributeList get(LLVMContext &C, unsigned Index,
337 const AttrBuilder &B);
339 /// \brief Add an attribute to the attribute set at the given index. Because
340 /// attribute sets are immutable, this returns a new set.
341 AttributeList addAttribute(LLVMContext &C, unsigned Index,
342 Attribute::AttrKind Kind) const;
344 /// \brief Add an attribute to the attribute set at the given index. Because
345 /// attribute sets are immutable, this returns a new set.
346 AttributeList addAttribute(LLVMContext &C, unsigned Index, StringRef Kind,
347 StringRef Value = StringRef()) const;
349 /// Add an attribute to the attribute set at the given indices. Because
350 /// attribute sets are immutable, this returns a new set.
351 AttributeList addAttribute(LLVMContext &C, ArrayRef<unsigned> Indices,
354 /// \brief Add attributes to the attribute set at the given index. Because
355 /// attribute sets are immutable, this returns a new set.
356 AttributeList addAttributes(LLVMContext &C, unsigned Index,
357 AttributeList Attrs) const;
359 AttributeList addAttributes(LLVMContext &C, unsigned Index,
360 const AttrBuilder &B) const;
362 /// \brief Remove the specified attribute at the specified index from this
363 /// attribute list. Because attribute lists are immutable, this returns the
365 AttributeList removeAttribute(LLVMContext &C, unsigned Index,
366 Attribute::AttrKind Kind) const;
368 /// \brief Remove the specified attribute at the specified index from this
369 /// attribute list. Because attribute lists are immutable, this returns the
371 AttributeList removeAttribute(LLVMContext &C, unsigned Index,
372 StringRef Kind) const;
374 /// \brief Remove the specified attributes at the specified index from this
375 /// attribute list. Because attribute lists are immutable, this returns the
377 AttributeList removeAttributes(LLVMContext &C, unsigned Index,
378 AttributeList Attrs) const;
380 /// \brief Remove the specified attributes at the specified index from this
381 /// attribute list. Because attribute lists are immutable, this returns the
383 AttributeList removeAttributes(LLVMContext &C, unsigned Index,
384 const AttrBuilder &Attrs) const;
386 /// \brief Remove all attributes at the specified index from this
387 /// attribute list. Because attribute lists are immutable, this returns the
389 AttributeList removeAttributes(LLVMContext &C, unsigned Index) const;
391 /// \brief Add the dereferenceable attribute to the attribute set at the given
392 /// index. Because attribute sets are immutable, this returns a new set.
393 AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index,
394 uint64_t Bytes) const;
396 /// \brief Add the dereferenceable_or_null attribute to the attribute set at
397 /// the given index. Because attribute sets are immutable, this returns a new
399 AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index,
400 uint64_t Bytes) const;
402 /// Add the allocsize attribute to the attribute set at the given index.
403 /// Because attribute sets are immutable, this returns a new set.
404 AttributeList addAllocSizeAttr(LLVMContext &C, unsigned Index,
405 unsigned ElemSizeArg,
406 const Optional<unsigned> &NumElemsArg);
408 //===--------------------------------------------------------------------===//
409 // AttributeList Accessors
410 //===--------------------------------------------------------------------===//
412 /// \brief Retrieve the LLVM context.
413 LLVMContext &getContext() const;
415 /// \brief The attributes for the specified index are returned.
416 AttributeSet getAttributes(unsigned Index) const;
418 /// \brief The attributes for the argument or parameter at the given index are
420 AttributeSet getParamAttributes(unsigned ArgNo) const;
422 /// \brief The attributes for the ret value are returned.
423 AttributeSet getRetAttributes() const;
425 /// \brief The function attributes are returned.
426 AttributeSet getFnAttributes() const;
428 /// \brief Return true if the attribute exists at the given index.
429 bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const;
431 /// \brief Return true if the attribute exists at the given index.
432 bool hasAttribute(unsigned Index, StringRef Kind) const;
434 /// \brief Return true if attribute exists at the given index.
435 bool hasAttributes(unsigned Index) const;
437 /// \brief Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but
439 bool hasFnAttribute(Attribute::AttrKind Kind) const;
441 /// \brief Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but
443 bool hasFnAttribute(StringRef Kind) const;
445 /// \brief Equivalent to hasAttribute(ArgNo + 1, Kind).
446 bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const;
448 /// \brief Return true if the specified attribute is set for at least one
449 /// parameter or for the return value. If Index is not nullptr, the index
450 /// of a parameter with the specified attribute is provided.
451 bool hasAttrSomewhere(Attribute::AttrKind Kind,
452 unsigned *Index = nullptr) const;
454 /// \brief Return the attribute object that exists at the given index.
455 Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const;
457 /// \brief Return the attribute object that exists at the given index.
458 Attribute getAttribute(unsigned Index, StringRef Kind) const;
460 /// \brief Return the alignment for the specified function parameter.
461 unsigned getParamAlignment(unsigned Index) const;
463 /// \brief Get the stack alignment.
464 unsigned getStackAlignment(unsigned Index) const;
466 /// \brief Get the number of dereferenceable bytes (or zero if unknown).
467 uint64_t getDereferenceableBytes(unsigned Index) const;
469 /// \brief Get the number of dereferenceable_or_null bytes (or zero if
471 uint64_t getDereferenceableOrNullBytes(unsigned Index) const;
473 /// Get the allocsize argument numbers (or pair(0, 0) if unknown).
474 std::pair<unsigned, Optional<unsigned>>
475 getAllocSizeArgs(unsigned Index) const;
477 /// \brief Return the attributes at the index as a string.
478 std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
480 typedef ArrayRef<Attribute>::iterator iterator;
482 iterator begin(unsigned Slot) const;
483 iterator end(unsigned Slot) const;
485 /// operator==/!= - Provide equality predicates.
486 bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
487 bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
489 //===--------------------------------------------------------------------===//
490 // AttributeList Introspection
491 //===--------------------------------------------------------------------===//
493 /// \brief Return a raw pointer that uniquely identifies this attribute list.
494 void *getRawPointer() const {
498 /// \brief Return true if there are no attributes.
499 bool isEmpty() const {
500 return getNumSlots() == 0;
503 /// \brief Return the number of slots used in this attribute list. This is
504 /// the number of arguments that have an attribute set on them (including the
505 /// function itself).
506 unsigned getNumSlots() const;
508 /// \brief Return the index for the given slot.
509 unsigned getSlotIndex(unsigned Slot) const;
511 /// \brief Return the attributes at the given slot.
512 AttributeList getSlotAttributes(unsigned Slot) const;
517 //===----------------------------------------------------------------------===//
519 /// \brief Provide DenseMapInfo for AttributeList.
520 template <> struct DenseMapInfo<AttributeList> {
521 static inline AttributeList getEmptyKey() {
522 uintptr_t Val = static_cast<uintptr_t>(-1);
523 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
524 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
527 static inline AttributeList getTombstoneKey() {
528 uintptr_t Val = static_cast<uintptr_t>(-2);
529 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
530 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
533 static unsigned getHashValue(AttributeList AS) {
534 return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
535 (unsigned((uintptr_t)AS.pImpl) >> 9);
538 static bool isEqual(AttributeList LHS, AttributeList RHS) {
543 //===----------------------------------------------------------------------===//
545 /// \brief This class is used in conjunction with the Attribute::get method to
546 /// create an Attribute object. The object itself is uniquified. The Builder's
547 /// value, however, is not. So this can be used as a quick way to test for
548 /// equality, presence of attributes, etc.
550 std::bitset<Attribute::EndAttrKinds> Attrs;
551 std::map<std::string, std::string> TargetDepAttrs;
552 uint64_t Alignment = 0;
553 uint64_t StackAlignment = 0;
554 uint64_t DerefBytes = 0;
555 uint64_t DerefOrNullBytes = 0;
556 uint64_t AllocSizeArgs = 0;
559 AttrBuilder() = default;
560 AttrBuilder(const Attribute &A) {
563 AttrBuilder(AttributeList AS, unsigned Idx);
564 AttrBuilder(AttributeSet AS);
568 /// \brief Add an attribute to the builder.
569 AttrBuilder &addAttribute(Attribute::AttrKind Val);
571 /// \brief Add the Attribute object to the builder.
572 AttrBuilder &addAttribute(Attribute A);
574 /// \brief Add the target-dependent attribute to the builder.
575 AttrBuilder &addAttribute(StringRef A, StringRef V = StringRef());
577 /// \brief Remove an attribute from the builder.
578 AttrBuilder &removeAttribute(Attribute::AttrKind Val);
580 /// \brief Remove the attributes from the builder.
581 AttrBuilder &removeAttributes(AttributeList A, uint64_t WithoutIndex);
583 /// \brief Remove the target-dependent attribute to the builder.
584 AttrBuilder &removeAttribute(StringRef A);
586 /// \brief Add the attributes from the builder.
587 AttrBuilder &merge(const AttrBuilder &B);
589 /// \brief Remove the attributes from the builder.
590 AttrBuilder &remove(const AttrBuilder &B);
592 /// \brief Return true if the builder has any attribute that's in the
593 /// specified builder.
594 bool overlaps(const AttrBuilder &B) const;
596 /// \brief Return true if the builder has the specified attribute.
597 bool contains(Attribute::AttrKind A) const {
598 assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
602 /// \brief Return true if the builder has the specified target-dependent
604 bool contains(StringRef A) const;
606 /// \brief Return true if the builder has IR-level attributes.
607 bool hasAttributes() const;
609 /// \brief Return true if the builder has any attribute that's in the
610 /// specified attribute.
611 bool hasAttributes(AttributeList A, uint64_t Index) const;
613 /// \brief Return true if the builder has an alignment attribute.
614 bool hasAlignmentAttr() const;
616 /// \brief Retrieve the alignment attribute, if it exists.
617 uint64_t getAlignment() const { return Alignment; }
619 /// \brief Retrieve the stack alignment attribute, if it exists.
620 uint64_t getStackAlignment() const { return StackAlignment; }
622 /// \brief Retrieve the number of dereferenceable bytes, if the
623 /// dereferenceable attribute exists (zero is returned otherwise).
624 uint64_t getDereferenceableBytes() const { return DerefBytes; }
626 /// \brief Retrieve the number of dereferenceable_or_null bytes, if the
627 /// dereferenceable_or_null attribute exists (zero is returned otherwise).
628 uint64_t getDereferenceableOrNullBytes() const { return DerefOrNullBytes; }
630 /// Retrieve the allocsize args, if the allocsize attribute exists. If it
631 /// doesn't exist, pair(0, 0) is returned.
632 std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
634 /// \brief This turns an int alignment (which must be a power of 2) into the
635 /// form used internally in Attribute.
636 AttrBuilder &addAlignmentAttr(unsigned Align);
638 /// \brief This turns an int stack alignment (which must be a power of 2) into
639 /// the form used internally in Attribute.
640 AttrBuilder &addStackAlignmentAttr(unsigned Align);
642 /// \brief This turns the number of dereferenceable bytes into the form used
643 /// internally in Attribute.
644 AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
646 /// \brief This turns the number of dereferenceable_or_null bytes into the
647 /// form used internally in Attribute.
648 AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
650 /// This turns one (or two) ints into the form used internally in Attribute.
651 AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
652 const Optional<unsigned> &NumElemsArg);
654 /// Add an allocsize attribute, using the representation returned by
655 /// Attribute.getIntValue().
656 AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr);
658 /// \brief Return true if the builder contains no target-independent
660 bool empty() const { return Attrs.none(); }
662 // Iterators for target-dependent attributes.
663 typedef std::pair<std::string, std::string> td_type;
664 typedef std::map<std::string, std::string>::iterator td_iterator;
665 typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
666 typedef iterator_range<td_iterator> td_range;
667 typedef iterator_range<td_const_iterator> td_const_range;
669 td_iterator td_begin() { return TargetDepAttrs.begin(); }
670 td_iterator td_end() { return TargetDepAttrs.end(); }
672 td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
673 td_const_iterator td_end() const { return TargetDepAttrs.end(); }
675 td_range td_attrs() { return td_range(td_begin(), td_end()); }
676 td_const_range td_attrs() const {
677 return td_const_range(td_begin(), td_end());
680 bool td_empty() const { return TargetDepAttrs.empty(); }
682 bool operator==(const AttrBuilder &B);
683 bool operator!=(const AttrBuilder &B) {
684 return !(*this == B);
688 namespace AttributeFuncs {
690 /// \brief Which attributes cannot be applied to a type.
691 AttrBuilder typeIncompatible(Type *Ty);
693 /// \returns Return true if the two functions have compatible target-independent
694 /// attributes for inlining purposes.
695 bool areInlineCompatible(const Function &Caller, const Function &Callee);
697 /// \brief Merge caller's and callee's attributes.
698 void mergeAttributesForInlining(Function &Caller, const Function &Callee);
700 } // end AttributeFuncs namespace
702 } // end llvm namespace
704 #endif // LLVM_IR_ATTRIBUTES_H