Use builder to create alignment attributes. Remove dead function.
authorBill Wendling <isanbard@gmail.com>
Sun, 14 Oct 2012 03:58:29 +0000 (03:58 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 14 Oct 2012 03:58:29 +0000 (03:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165890 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Core.h
include/llvm/Attributes.h
lib/VMCore/Attributes.cpp
lib/VMCore/Core.cpp

index 8cf03c268cdb6be42e641c4ed42cdb5cff0c4125..badc70ba22f464bb733f05df12a55c59c469375f 100644 (file)
@@ -1803,7 +1803,7 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
  * Set the alignment for a function parameter.
  *
  * @see llvm::Argument::addAttr()
- * @see llvm::Attributes::constructAlignmentFromInt()
+ * @see llvm::Attributes::Builder::addAlignmentAttr()
  */
 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
 
index c757951a1f9e32d19a2cebf913bf8f3a174885d8..eb1798fb5ed489913131eb541aa4484e1dd879fb 100644 (file)
@@ -118,11 +118,13 @@ public:
     Builder &addAttribute(Attributes::AttrVal Val);
     Builder &removeAttribute(Attributes::AttrVal Val);
 
-    void addAlignmentAttr(unsigned Align);
+    /// 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.
-    void addStackAlignmentAttr(unsigned Align);
+    Builder &addStackAlignmentAttr(unsigned Align);
 
     void removeAttributes(const Attributes &A);
 
@@ -229,18 +231,6 @@ public:
 
   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);
-  }
-
   /// @brief Which attributes cannot be applied to a type.
   static Attributes typeIncompatible(Type *Ty);
 
@@ -277,8 +267,11 @@ public:
            "Alignment must be a power of two.");
 
     Attributes Attrs(EncodedAttrs & 0xffff);
-    if (Alignment)
-      Attrs |= Attributes::constructAlignmentFromInt(Alignment);
+    if (Alignment) {
+      Attributes::Builder B;
+      B.addAlignmentAttr(Alignment);
+      Attrs |= Attributes::get(B);
+    }
     Attrs |= Attributes((EncodedAttrs & (0xfffULL << 32)) >> 11);
     return Attrs;
   }
index 16c5466f17394779ac8052a69065561810283576..5f4b51fc6b8d4c14e95cd42da03657048fbef7d9 100644 (file)
@@ -215,18 +215,20 @@ addAttribute(Attributes::AttrVal Val) {
   return *this;
 }
 
-void Attributes::Builder::addAlignmentAttr(unsigned Align) {
-  if (Align == 0) return;
+Attributes::Builder &Attributes::Builder::addAlignmentAttr(unsigned Align) {
+  if (Align == 0) return *this;
   assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
   assert(Align <= 0x40000000 && "Alignment too large.");
   Bits |= (Log2_32(Align) + 1) << 16;
+  return *this;
 }
-void Attributes::Builder::addStackAlignmentAttr(unsigned Align) {
+Attributes::Builder &Attributes::Builder::addStackAlignmentAttr(unsigned Align){
   // Default alignment, allow the target to define how to align it.
-  if (Align == 0) return;
+  if (Align == 0) return *this;
   assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
   assert(Align <= 0x100 && "Alignment too large.");
   Bits |= (Log2_32(Align) + 1) << 26;
+  return *this;
 }
 
 Attributes::Builder &Attributes::Builder::
index 90ecdaecf41ef867d58e86fb34dc570a58811047..7973325e508df8c5a2714fb706b70546c94e882f 100644 (file)
@@ -1474,8 +1474,9 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
   
 
 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
-  unwrap<Argument>(Arg)->addAttr(
-          Attributes::constructAlignmentFromInt(align));
+  Attributes::Builder B;
+  B.addAlignmentAttr(align);
+  unwrap<Argument>(Arg)->addAttr(Attributes::get(B));
 }
 
 /*--.. Operations on basic blocks ..........................................--*/
@@ -1678,9 +1679,9 @@ void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, 
                                 unsigned align) {
   CallSite Call = CallSite(unwrap<Instruction>(Instr));
-  Call.setAttributes(
-    Call.getAttributes().addAttr(index, 
-        Attributes::constructAlignmentFromInt(align)));
+  Attributes::Builder B;
+  B.addAlignmentAttr(align);
+  Call.setAttributes(Call.getAttributes().addAttr(index, Attributes::get(B)));
 }
 
 /*--.. Operations on call instructions (only) ..............................--*/