llvm/llvm/include/llvm/ADT/DenseMapInfo.h

//===- llvm/ADT/DenseMapInfo.h - Type traits for DenseMap -------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file defines DenseMapInfo traits for DenseMap.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_ADT_DENSEMAPINFO_H
#define LLVM_ADT_DENSEMAPINFO_H

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <tuple>
#include <type_traits>
#include <utility>

namespace llvm {

namespace densemap::detail {
// A bit mixer with very low latency using one multiplications and one
// xor-shift. The constant is from splitmix64.
inline uint64_t mix(uint64_t x) {}
} // namespace densemap::detail

namespace detail {

/// Simplistic combination of 32-bit hash values into 32-bit hash values.
inline unsigned combineHashValue(unsigned a, unsigned b) {}

} // end namespace detail

/// An information struct used to provide DenseMap with the various necessary
/// components for a given value type `T`. `Enable` is an optional additional
/// parameter that is used to support SFINAE (generally using std::enable_if_t)
/// in derived DenseMapInfo specializations; in non-SFINAE use cases this should
/// just be `void`.
template<typename T, typename Enable = void>
struct DenseMapInfo {};

// Provide DenseMapInfo for all pointers. Come up with sentinel pointer values
// that are aligned to alignof(T) bytes, but try to avoid requiring T to be
// complete. This allows clients to instantiate DenseMap<T*, ...> with forward
// declared key types. Assume that no pointer key type requires more than 4096
// bytes of alignment.
DenseMapInfo<T *>;

// Provide DenseMapInfo for chars.
template<> struct DenseMapInfo<char> {};

// Provide DenseMapInfo for unsigned chars.
template <> struct DenseMapInfo<unsigned char> {};

// Provide DenseMapInfo for unsigned shorts.
template <> struct DenseMapInfo<unsigned short> {};

// Provide DenseMapInfo for unsigned ints.
template<> struct DenseMapInfo<unsigned> {};

// Provide DenseMapInfo for unsigned longs.
template<> struct DenseMapInfo<unsigned long> {};

// Provide DenseMapInfo for unsigned long longs.
template<> struct DenseMapInfo<unsigned long long> {};

// Provide DenseMapInfo for shorts.
template <> struct DenseMapInfo<short> {};

// Provide DenseMapInfo for ints.
template<> struct DenseMapInfo<int> {};

// Provide DenseMapInfo for longs.
template<> struct DenseMapInfo<long> {};

// Provide DenseMapInfo for long longs.
template<> struct DenseMapInfo<long long> {};

// Provide DenseMapInfo for all pairs whose members have info.
DenseMapInfo<std::pair<T, U>>;

// Provide DenseMapInfo for all tuples whose members have info.
DenseMapInfo<std::tuple<Ts...>>;

// Provide DenseMapInfo for enum classes.
DenseMapInfo<Enum, std::enable_if_t<std::is_enum_v<Enum>>>;
} // end namespace llvm

#endif // LLVM_ADT_DENSEMAPINFO_H