Template Function sequant::eval::build_value_node_map

Function Documentation

template<meta::eval_node_range R>
ValueNodeMap<std::ranges::range_value_t<R>> sequant::eval::build_value_node_map(R const &forest)

The value_id -> forest-node bridge (design integration point 1).

A schedule addresses a value by its ValueCell::value_id (e.g. BuildStep::value_id); the value’s eval node is recovered through the ValueCell::hash that cell carries &#8212; exactly the EvalExpr::hash_value() identity CacheManager dedups by. This maps every distinct forest node by that hash, so a value_id resolves as map[rich.cells[value_id].hash]. Under perfect CSE many occurrences share one hash; a single representative node (the first visited) is kept, which is all a homed value needs (every occurrence is the same value). Pure lookup construction &#8212; no execution.

Note

Lives in its own header so that ordered_executor.hpp &#8212; which needs this bridge to resolve a BuildStep::value_id to a forest node &#8212; can use it without depending on an executor header.

Returns:

A ValueNodeMap pointing into forest &#8212; see its warning; the result must not outlive forest.