Skip to main content

Match

Struct Match 

Source
pub struct Match<Cfg: EGraphConfig> {
    pub nodes: Vec<Option<Cfg::G>>,
    pub mults: Vec<Cfg::M>,
    pub lit_vals: Vec<Cfg::V>,
    pub seq_pool: Vec<Cfg::G>,
    pub seq_spans: Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>,
    pub set_pool: Vec<Cfg::G>,
    pub set_spans: Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>,
    pub mset_pool: Vec<Cfg::C>,
    pub mset_spans: Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>,
}

Fields§

§nodes: Vec<Option<Cfg::G>>

E-node bindings indexed by VarId.

§mults: Vec<Cfg::M>

Multiplicity bindings indexed by MultVarId.

§lit_vals: Vec<Cfg::V>

Literal value bindings indexed by LitValVarId.

§seq_pool: Vec<Cfg::G>

Sequence rest pool — all seq slices packed contiguously.

§seq_spans: Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>

Span (start, len) into seq_pool, indexed by SeqVarId.

§set_pool: Vec<Cfg::G>

Set rest pool — all set slices packed contiguously.

§set_spans: Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>

Span (start, len) into set_pool, indexed by SetVarId.

§mset_pool: Vec<Cfg::C>

Multiset rest pool — packed AC children (id + mult).

§mset_spans: Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>

Span (start, len) into mset_pool, indexed by MsetVarId.

Implementations§

Source§

impl<Cfg: EGraphConfig> Match<Cfg>

Source

pub fn new(shape: &MatchShape) -> Self

Source

pub fn get(&self, v: VarId) -> Cfg::G

Source

pub fn set(&mut self, v: VarId, val: Cfg::G)

Source

pub fn clear(&mut self, v: VarId)

Source

pub fn get_opt(&self, v: VarId) -> Option<Cfg::G>

Read the raw binding (bound value or None). For save/restore of a slot that may already be bound (the bound-node re-join in leapfrog_join).

Source

pub fn set_opt(&mut self, v: VarId, val: Option<Cfg::G>)

Restore a raw binding saved by get_opt.

Source

pub fn resolve_pv<S: Copy>( &self, pv: PatVar, globals: &GlobalCtx<S, Cfg::G>, ) -> Cfg::G

Resolve a PatVar: local from env, global from GlobalCtx.

Source

pub fn get_mult(&self, v: MultVarId) -> Cfg::M

Source

pub fn set_mult(&mut self, v: MultVarId, val: Cfg::M)

Source

pub fn get_lit_val(&self, v: LitValVarId) -> Cfg::V

Source

pub fn set_lit_val(&mut self, v: LitValVarId, val: Cfg::V)

Source

pub fn seq_slice(&self, v: SeqVarId) -> &[Cfg::G]

Source

pub fn push_seq(&mut self, v: SeqVarId, data: &[Cfg::G])

Source

pub fn pop_seq(&mut self, v: SeqVarId)

Source

pub fn set_slice(&self, v: SetVarId) -> &[Cfg::G]

Source

pub fn push_set(&mut self, v: SetVarId, data: &[Cfg::G])

Source

pub fn pop_set(&mut self, v: SetVarId)

Source

pub fn mset_slice(&self, v: MsetVarId) -> &[Cfg::C]

Source

pub fn push_mset(&mut self, v: MsetVarId, data: &[Cfg::C])

Source

pub fn pop_mset(&mut self, v: MsetVarId)

Source

pub fn push_mset_residual( &mut self, v: MsetVarId, residual: &[(Cfg::G, Cfg::M)], )

Bind v to the still-available residual entries, writing them straight onto the pool tail (E15). push_mset with a caller-built slice re-bought a temporary per binding at every leaf of the AC assignment search - 221k bindings per allocprobe run, three growth allocations each; the pool was the destination all along.

Source

pub fn push_set_residual( &mut self, v: SetVarId, residual: &[Cfg::G], used: &BitSet, )

The ACI counterpart: bind v to the residual ids not consumed by the element assignment (same write-through mechanism).

Trait Implementations§

Source§

impl<Cfg: EGraphConfig> Clone for Match<Cfg>

Source§

fn clone_from(&mut self, source: &Self)

Overwrite in place, keeping every existing allocation.

Spelled out rather than left to the default *self = source.clone(), which drops nine buffers and allocates nine more. Vec::clone_from reuses the destination’s capacity when it suffices, so a recycled match costs nine memcpys and no allocator traffic. This is what makes MatchPool worth retaining across matches.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

impl<Cfg: Debug + EGraphConfig> Debug for Match<Cfg>
where Cfg::G: Debug, Cfg::M: Debug, Cfg::V: Debug, Cfg::C: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Cfg: EGraphConfig> MatchView<Cfg> for Match<Cfg>

Source§

fn get(&self, v: VarId) -> Cfg::G

Source§

fn get_mult(&self, v: MultVarId) -> Cfg::M

Source§

fn get_lit_val(&self, v: LitValVarId) -> Cfg::V

Source§

fn seq_slice(&self, v: SeqVarId) -> &[Cfg::G]

Source§

fn set_slice(&self, v: SetVarId) -> &[Cfg::G]

Source§

fn mset_slice(&self, v: MsetVarId) -> &[Cfg::C]

Auto Trait Implementations§

§

impl<Cfg> Freeze for Match<Cfg>
where Vec<Option<<Cfg as EGraphConfig>::G>>: Freeze, Vec<<Cfg as EGraphConfig>::M>: Freeze, Vec<<Cfg as EGraphConfig>::V>: Freeze, Vec<<Cfg as EGraphConfig>::G>: Freeze, Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>: Freeze, Vec<<Cfg as EGraphConfig>::C>: Freeze,

§

impl<Cfg> RefUnwindSafe for Match<Cfg>

§

impl<Cfg> Send for Match<Cfg>
where Vec<Option<<Cfg as EGraphConfig>::G>>: Send, Vec<<Cfg as EGraphConfig>::M>: Send, Vec<<Cfg as EGraphConfig>::V>: Send, Vec<<Cfg as EGraphConfig>::G>: Send, Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>: Send, Vec<<Cfg as EGraphConfig>::C>: Send,

§

impl<Cfg> Sync for Match<Cfg>
where Vec<Option<<Cfg as EGraphConfig>::G>>: Sync, Vec<<Cfg as EGraphConfig>::M>: Sync, Vec<<Cfg as EGraphConfig>::V>: Sync, Vec<<Cfg as EGraphConfig>::G>: Sync, Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>: Sync, Vec<<Cfg as EGraphConfig>::C>: Sync,

§

impl<Cfg> Unpin for Match<Cfg>
where Vec<Option<<Cfg as EGraphConfig>::G>>: Unpin, Vec<<Cfg as EGraphConfig>::M>: Unpin, Vec<<Cfg as EGraphConfig>::V>: Unpin, Vec<<Cfg as EGraphConfig>::G>: Unpin, Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>: Unpin, Vec<<Cfg as EGraphConfig>::C>: Unpin,

§

impl<Cfg> UnsafeUnpin for Match<Cfg>

§

impl<Cfg> UnwindSafe for Match<Cfg>
where Vec<Option<<Cfg as EGraphConfig>::G>>: UnwindSafe, Vec<<Cfg as EGraphConfig>::M>: UnwindSafe, Vec<<Cfg as EGraphConfig>::V>: UnwindSafe, Vec<<Cfg as EGraphConfig>::G>: UnwindSafe, Vec<(<Cfg as EGraphConfig>::Index, <Cfg as EGraphConfig>::Index)>: UnwindSafe, Vec<<Cfg as EGraphConfig>::C>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.