[llvm-commits] [llvm] r165890 - in /llvm/trunk: include/llvm-c/Core.h include/llvm/Attributes.h lib/VMCore/Attributes.cpp lib/VMCore/Core.cpp
Bill Wendling
isanbard at gmail.com
Sat Oct 13 20:58:29 PDT 2012
Author: void
Date: Sat Oct 13 22:58:29 2012
New Revision: 165890
URL: http://llvm.org/viewvc/llvm-project?rev=165890&view=rev
Log:
Use builder to create alignment attributes. Remove dead function.
Modified:
llvm/trunk/include/llvm-c/Core.h
llvm/trunk/include/llvm/Attributes.h
llvm/trunk/lib/VMCore/Attributes.cpp
llvm/trunk/lib/VMCore/Core.cpp
Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=165890&r1=165889&r2=165890&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Sat Oct 13 22:58:29 2012
@@ -1803,7 +1803,7 @@
* 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);
Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=165890&r1=165889&r2=165890&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Sat Oct 13 22:58:29 2012
@@ -118,11 +118,13 @@
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 @@
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 @@
"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;
}
Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=165890&r1=165889&r2=165890&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Sat Oct 13 22:58:29 2012
@@ -215,18 +215,20 @@
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::
Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=165890&r1=165889&r2=165890&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Sat Oct 13 22:58:29 2012
@@ -1474,8 +1474,9 @@
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 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) ..............................--*/
More information about the llvm-commits
mailing list