15#ifndef LLVM_SUPPORT_HASHBUILDER_H
16#define LLVM_SUPPORT_HASHBUILDER_H
31namespace hashbuilder_detail {
36 : std::integral_constant<bool, is_integral_or_enum<U>::value> {};
43 template <
typename HasherT_ = HasherT>
78 template <
typename... ArgTypes>
80 : OptionalHasher(
std::in_place,
std::forward<ArgTypes>(Args)...),
81 Hasher(*OptionalHasher) {}
84 std::optional<HasherT> OptionalHasher;
138template <
typename HasherT, llvm::endianness Endianness>
142 template <
typename... ArgTypes>
147 template <
typename T>
148 std::enable_if_t<hashbuilder_detail::IsHashableData<T>::value,
HashBuilder &>
175 Value.size() *
sizeof(
T)));
177 for (
auto &V :
Value)
207 template <
typename T>
209 decltype(addHash(std::declval<HashBuilder &>(), std::declval<T &>()));
293 template <
typename T>
294 std::enable_if_t<is_detected<HasAddHashT, T>::value &&
298 addHash(*
this,
Value);
302 template <
typename T1,
typename T2>
308 std::apply([
this](
const auto &...Args) { this->
add(Args...); }, Arg);
322 template <
typename... Ts>
324 return (
add(Args), ...);
327 template <
typename ForwardIteratorT>
337 template <
typename ForwardIteratorT>
339 return addRangeElementsImpl(
341 typename std::iterator_traits<ForwardIteratorT>::iterator_category());
344 template <
typename RangeT>
349 template <
typename T>
353 template <
typename T>
354 std::enable_if_t<is_detected<HasByteSwapT, T>::value,
HashBuilder &>
358 sizeof(SwappedValue)));
365 template <
typename ForwardIteratorT>
367 ForwardIteratorT
Last,
368 std::forward_iterator_tag) {
374 template <
typename T>
375 std::enable_if_t<hashbuilder_detail::IsHashableData<T>::value &&
378 addRangeElementsImpl(
T *
First,
T *
Last, std::forward_iterator_tag) {
385namespace hashbuilder_detail {
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Declares the hasher member, and functions forwarding directly to the hasher.
void update(StringRef Data)
Forward to HasherT::update(ArrayRef<uint8_t>).
HashResultTy< HasherT_ > result()
Forward to HasherT::result() if available.
HashBuilderBase(HasherT &Hasher)
HashBuilderBase(ArgTypes &&...Args)
decltype(std::declval< HasherT_ & >().final()) HashResultTy
void update(ArrayRef< uint8_t > Data)
Forward to HasherT::update(ArrayRef<uint8_t>).
Interface to help hash various types through a hasher type.
HashBuilder & add(StringRef Value)
Support hashing StringRef.
std::enable_if_t< is_detected< HasByteSwapT, T >::value, HashBuilder & > adjustForEndiannessAndAdd(const T &Value)
Adjust Value for the target endianness and add it to the hash.
HashBuilder(HasherT &Hasher)
std::enable_if_t<(sizeof...(Ts) > 1), HashBuilder & > add(const Ts &...Args)
A convenenience variadic helper.
HashBuilder & addRangeElements(const RangeT &Range)
decltype(addHash(std::declval< HashBuilder & >(), std::declval< T & >())) HasAddHashT
HashBuilder & addRange(const RangeT &Range)
HashBuilder & addRangeElements(ForwardIteratorT First, ForwardIteratorT Last)
HashBuilder & add(const std::tuple< Ts... > &Arg)
std::enable_if_t< is_detected< HasAddHashT, T >::value &&!hashbuilder_detail::IsHashableData< T >::value, HashBuilder & > add(const T &Value)
Implement hashing for user-defined structs.
HashBuilder & add(ArrayRef< T > Value)
Support hashing ArrayRef.
std::enable_if_t< hashbuilder_detail::IsHashableData< T >::value, HashBuilder & > add(T Value)
Implement hashing for hashable data types, e.g. integral or enum values.
decltype(support::endian::byte_swap(std::declval< T & >(), llvm::endianness::little)) HasByteSwapT
HashBuilder & addRange(ForwardIteratorT First, ForwardIteratorT Last)
HashBuilder & add(const std::pair< T1, T2 > &Value)
HashBuilder(ArgTypes &&...Args)
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
An opaque object representing a hash code.
void update(ArrayRef< uint8_t > Data)
value_type byte_swap(value_type value, endianness endian)
This is an optimization pass for GlobalISel generic memory operations.
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...
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...
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Implement std::hash so that hash_code can be used in STL containers.
Trait to indicate whether a type's bits can be hashed directly (after endianness correction).