[llvm-commits] [llvm] r165891 - in /llvm/trunk: include/llvm/Attributes.h lib/VMCore/Attributes.cpp
Bill Wendling
isanbard at gmail.com
Sat Oct 13 21:10:01 PDT 2012
Author: void
Date: Sat Oct 13 23:10:01 2012
New Revision: 165891
URL: http://llvm.org/viewvc/llvm-project?rev=165891&view=rev
Log:
Decode the LLVM attributes from bitcode using the attributes builder.
Modified:
llvm/trunk/include/llvm/Attributes.h
llvm/trunk/lib/VMCore/Attributes.cpp
Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=165891&r1=165890&r2=165891&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Sat Oct 13 23:10:01 2012
@@ -103,6 +103,7 @@
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,6 +119,10 @@
Builder &addAttribute(Attributes::AttrVal Val);
Builder &removeAttribute(Attributes::AttrVal Val);
+ /// addRawValue - Add the raw value to the internal representation. This
+ /// should be used ONLY for decoding bitcode!
+ Builder &addRawValue(uint64_t Val);
+
/// addAlignmentAttr - This turns an int alignment (which must be a power of
/// 2) into the form used internally in Attributes.
Builder &addAlignmentAttr(unsigned Align);
@@ -266,14 +271,11 @@
assert((!Alignment || isPowerOf2_32(Alignment)) &&
"Alignment must be a power of two.");
- Attributes Attrs(EncodedAttrs & 0xffff);
- if (Alignment) {
- Attributes::Builder B;
+ Attributes::Builder B(EncodedAttrs & 0xffff);
+ if (Alignment)
B.addAlignmentAttr(Alignment);
- Attrs |= Attributes::get(B);
- }
- Attrs |= Attributes((EncodedAttrs & (0xfffULL << 32)) >> 11);
- return Attrs;
+ B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
+ return Attributes::get(B);
}
/// getAsString - The set of Attributes set in Attributes is converted to a
Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=165891&r1=165890&r2=165891&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Sat Oct 13 23:10:01 2012
@@ -215,6 +215,11 @@
return *this;
}
+Attributes::Builder &Attributes::Builder::addRawValue(uint64_t Val) {
+ Bits |= Val;
+ return *this;
+}
+
Attributes::Builder &Attributes::Builder::addAlignmentAttr(unsigned Align) {
if (Align == 0) return *this;
assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
More information about the llvm-commits
mailing list