27 size_t h1 = node->getSort()->hash_without_name();
28 size_t h2 =
static_cast<size_t>(node->getKind());
29 size_t h3 = node->getChildren().size();
30 size_t h4 = node->isConst() ? std::hash<std::string>{}(node->toString()) : 0;
41 constexpr size_t m = 0xe9846af9b1a615d;
51 seed =
hash_mix(seed + 0x9e3779b9 + value);
55void hash_children(
size_t &seed,
const std::vector<size_t> &children,
const std::vector<size_t> &hash_table) {
56 for (
const auto &child_index : children)
62 const size_t s2(seed);
63 for (
const auto &child : children) {
71void hash_parents(
size_t &seed,
const std::vector<std::pair<size_t, size_t>> &parents,
const std::vector<size_t> &hash_table) {
72 const size_t s2(seed);
73 for (
const auto &[parent_index, oper_index] : parents) {
size_t hash_node(const node::Node &node)
Compute a stable structural hash seed for a parser/node DAG node.
void hash_combine(size_t &seed, const size_t &value)
Mix one value into a hash seed.
void hash_children(size_t &seed, const std::vector< size_t > &children, const std::vector< size_t > &hash_table)
Mix child-node hashes into a parent seed in argument order.
size_t hash_mix(size_t x)
void hash_parents(size_t &seed, const std::vector< std::pair< size_t, size_t > > &parents, const std::vector< size_t > &hash_table)
Propagate a node hash contribution to parent nodes.
void hash_communative_children(size_t &seed, const std::vector< size_t > &children, const std::vector< size_t > &hash_table)
Mix child-node hashes as a commutative multiset.