diff options
Diffstat (limited to 'include/llvm/IR/Attributes.h')
-rw-r--r-- | include/llvm/IR/Attributes.h | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index b6ca1ad9f9..d3190ffae4 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -17,8 +17,8 @@ #define LLVM_IR_ATTRIBUTES_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/Support/PointerLikeTypeTraits.h" #include <cassert> #include <map> #include <string> @@ -30,6 +30,7 @@ class AttributeImpl; class AttributeSetImpl; class AttributeSetNode; class Constant; +template<typename T> struct DenseMapInfo; class LLVMContext; class Type; @@ -101,9 +102,6 @@ public: ZExt, ///< Zero extended before/after call EndAttrKinds, ///< Sentinal value useful for loops - - AttrKindEmptyKey, ///< Empty key value for DenseMapInfo - AttrKindTombstoneKey ///< Tombstone key value for DenseMapInfo }; private: AttributeImpl *pImpl; @@ -187,26 +185,6 @@ public: //===----------------------------------------------------------------------===// /// \class -/// \brief Provide DenseMapInfo for Attribute::AttrKinds. This is used by -/// AttrBuilder. -template<> struct DenseMapInfo<Attribute::AttrKind> { - static inline Attribute::AttrKind getEmptyKey() { - return Attribute::AttrKindEmptyKey; - } - static inline Attribute::AttrKind getTombstoneKey() { - return Attribute::AttrKindTombstoneKey; - } - static unsigned getHashValue(const Attribute::AttrKind &Val) { - return Val * 37U; - } - static bool isEqual(const Attribute::AttrKind &LHS, - const Attribute::AttrKind &RHS) { - return LHS == RHS; - } -}; - -//===----------------------------------------------------------------------===// -/// \class /// \brief This class holds the attributes for a function, its return value, and /// its parameters. You access the attributes for each of them via an index into /// the AttributeSet object. The function attributes are at index @@ -400,16 +378,17 @@ template<> struct DenseMapInfo<AttributeSet> { /// value, however, is not. So this can be used as a quick way to test for /// equality, presence of attributes, etc. class AttrBuilder { - DenseSet<Attribute::AttrKind> Attrs; + uint64_t Attrs; std::map<std::string, std::string> TargetDepAttrs; uint64_t Alignment; uint64_t StackAlignment; public: - AttrBuilder() : Alignment(0), StackAlignment(0) {} - explicit AttrBuilder(uint64_t Val) : Alignment(0), StackAlignment(0) { + AttrBuilder() : Attrs(0), Alignment(0), StackAlignment(0) {} + explicit AttrBuilder(uint64_t Val) + : Attrs(0), Alignment(0), StackAlignment(0) { addRawValue(Val); } - AttrBuilder(const Attribute &A) : Alignment(0), StackAlignment(0) { + AttrBuilder(const Attribute &A) : Attrs(0), Alignment(0), StackAlignment(0) { addAttribute(A); } AttrBuilder(AttributeSet AS, unsigned Idx); @@ -442,7 +421,11 @@ public: AttrBuilder &merge(const AttrBuilder &B); /// \brief Return true if the builder has the specified attribute. - bool contains(Attribute::AttrKind A) const; + bool contains(Attribute::AttrKind A) const { + assert((unsigned)A < 64 && A < Attribute::EndAttrKinds && + "Attribute out of range!"); + return Attrs & (1ULL << A); + } /// \brief Return true if the builder has the specified target-dependent /// attribute. @@ -472,17 +455,9 @@ public: /// the form used internally in Attribute. AttrBuilder &addStackAlignmentAttr(unsigned Align); - // Iterators for target-independent attributes. - typedef DenseSet<Attribute::AttrKind>::iterator iterator; - typedef DenseSet<Attribute::AttrKind>::const_iterator const_iterator; - - iterator begin() { return Attrs.begin(); } - iterator end() { return Attrs.end(); } - - const_iterator begin() const { return Attrs.begin(); } - const_iterator end() const { return Attrs.end(); } - - bool empty() const { return Attrs.empty(); } + /// \brief Return true if the builder contains no target-independent + /// attributes. + bool empty() const { return Attrs == 0; } // Iterators for target-dependent attributes. typedef std::pair<std::string, std::string> td_type; |