LLVM  mainline
Attributes.h
Go to the documentation of this file.
00001 //===-- llvm/Attributes.h - Container for Attributes ------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 ///
00010 /// \file
00011 /// \brief This file contains the simple types necessary to represent the
00012 /// attributes associated with functions and their calls.
00013 ///
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_IR_ATTRIBUTES_H
00017 #define LLVM_IR_ATTRIBUTES_H
00018 
00019 #include "llvm/ADT/ArrayRef.h"
00020 #include "llvm/ADT/FoldingSet.h"
00021 #include "llvm/Support/Compiler.h"
00022 #include "llvm/Support/PointerLikeTypeTraits.h"
00023 #include <bitset>
00024 #include <cassert>
00025 #include <map>
00026 #include <string>
00027 
00028 namespace llvm {
00029 
00030 class AttrBuilder;
00031 class AttributeImpl;
00032 class AttributeSetImpl;
00033 class AttributeSetNode;
00034 class Constant;
00035 template<typename T> struct DenseMapInfo;
00036 class LLVMContext;
00037 class Type;
00038 
00039 //===----------------------------------------------------------------------===//
00040 /// \class
00041 /// \brief Functions, function parameters, and return types can have attributes
00042 /// to indicate how they should be treated by optimizations and code
00043 /// generation. This class represents one of those attributes. It's light-weight
00044 /// and should be passed around by-value.
00045 class Attribute {
00046 public:
00047   /// This enumeration lists the attributes that can be associated with
00048   /// parameters, function results, or the function itself.
00049   ///
00050   /// Note: The `uwtable' attribute is about the ABI or the user mandating an
00051   /// entry in the unwind table. The `nounwind' attribute is about an exception
00052   /// passing by the function.
00053   ///
00054   /// In a theoretical system that uses tables for profiling and SjLj for
00055   /// exceptions, they would be fully independent. In a normal system that uses
00056   /// tables for both, the semantics are:
00057   ///
00058   /// nil                = Needs an entry because an exception might pass by.
00059   /// nounwind           = No need for an entry
00060   /// uwtable            = Needs an entry because the ABI says so and because
00061   ///                      an exception might pass by.
00062   /// uwtable + nounwind = Needs an entry because the ABI says so.
00063 
00064   enum AttrKind {
00065     // IR-Level Attributes
00066     None,                  ///< No attributes have been set
00067     Alignment,             ///< Alignment of parameter (5 bits)
00068                            ///< stored as log2 of alignment with +1 bias
00069                            ///< 0 means unaligned (different from align(1))
00070     AlwaysInline,          ///< inline=always
00071     Builtin,               ///< Callee is recognized as a builtin, despite
00072                            ///< nobuiltin attribute on its declaration.
00073     ByVal,                 ///< Pass structure by value
00074     InAlloca,              ///< Pass structure in an alloca
00075     Cold,                  ///< Marks function as being in a cold path.
00076     Convergent,            ///< Can only be moved to control-equivalent blocks
00077     InlineHint,            ///< Source said inlining was desirable
00078     InReg,                 ///< Force argument to be passed in register
00079     JumpTable,             ///< Build jump-instruction tables and replace refs.
00080     MinSize,               ///< Function must be optimized for size first
00081     Naked,                 ///< Naked function
00082     Nest,                  ///< Nested function static chain
00083     NoAlias,               ///< Considered to not alias after call
00084     NoBuiltin,             ///< Callee isn't recognized as a builtin
00085     NoCapture,             ///< Function creates no aliases of pointer
00086     NoDuplicate,           ///< Call cannot be duplicated
00087     NoImplicitFloat,       ///< Disable implicit floating point insts
00088     NoInline,              ///< inline=never
00089     NonLazyBind,           ///< Function is called early and/or
00090                            ///< often, so lazy binding isn't worthwhile
00091     NonNull,               ///< Pointer is known to be not null
00092     Dereferenceable,       ///< Pointer is known to be dereferenceable
00093     DereferenceableOrNull, ///< Pointer is either null or dereferenceable
00094     NoRedZone,             ///< Disable redzone
00095     NoReturn,              ///< Mark the function as not returning
00096     NoUnwind,              ///< Function doesn't unwind stack
00097     OptimizeForSize,       ///< opt_size
00098     OptimizeNone,          ///< Function must not be optimized.
00099     ReadNone,              ///< Function does not access memory
00100     ReadOnly,              ///< Function only reads from memory
00101     Returned,              ///< Return value is always equal to this argument
00102     ReturnsTwice,          ///< Function can return twice
00103     SExt,                  ///< Sign extended before/after call
00104     StackAlignment,        ///< Alignment of stack for function (3 bits)
00105                            ///< stored as log2 of alignment with +1 bias 0
00106                            ///< means unaligned (different from
00107                            ///< alignstack=(1))
00108     StackProtect,          ///< Stack protection.
00109     StackProtectReq,       ///< Stack protection required.
00110     StackProtectStrong,    ///< Strong Stack protection.
00111     StructRet,             ///< Hidden pointer to structure to return
00112     SanitizeAddress,       ///< AddressSanitizer is on.
00113     SanitizeThread,        ///< ThreadSanitizer is on.
00114     SanitizeMemory,        ///< MemorySanitizer is on.
00115     UWTable,               ///< Function must be in a unwind table
00116     ZExt,                  ///< Zero extended before/after call
00117 
00118     EndAttrKinds           ///< Sentinal value useful for loops
00119   };
00120 private:
00121   AttributeImpl *pImpl;
00122   Attribute(AttributeImpl *A) : pImpl(A) {}
00123 public:
00124   Attribute() : pImpl(nullptr) {}
00125 
00126   //===--------------------------------------------------------------------===//
00127   // Attribute Construction
00128   //===--------------------------------------------------------------------===//
00129 
00130   /// \brief Return a uniquified Attribute object.
00131   static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
00132   static Attribute get(LLVMContext &Context, StringRef Kind,
00133                        StringRef Val = StringRef());
00134 
00135   /// \brief Return a uniquified Attribute object that has the specific
00136   /// alignment set.
00137   static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align);
00138   static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align);
00139   static Attribute getWithDereferenceableBytes(LLVMContext &Context,
00140                                               uint64_t Bytes);
00141   static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context,
00142                                                      uint64_t Bytes);
00143 
00144   //===--------------------------------------------------------------------===//
00145   // Attribute Accessors
00146   //===--------------------------------------------------------------------===//
00147 
00148   /// \brief Return true if the attribute is an Attribute::AttrKind type.
00149   bool isEnumAttribute() const;
00150 
00151   /// \brief Return true if the attribute is an integer attribute.
00152   bool isIntAttribute() const;
00153 
00154   /// \brief Return true if the attribute is a string (target-dependent)
00155   /// attribute.
00156   bool isStringAttribute() const;
00157 
00158   /// \brief Return true if the attribute is present.
00159   bool hasAttribute(AttrKind Val) const;
00160 
00161   /// \brief Return true if the target-dependent attribute is present.
00162   bool hasAttribute(StringRef Val) const;
00163 
00164   /// \brief Return the attribute's kind as an enum (Attribute::AttrKind). This
00165   /// requires the attribute to be an enum or alignment attribute.
00166   Attribute::AttrKind getKindAsEnum() const;
00167 
00168   /// \brief Return the attribute's value as an integer. This requires that the
00169   /// attribute be an alignment attribute.
00170   uint64_t getValueAsInt() const;
00171 
00172   /// \brief Return the attribute's kind as a string. This requires the
00173   /// attribute to be a string attribute.
00174   StringRef getKindAsString() const;
00175 
00176   /// \brief Return the attribute's value as a string. This requires the
00177   /// attribute to be a string attribute.
00178   StringRef getValueAsString() const;
00179 
00180   /// \brief Returns the alignment field of an attribute as a byte alignment
00181   /// value.
00182   unsigned getAlignment() const;
00183 
00184   /// \brief Returns the stack alignment field of an attribute as a byte
00185   /// alignment value.
00186   unsigned getStackAlignment() const;
00187 
00188   /// \brief Returns the number of dereferenceable bytes from the
00189   /// dereferenceable attribute (or zero if unknown).
00190   uint64_t getDereferenceableBytes() const;
00191 
00192   /// \brief Returns the number of dereferenceable_or_null bytes from the
00193   /// dereferenceable_or_null attribute (or zero if unknown).
00194   uint64_t getDereferenceableOrNullBytes() const;
00195 
00196   /// \brief The Attribute is converted to a string of equivalent mnemonic. This
00197   /// is, presumably, for writing out the mnemonics for the assembly writer.
00198   std::string getAsString(bool InAttrGrp = false) const;
00199 
00200   /// \brief Equality and non-equality operators.
00201   bool operator==(Attribute A) const { return pImpl == A.pImpl; }
00202   bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
00203 
00204   /// \brief Less-than operator. Useful for sorting the attributes list.
00205   bool operator<(Attribute A) const;
00206 
00207   void Profile(FoldingSetNodeID &ID) const {
00208     ID.AddPointer(pImpl);
00209   }
00210 };
00211 
00212 //===----------------------------------------------------------------------===//
00213 /// \class
00214 /// \brief This class holds the attributes for a function, its return value, and
00215 /// its parameters. You access the attributes for each of them via an index into
00216 /// the AttributeSet object. The function attributes are at index
00217 /// `AttributeSet::FunctionIndex', the return value is at index
00218 /// `AttributeSet::ReturnIndex', and the attributes for the parameters start at
00219 /// index `1'.
00220 class AttributeSet {
00221 public:
00222   enum AttrIndex : unsigned {
00223     ReturnIndex = 0U,
00224     FunctionIndex = ~0U
00225   };
00226 private:
00227   friend class AttrBuilder;
00228   friend class AttributeSetImpl;
00229   template <typename Ty> friend struct DenseMapInfo;
00230 
00231   /// \brief The attributes that we are managing. This can be null to represent
00232   /// the empty attributes list.
00233   AttributeSetImpl *pImpl;
00234 
00235   /// \brief The attributes for the specified index are returned.
00236   AttributeSetNode *getAttributes(unsigned Index) const;
00237 
00238   /// \brief Create an AttributeSet with the specified parameters in it.
00239   static AttributeSet get(LLVMContext &C,
00240                           ArrayRef<std::pair<unsigned, Attribute> > Attrs);
00241   static AttributeSet get(LLVMContext &C,
00242                           ArrayRef<std::pair<unsigned,
00243                                              AttributeSetNode*> > Attrs);
00244 
00245   static AttributeSet getImpl(LLVMContext &C,
00246                               ArrayRef<std::pair<unsigned,
00247                                                  AttributeSetNode*> > Attrs);
00248 
00249 
00250   explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
00251 public:
00252   AttributeSet() : pImpl(nullptr) {}
00253 
00254   //===--------------------------------------------------------------------===//
00255   // AttributeSet Construction and Mutation
00256   //===--------------------------------------------------------------------===//
00257 
00258   /// \brief Return an AttributeSet with the specified parameters in it.
00259   static AttributeSet get(LLVMContext &C, ArrayRef<AttributeSet> Attrs);
00260   static AttributeSet get(LLVMContext &C, unsigned Index,
00261                           ArrayRef<Attribute::AttrKind> Kind);
00262   static AttributeSet get(LLVMContext &C, unsigned Index, const AttrBuilder &B);
00263 
00264   /// \brief Add an attribute to the attribute set at the given index. Because
00265   /// attribute sets are immutable, this returns a new set.
00266   AttributeSet addAttribute(LLVMContext &C, unsigned Index,
00267                             Attribute::AttrKind Attr) const;
00268 
00269   /// \brief Add an attribute to the attribute set at the given index. Because
00270   /// attribute sets are immutable, this returns a new set.
00271   AttributeSet addAttribute(LLVMContext &C, unsigned Index,
00272                             StringRef Kind) const;
00273   AttributeSet addAttribute(LLVMContext &C, unsigned Index,
00274                             StringRef Kind, StringRef Value) const;
00275 
00276   /// \brief Add attributes to the attribute set at the given index. Because
00277   /// attribute sets are immutable, this returns a new set.
00278   AttributeSet addAttributes(LLVMContext &C, unsigned Index,
00279                              AttributeSet Attrs) const;
00280 
00281   /// \brief Remove the specified attribute at the specified index from this
00282   /// attribute list. Because attribute lists are immutable, this returns the
00283   /// new list.
00284   AttributeSet removeAttribute(LLVMContext &C, unsigned Index, 
00285                                Attribute::AttrKind Attr) const;
00286 
00287   /// \brief Remove the specified attributes at the specified index from this
00288   /// attribute list. Because attribute lists are immutable, this returns the
00289   /// new list.
00290   AttributeSet removeAttributes(LLVMContext &C, unsigned Index, 
00291                                 AttributeSet Attrs) const;
00292 
00293   /// \brief Remove the specified attributes at the specified index from this
00294   /// attribute list. Because attribute lists are immutable, this returns the
00295   /// new list.
00296   AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
00297                                 const AttrBuilder &Attrs) const;
00298 
00299   /// \brief Add the dereferenceable attribute to the attribute set at the given
00300   /// index. Because attribute sets are immutable, this returns a new set.
00301   AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index,
00302                                       uint64_t Bytes) const;
00303 
00304   /// \brief Add the dereferenceable_or_null attribute to the attribute set at
00305   /// the given index. Because attribute sets are immutable, this returns a new
00306   /// set.
00307   AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index,
00308                                             uint64_t Bytes) const;
00309 
00310   //===--------------------------------------------------------------------===//
00311   // AttributeSet Accessors
00312   //===--------------------------------------------------------------------===//
00313 
00314   /// \brief Retrieve the LLVM context.
00315   LLVMContext &getContext() const;
00316 
00317   /// \brief The attributes for the specified index are returned.
00318   AttributeSet getParamAttributes(unsigned Index) const;
00319 
00320   /// \brief The attributes for the ret value are returned.
00321   AttributeSet getRetAttributes() const;
00322 
00323   /// \brief The function attributes are returned.
00324   AttributeSet getFnAttributes() const;
00325 
00326   /// \brief Return true if the attribute exists at the given index.
00327   bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const;
00328 
00329   /// \brief Return true if the attribute exists at the given index.
00330   bool hasAttribute(unsigned Index, StringRef Kind) const;
00331 
00332   /// \brief Return true if attribute exists at the given index.
00333   bool hasAttributes(unsigned Index) const;
00334 
00335   /// \brief Return true if the specified attribute is set for at least one
00336   /// parameter or for the return value.
00337   bool hasAttrSomewhere(Attribute::AttrKind Attr) const;
00338 
00339   /// \brief Return the attribute object that exists at the given index.
00340   Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const;
00341 
00342   /// \brief Return the attribute object that exists at the given index.
00343   Attribute getAttribute(unsigned Index, StringRef Kind) const;
00344 
00345   /// \brief Return the alignment for the specified function parameter.
00346   unsigned getParamAlignment(unsigned Index) const;
00347 
00348   /// \brief Get the stack alignment.
00349   unsigned getStackAlignment(unsigned Index) const;
00350 
00351   /// \brief Get the number of dereferenceable bytes (or zero if unknown).
00352   uint64_t getDereferenceableBytes(unsigned Index) const;
00353 
00354   /// \brief Get the number of dereferenceable_or_null bytes (or zero if
00355   /// unknown).
00356   uint64_t getDereferenceableOrNullBytes(unsigned Index) const;
00357 
00358   /// \brief Return the attributes at the index as a string.
00359   std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
00360 
00361   typedef ArrayRef<Attribute>::iterator iterator;
00362 
00363   iterator begin(unsigned Slot) const;
00364   iterator end(unsigned Slot) const;
00365 
00366   /// operator==/!= - Provide equality predicates.
00367   bool operator==(const AttributeSet &RHS) const {
00368     return pImpl == RHS.pImpl;
00369   }
00370   bool operator!=(const AttributeSet &RHS) const {
00371     return pImpl != RHS.pImpl;
00372   }
00373 
00374   //===--------------------------------------------------------------------===//
00375   // AttributeSet Introspection
00376   //===--------------------------------------------------------------------===//
00377 
00378   // FIXME: Remove this.
00379   uint64_t Raw(unsigned Index) const;
00380 
00381   /// \brief Return a raw pointer that uniquely identifies this attribute list.
00382   void *getRawPointer() const {
00383     return pImpl;
00384   }
00385 
00386   /// \brief Return true if there are no attributes.
00387   bool isEmpty() const {
00388     return getNumSlots() == 0;
00389   }
00390 
00391   /// \brief Return the number of slots used in this attribute list.  This is
00392   /// the number of arguments that have an attribute set on them (including the
00393   /// function itself).
00394   unsigned getNumSlots() const;
00395 
00396   /// \brief Return the index for the given slot.
00397   unsigned getSlotIndex(unsigned Slot) const;
00398 
00399   /// \brief Return the attributes at the given slot.
00400   AttributeSet getSlotAttributes(unsigned Slot) const;
00401 
00402   void dump() const;
00403 };
00404 
00405 //===----------------------------------------------------------------------===//
00406 /// \class
00407 /// \brief Provide DenseMapInfo for AttributeSet.
00408 template<> struct DenseMapInfo<AttributeSet> {
00409   static inline AttributeSet getEmptyKey() {
00410     uintptr_t Val = static_cast<uintptr_t>(-1);
00411     Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
00412     return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
00413   }
00414   static inline AttributeSet getTombstoneKey() {
00415     uintptr_t Val = static_cast<uintptr_t>(-2);
00416     Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
00417     return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
00418   }
00419   static unsigned getHashValue(AttributeSet AS) {
00420     return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
00421            (unsigned((uintptr_t)AS.pImpl) >> 9);
00422   }
00423   static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
00424 };
00425 
00426 //===----------------------------------------------------------------------===//
00427 /// \class
00428 /// \brief This class is used in conjunction with the Attribute::get method to
00429 /// create an Attribute object. The object itself is uniquified. The Builder's
00430 /// value, however, is not. So this can be used as a quick way to test for
00431 /// equality, presence of attributes, etc.
00432 class AttrBuilder {
00433   std::bitset<Attribute::EndAttrKinds> Attrs;
00434   std::map<std::string, std::string> TargetDepAttrs;
00435   uint64_t Alignment;
00436   uint64_t StackAlignment;
00437   uint64_t DerefBytes;
00438   uint64_t DerefOrNullBytes;
00439 public:
00440   AttrBuilder()
00441       : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
00442         DerefOrNullBytes(0) {}
00443   explicit AttrBuilder(uint64_t Val)
00444       : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
00445         DerefOrNullBytes(0) {
00446     addRawValue(Val);
00447   }
00448   AttrBuilder(const Attribute &A)
00449       : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
00450         DerefOrNullBytes(0) {
00451     addAttribute(A);
00452   }
00453   AttrBuilder(AttributeSet AS, unsigned Idx);
00454 
00455   void clear();
00456 
00457   /// \brief Add an attribute to the builder.
00458   AttrBuilder &addAttribute(Attribute::AttrKind Val);
00459 
00460   /// \brief Add the Attribute object to the builder.
00461   AttrBuilder &addAttribute(Attribute A);
00462 
00463   /// \brief Add the target-dependent attribute to the builder.
00464   AttrBuilder &addAttribute(StringRef A, StringRef V = StringRef());
00465 
00466   /// \brief Remove an attribute from the builder.
00467   AttrBuilder &removeAttribute(Attribute::AttrKind Val);
00468 
00469   /// \brief Remove the attributes from the builder.
00470   AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
00471 
00472   /// \brief Remove the target-dependent attribute to the builder.
00473   AttrBuilder &removeAttribute(StringRef A);
00474 
00475   /// \brief Add the attributes from the builder.
00476   AttrBuilder &merge(const AttrBuilder &B);
00477 
00478   /// \brief Remove the attributes from the builder.
00479   AttrBuilder &remove(const AttrBuilder &B);
00480 
00481   /// \brief Return true if the builder has any attribute that's in the
00482   /// specified builder.
00483   bool overlaps(const AttrBuilder &B) const;
00484 
00485   /// \brief Return true if the builder has the specified attribute.
00486   bool contains(Attribute::AttrKind A) const {
00487     assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
00488     return Attrs[A];
00489   }
00490 
00491   /// \brief Return true if the builder has the specified target-dependent
00492   /// attribute.
00493   bool contains(StringRef A) const;
00494 
00495   /// \brief Return true if the builder has IR-level attributes.
00496   bool hasAttributes() const;
00497 
00498   /// \brief Return true if the builder has any attribute that's in the
00499   /// specified attribute.
00500   bool hasAttributes(AttributeSet A, uint64_t Index) const;
00501 
00502   /// \brief Return true if the builder has an alignment attribute.
00503   bool hasAlignmentAttr() const;
00504 
00505   /// \brief Retrieve the alignment attribute, if it exists.
00506   uint64_t getAlignment() const { return Alignment; }
00507 
00508   /// \brief Retrieve the stack alignment attribute, if it exists.
00509   uint64_t getStackAlignment() const { return StackAlignment; }
00510 
00511   /// \brief Retrieve the number of dereferenceable bytes, if the dereferenceable
00512   /// attribute exists (zero is returned otherwise).
00513   uint64_t getDereferenceableBytes() const { return DerefBytes; }
00514 
00515   /// \brief Retrieve the number of dereferenceable_or_null bytes, if the
00516   /// dereferenceable_or_null attribute exists (zero is returned otherwise).
00517   uint64_t getDereferenceableOrNullBytes() const { return DerefOrNullBytes; }
00518 
00519   /// \brief This turns an int alignment (which must be a power of 2) into the
00520   /// form used internally in Attribute.
00521   AttrBuilder &addAlignmentAttr(unsigned Align);
00522 
00523   /// \brief This turns an int stack alignment (which must be a power of 2) into
00524   /// the form used internally in Attribute.
00525   AttrBuilder &addStackAlignmentAttr(unsigned Align);
00526 
00527   /// \brief This turns the number of dereferenceable bytes into the form used
00528   /// internally in Attribute.
00529   AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
00530 
00531   /// \brief This turns the number of dereferenceable_or_null bytes into the
00532   /// form used internally in Attribute.
00533   AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
00534 
00535   /// \brief Return true if the builder contains no target-independent
00536   /// attributes.
00537   bool empty() const { return Attrs.none(); }
00538 
00539   // Iterators for target-dependent attributes.
00540   typedef std::pair<std::string, std::string>                td_type;
00541   typedef std::map<std::string, std::string>::iterator       td_iterator;
00542   typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
00543   typedef llvm::iterator_range<td_iterator>                  td_range;
00544   typedef llvm::iterator_range<td_const_iterator>            td_const_range;
00545 
00546   td_iterator td_begin()             { return TargetDepAttrs.begin(); }
00547   td_iterator td_end()               { return TargetDepAttrs.end(); }
00548 
00549   td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
00550   td_const_iterator td_end() const   { return TargetDepAttrs.end(); }
00551 
00552   td_range td_attrs() { return td_range(td_begin(), td_end()); }
00553   td_const_range td_attrs() const {
00554     return td_const_range(td_begin(), td_end());
00555   }
00556 
00557   bool td_empty() const              { return TargetDepAttrs.empty(); }
00558 
00559   bool operator==(const AttrBuilder &B);
00560   bool operator!=(const AttrBuilder &B) {
00561     return !(*this == B);
00562   }
00563 
00564   // FIXME: Remove this in 4.0.
00565 
00566   /// \brief Add the raw value to the internal representation.
00567   AttrBuilder &addRawValue(uint64_t Val);
00568 };
00569 
00570 namespace AttributeFuncs {
00571 
00572 /// \brief Which attributes cannot be applied to a type.
00573 AttrBuilder typeIncompatible(const Type *Ty);
00574 
00575 } // end AttributeFuncs namespace
00576 
00577 } // end llvm namespace
00578 
00579 #endif