diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-10-15 04:46:55 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-10-15 04:46:55 +0000 |
commit | cb3de0bc800d7920087b19bb12a545d4cc84114e (patch) | |
tree | cbd5a447bcc1d11449532b3c92119f26eeb5a815 /include | |
parent | a239c2e6a7775e890bcfb0867b84e512ceb993de (diff) |
Attributes Rewrite
Convert the internal representation of the Attributes class into a pointer to an
opaque object that's uniqued by and stored in the LLVMContext object. The
Attributes class then becomes a thin wrapper around this opaque
object. Eventually, the internal representation will be expanded to include
attributes that represent code generation options, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165917 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Attributes.h | 22 | ||||
-rw-r--r-- | include/llvm/Function.h | 6 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 22 | ||||
-rw-r--r-- | include/llvm/Intrinsics.h | 4 |
4 files changed, 27 insertions, 27 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index a69667b047e..ad33a8a9594 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -89,13 +89,12 @@ public: ZExt = 27 ///< Zero extended before/after call }; private: - AttributesImpl Attrs; + AttributesImpl *Attrs; explicit Attributes(AttributesImpl *A); public: Attributes() : Attrs(0) {} - explicit Attributes(uint64_t Val); - explicit Attributes(LLVMContext &C, AttrVal Val); + explicit Attributes(LLVMContext &C, ArrayRef<AttrVal> Vals); Attributes(const Attributes &A); class Builder { @@ -105,6 +104,7 @@ public: Builder() : Bits(0) {} explicit Builder(uint64_t B) : Bits(B) {} Builder(const Attributes &A) : Bits(A.Raw()) {} + Builder(const Builder &B) : Bits(B.Bits) {} void clear() { Bits = 0; } @@ -166,7 +166,6 @@ public: /// get - Return a uniquified Attributes object. This takes the uniquified /// value from the Builder and wraps it in the Attributes class. - static Attributes get(Builder &B); static Attributes get(LLVMContext &Context, Builder &B); /// @brief Return true if the attribute is present. @@ -174,7 +173,7 @@ public: /// @brief Return true if attributes exist bool hasAttributes() const { - return Attrs.hasAttributes(); + return Attrs && Attrs->hasAttributes(); } /// @brief Return true if the attributes are a non-null intersection. @@ -225,10 +224,10 @@ public: } bool operator == (const Attributes &A) const { - return Attrs.Bits == A.Attrs.Bits; + return Attrs == A.Attrs; } bool operator != (const Attributes &A) const { - return Attrs.Bits != A.Attrs.Bits; + return Attrs != A.Attrs; } uint64_t Raw() const; @@ -261,7 +260,8 @@ public: /// containing the LLVM attributes that have been decoded from the given /// integer. This function must stay in sync with /// 'encodeLLVMAttributesForBitcode'. - static Attributes decodeLLVMAttributesForBitcode(uint64_t EncodedAttrs) { + static Attributes decodeLLVMAttributesForBitcode(LLVMContext &C, + uint64_t EncodedAttrs) { // The alignment is stored as a 16-bit raw value from bits 31--16. We shift // the bits above 31 down by 11 bits. unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16; @@ -272,7 +272,7 @@ public: if (Alignment) B.addAlignmentAttr(Alignment); B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11); - return Attributes::get(B); + return Attributes::get(C, B); } /// getAsString - The set of Attributes set in Attributes is converted to a @@ -294,7 +294,7 @@ struct AttributeWithIndex { ///< Index 0 is used for return value attributes. ///< Index ~0U is used for function attributes. - static AttributeWithIndex get(unsigned Idx, + static AttributeWithIndex get(LLVMContext &C, unsigned Idx, ArrayRef<Attributes::AttrVal> Attrs) { Attributes::Builder B; @@ -304,7 +304,7 @@ struct AttributeWithIndex { AttributeWithIndex P; P.Index = Idx; - P.Attrs = Attributes::get(B); + P.Attrs = Attributes::get(C, B); return P; } static AttributeWithIndex get(unsigned Idx, Attributes Attrs) { diff --git a/include/llvm/Function.h b/include/llvm/Function.h index f28aa5cdd7a..f36d5650b3e 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -180,7 +180,7 @@ public: // Function Attributes are stored at ~0 index Attributes::Builder B; B.addAttribute(N); - addAttribute(~0U, Attributes::get(B)); + addAttribute(~0U, Attributes::get(getContext(), B)); } /// removeFnAttr - Remove function attributes from this function. @@ -280,7 +280,7 @@ public: void setDoesNotAlias(unsigned n) { Attributes::Builder B; B.addAttribute(Attributes::NoAlias); - addAttribute(n, Attributes::get(B)); + addAttribute(n, Attributes::get(getContext(), B)); } /// @brief Determine if the parameter can be captured. @@ -291,7 +291,7 @@ public: void setDoesNotCapture(unsigned n) { Attributes::Builder B; B.addAttribute(Attributes::NoCapture); - addAttribute(n, Attributes::get(B)); + addAttribute(n, Attributes::get(getContext(), B)); } /// copyAttributesFrom - copy all additional attributes (those not needed to diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index e43b476fab8..7b68aef8747 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1274,7 +1274,7 @@ public: void setIsNoInline() { Attributes::Builder B; B.addAttribute(Attributes::NoInline); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Return true if the call can return twice @@ -1284,7 +1284,7 @@ public: void setCanReturnTwice() { Attributes::Builder B; B.addAttribute(Attributes::ReturnsTwice); - addAttribute(~0U, Attributes::get(B)); + addAttribute(~0U, Attributes::get(getContext(), B)); } /// @brief Determine if the call does not access memory. @@ -1294,7 +1294,7 @@ public: void setDoesNotAccessMemory() { Attributes::Builder B; B.addAttribute(Attributes::ReadNone); - addAttribute(~0U, Attributes::get(B)); + addAttribute(~0U, Attributes::get(getContext(), B)); } /// @brief Determine if the call does not access or only reads memory. @@ -1304,7 +1304,7 @@ public: void setOnlyReadsMemory() { Attributes::Builder B; B.addAttribute(Attributes::ReadOnly); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call cannot return. @@ -1312,7 +1312,7 @@ public: void setDoesNotReturn() { Attributes::Builder B; B.addAttribute(Attributes::NoReturn); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call cannot unwind. @@ -1320,7 +1320,7 @@ public: void setDoesNotThrow() { Attributes::Builder B; B.addAttribute(Attributes::NoUnwind); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call returns a structure through first @@ -3029,7 +3029,7 @@ public: void setIsNoInline() { Attributes::Builder B; B.addAttribute(Attributes::NoInline); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call does not access memory. @@ -3039,7 +3039,7 @@ public: void setDoesNotAccessMemory() { Attributes::Builder B; B.addAttribute(Attributes::ReadNone); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call does not access or only reads memory. @@ -3049,7 +3049,7 @@ public: void setOnlyReadsMemory() { Attributes::Builder B; B.addAttribute(Attributes::ReadOnly); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call cannot return. @@ -3057,7 +3057,7 @@ public: void setDoesNotReturn() { Attributes::Builder B; B.addAttribute(Attributes::NoReturn); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call cannot unwind. @@ -3065,7 +3065,7 @@ public: void setDoesNotThrow() { Attributes::Builder B; B.addAttribute(Attributes::NoUnwind); - addAttribute(~0, Attributes::get(B)); + addAttribute(~0, Attributes::get(getContext(), B)); } /// @brief Determine if the call returns a structure through first diff --git a/include/llvm/Intrinsics.h b/include/llvm/Intrinsics.h index c3503889e70..3108a8e5251 100644 --- a/include/llvm/Intrinsics.h +++ b/include/llvm/Intrinsics.h @@ -50,7 +50,7 @@ namespace Intrinsic { /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// FunctionType *getType(LLVMContext &Context, ID id, - ArrayRef<Type*> Tys = ArrayRef<Type*>()); + ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. @@ -58,7 +58,7 @@ namespace Intrinsic { /// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic. /// - AttrListPtr getAttributes(ID id); + AttrListPtr getAttributes(LLVMContext &C, ID id); /// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function /// declaration for an intrinsic, and return it. |