[tint][ir] Remove Usage::Hasher
Instead add a HashCode() method.
Change-Id: If6fe2f1855ca72dffe68620afdaacca8cba1e476
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/161009
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/lang/core/ir/disassembler.h b/src/tint/lang/core/ir/disassembler.h
index d26d98c..a22182d 100644
--- a/src/tint/lang/core/ir/disassembler.h
+++ b/src/tint/lang/core/ir/disassembler.h
@@ -176,8 +176,8 @@
Hashmap<Block*, Source, 8> block_to_src_;
Hashmap<Instruction*, Source, 8> instruction_to_src_;
- Hashmap<Usage, Source, 8, Usage::Hasher> operand_to_src_;
- Hashmap<Usage, Source, 8, Usage::Hasher> result_to_src_;
+ Hashmap<Usage, Source, 8> operand_to_src_;
+ Hashmap<Usage, Source, 8> result_to_src_;
Hashmap<If*, std::string, 8> if_names_;
Hashmap<Loop*, std::string, 8> loop_names_;
Hashmap<Switch*, std::string, 8> switch_names_;
diff --git a/src/tint/lang/core/ir/value.h b/src/tint/lang/core/ir/value.h
index f309206..b368ff0 100644
--- a/src/tint/lang/core/ir/value.h
+++ b/src/tint/lang/core/ir/value.h
@@ -47,14 +47,8 @@
/// The index of the operand that is the value being used.
size_t operand_index = 0u;
- /// A specialization of Hasher for Usage.
- struct Hasher {
- /// @param u the usage to hash
- /// @returns a hash of the usage
- inline std::size_t operator()(const Usage& u) const {
- return Hash(u.instruction, u.operand_index);
- }
- };
+ /// @returns the hash code of the Usage
+ size_t HashCode() const { return Hash(instruction, operand_index); }
/// An equality helper for Usage.
/// @param other the usage to compare against
@@ -94,7 +88,7 @@
/// @returns the set of usages of this value. An instruction may appear multiple times if it
/// uses the value for multiple different operands.
- const Hashset<Usage, 4, Usage::Hasher>& Usages() { return uses_; }
+ const Hashset<Usage, 4>& Usages() { return uses_; }
/// Apply a function to all uses of the value that exist prior to calling this method.
/// @param func the function will be applied to each use
@@ -119,7 +113,7 @@
kDead,
};
- Hashset<Usage, 4, Usage::Hasher> uses_;
+ Hashset<Usage, 4> uses_;
/// Bitset of value flags
tint::EnumSet<Flag> flags_;