44#ifndef LLVM_ADT_HASHING_H 
   45#define LLVM_ADT_HASHING_H 
   48#include "llvm/Config/abi-breaking.h" 
   62template <
typename T, 
typename Enable> 
struct DenseMapInfo;
 
   88   operator size_t()
 const { 
return value; }
 
   91    return lhs.value == rhs.value;
 
 
   94    return lhs.value != rhs.value;
 
 
 
  109std::enable_if_t<is_integral_or_enum<T>::value, hash_code> 
hash_value(
T value);
 
  114template <
typename T> hash_code 
hash_value(
const T *ptr);
 
  117template <
typename T, 
typename U>
 
  118hash_code 
hash_value(
const std::pair<T, U> &arg);
 
  121template <
typename... Ts>
 
  122hash_code 
hash_value(
const std::tuple<Ts...> &arg);
 
  126hash_code 
hash_value(
const std::basic_string<T> &arg);
 
  129template <
typename T> hash_code 
hash_value(
const std::optional<T> &arg);
 
  139  std::memcpy(&result, p, 
sizeof(result));
 
 
  147  std::memcpy(&result, p, 
sizeof(result));
 
 
  164  return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
 
 
  168  return val ^ (val >> 47);
 
 
  173  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
 
 
  236  if (length >= 4 && length <= 8)
 
  238  if (length > 8 && length <= 16)
 
  240  if (length > 16 && length <= 32)
 
 
  315#if LLVM_ENABLE_ABI_BREAKING_CHECKS 
  319  return 0xff51afd7ed558ccdULL;
 
 
  338                                               std::is_pointer<T>::value) &&
 
  339                                              64 % sizeof(T) == 0)> {};
 
 
  345template <
