summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-09 15:42:51 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-09 15:42:51 +0000
commit33ab8a2187b9e14355646f9dd2ff472e0965a7c6 (patch)
treed9babf41758b55aa7e1f72b98bedf8de216fa7fc
parentf340008eab56a3541e1d9105f82f9760cd991bed (diff)
downloadbcm5719-llvm-33ab8a2187b9e14355646f9dd2ff472e0965a7c6.tar.gz
bcm5719-llvm-33ab8a2187b9e14355646f9dd2ff472e0965a7c6.zip
Add a DenseMapInfo class for the AttributeSet.
We are going to place the AttributeSet into a DenseMap during assembly writing. llvm-svn: 174812
-rw-r--r--llvm/include/llvm/IR/Attributes.h48
1 files changed, 35 insertions, 13 deletions
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 4aee10fab3d..a5539cc713b 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -185,6 +185,26 @@ 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
@@ -200,6 +220,7 @@ public:
private:
friend class AttrBuilder;
friend class AttributeSetImpl;
+ template <typename Ty> friend struct DenseMapInfo;
/// \brief The attributes that we are managing. This can be null to represent
/// the empty attributes list.
@@ -339,22 +360,23 @@ 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;
+/// \brief Provide DenseMapInfo for AttributeSet.
+template<> struct DenseMapInfo<AttributeSet> {
+ static inline AttributeSet getEmptyKey() {
+ uintptr_t Val = static_cast<uintptr_t>(-1);
+ Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
+ return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
}
- static inline Attribute::AttrKind getTombstoneKey() {
- return Attribute::AttrKindTombstoneKey;
- }
- static unsigned getHashValue(const Attribute::AttrKind &Val) {
- return Val * 37U;
+ static inline AttributeSet getTombstoneKey() {
+ uintptr_t Val = static_cast<uintptr_t>(-2);
+ Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
+ return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
}
- static bool isEqual(const Attribute::AttrKind &LHS,
- const Attribute::AttrKind &RHS) {
- return LHS == RHS;
+ static unsigned getHashValue(AttributeSet AS) {
+ return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
+ (unsigned((uintptr_t)AS.pImpl) >> 9);
}
+ static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
};
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud