[llvm-commits] [llvm] r165373 - in /llvm/trunk: include/llvm/Attributes.h lib/VMCore/Attributes.cpp
Bill Wendling
isanbard at gmail.com
Sun Oct 7 01:55:05 PDT 2012
Author: void
Date: Sun Oct 7 03:55:05 2012
New Revision: 165373
URL: http://llvm.org/viewvc/llvm-project?rev=165373&view=rev
Log:
Move more methods out-of-line. This is in preparation for changing the internal
contents of the Attributes class over to an AttributesImpl.
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=165373&r1=165372&r2=165373&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Sun Oct 7 03:55:05 2012
@@ -196,10 +196,7 @@
bool hasAttributes() const {
return Bits != 0;
}
- bool hasAttributes(const Attributes &A) const {
- return Bits & A.Bits;
- }
-
+ bool hasAttributes(const Attributes &A) const;
bool hasAddressSafetyAttr() const;
bool hasAlignmentAttr() const;
bool hasAlwaysInlineAttr() const;
@@ -236,9 +233,10 @@
/// value.
unsigned getStackAlignment() const;
+ bool isEmptyOrSingleton() const;
+
// This is a "safe bool() operator".
operator const void *() const { return Bits ? this : 0; }
- bool isEmptyOrSingleton() const { return (Bits & (Bits - 1)) == 0; }
bool operator == (const Attributes &Attrs) const {
return Bits == Attrs.Bits;
}
@@ -246,24 +244,13 @@
return Bits != Attrs.Bits;
}
- Attributes operator | (const Attributes &Attrs) const {
- return Attributes(Bits | Attrs.Bits);
- }
- Attributes operator & (const Attributes &Attrs) const {
- return Attributes(Bits & Attrs.Bits);
- }
- Attributes operator ^ (const Attributes &Attrs) const {
- return Attributes(Bits ^ Attrs.Bits);
- }
- Attributes &operator |= (const Attributes &Attrs) {
- Bits |= Attrs.Bits;
- return *this;
- }
- Attributes &operator &= (const Attributes &Attrs) {
- Bits &= Attrs.Bits;
- return *this;
- }
- Attributes operator ~ () const { return Attributes(~Bits); }
+ Attributes operator | (const Attributes &Attrs) const;
+ Attributes operator & (const Attributes &Attrs) const;
+ Attributes operator ^ (const Attributes &Attrs) const;
+ Attributes &operator |= (const Attributes &Attrs);
+ Attributes &operator &= (const Attributes &Attrs);
+ Attributes operator ~ () const;
+
uint64_t Raw() const { return Bits; }
/// constructAlignmentFromInt - This turns an int alignment (a power of 2,
@@ -307,11 +294,11 @@
// Store the alignment in the bitcode as a 16-bit raw value instead of a
// 5-bit log2 encoded value. Shift the bits above the alignment up by 11
// bits.
- uint64_t EncodedAttrs = Attrs.Bits & 0xffff;
+ uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
if (Attrs.hasAlignmentAttr())
EncodedAttrs |= (1ULL << 16) <<
- (((Attrs.Bits & Attribute::Alignment_i) - 1) >> 16);
- EncodedAttrs |= (Attrs.Bits & (0xfffULL << 21)) << 11;
+ (((Attrs.Raw() & Attribute::Alignment_i) - 1) >> 16);
+ EncodedAttrs |= (Attrs.Raw() & (0xfffULL << 21)) << 11;
return EncodedAttrs;
}
Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=165373&r1=165372&r2=165373&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Sun Oct 7 03:55:05 2012
@@ -28,6 +28,9 @@
// Attribute Function Definitions
//===----------------------------------------------------------------------===//
+bool Attributes::hasAttributes(const Attributes &A) const {
+ return Bits & A.Bits;
+}
bool Attributes::hasAddressSafetyAttr() const {
return Bits & Attribute::AddressSafety_i;
}
@@ -125,6 +128,31 @@
return 1U << (((Bits & Attribute::StackAlignment_i) >> 26) - 1);
}
+bool Attributes::isEmptyOrSingleton() const {
+ return (Bits & (Bits - 1)) == 0;
+}
+
+Attributes Attributes::operator | (const Attributes &Attrs) const {
+ return Attributes(Bits | Attrs.Bits);
+}
+Attributes Attributes::operator & (const Attributes &Attrs) const {
+ return Attributes(Bits & Attrs.Bits);
+}
+Attributes Attributes::operator ^ (const Attributes &Attrs) const {
+ return Attributes(Bits ^ Attrs.Bits);
+}
+Attributes &Attributes::operator |= (const Attributes &Attrs) {
+ Bits |= Attrs.Bits;
+ return *this;
+}
+Attributes &Attributes::operator &= (const Attributes &Attrs) {
+ Bits &= Attrs.Bits;
+ return *this;
+}
+Attributes Attributes::operator ~ () const {
+ return Attributes(~Bits);
+}
+
Attributes Attributes::typeIncompatible(Type *Ty) {
Attributes::Builder Incompatible;
More information about the llvm-commits
mailing list