14#ifndef LLVM_ADT_DENSEMAPINFO_H
15#define LLVM_ADT_DENSEMAPINFO_H
28namespace densemap::detail {
32 x *= 0xbf58476d1ce4e5b9u;
53template<
typename T,
typename Enable =
void>
72 static constexpr uintptr_t Log2MaxAlign = 12;
75 uintptr_t Val =
static_cast<uintptr_t
>(-1);
77 return reinterpret_cast<T*
>(Val);
81 uintptr_t Val =
static_cast<uintptr_t
>(-2);
83 return reinterpret_cast<T*
>(Val);
87 return (
unsigned((uintptr_t)PtrVal) >> 4) ^
98 static unsigned getHashValue(
const char& Val) {
return Val * 37U; }
113 T,
std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, char>>> {
114 static constexpr T getEmptyKey() {
return std::numeric_limits<T>::max(); }
117 if constexpr (std::is_unsigned_v<T> || std::is_same_v<T, long>)
118 return std::numeric_limits<T>::max() - 1;
120 return std::numeric_limits<T>::min();
124 if constexpr (std::is_unsigned_v<T> &&
sizeof(
T) >
sizeof(
unsigned))
127 return static_cast<unsigned>(Val *
128 static_cast<std::make_unsigned_t<T>
>(37U));
135template<
typename T,
typename U>
142 return std::make_pair(FirstInfo::getEmptyKey(),
143 SecondInfo::getEmptyKey());
147 return std::make_pair(FirstInfo::getTombstoneKey(),
148 SecondInfo::getTombstoneKey());
153 SecondInfo::getHashValue(PairVal.second));
161 SecondInfo::getHashValue(Second));
165 return FirstInfo::isEqual(
LHS.first,
RHS.first) &&
166 SecondInfo::isEqual(
LHS.second,
RHS.second);
182 template <
unsigned I>
184 using EltType = std::tuple_element_t<I, Tuple>;
185 std::integral_constant<
bool,
I + 1 ==
sizeof...(Ts)> atEnd;
188 getHashValueImpl<I + 1>(
values, atEnd));
191 template <
unsigned I>
197 std::integral_constant<
bool, 0 ==
sizeof...(Ts)> atEnd;
198 return getHashValueImpl<0>(
values, atEnd);
201 template <
unsigned I>
203 using EltType = std::tuple_element_t<I, Tuple>;
204 std::integral_constant<
bool,
I + 1 ==
sizeof...(Ts)> atEnd;
206 isEqualImpl<I + 1>(lhs, rhs, atEnd);
209 template <
unsigned I>
215 std::integral_constant<
bool, 0 ==
sizeof...(Ts)> atEnd;
216 return isEqualImpl<0>(lhs, rhs, atEnd);
221template <
typename Enum>
235 constexpr Enum V =
static_cast<Enum
>(Info::getEmptyKey());
240 constexpr Enum V =
static_cast<Enum
>(Info::getTombstoneKey());
258 return {Info::getTombstoneKey()};
263 OptionalVal.has_value(),
264 Info::getHashValue(OptionalVal.value_or(Info::getEmptyKey())));
269 return Info::isEqual(
LHS.value(),
RHS.value());
Mark the given Function as meaning that it cannot be changed in any way mark any values that are used as this function s parameters or by its return values(according to Uses) live as well. void DeadArgumentEliminationPass
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
This is an optimization pass for GlobalISel generic memory operations.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Implement std::hash so that hash_code can be used in STL containers.
static constexpr Enum getTombstoneKey()
std::underlying_type_t< Enum > UnderlyingType
static bool isEqual(const Enum &LHS, const Enum &RHS)
static unsigned getHashValue(const Enum &Val)
static constexpr Enum getEmptyKey()
static unsigned getHashValue(const T &Val)
static bool isEqual(const T &LHS, const T &RHS)
static constexpr T getEmptyKey()
static constexpr T getTombstoneKey()
static constexpr T * getTombstoneKey()
static constexpr T * getEmptyKey()
static unsigned getHashValue(const T *PtrVal)
static bool isEqual(const T *LHS, const T *RHS)
static bool isEqual(const char &LHS, const char &RHS)
static constexpr char getEmptyKey()
static unsigned getHashValue(const char &Val)
static constexpr char getTombstoneKey()
static constexpr Optional getEmptyKey()
static constexpr Optional getTombstoneKey()
std::optional< T > Optional
static unsigned getHashValue(const Optional &OptionalVal)
static bool isEqual(const Optional &LHS, const Optional &RHS)
static unsigned getHashValuePiecewise(const T &First, const U &Second)
static constexpr Pair getEmptyKey()
static unsigned getHashValue(const Pair &PairVal)
static constexpr Pair getTombstoneKey()
static bool isEqual(const Pair &LHS, const Pair &RHS)
std::tuple< Ts... > Tuple
static unsigned getHashValueImpl(const Tuple &values, std::false_type)
static bool isEqualImpl(const Tuple &lhs, const Tuple &rhs, std::false_type)
static constexpr Tuple getTombstoneKey()
static unsigned getHashValue(const std::tuple< Ts... > &values)
static bool isEqualImpl(const Tuple &, const Tuple &, std::true_type)
static bool isEqual(const Tuple &lhs, const Tuple &rhs)
static constexpr Tuple getEmptyKey()
static unsigned getHashValueImpl(const Tuple &, std::true_type)
An information struct used to provide DenseMap with the various necessary components for a given valu...