Struct cranelift_egraph::EGraph
source · pub struct EGraph<L: Language, A: Analysis<L = L>> {
pub nodes: Vec<L::Node>,
pub classes: PrimaryMap<Id, EClass>,
pub unionfind: UnionFind,
pub analysis: Option<(A, SecondaryMap<Id, A::Value>)>,
/* private fields */
}
Expand description
An egraph.
Fields§
§nodes: Vec<L::Node>
Node-allocation arena.
classes: PrimaryMap<Id, EClass>
Eclass definitions. Each eclass consists of an enode, and child pointer to the rest of the eclass.
unionfind: UnionFind
Union-find for canonical ID generation. This lets us name an eclass with a canonical ID that is the same for all generations of the class.
analysis: Option<(A, SecondaryMap<Id, A::Value>)>
Analysis and per-node state.
Implementations§
source§impl<L: Language, A: Analysis<L = L>> EGraph<L, A>where
L::Node: 'static,
impl<L: Language, A: Analysis<L = L>> EGraph<L, A>where L::Node: 'static,
sourcepub fn with_capacity(nodes: usize, analysis: Option<A>) -> Self
pub fn with_capacity(nodes: usize, analysis: Option<A>) -> Self
Create a new aegraph with the given capacity.
sourcepub fn union(&mut self, ctx: &L, a: Id, b: Id) -> Id
pub fn union(&mut self, ctx: &L, a: Id, b: Id) -> Id
Merge one eclass into another, maintaining the acyclic property (args must have lower eclass Ids than the eclass containing the node with those args). Returns the Id of the merged eclass.
sourcepub fn canonical_id_mut(&mut self, eclass: Id) -> Id
pub fn canonical_id_mut(&mut self, eclass: Id) -> Id
Get the canonical ID for an eclass. This may be an older generation, so will not be able to see all enodes in the eclass; but it will allow us to unambiguously refer to an eclass, even across merging.
sourcepub fn canonical_id(&self, eclass: Id) -> Id
pub fn canonical_id(&self, eclass: Id) -> Id
Get the canonical ID for an eclass. This may be an older generation, so will not be able to see all enodes in the eclass; but it will allow us to unambiguously refer to an eclass, even across merging.
sourcepub fn analysis_value(&self, eclass: Id) -> &A::Value
pub fn analysis_value(&self, eclass: Id) -> &A::Value
Get the analysis value for a given eclass. Panics if no analysis is present.