mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-11 14:41:50 +00:00
sem: Split sem::Variable into global, local and parameter
Each of these may contain information specific to their kind. Change-Id: Ic8ac808088132b7bc2e43da6ce46a06571e0fed5 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59200 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
@@ -43,16 +43,16 @@ struct HashCombineOffset<8> {
|
||||
static constexpr inline uint64_t value() { return 0x9e3779b97f4a7c16; }
|
||||
};
|
||||
|
||||
// When hashing sparse structures we want to iteratively build a hash value with
|
||||
// only parts of the data. HashCombine "hashes" together an existing hash and
|
||||
// hashable values.
|
||||
} // namespace detail
|
||||
|
||||
/// HashCombine "hashes" together an existing hash and hashable values.
|
||||
template <typename T>
|
||||
void HashCombine(size_t* hash, const T& value) {
|
||||
constexpr size_t offset = HashCombineOffset<sizeof(size_t)>::value();
|
||||
constexpr size_t offset = detail::HashCombineOffset<sizeof(size_t)>::value();
|
||||
*hash ^= std::hash<T>()(value) + offset + (*hash << 6) + (*hash >> 2);
|
||||
}
|
||||
|
||||
// Helper for hashing vectors
|
||||
/// HashCombine "hashes" together an existing hash and hashable values.
|
||||
template <typename T>
|
||||
void HashCombine(size_t* hash, const std::vector<T>& vector) {
|
||||
HashCombine(hash, vector.size());
|
||||
@@ -61,20 +61,19 @@ void HashCombine(size_t* hash, const std::vector<T>& vector) {
|
||||
}
|
||||
}
|
||||
|
||||
/// HashCombine "hashes" together an existing hash and hashable values.
|
||||
template <typename T, typename... ARGS>
|
||||
void HashCombine(size_t* hash, const T& value, const ARGS&... args) {
|
||||
HashCombine(hash, value);
|
||||
HashCombine(hash, args...);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// @returns a hash of the combined arguments. The returned hash is dependent on
|
||||
/// the order of the arguments.
|
||||
template <typename... ARGS>
|
||||
size_t Hash(const ARGS&... args) {
|
||||
size_t hash = 102931; // seed with an arbitrary prime
|
||||
detail::HashCombine(&hash, args...);
|
||||
HashCombine(&hash, args...);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user