Remove the bitwise XOR operator from the Attributes class. Replace it with the equiva...
[oota-llvm.git] / include / llvm / Attributes.h
index 8b43e08f084df3d140d2afcc318df6078cdc73b8..c8f723a7dcffe43c3129bb1ea3df12d351a5920f 100644 (file)
@@ -95,7 +95,7 @@ private:
 public:
   Attributes() : Attrs(0) {}
   explicit Attributes(uint64_t Val);
-  explicit Attributes(AttrVal Val);
+  explicit Attributes(LLVMContext &C, AttrVal Val);
   Attributes(const Attributes &A);
 
   class Builder {
@@ -103,6 +103,7 @@ public:
     uint64_t Bits;
   public:
     Builder() : Bits(0) {}
+    explicit Builder(uint64_t B) : Bits(B) {}
     Builder(const Attributes &A) : Bits(A.Raw()) {}
 
     void clear() { Bits = 0; }
@@ -118,10 +119,19 @@ public:
     Builder &addAttribute(Attributes::AttrVal Val);
     Builder &removeAttribute(Attributes::AttrVal Val);
 
-    void addAlignmentAttr(unsigned Align);
-    void addStackAlignmentAttr(unsigned Align);
+    /// addRawValue - Add the raw value to the internal representation. This
+    /// should be used ONLY for decoding bitcode!
+    Builder &addRawValue(uint64_t Val);
 
-    void removeAttributes(const Attributes &A);
+    /// addAlignmentAttr - This turns an int alignment (which must be a power of
+    /// 2) into the form used internally in Attributes.
+    Builder &addAlignmentAttr(unsigned Align);
+
+    /// addStackAlignmentAttr - This turns an int stack alignment (which must be
+    /// a power of 2) into the form used internally in Attributes.
+    Builder &addStackAlignmentAttr(unsigned Align);
+
+    Builder &removeAttributes(const Attributes &A);
 
     /// @brief Remove attributes that are used on functions only.
     void removeFunctionOnlyAttrs() {
@@ -144,6 +154,13 @@ public:
         .removeAttribute(Attributes::ReturnsTwice)
         .removeAttribute(Attributes::AddressSafety);
     }
+
+    bool operator==(const Builder &B) {
+      return Bits == B.Bits;
+    }
+    bool operator!=(const Builder &B) {
+      return Bits != B.Bits;
+    }
   };
 
   /// get - Return a uniquified Attributes object. This takes the uniquified
@@ -219,37 +236,11 @@ public:
 
   Attributes operator | (const Attributes &A) const;
   Attributes operator & (const Attributes &A) const;
-  Attributes operator ^ (const Attributes &A) const;
   Attributes &operator |= (const Attributes &A);
   Attributes &operator &= (const Attributes &A);
-  Attributes operator ~ () const;
 
   uint64_t Raw() const;
 
-  /// constructAlignmentFromInt - This turns an int alignment (a power of 2,
-  /// normally) into the form used internally in Attributes.
-  static Attributes constructAlignmentFromInt(unsigned i) {
-    // Default alignment, allow the target to define how to align it.
-    if (i == 0)
-      return Attributes();
-
-    assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
-    assert(i <= 0x40000000 && "Alignment too large.");
-    return Attributes((Log2_32(i)+1) << 16);
-  }
-
-  /// constructStackAlignmentFromInt - This turns an int stack alignment (which
-  /// must be a power of 2) into the form used internally in Attributes.
-  static Attributes constructStackAlignmentFromInt(unsigned i) {
-    // Default alignment, allow the target to define how to align it.
-    if (i == 0)
-      return Attributes();
-
-    assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
-    assert(i <= 0x100 && "Alignment too large.");
-    return Attributes((Log2_32(i)+1) << 26);
-  }
-
   /// @brief Which attributes cannot be applied to a type.
   static Attributes typeIncompatible(Type *Ty);
 
@@ -285,11 +276,11 @@ public:
     assert((!Alignment || isPowerOf2_32(Alignment)) &&
            "Alignment must be a power of two.");
 
-    Attributes Attrs(EncodedAttrs & 0xffff);
+    Attributes::Builder B(EncodedAttrs & 0xffff);
     if (Alignment)
-      Attrs |= Attributes::constructAlignmentFromInt(Alignment);
-    Attrs |= Attributes((EncodedAttrs & (0xfffULL << 32)) >> 11);
-    return Attrs;
+      B.addAlignmentAttr(Alignment);
+    B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
+    return Attributes::get(B);
   }
 
   /// getAsString - The set of Attributes set in Attributes is converted to a
@@ -365,7 +356,7 @@ public:
   /// removeAttr - Remove the specified attribute at the specified index from
   /// this attribute list.  Since attribute lists are immutable, this
   /// returns the new list.
-  AttrListPtr removeAttr(unsigned Idx, Attributes Attrs) const;
+  AttrListPtr removeAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
 
   //===--------------------------------------------------------------------===//
   // Attribute List Accessors