Attributes.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. //===-- llvm/Attributes.h - Container for Attributes ------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. ///
  10. /// \file
  11. /// \brief This file contains the simple types necessary to represent the
  12. /// attributes associated with functions and their calls.
  13. ///
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_IR_ATTRIBUTES_H
  16. #define LLVM_IR_ATTRIBUTES_H
  17. #include "llvm/ADT/ArrayRef.h"
  18. #include "llvm/ADT/FoldingSet.h"
  19. #include "llvm/Support/Compiler.h"
  20. #include "llvm/Support/PointerLikeTypeTraits.h"
  21. #include <bitset>
  22. #include <cassert>
  23. #include <map>
  24. #include <string>
  25. namespace llvm {
  26. class AttrBuilder;
  27. class AttributeImpl;
  28. class AttributeSetImpl;
  29. class AttributeSetNode;
  30. class Constant;
  31. template<typename T> struct DenseMapInfo;
  32. class LLVMContext;
  33. class Type;
  34. //===----------------------------------------------------------------------===//
  35. /// \class
  36. /// \brief Functions, function parameters, and return types can have attributes
  37. /// to indicate how they should be treated by optimizations and code
  38. /// generation. This class represents one of those attributes. It's light-weight
  39. /// and should be passed around by-value.
  40. class Attribute {
  41. public:
  42. /// This enumeration lists the attributes that can be associated with
  43. /// parameters, function results, or the function itself.
  44. ///
  45. /// Note: The `uwtable' attribute is about the ABI or the user mandating an
  46. /// entry in the unwind table. The `nounwind' attribute is about an exception
  47. /// passing by the function.
  48. ///
  49. /// In a theoretical system that uses tables for profiling and SjLj for
  50. /// exceptions, they would be fully independent. In a normal system that uses
  51. /// tables for both, the semantics are:
  52. ///
  53. /// nil = Needs an entry because an exception might pass by.
  54. /// nounwind = No need for an entry
  55. /// uwtable = Needs an entry because the ABI says so and because
  56. /// an exception might pass by.
  57. /// uwtable + nounwind = Needs an entry because the ABI says so.
  58. enum AttrKind {
  59. // IR-Level Attributes
  60. None, ///< No attributes have been set
  61. Alignment, ///< Alignment of parameter (5 bits)
  62. ///< stored as log2 of alignment with +1 bias
  63. ///< 0 means unaligned (different from align(1))
  64. AlwaysInline, ///< inline=always
  65. Builtin, ///< Callee is recognized as a builtin, despite
  66. ///< nobuiltin attribute on its declaration.
  67. ByVal, ///< Pass structure by value
  68. InAlloca, ///< Pass structure in an alloca
  69. Cold, ///< Marks function as being in a cold path.
  70. Convergent, ///< Can only be moved to control-equivalent blocks
  71. InlineHint, ///< Source said inlining was desirable
  72. InReg, ///< Force argument to be passed in register
  73. JumpTable, ///< Build jump-instruction tables and replace refs.
  74. MinSize, ///< Function must be optimized for size first
  75. Naked, ///< Naked function
  76. Nest, ///< Nested function static chain
  77. NoAlias, ///< Considered to not alias after call
  78. NoBuiltin, ///< Callee isn't recognized as a builtin
  79. NoCapture, ///< Function creates no aliases of pointer
  80. NoDuplicate, ///< Call cannot be duplicated
  81. NoImplicitFloat, ///< Disable implicit floating point insts
  82. NoInline, ///< inline=never
  83. NonLazyBind, ///< Function is called early and/or
  84. ///< often, so lazy binding isn't worthwhile
  85. NonNull, ///< Pointer is known to be not null
  86. Dereferenceable, ///< Pointer is known to be dereferenceable
  87. DereferenceableOrNull, ///< Pointer is either null or dereferenceable
  88. NoRedZone, ///< Disable redzone
  89. NoReturn, ///< Mark the function as not returning
  90. NoUnwind, ///< Function doesn't unwind stack
  91. OptimizeForSize, ///< opt_size
  92. OptimizeNone, ///< Function must not be optimized.
  93. ReadNone, ///< Function does not access memory
  94. ReadOnly, ///< Function only reads from memory
  95. ArgMemOnly, ///< Funciton can access memory only using pointers
  96. ///< based on its arguments.
  97. Returned, ///< Return value is always equal to this argument
  98. ReturnsTwice, ///< Function can return twice
  99. SExt, ///< Sign extended before/after call
  100. StackAlignment, ///< Alignment of stack for function (3 bits)
  101. ///< stored as log2 of alignment with +1 bias 0
  102. ///< means unaligned (different from
  103. ///< alignstack=(1))
  104. StackProtect, ///< Stack protection.
  105. StackProtectReq, ///< Stack protection required.
  106. StackProtectStrong, ///< Strong Stack protection.
  107. SafeStack, ///< Safe Stack protection.
  108. StructRet, ///< Hidden pointer to structure to return
  109. SanitizeAddress, ///< AddressSanitizer is on.
  110. SanitizeThread, ///< ThreadSanitizer is on.
  111. SanitizeMemory, ///< MemorySanitizer is on.
  112. UWTable, ///< Function must be in a unwind table
  113. ZExt, ///< Zero extended before/after call
  114. EndAttrKinds ///< Sentinal value useful for loops
  115. };
  116. private:
  117. AttributeImpl *pImpl;
  118. Attribute(AttributeImpl *A) : pImpl(A) {}
  119. public:
  120. Attribute() : pImpl(nullptr) {}
  121. //===--------------------------------------------------------------------===//
  122. // Attribute Construction
  123. //===--------------------------------------------------------------------===//
  124. /// \brief Return a uniquified Attribute object.
  125. static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
  126. static Attribute get(LLVMContext &Context, StringRef Kind,
  127. StringRef Val = StringRef());
  128. /// \brief Return a uniquified Attribute object that has the specific
  129. /// alignment set.
  130. static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align);
  131. static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align);
  132. static Attribute getWithDereferenceableBytes(LLVMContext &Context,
  133. uint64_t Bytes);
  134. static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context,
  135. uint64_t Bytes);
  136. //===--------------------------------------------------------------------===//
  137. // Attribute Accessors
  138. //===--------------------------------------------------------------------===//
  139. /// \brief Return true if the attribute is an Attribute::AttrKind type.
  140. bool isEnumAttribute() const;
  141. /// \brief Return true if the attribute is an integer attribute.
  142. bool isIntAttribute() const;
  143. /// \brief Return true if the attribute is a string (target-dependent)
  144. /// attribute.
  145. bool isStringAttribute() const;
  146. /// \brief Return true if the attribute is present.
  147. bool hasAttribute(AttrKind Val) const;
  148. /// \brief Return true if the target-dependent attribute is present.
  149. bool hasAttribute(StringRef Val) const;
  150. /// \brief Return the attribute's kind as an enum (Attribute::AttrKind). This
  151. /// requires the attribute to be an enum or alignment attribute.
  152. Attribute::AttrKind getKindAsEnum() const;
  153. /// \brief Return the attribute's value as an integer. This requires that the
  154. /// attribute be an alignment attribute.
  155. uint64_t getValueAsInt() const;
  156. /// \brief Return the attribute's kind as a string. This requires the
  157. /// attribute to be a string attribute.
  158. StringRef getKindAsString() const;
  159. /// \brief Return the attribute's value as a string. This requires the
  160. /// attribute to be a string attribute.
  161. StringRef getValueAsString() const;
  162. /// \brief Returns the alignment field of an attribute as a byte alignment
  163. /// value.
  164. unsigned getAlignment() const;
  165. /// \brief Returns the stack alignment field of an attribute as a byte
  166. /// alignment value.
  167. unsigned getStackAlignment() const;
  168. /// \brief Returns the number of dereferenceable bytes from the
  169. /// dereferenceable attribute (or zero if unknown).
  170. uint64_t getDereferenceableBytes() const;
  171. /// \brief Returns the number of dereferenceable_or_null bytes from the
  172. /// dereferenceable_or_null attribute (or zero if unknown).
  173. uint64_t getDereferenceableOrNullBytes() const;
  174. /// \brief The Attribute is converted to a string of equivalent mnemonic. This
  175. /// is, presumably, for writing out the mnemonics for the assembly writer.
  176. std::string getAsString(bool InAttrGrp = false) const;
  177. /// \brief Equality and non-equality operators.
  178. bool operator==(Attribute A) const { return pImpl == A.pImpl; }
  179. bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
  180. /// \brief Less-than operator. Useful for sorting the attributes list.
  181. bool operator<(Attribute A) const;
  182. void Profile(FoldingSetNodeID &ID) const {
  183. ID.AddPointer(pImpl);
  184. }
  185. };
  186. //===----------------------------------------------------------------------===//
  187. /// \class
  188. /// \brief This class holds the attributes for a function, its return value, and
  189. /// its parameters. You access the attributes for each of them via an index into
  190. /// the AttributeSet object. The function attributes are at index
  191. /// `AttributeSet::FunctionIndex', the return value is at index
  192. /// `AttributeSet::ReturnIndex', and the attributes for the parameters start at
  193. /// index `1'.
  194. class AttributeSet {
  195. public:
  196. enum AttrIndex : unsigned {
  197. ReturnIndex = 0U,
  198. FunctionIndex = ~0U
  199. };
  200. private:
  201. friend class AttrBuilder;
  202. friend class AttributeSetImpl;
  203. template <typename Ty> friend struct DenseMapInfo;
  204. /// \brief The attributes that we are managing. This can be null to represent
  205. /// the empty attributes list.
  206. AttributeSetImpl *pImpl;
  207. /// \brief The attributes for the specified index are returned.
  208. AttributeSetNode *getAttributes(unsigned Index) const;
  209. /// \brief Create an AttributeSet with the specified parameters in it.
  210. static AttributeSet get(LLVMContext &C,
  211. ArrayRef<std::pair<unsigned, Attribute> > Attrs);
  212. static AttributeSet get(LLVMContext &C,
  213. ArrayRef<std::pair<unsigned,
  214. AttributeSetNode*> > Attrs);
  215. static AttributeSet getImpl(LLVMContext &C,
  216. ArrayRef<std::pair<unsigned,
  217. AttributeSetNode*> > Attrs);
  218. explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
  219. public:
  220. AttributeSet() : pImpl(nullptr) {}
  221. //===--------------------------------------------------------------------===//
  222. // AttributeSet Construction and Mutation
  223. //===--------------------------------------------------------------------===//
  224. /// \brief Return an AttributeSet with the specified parameters in it.
  225. static AttributeSet get(LLVMContext &C, ArrayRef<AttributeSet> Attrs);
  226. static AttributeSet get(LLVMContext &C, unsigned Index,
  227. ArrayRef<Attribute::AttrKind> Kind);
  228. static AttributeSet get(LLVMContext &C, unsigned Index, const AttrBuilder &B);
  229. /// \brief Add an attribute to the attribute set at the given index. Because
  230. /// attribute sets are immutable, this returns a new set.
  231. AttributeSet addAttribute(LLVMContext &C, unsigned Index,
  232. Attribute::AttrKind Attr) const;
  233. /// \brief Add an attribute to the attribute set at the given index. Because
  234. /// attribute sets are immutable, this returns a new set.
  235. AttributeSet addAttribute(LLVMContext &C, unsigned Index,
  236. StringRef Kind) const;
  237. AttributeSet addAttribute(LLVMContext &C, unsigned Index,
  238. StringRef Kind, StringRef Value) const;
  239. /// \brief Add attributes to the attribute set at the given index. Because
  240. /// attribute sets are immutable, this returns a new set.
  241. AttributeSet addAttributes(LLVMContext &C, unsigned Index,
  242. AttributeSet Attrs) const;
  243. /// \brief Remove the specified attribute at the specified index from this
  244. /// attribute list. Because attribute lists are immutable, this returns the
  245. /// new list.
  246. AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
  247. Attribute::AttrKind Attr) const;
  248. /// \brief Remove the specified attributes at the specified index from this
  249. /// attribute list. Because attribute lists are immutable, this returns the
  250. /// new list.
  251. AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
  252. AttributeSet Attrs) const;
  253. /// \brief Remove the specified attributes at the specified index from this
  254. /// attribute list. Because attribute lists are immutable, this returns the
  255. /// new list.
  256. AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
  257. const AttrBuilder &Attrs) const;
  258. /// \brief Add the dereferenceable attribute to the attribute set at the given
  259. /// index. Because attribute sets are immutable, this returns a new set.
  260. AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index,
  261. uint64_t Bytes) const;
  262. /// \brief Add the dereferenceable_or_null attribute to the attribute set at
  263. /// the given index. Because attribute sets are immutable, this returns a new
  264. /// set.
  265. AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index,
  266. uint64_t Bytes) const;
  267. //===--------------------------------------------------------------------===//
  268. // AttributeSet Accessors
  269. //===--------------------------------------------------------------------===//
  270. /// \brief Retrieve the LLVM context.
  271. LLVMContext &getContext() const;
  272. /// \brief The attributes for the specified index are returned.
  273. AttributeSet getParamAttributes(unsigned Index) const;
  274. /// \brief The attributes for the ret value are returned.
  275. AttributeSet getRetAttributes() const;
  276. /// \brief The function attributes are returned.
  277. AttributeSet getFnAttributes() const;
  278. /// \brief Return true if the attribute exists at the given index.
  279. bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const;
  280. /// \brief Return true if the attribute exists at the given index.
  281. bool hasAttribute(unsigned Index, StringRef Kind) const;
  282. /// \brief Return true if attribute exists at the given index.
  283. bool hasAttributes(unsigned Index) const;
  284. /// \brief Return true if the specified attribute is set for at least one
  285. /// parameter or for the return value.
  286. bool hasAttrSomewhere(Attribute::AttrKind Attr) const;
  287. /// \brief Return the attribute object that exists at the given index.
  288. Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const;
  289. /// \brief Return the attribute object that exists at the given index.
  290. Attribute getAttribute(unsigned Index, StringRef Kind) const;
  291. /// \brief Return the alignment for the specified function parameter.
  292. unsigned getParamAlignment(unsigned Index) const;
  293. /// \brief Get the stack alignment.
  294. unsigned getStackAlignment(unsigned Index) const;
  295. /// \brief Get the number of dereferenceable bytes (or zero if unknown).
  296. uint64_t getDereferenceableBytes(unsigned Index) const;
  297. /// \brief Get the number of dereferenceable_or_null bytes (or zero if
  298. /// unknown).
  299. uint64_t getDereferenceableOrNullBytes(unsigned Index) const;
  300. /// \brief Return the attributes at the index as a string.
  301. std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
  302. typedef ArrayRef<Attribute>::iterator iterator;
  303. iterator begin(unsigned Slot) const;
  304. iterator end(unsigned Slot) const;
  305. /// operator==/!= - Provide equality predicates.
  306. bool operator==(const AttributeSet &RHS) const {
  307. return pImpl == RHS.pImpl;
  308. }
  309. bool operator!=(const AttributeSet &RHS) const {
  310. return pImpl != RHS.pImpl;
  311. }
  312. //===--------------------------------------------------------------------===//
  313. // AttributeSet Introspection
  314. //===--------------------------------------------------------------------===//
  315. // FIXME: Remove this.
  316. uint64_t Raw(unsigned Index) const;
  317. /// \brief Return a raw pointer that uniquely identifies this attribute list.
  318. void *getRawPointer() const {
  319. return pImpl;
  320. }
  321. /// \brief Return true if there are no attributes.
  322. bool isEmpty() const {
  323. return getNumSlots() == 0;
  324. }
  325. /// \brief Return the number of slots used in this attribute list. This is
  326. /// the number of arguments that have an attribute set on them (including the
  327. /// function itself).
  328. unsigned getNumSlots() const;
  329. /// \brief Return the index for the given slot.
  330. unsigned getSlotIndex(unsigned Slot) const;
  331. /// \brief Return the attributes at the given slot.
  332. AttributeSet getSlotAttributes(unsigned Slot) const;
  333. void dump() const;
  334. };
  335. //===----------------------------------------------------------------------===//
  336. /// \class
  337. /// \brief Provide DenseMapInfo for AttributeSet.
  338. template<> struct DenseMapInfo<AttributeSet> {
  339. static inline AttributeSet getEmptyKey() {
  340. uintptr_t Val = static_cast<uintptr_t>(-1);
  341. Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
  342. return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
  343. }
  344. static inline AttributeSet getTombstoneKey() {
  345. uintptr_t Val = static_cast<uintptr_t>(-2);
  346. Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
  347. return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
  348. }
  349. static unsigned getHashValue(AttributeSet AS) {
  350. return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
  351. (unsigned((uintptr_t)AS.pImpl) >> 9);
  352. }
  353. static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
  354. };
  355. // //
  356. ///////////////////////////////////////////////////////////////////////////////
  357. /// \class
  358. /// \brief This class is used in conjunction with the Attribute::get method to
  359. /// create an Attribute object. The object itself is uniquified. The Builder's
  360. /// value, however, is not. So this can be used as a quick way to test for
  361. /// equality, presence of attributes, etc.
  362. class AttrBuilder {
  363. std::bitset<Attribute::EndAttrKinds> Attrs;
  364. std::map<std::string, std::string> TargetDepAttrs;
  365. uint64_t Alignment;
  366. uint64_t StackAlignment;
  367. uint64_t DerefBytes;
  368. uint64_t DerefOrNullBytes;
  369. public:
  370. AttrBuilder()
  371. : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
  372. DerefOrNullBytes(0) {}
  373. explicit AttrBuilder(uint64_t Val)
  374. : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
  375. DerefOrNullBytes(0) {
  376. addRawValue(Val);
  377. }
  378. AttrBuilder(const Attribute &A)
  379. : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
  380. DerefOrNullBytes(0) {
  381. addAttribute(A);
  382. }
  383. AttrBuilder(AttributeSet AS, unsigned Idx);
  384. void clear();
  385. /// \brief Add an attribute to the builder.
  386. AttrBuilder &addAttribute(Attribute::AttrKind Val);
  387. /// \brief Add the Attribute object to the builder.
  388. AttrBuilder &addAttribute(Attribute A);
  389. /// \brief Add the target-dependent attribute to the builder.
  390. AttrBuilder &addAttribute(StringRef A, StringRef V = StringRef());
  391. /// \brief Remove an attribute from the builder.
  392. AttrBuilder &removeAttribute(Attribute::AttrKind Val);
  393. /// \brief Remove the attributes from the builder.
  394. AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
  395. /// \brief Remove the target-dependent attribute to the builder.
  396. AttrBuilder &removeAttribute(StringRef A);
  397. /// \brief Add the attributes from the builder.
  398. AttrBuilder &merge(const AttrBuilder &B);
  399. /// \brief Remove the attributes from the builder.
  400. AttrBuilder &remove(const AttrBuilder &B);
  401. /// \brief Return true if the builder has any attribute that's in the
  402. /// specified builder.
  403. bool overlaps(const AttrBuilder &B) const;
  404. /// \brief Return true if the builder has the specified attribute.
  405. bool contains(Attribute::AttrKind A) const {
  406. assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
  407. return Attrs[A];
  408. }
  409. /// \brief Return true if the builder has the specified target-dependent
  410. /// attribute.
  411. bool contains(StringRef A) const;
  412. /// \brief Return true if the builder has IR-level attributes.
  413. bool hasAttributes() const;
  414. /// \brief Return true if the builder has any attribute that's in the
  415. /// specified attribute.
  416. bool hasAttributes(AttributeSet A, uint64_t Index) const;
  417. /// \brief Return true if the builder has an alignment attribute.
  418. bool hasAlignmentAttr() const;
  419. /// \brief Retrieve the alignment attribute, if it exists.
  420. uint64_t getAlignment() const { return Alignment; }
  421. /// \brief Retrieve the stack alignment attribute, if it exists.
  422. uint64_t getStackAlignment() const { return StackAlignment; }
  423. /// \brief Retrieve the number of dereferenceable bytes, if the dereferenceable
  424. /// attribute exists (zero is returned otherwise).
  425. uint64_t getDereferenceableBytes() const { return DerefBytes; }
  426. /// \brief Retrieve the number of dereferenceable_or_null bytes, if the
  427. /// dereferenceable_or_null attribute exists (zero is returned otherwise).
  428. uint64_t getDereferenceableOrNullBytes() const { return DerefOrNullBytes; }
  429. /// \brief This turns an int alignment (which must be a power of 2) into the
  430. /// form used internally in Attribute.
  431. AttrBuilder &addAlignmentAttr(unsigned Align);
  432. /// \brief This turns an int stack alignment (which must be a power of 2) into
  433. /// the form used internally in Attribute.
  434. AttrBuilder &addStackAlignmentAttr(unsigned Align);
  435. /// \brief This turns the number of dereferenceable bytes into the form used
  436. /// internally in Attribute.
  437. AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
  438. /// \brief This turns the number of dereferenceable_or_null bytes into the
  439. /// form used internally in Attribute.
  440. AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
  441. /// \brief Return true if the builder contains no target-independent
  442. /// attributes.
  443. bool empty() const { return Attrs.none(); }
  444. // Iterators for target-dependent attributes.
  445. typedef std::pair<std::string, std::string> td_type;
  446. typedef std::map<std::string, std::string>::iterator td_iterator;
  447. typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
  448. typedef llvm::iterator_range<td_iterator> td_range;
  449. typedef llvm::iterator_range<td_const_iterator> td_const_range;
  450. td_iterator td_begin() { return TargetDepAttrs.begin(); }
  451. td_iterator td_end() { return TargetDepAttrs.end(); }
  452. td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
  453. td_const_iterator td_end() const { return TargetDepAttrs.end(); }
  454. td_range td_attrs() { return td_range(td_begin(), td_end()); }
  455. td_const_range td_attrs() const {
  456. return td_const_range(td_begin(), td_end());
  457. }
  458. bool td_empty() const { return TargetDepAttrs.empty(); }
  459. bool operator==(const AttrBuilder &B);
  460. bool operator!=(const AttrBuilder &B) {
  461. return !(*this == B);
  462. }
  463. // FIXME: Remove this in 4.0.
  464. /// \brief Add the raw value to the internal representation.
  465. AttrBuilder &addRawValue(uint64_t Val);
  466. };
  467. namespace AttributeFuncs {
  468. /// \brief Which attributes cannot be applied to a type.
  469. AttrBuilder typeIncompatible(const Type *Ty);
  470. } // end AttributeFuncs namespace
  471. } // end llvm namespace
  472. #endif