Move more methods out-of-line. This is in preparation for changing the internal

contents of the Attributes class over to an AttributesImpl.

llvm-svn: 165373
This commit is contained in:
Bill Wendling 2012-10-07 08:55:05 +00:00
parent 954e430e9b
commit be7c6f23a2
2 changed files with 41 additions and 26 deletions

View File

@ -196,10 +196,7 @@ public:
bool hasAttributes() const { bool hasAttributes() const {
return Bits != 0; return Bits != 0;
} }
bool hasAttributes(const Attributes &A) const { bool hasAttributes(const Attributes &A) const;
return Bits & A.Bits;
}
bool hasAddressSafetyAttr() const; bool hasAddressSafetyAttr() const;
bool hasAlignmentAttr() const; bool hasAlignmentAttr() const;
bool hasAlwaysInlineAttr() const; bool hasAlwaysInlineAttr() const;
@ -236,9 +233,10 @@ public:
/// value. /// value.
unsigned getStackAlignment() const; unsigned getStackAlignment() const;
bool isEmptyOrSingleton() const;
// This is a "safe bool() operator". // This is a "safe bool() operator".
operator const void *() const { return Bits ? this : 0; } operator const void *() const { return Bits ? this : 0; }
bool isEmptyOrSingleton() const { return (Bits & (Bits - 1)) == 0; }
bool operator == (const Attributes &Attrs) const { bool operator == (const Attributes &Attrs) const {
return Bits == Attrs.Bits; return Bits == Attrs.Bits;
} }
@ -246,24 +244,13 @@ public:
return Bits != Attrs.Bits; return Bits != Attrs.Bits;
} }
Attributes operator | (const Attributes &Attrs) const { Attributes operator | (const Attributes &Attrs) const;
return Attributes(Bits | Attrs.Bits); Attributes operator & (const Attributes &Attrs) const;
} Attributes operator ^ (const Attributes &Attrs) const;
Attributes operator & (const Attributes &Attrs) const { Attributes &operator |= (const Attributes &Attrs);
return Attributes(Bits & Attrs.Bits); Attributes &operator &= (const Attributes &Attrs);
} Attributes operator ~ () const;
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); }
uint64_t Raw() const { return Bits; } uint64_t Raw() const { return Bits; }
/// constructAlignmentFromInt - This turns an int alignment (a power of 2, /// constructAlignmentFromInt - This turns an int alignment (a power of 2,
@ -307,11 +294,11 @@ public:
// Store the alignment in the bitcode as a 16-bit raw value instead of a // 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 // 5-bit log2 encoded value. Shift the bits above the alignment up by 11
// bits. // bits.
uint64_t EncodedAttrs = Attrs.Bits & 0xffff; uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
if (Attrs.hasAlignmentAttr()) if (Attrs.hasAlignmentAttr())
EncodedAttrs |= (1ULL << 16) << EncodedAttrs |= (1ULL << 16) <<
(((Attrs.Bits & Attribute::Alignment_i) - 1) >> 16); (((Attrs.Raw() & Attribute::Alignment_i) - 1) >> 16);
EncodedAttrs |= (Attrs.Bits & (0xfffULL << 21)) << 11; EncodedAttrs |= (Attrs.Raw() & (0xfffULL << 21)) << 11;
return EncodedAttrs; return EncodedAttrs;
} }

View File

@ -28,6 +28,9 @@ using namespace llvm;
// Attribute Function Definitions // Attribute Function Definitions
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
bool Attributes::hasAttributes(const Attributes &A) const {
return Bits & A.Bits;
}
bool Attributes::hasAddressSafetyAttr() const { bool Attributes::hasAddressSafetyAttr() const {
return Bits & Attribute::AddressSafety_i; return Bits & Attribute::AddressSafety_i;
} }
@ -125,6 +128,31 @@ unsigned Attributes::getStackAlignment() const {
return 1U << (((Bits & Attribute::StackAlignment_i) >> 26) - 1); 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 Attributes::typeIncompatible(Type *Ty) {
Attributes::Builder Incompatible; Attributes::Builder Incompatible;