diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-01-21 21:57:28 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-01-21 21:57:28 +0000 |
commit | c5f1bc88a2eb7ad9ff924ca90cf88494e5f947b9 (patch) | |
tree | fdb62d85df750d2679b71fdab4d43d4e8258162b /include | |
parent | 8e528100d210e225cee417229d94af91355118c0 (diff) | |
download | external_llvm-c5f1bc88a2eb7ad9ff924ca90cf88494e5f947b9.zip external_llvm-c5f1bc88a2eb7ad9ff924ca90cf88494e5f947b9.tar.gz external_llvm-c5f1bc88a2eb7ad9ff924ca90cf88494e5f947b9.tar.bz2 |
Make AttributeSet::getFnAttributes() return an AttributeSet instead of an Attribute.
This is more code to isolate the use of the Attribute class to that of just
holding one attribute instead of a collection of attributes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/IR/Attributes.h | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 96fcbf9..121eae2 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -184,42 +184,12 @@ template<> struct DenseMapInfo<Attribute::AttrKind> { }; //===----------------------------------------------------------------------===// -/// \class -/// \brief This is just a pair of values to associate a set of attributes with -/// an index. -struct AttributeWithIndex { - Attribute Attrs; ///< The attributes that are set, or'd together. - Constant *Val; ///< Value attached to attribute, e.g. alignment. - unsigned Index; ///< Index of the parameter for which the attributes apply. - ///< Index 0 is used for return value attributes. - ///< Index ~0U is used for function attributes. - - static AttributeWithIndex get(LLVMContext &C, unsigned Idx, - ArrayRef<Attribute::AttrKind> Attrs) { - return get(Idx, Attribute::get(C, Attrs)); - } - static AttributeWithIndex get(unsigned Idx, Attribute Attrs) { - AttributeWithIndex P; - P.Index = Idx; - P.Attrs = Attrs; - P.Val = 0; - return P; - } - static AttributeWithIndex get(unsigned Idx, Attribute Attrs, Constant *Val) { - AttributeWithIndex P; - P.Index = Idx; - P.Attrs = Attrs; - P.Val = Val; - return P; - } -}; - -//===----------------------------------------------------------------------===// // AttributeSet Smart Pointer //===----------------------------------------------------------------------===// class AttrBuilder; class AttributeSetImpl; +struct AttributeWithIndex; //===----------------------------------------------------------------------===// /// \class @@ -289,9 +259,7 @@ public: } /// \brief The function attributes are returned. - Attribute getFnAttributes() const { - return getAttributes(FunctionIndex); - } + AttributeSet getFnAttributes() const; /// \brief Return the alignment for the specified function parameter. unsigned getParamAlignment(unsigned Idx) const; @@ -354,6 +322,39 @@ public: //===----------------------------------------------------------------------===// /// \class +/// \brief This is just a pair of values to associate a set of attributes with +/// an index. +struct AttributeWithIndex { + Attribute Attrs; ///< The attributes that are set, or'd together. + Constant *Val; ///< Value attached to attribute, e.g. alignment. + unsigned Index; ///< Index of the parameter for which the attributes apply. + ///< Index 0 is used for return value attributes. + ///< Index ~0U is used for function attributes. + + // FIXME: These methods all need to be revised. The first one is temporary. + static AttributeWithIndex get(LLVMContext &C, unsigned Idx, AttributeSet AS); + static AttributeWithIndex get(LLVMContext &C, unsigned Idx, + ArrayRef<Attribute::AttrKind> Attrs) { + return get(Idx, Attribute::get(C, Attrs)); + } + static AttributeWithIndex get(unsigned Idx, Attribute Attrs) { + AttributeWithIndex P; + P.Index = Idx; + P.Attrs = Attrs; + P.Val = 0; + return P; + } + static AttributeWithIndex get(unsigned Idx, Attribute Attrs, Constant *Val) { + AttributeWithIndex P; + P.Index = Idx; + P.Attrs = Attrs; + P.Val = Val; + return P; + } +}; + +//===----------------------------------------------------------------------===// +/// \class /// \brief This class is used in conjunction with the Attribute::get method to /// create an Attribute object. The object itself is uniquified. The Builder's /// value, however, is not. So this can be used as a quick way to test for |