14 #ifndef LLVM_ADT_DENSEMAPINFO_H
15 #define LLVM_ADT_DENSEMAPINFO_H
36 uintptr_t Val =
static_cast<uintptr_t
>(-1);
37 Val <<= PointerLikeTypeTraits<T*>::NumLowBitsAvailable;
38 return reinterpret_cast<T*
>(Val);
41 uintptr_t Val =
static_cast<uintptr_t
>(-2);
42 Val <<= PointerLikeTypeTraits<T*>::NumLowBitsAvailable;
43 return reinterpret_cast<T*
>(Val);
46 return (
unsigned((uintptr_t)PtrVal) >> 4) ^
49 static bool isEqual(
const T *LHS,
const T *RHS) {
return LHS == RHS; }
56 static unsigned getHashValue(
const char& Val) {
return Val * 37U; }
57 static bool isEqual(
const char &LHS,
const char &RHS) {
66 static unsigned getHashValue(
const unsigned& Val) {
return Val * 37U; }
67 static bool isEqual(
const unsigned& LHS,
const unsigned& RHS) {
77 return (
unsigned)(Val * 37UL);
79 static bool isEqual(
const unsigned long& LHS,
const unsigned long& RHS) {
86 static inline unsigned long long getEmptyKey() {
return ~0ULL; }
89 return (
unsigned)(Val * 37ULL);
91 static bool isEqual(
const unsigned long long& LHS,
92 const unsigned long long& RHS) {
101 static unsigned getHashValue(
const int& Val) {
return (
unsigned)(Val * 37U); }
102 static bool isEqual(
const int& LHS,
const int& RHS) {
110 return (1UL << (
sizeof(
long) * 8 - 1)) - 1UL;
114 return (
unsigned)(Val * 37UL);
116 static bool isEqual(
const long& LHS,
const long& RHS) {
123 static inline long long getEmptyKey() {
return 0x7fffffffffffffffLL; }
126 return (
unsigned)(Val * 37ULL);
129 const long long& RHS) {
135 template<
typename T,
typename U>
142 return std::make_pair(FirstInfo::getEmptyKey(),
143 SecondInfo::getEmptyKey());
146 return std::make_pair(FirstInfo::getTombstoneKey(),
147 SecondInfo::getTombstoneKey());
150 uint64_t key = (uint64_t)FirstInfo::getHashValue(PairVal.first) << 32
151 | (uint64_t)SecondInfo::getHashValue(PairVal.second);
160 return (
unsigned)key;
163 return FirstInfo::isEqual(LHS.first, RHS.first) &&
164 SecondInfo::isEqual(LHS.second, RHS.second);
171 return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(0)),
175 return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)),
179 assert(Val.
data() != getEmptyKey().data() &&
"Cannot hash the empty key!");
180 assert(Val.
data() != getTombstoneKey().data() &&
181 "Cannot hash the tombstone key!");
185 if (RHS.
data() == getEmptyKey().data())
186 return LHS.
data() == getEmptyKey().data();
187 if (RHS.
data() == getTombstoneKey().data())
188 return LHS.
data() == getTombstoneKey().data();
static bool isEqual(const char &LHS, const char &RHS)
static unsigned getHashValue(const unsigned long &Val)
static unsigned long getEmptyKey()
static unsigned getHashValue(const unsigned long long &Val)
static bool isEqual(const T *LHS, const T *RHS)
static bool isEqual(StringRef LHS, StringRef RHS)
DenseMapInfo< T > FirstInfo
static unsigned getHashValue(const long &Val)
static unsigned getEmptyKey()
static unsigned getHashValue(const long long &Val)
static bool isEqual(const unsigned long long &LHS, const unsigned long long &RHS)
static bool isEqual(const long long &LHS, const long long &RHS)
static bool isEqual(const int &LHS, const int &RHS)
static char getEmptyKey()
static bool isEqual(const Pair &LHS, const Pair &RHS)
static unsigned getHashValue(StringRef Val)
static unsigned long long getEmptyKey()
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static long long getEmptyKey()
static bool isEqual(const unsigned &LHS, const unsigned &RHS)
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
static unsigned long getTombstoneKey()
static char getTombstoneKey()
static bool isEqual(const unsigned long &LHS, const unsigned long &RHS)
static long getTombstoneKey()
static bool isEqual(const long &LHS, const long &RHS)
static StringRef getEmptyKey()
static unsigned getHashValue(const unsigned &Val)
static unsigned getTombstoneKey()
static int getTombstoneKey()
static StringRef getTombstoneKey()
static long long getTombstoneKey()
static unsigned getHashValue(const int &Val)
static unsigned getHashValue(const T *PtrVal)
static unsigned getHashValue(const Pair &PairVal)
static unsigned getHashValue(const char &Val)
DenseMapInfo< U > SecondInfo
static Pair getTombstoneKey()
static unsigned long long getTombstoneKey()
StringRef - Represent a constant reference to a string, i.e.
static long getEmptyKey()
static Pair getEmptyKey()
static T * getTombstoneKey()