Struct transform::cse::relation_cse::Bindings [−][src]
pub struct Bindings {
bindings: HashMap<MirRelationExpr, u64>,
rebindings: HashMap<LocalId, LocalId>,
recursion_guard: RecursionGuard,
}
Expand description
Maintains Let
bindings in a compact, explicit representation.
The bindings
map contains neither Let
bindings nor two structurally
equivalent expressions.
The bindings can be interpreted as an ordered sequence of let bindings, ordered by their identifier, that should be applied in order before the use of the expression from which they have been extracted.
Fields
bindings: HashMap<MirRelationExpr, u64>
A list of let-bound expressions and their order / identifier.
rebindings: HashMap<LocalId, LocalId>
Mapping from conventional local Get
identifiers to new ones.
recursion_guard: RecursionGuard
Implementations
Replace relation
with an equivalent Get
expression referencing a location in bindings
.
The algorithm performs a post-order traversal of the expression tree, binding each distinct
expression to a new local identifier. It maintains the invariant that bindings
contains no
Let
expressions, nor any two structurally equivalent expressions.
Once each sub-expression is replaced by a canonical Get
expression, each expression is also
in a canonical representation, which is used to check for prior instances and drives re-use.
Populates expression
with necessary Let
bindings.
This population may result in substantially more Let
bindings that one
might expect. It is very appropriate to run the InlineLet
transformation
afterwards to remove Let
bindings that it deems unhelpful.
Trait Implementations
Extracts a reference to the recursion guard embedded within the type.
fn checked_recur<F, T, E>(&self, f: F) -> Result<T, E> where
F: FnOnce(&Self) -> Result<T, E>,
E: From<RecursionLimitError>,
fn checked_recur<F, T, E>(&self, f: F) -> Result<T, E> where
F: FnOnce(&Self) -> Result<T, E>,
E: From<RecursionLimitError>,
Checks whether it is safe to recur and calls f
if so. Read more
fn checked_recur_mut<F, T, E>(&mut self, f: F) -> Result<T, E> where
F: FnOnce(&mut Self) -> Result<T, E>,
E: From<RecursionLimitError>,
fn checked_recur_mut<F, T, E>(&mut self, f: F) -> Result<T, E> where
F: FnOnce(&mut Self) -> Result<T, E>,
E: From<RecursionLimitError>,
Like CheckedRecursion::checked_recur
, but operates on a mutable
reference to Self
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Bindings
impl UnwindSafe for Bindings
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more