public:
Attributes() : Attrs(0) {}
explicit Attributes(uint64_t Val);
- explicit Attributes(AttrVal Val);
+ explicit Attributes(LLVMContext &C, AttrVal Val);
Attributes(const Attributes &A);
class Builder {
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; }
Builder &addAttribute(Attributes::AttrVal Val);
Builder &removeAttribute(Attributes::AttrVal Val);
- void addAlignmentAttr(unsigned Align);
- void addStackAlignmentAttr(unsigned Align);
+ /// addRawValue - Add the raw value to the internal representation. This
+ /// should be used ONLY for decoding bitcode!
+ Builder &addRawValue(uint64_t Val);
- void removeAttributes(const Attributes &A);
+ /// 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.
+ Builder &addStackAlignmentAttr(unsigned Align);
+
+ Builder &removeAttributes(const Attributes &A);
/// @brief Remove attributes that are used on functions only.
void removeFunctionOnlyAttrs() {
.removeAttribute(Attributes::ReturnsTwice)
.removeAttribute(Attributes::AddressSafety);
}
+
+ bool operator==(const Builder &B) {
+ return Bits == B.Bits;
+ }
+ bool operator!=(const Builder &B) {
+ return Bits != B.Bits;
+ }
};
/// get - Return a uniquified Attributes object. This takes the uniquified
Attributes operator | (const Attributes &A) const;
Attributes operator & (const Attributes &A) const;
- Attributes operator ^ (const Attributes &A) const;
Attributes &operator |= (const Attributes &A);
Attributes &operator &= (const Attributes &A);
- Attributes operator ~ () const;
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);
- }
-
- /// constructStackAlignmentFromInt - 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 Attributes();
-
- assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
- assert(i <= 0x100 && "Alignment too large.");
- return Attributes((Log2_32(i)+1) << 26);
- }
-
/// @brief Which attributes cannot be applied to a type.
static Attributes typeIncompatible(Type *Ty);
assert((!Alignment || isPowerOf2_32(Alignment)) &&
"Alignment must be a power of two.");
- Attributes Attrs(EncodedAttrs & 0xffff);
+ Attributes::Builder B(EncodedAttrs & 0xffff);
if (Alignment)
- Attrs |= Attributes::constructAlignmentFromInt(Alignment);
- Attrs |= Attributes((EncodedAttrs & (0xfffULL << 32)) >> 11);
- return Attrs;
+ B.addAlignmentAttr(Alignment);
+ B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
+ return Attributes::get(B);
}
/// getAsString - The set of Attributes set in Attributes is converted to a
/// removeAttr - Remove the specified attribute at the specified index from
/// this attribute list. Since attribute lists are immutable, this
/// returns the new list.
- AttrListPtr removeAttr(unsigned Idx, Attributes Attrs) const;
+ AttrListPtr removeAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
//===--------------------------------------------------------------------===//
// Attribute List Accessors