[llvm-commits] [llvm] r164373 - in /llvm/trunk: include/llvm/Attributes.h lib/AsmParser/LLParser.cpp lib/VMCore/Core.cpp
Bill Wendling
isanbard at gmail.com
Fri Sep 21 09:07:28 PDT 2012
Author: void
Date: Fri Sep 21 11:07:28 2012
New Revision: 164373
URL: http://llvm.org/viewvc/llvm-project?rev=164373&view=rev
Log:
Encapsulate the "construct*AlignmentFromInt" functions.
Modified:
llvm/trunk/include/llvm/Attributes.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/VMCore/Core.cpp
Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=164373&r1=164372&r2=164373&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Fri Sep 21 11:07:28 2012
@@ -223,6 +223,30 @@
return 1U << ((getRawStackAlignment() >> 26) - 1);
}
+ /// 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 Attribute::None;
+
+ assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
+ assert(i <= 0x40000000 && "Alignment too large.");
+ return Attributes((Log2_32(i)+1) << 16);
+ }
+
+ /// 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 Attribute::None;
+
+ assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
+ assert(i <= 0x100 && "Alignment too large.");
+ return Attributes((Log2_32(i)+1) << 26);
+ }
+
// This is a "safe bool() operator".
operator const void *() const { return Bits ? this : 0; }
bool isEmptyOrSingleton() const { return (Bits & (Bits - 1)) == 0; }
@@ -300,30 +324,6 @@
/// @brief Which attributes cannot be applied to a type.
Attributes typeIncompatible(Type *Ty);
-/// This turns an int alignment (a power of 2, normally) into the
-/// form used internally in Attributes.
-inline Attributes constructAlignmentFromInt(unsigned i) {
- // Default alignment, allow the target to define how to align it.
- if (i == 0)
- return None;
-
- assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
- assert(i <= 0x40000000 && "Alignment too large.");
- return Attributes((Log2_32(i)+1) << 16);
-}
-
-/// This turns an int stack alignment (which must be a power of 2) into
-/// the form used internally in Attributes.
-inline Attributes constructStackAlignmentFromInt(unsigned i) {
- // Default alignment, allow the target to define how to align it.
- if (i == 0)
- return None;
-
- assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
- assert(i <= 0x100 && "Alignment too large.");
- return Attributes((Log2_32(i)+1) << 26);
-}
-
/// 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
@@ -362,7 +362,7 @@
Attributes Attrs(EncodedAttrs & 0xffff);
if (Alignment)
- Attrs |= Attribute::constructAlignmentFromInt(Alignment);
+ Attrs |= Attributes::constructAlignmentFromInt(Alignment);
Attrs |= Attributes((EncodedAttrs & (0xfffull << 32)) >> 11);
return Attrs;
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=164373&r1=164372&r2=164373&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Sep 21 11:07:28 2012
@@ -967,7 +967,7 @@
unsigned Alignment;
if (ParseOptionalStackAlignment(Alignment))
return true;
- Attrs |= Attribute::constructStackAlignmentFromInt(Alignment);
+ Attrs |= Attributes::constructStackAlignmentFromInt(Alignment);
continue;
}
@@ -975,7 +975,7 @@
unsigned Alignment;
if (ParseOptionalAlignment(Alignment))
return true;
- Attrs |= Attribute::constructAlignmentFromInt(Alignment);
+ Attrs |= Attributes::constructAlignmentFromInt(Alignment);
continue;
}
Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=164373&r1=164372&r2=164373&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Fri Sep 21 11:07:28 2012
@@ -1475,7 +1475,7 @@
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
unwrap<Argument>(Arg)->addAttr(
- Attribute::constructAlignmentFromInt(align));
+ Attributes::constructAlignmentFromInt(align));
}
/*--.. Operations on basic blocks ..........................................--*/
@@ -1680,7 +1680,7 @@
CallSite Call = CallSite(unwrap<Instruction>(Instr));
Call.setAttributes(
Call.getAttributes().addAttr(index,
- Attribute::constructAlignmentFromInt(align)));
+ Attributes::constructAlignmentFromInt(align)));
}
/*--.. Operations on call instructions (only) ..............................--*/
More information about the llvm-commits
mailing list