pub struct CombProp { /* private fields */ }
Expand description
Propagate unconditional reads and writes from wires.
If the source is a wire, we have something like:
c.in = wire.out;
Which means all instances of wire.in
can be replaced with c.in
because the wire
is being used to unconditionally forward values.
If the destination is a wire, then we have something like:
wire.in = c.out;
Which means all instances of wire.out
can be replaced with c.out
because the
wire is being used to forward values from c.out
.
For example, we can safely inline the value c
wherever w.out
is read.
w.in = c;
group g {
r.in = w.out
}
Gets rewritten to:
w.in = c;
group g {
r.in = c;
}
Correctly propagates writes through mutliple wires:
w1.in = c;
w2.in = w1.out;
r.in = w2.out;
into:
w1.in = c;
w2.in = c;
r.in = c;
Trait Implementations§
Source§impl ConstructVisitor for CombProp
impl ConstructVisitor for CombProp
Source§fn from(ctx: &Context) -> CalyxResult<Self>where
Self: Sized,
fn from(ctx: &Context) -> CalyxResult<Self>where
Self: Sized,
Construct the visitor using information from the Context
Source§fn clear_data(&mut self)
fn clear_data(&mut self)
Clear the data stored in the visitor. Called before traversing the
next component by [ir::traversal::Visitor].
fn get_opts(ctx: &Context) -> LinkedHashMap<&'static str, ParseVal>where
Self: Named,
Source§impl Visitor for CombProp
impl Visitor for CombProp
Source§fn start(
&mut self,
comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start( &mut self, comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before the traversal begins.
Source§fn precondition(_ctx: &Context) -> Option<String>where
Self: Sized,
fn precondition(_ctx: &Context) -> Option<String>where
Self: Sized,
Precondition for this pass to run on the program. If this function returns
None, the pass triggers. Otherwise it aborts and logs the string as the reason.
Source§fn start_context(&mut self, _ctx: &mut Context) -> VisResult
fn start_context(&mut self, _ctx: &mut Context) -> VisResult
Transform the
ir::Context
before visiting the components.Source§fn finish_context(&mut self, _ctx: &mut Context) -> VisResult
fn finish_context(&mut self, _ctx: &mut Context) -> VisResult
Transform the
ir::Context
after visiting the components.Source§fn iteration_order() -> Orderwhere
Self: Sized,
fn iteration_order() -> Orderwhere
Self: Sized,
Define the iteration order in which components should be visited
Source§fn traverse_component(
&mut self,
comp: &mut Component,
signatures: &LibrarySignatures,
components: &[Component],
) -> CalyxResult<()>where
Self: Sized,
fn traverse_component(
&mut self,
comp: &mut Component,
signatures: &LibrarySignatures,
components: &[Component],
) -> CalyxResult<()>where
Self: Sized,
Define the traversal over a component.
Calls Visitor::start, visits each control node, and finally calls
Visitor::finish.
Source§fn do_pass(&mut self, context: &mut Context) -> CalyxResult<()>
fn do_pass(&mut self, context: &mut Context) -> CalyxResult<()>
Run the visitor on a given program
ir::Context
.
The function mutably borrows the control
program in each component and
traverses it. Read moreSource§fn do_pass_default(context: &mut Context) -> CalyxResult<Self>
fn do_pass_default(context: &mut Context) -> CalyxResult<Self>
Build a Default implementation of this pass and call Visitor::do_pass
using it.
Source§fn finish(
&mut self,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish( &mut self, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after the traversal ends.
This method is always invoked regardless of the Action returned from
the children.
Source§fn start_seq(
&mut self,
_s: &mut Seq,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_seq( &mut self, _s: &mut Seq, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::Seq node.
Source§fn finish_seq(
&mut self,
_s: &mut Seq,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_seq( &mut self, _s: &mut Seq, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::Seq node.
Source§fn start_par(
&mut self,
_s: &mut Par,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_par( &mut self, _s: &mut Par, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::Par node.
Source§fn finish_par(
&mut self,
_s: &mut Par,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_par( &mut self, _s: &mut Par, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::Par node.
Source§fn start_if(
&mut self,
_s: &mut If,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_if( &mut self, _s: &mut If, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::If node.
Source§fn finish_if(
&mut self,
_s: &mut If,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_if( &mut self, _s: &mut If, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::If node.
Source§fn start_while(
&mut self,
_s: &mut While,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_while( &mut self, _s: &mut While, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::While node.
Source§fn finish_while(
&mut self,
_s: &mut While,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_while( &mut self, _s: &mut While, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::While node.
Source§fn start_repeat(
&mut self,
_s: &mut Repeat,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_repeat( &mut self, _s: &mut Repeat, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::Repeat node.
Source§fn finish_repeat(
&mut self,
_s: &mut Repeat,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_repeat( &mut self, _s: &mut Repeat, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::Repeat node.
Source§fn start_static_control(
&mut self,
_s: &mut StaticControl,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_static_control( &mut self, _s: &mut StaticControl, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the contents of an ir::StaticControl node.
Source§fn finish_static_control(
&mut self,
_s: &mut StaticControl,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_static_control( &mut self, _s: &mut StaticControl, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the conetnts of an ir::StaticControl node.
Source§fn enable(
&mut self,
_s: &mut Enable,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn enable( &mut self, _s: &mut Enable, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed at an ir::Enable node.
Source§fn static_enable(
&mut self,
_s: &mut StaticEnable,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn static_enable( &mut self, _s: &mut StaticEnable, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed at an ir::StaticEnable node.
Source§fn start_static_if(
&mut self,
_s: &mut StaticIf,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_static_if( &mut self, _s: &mut StaticIf, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::StaticIf node.
Source§fn finish_static_if(
&mut self,
_s: &mut StaticIf,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_static_if( &mut self, _s: &mut StaticIf, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::StaticIf node.
Source§fn start_static_repeat(
&mut self,
_s: &mut StaticRepeat,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn start_static_repeat( &mut self, _s: &mut StaticRepeat, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed before visiting the children of a ir::StaticRepeat node.
Source§fn finish_static_repeat(
&mut self,
_s: &mut StaticRepeat,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn finish_static_repeat( &mut self, _s: &mut StaticRepeat, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed after visiting the children of a ir::StaticRepeat node.
fn start_static_seq( &mut self, _s: &mut StaticSeq, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
fn finish_static_seq( &mut self, _s: &mut StaticSeq, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
fn start_static_par( &mut self, _s: &mut StaticPar, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
fn finish_static_par( &mut self, _s: &mut StaticPar, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Source§fn invoke(
&mut self,
_s: &mut Invoke,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn invoke( &mut self, _s: &mut Invoke, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed at an ir::Invoke node.
Source§fn static_invoke(
&mut self,
_s: &mut StaticInvoke,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component],
) -> VisResult
fn static_invoke( &mut self, _s: &mut StaticInvoke, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult
Executed at a ir::StaticInvoke node.
Auto Trait Implementations§
impl Freeze for CombProp
impl RefUnwindSafe for CombProp
impl Send for CombProp
impl Sync for CombProp
impl Unpin for CombProp
impl UnwindSafe for CombProp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more