typename T, 
typename U>
 
  347    : std::bool_constant<(is_hashable_data<T>::value &&
 
  348                          is_hashable_data<U>::value &&
 
  349                          (sizeof(T) + sizeof(U)) == sizeof(std::pair<T, U>))> {
 
 
  361    return static_cast<size_t>(
hash_value(value));
 
 
  375  size_t store_size = 
sizeof(value) - offset;
 
  376  if (buffer_ptr + store_size > buffer_end)
 
  378  const char *value_data = 
reinterpret_cast<const char *
>(&value);
 
  379  std::memcpy(buffer_ptr, value_data + offset, store_size);
 
  380  buffer_ptr += store_size;
 
 
  389template <
typename InputIteratorT>
 
  392  char buffer[64], *buffer_ptr = buffer;
 
  393  char *
const buffer_end = std::end(buffer);
 
  398    return hash_short(buffer, buffer_ptr - buffer, seed);
 
  399  assert(buffer_ptr == buffer_end);
 
  403  while (first != last) {
 
  414    std::rotate(buffer, buffer_ptr, buffer_end);
 
  418    length += buffer_ptr - buffer;
 
 
  432template <
typename ValueT>
 
  433std::enable_if_t<is_hashable_data<ValueT>::value, 
hash_code>
 
  436  const char *s_begin = 
reinterpret_cast<const char *
>(first);
 
  437  const char *s_end = 
reinterpret_cast<const char *
>(last);
 
  438  const size_t length = std::distance(s_begin, s_end);
 
  442  const char *s_aligned_end = s_begin + (length & ~63);
 
  445  while (s_begin != s_aligned_end) {
 
  450    state.mix(s_end - 64);
 
  452  return state.finalize(length);
 
 
 
 
  465template <
typename InputIteratorT>
 
  467  return ::llvm::hashing::detail::hash_combine_range_impl(first, last);
 
 
  505  template <
typename T>
 
  512      size_t partial_store_size = buffer_end - buffer_ptr;
 
  513      std::memcpy(buffer_ptr, &
data, partial_store_size);
 
 
  544  template <
typename T, 
typename ...Ts>
 
  546                    const T &arg, 
const Ts &...
args) {
 
  550    return combine(length, buffer_ptr, buffer_end, 
args...);
 
 
  568    std::rotate(
buffer, buffer_ptr, buffer_end);
 
  572    length += buffer_ptr - 
buffer;
 
  574    return state.finalize(length);
 
 
 
  611  const char *s = 
reinterpret_cast<const char *
>(&value);
 
 
  623  return ::llvm::hashing::detail::hash_integer_value(
 
 
  630  return ::llvm::hashing::detail::hash_integer_value(
 
  631    reinterpret_cast<uintptr_t
>(ptr));
 
 
  636template <
typename T, 
typename U>
 
  642  return std::apply([](
const auto &...xs) { 
return hash_combine(xs...); }, arg);
 
 
  660    return static_cast<unsigned>(size_t(val));
 
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
An opaque object representing a hash code.
friend size_t hash_value(const hash_code &code)
Allow a hash_code to be directly run through hash_value.
friend bool operator==(const hash_code &lhs, const hash_code &rhs)
friend bool operator!=(const hash_code &lhs, const hash_code &rhs)
hash_code(size_t value)
Form a hash code directly from a numerical value.
hash_code()=default
Default construct a hash_code.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint64_t hash_1to3_bytes(const char *s, size_t len, uint64_t seed)
bool store_and_advance(char *&buffer_ptr, char *buffer_end, const T &value, size_t offset=0)
Helper to store data from a value into a buffer and advance the pointer into that buffer.
uint64_t hash_9to16_bytes(const char *s, size_t len, uint64_t seed)
uint64_t hash_4to8_bytes(const char *s, size_t len, uint64_t seed)
hash_code hash_combine_range_impl(InputIteratorT first, InputIteratorT last)
Implement the combining of integral values into a hash_code.
hash_code hash_integer_value(uint64_t value)
Helper to hash the value of a single integer.
uint64_t rotate(uint64_t val, size_t shift)
Bitwise right rotate.
static constexpr uint64_t k2
auto get_hashable_data(const T &value)
Helper to get the hashable data representation for a type.
uint64_t fetch64(const char *p)
uint64_t hash_17to32_bytes(const char *s, size_t len, uint64_t seed)
static constexpr uint64_t k1
uint64_t get_execution_seed()
In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic per process (address of a fu...
uint32_t fetch32(const char *p)
static constexpr uint64_t k3
uint64_t hash_short(const char *s, size_t length, uint64_t seed)
static constexpr uint64_t k0
Some primes between 2^63 and 2^64 for various uses.
uint64_t shift_mix(uint64_t val)
uint64_t hash_33to64_bytes(const char *s, size_t len, uint64_t seed)
uint64_t hash_16_bytes(uint64_t low, uint64_t high)
constexpr bool IsBigEndianHost
void swapByteOrder(T &Value)
This is an optimization pass for GlobalISel generic memory operations.
constexpr T rotr(T V, int R)
hash_code hash_value(const FixedPointSemantics &Val)
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
LLVM_ABI void install_fatal_error_handler(fatal_error_handler_t handler, void *user_data=nullptr)
install_fatal_error_handler - Installs a new error handler to be used whenever a serious (non-recover...
constexpr auto adl_end(RangeT &&range) -> decltype(adl_detail::end_impl(std::forward< RangeT >(range)))
Returns the end iterator to range using std::end and functions found through Argument-Dependent Looku...
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static bool isEqual(hash_code LHS, hash_code RHS)
static hash_code getEmptyKey()
static unsigned getHashValue(hash_code val)
static hash_code getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Helper class to manage the recursive combining of hash_combine arguments.
hash_code combine(size_t length, char *buffer_ptr, char *buffer_end)
Base case for recursive, variadic combining.
char * combine_data(size_t &length, char *buffer_ptr, char *buffer_end, T data)
Combine one chunk of data into the current in-flight hash.
hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, const T &arg, const Ts &...args)
Recursive, variadic combining method.
hash_combine_recursive_helper()
Construct a recursive hash combining helper.
The intermediate state used during hashing.
static hash_state create(const char *s, uint64_t seed)
Create a new hash_state structure and initialize it based on the seed and the first 64-byte chunk.
uint64_t finalize(size_t length)
Compute the final 64-bit hash code value based on the current state and the length of bytes hashed.
static void mix_32_bytes(const char *s, uint64_t &a, uint64_t &b)
Mix 32-bytes from the input sequence into the 16-bytes of 'a' and 'b', including whatever is already ...
void mix(const char *s)
Mix in a 64-byte buffer of data.
Trait to indicate whether a type's bits can be hashed directly.
size_t operator()(llvm::hash_code const &Val) const