pub struct EGraph { /* private fields */ }Expand description
An equivalence graph for layout expressions.
Stores expressions and their equivalence classes. Supports adding expressions, merging equivalence classes, and applying rewrite rules to discover equivalent layouts.
Implementations§
Source§impl EGraph
impl EGraph
Sourcepub fn add(&mut self, expr: Expr) -> Id
pub fn add(&mut self, expr: Expr) -> Id
Add an expression to the e-graph, returning its equivalence class id.
If the expression already exists (structurally identical after canonicalization), returns the existing id.
Sourcepub fn merge(&mut self, a: Id, b: Id) -> Id
pub fn merge(&mut self, a: Id, b: Id) -> Id
Merge two equivalence classes, returning the new canonical id.
Sourcepub fn class_count(&self) -> usize
pub fn class_count(&self) -> usize
Number of equivalence classes.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total number of expression nodes.
Sourcepub fn last_apply_count(&self) -> usize
pub fn last_apply_count(&self) -> usize
Number of rule applications in the last apply_rules call.
Sourcepub fn apply_rules(&mut self) -> usize
pub fn apply_rules(&mut self) -> usize
Apply rewrite rules until saturation (no new equalities discovered) or the iteration budget is exhausted.
Returns the total number of rule applications.
Sourcepub fn apply_rules_with_budget(&mut self, max_iterations: usize) -> usize
pub fn apply_rules_with_budget(&mut self, max_iterations: usize) -> usize
Apply rewrite rules with an explicit iteration budget.
Source§impl EGraph
impl EGraph
Sourcepub fn saturate(&mut self, config: &SaturationConfig) -> SaturationResult
pub fn saturate(&mut self, config: &SaturationConfig) -> SaturationResult
Run equality saturation with explicit resource bounds.
Returns a SaturationResult indicating completion status. If the
node budget, time limit, or memory limit is hit, the current state
is preserved and the caller can still extract results.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Estimated memory usage in bytes.