Struct calyx_opt::passes::CollapseControl
source · [−]pub struct CollapseControl {}
Expand description
Collapses and de-nests control constructs.
Running this pass removes unnecessary FSM transitions and compilation groups during the lowering phase. If a seq is marked with @new_fsm, then we don’t collapse it, since we need that fsm transition to transition from our old fsm to our new one.
Example
- Collapses nested
seq
:
seq {
seq { A; B }
C;
}
into
seq { A; B C; }
- Collapses nested
par
:
par {
par { A; B }
C;
}
into
par { A; B C; }
- Collapses nested
static seq
in the same way as 1 - Collapses nested
static par
in the same way as 2 - Collapses
static repeat
: Collapse
static repeat 0 { ** body ** }
into empty control and
static repeat 1 {** body **}
into
** body **
Trait Implementations
sourceimpl Default for CollapseControl
impl Default for CollapseControl
sourcefn default() -> CollapseControl
fn default() -> CollapseControl
Returns the “default value” for a type. Read more
sourceimpl Named for CollapseControl
impl Named for CollapseControl
sourcefn description() -> &'static str
fn description() -> &'static str
A short description of the pass.
sourceimpl Visitor for CollapseControl
impl Visitor for CollapseControl
sourcefn finish_seq(
&mut self,
s: &mut Seq,
_comp: &mut Component,
_c: &LibrarySignatures,
_comps: &[Component]
) -> VisResult
fn finish_seq(
&mut self,
s: &mut Seq,
_comp: &mut Component,
_c: &LibrarySignatures,
_comps: &[Component]
) -> VisResult
Collapse seq { seq { A }; B } into seq { A; B }.
sourcefn finish_par(
&mut self,
s: &mut Par,
_comp: &mut Component,
_c: &LibrarySignatures,
_comps: &[Component]
) -> VisResult
fn finish_par(
&mut self,
s: &mut Par,
_comp: &mut Component,
_c: &LibrarySignatures,
_comps: &[Component]
) -> VisResult
Collapse par { par { A }; B } into par { A; B }.
sourcefn finish_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
Collapse static par {static par {A; B;}} into static par {A; B; }
sourcefn finish_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
Collase static seq {static seq {A; B; }} into static seq {A; B;}
sourcefn 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
Collapse
static repeat 0 { ** body ** }
into empty control and
static repeat 1 {** body **}
into
** body **
sourcefn 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.
sourcefn 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. Read more
sourcefn 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.sourcefn 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.sourcefn iteration_order() -> Orderwhere
Self: Sized,
fn iteration_order() -> Orderwhere
Self: Sized,
Define the iteration order in which components should be visited
sourcefn 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. Read more
sourcefn do_pass(&mut self, context: &mut Context) -> CalyxResult<()>where
Self: Sized + ConstructVisitor + Named,
fn do_pass(&mut self, context: &mut Context) -> CalyxResult<()>where
Self: Sized + ConstructVisitor + Named,
Run the visitor on a given program
ir::Context
.
The function mutably borrows the control
program in each component and
traverses it. Read moresourcefn do_pass_default(context: &mut Context) -> CalyxResult<Self>where
Self: ConstructVisitor + Sized + Named,
fn do_pass_default(context: &mut Context) -> CalyxResult<Self>where
Self: ConstructVisitor + Sized + Named,
sourcefn 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.
sourcefn finish(
&mut self,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component]
) -> VisResult
fn finish(
&mut self,
_comp: &mut Component,
_sigs: &LibrarySignatures,
_comps: &[Component]
) -> VisResult
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
fn start_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
sourcefn 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.
sourcefn 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 RefUnwindSafe for CollapseControl
impl Send for CollapseControl
impl Sync for CollapseControl
impl Unpin for CollapseControl
impl UnwindSafe for CollapseControl
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more