Initial cleanups of the param-attribute code in the bitcode reader/writer.
[oota-llvm.git] / include / llvm / IR / Attributes.h
index f53cfd6a080b67a41d99a48b374b495178aadea4..c726020ab80de1c640af5d6e9ce40a91563dcb73 100644 (file)
@@ -114,6 +114,7 @@ public:
 
   /// \brief Return a uniquified Attribute object.
   static Attribute get(LLVMContext &Context, AttrKind Kind, Constant *Val = 0);
+  static Attribute get(LLVMContext &Context, Constant *Kind, Constant *Val = 0);
 
   /// \brief Return a uniquified Attribute object that has the specific
   /// alignment set.
@@ -127,14 +128,13 @@ public:
   /// \brief Return true if the attribute is present.
   bool hasAttribute(AttrKind Val) const;
 
-  /// \brief Return true if attributes exist
-  bool hasAttributes() const;
-
-  /// \brief Return the kind of this attribute.
+  /// \brief Return the kind of this attribute: enum or string.
   Constant *getAttributeKind() const;
 
-  /// \brief Return the value (if present) of the non-target-specific attribute.
-  ArrayRef<Constant*> getAttributeValues() const;
+  /// \brief Return the values (if present) of the attribute. This may be a
+  /// ConstantVector to represent a list of values associated with the
+  /// attribute.
+  Constant *getAttributeValues() const;
 
   /// \brief Returns the alignment field of an attribute as a byte alignment
   /// value.
@@ -161,9 +161,6 @@ public:
   void Profile(FoldingSetNodeID &ID) const {
     ID.AddPointer(pImpl);
   }
-
-  // FIXME: Remove this.
-  uint64_t Raw() const;
 };
 
 //===----------------------------------------------------------------------===//
@@ -272,6 +269,11 @@ public:
   /// \brief Return the attributes at the index as a string.
   std::string getAsString(unsigned Index) const;
 
+  typedef ArrayRef<Attribute>::iterator iterator;
+
+  iterator begin(unsigned Idx) const;
+  iterator end(unsigned Idx) const;
+
   /// operator==/!= - Provide equality predicates.
   bool operator==(const AttributeSet &RHS) const {
     return pImpl == RHS.pImpl;
@@ -343,11 +345,11 @@ class AttrBuilder {
   uint64_t StackAlignment;
 public:
   AttrBuilder() : Alignment(0), StackAlignment(0) {}
-  explicit AttrBuilder(uint64_t B) : Alignment(0), StackAlignment(0) {
-    addRawValue(B);
+  explicit AttrBuilder(uint64_t Val) : Alignment(0), StackAlignment(0) {
+    addRawValue(Val);
   }
   AttrBuilder(const Attribute &A) : Alignment(0), StackAlignment(0) {
-    addAttributes(A);
+    addAttribute(A);
   }
   AttrBuilder(AttributeSet AS, unsigned Idx);
 
@@ -356,12 +358,12 @@ public:
   /// \brief Add an attribute to the builder.
   AttrBuilder &addAttribute(Attribute::AttrKind Val);
 
+  /// \brief Add the Attribute object to the builder.
+  AttrBuilder &addAttribute(Attribute A);
+
   /// \brief Remove an attribute from the builder.
   AttrBuilder &removeAttribute(Attribute::AttrKind Val);
 
-  /// \brief Add the attributes to the builder.
-  AttrBuilder &addAttributes(Attribute A);
-
   /// \brief Remove the attributes from the builder.
   AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
 
@@ -431,14 +433,10 @@ public:
     return !(*this == B);
   }
 
-  // FIXME: Remove these.
+  // FIXME: Remove this in 4.0.
 
   /// \brief Add the raw value to the internal representation.
-  /// 
-  /// N.B. This should be used ONLY for decoding LLVM bitcode!
   AttrBuilder &addRawValue(uint64_t Val);
-
-  uint64_t Raw() const;
 };
 
 namespace AttributeFuncs {
@@ -446,18 +444,6 @@ namespace AttributeFuncs {
 /// \brief Which attributes cannot be applied to a type.
 AttributeSet typeIncompatible(Type *Ty, uint64_t Index);
 
-/// \brief This returns an integer containing an encoding of all the LLVM
-/// attributes found in the given attribute bitset.  Any change to this encoding
-/// is a breaking change to bitcode compatibility.
-uint64_t encodeLLVMAttributesForBitcode(AttributeSet Attrs, unsigned Index);
-
-/// \brief This fills an AttrBuilder object with the LLVM attributes that have
-/// been decoded from the given integer. This function must stay in sync with
-/// 'encodeLLVMAttributesForBitcode'.
-/// N.B. This should be used only by the bitcode reader!
-void decodeLLVMAttributesForBitcode(LLVMContext &C, AttrBuilder &B,
-                                    uint64_t EncodedAttrs);
-
 } // end AttributeFuncs namespace
 
 } // end llvm namespace