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

  1. Collapses nested seq:
seq {
    seq { A; B }
    C;
}

into

seq { A; B C; }
  1. Collapses nested par:
par {
    par { A; B }
    C;
}

into

par { A; B C; }
  1. Collapses nested static seq in the same way as 1
  2. Collapses nested static par in the same way as 2
  3. Collapses static repeat: Collapse
static repeat 0 { ** body ** }

into empty control and

static repeat 1 {** body **}

into

** body **

Trait Implementations

Returns the “default value” for a type. Read more
The name of a pass. Is used for identifying passes.
A short description of the pass.
Set of options that can be passed to the pass. The options contains a tuple of the option name and a description. Read more

Collapse seq { seq { A }; B } into seq { A; B }.

Collapse par { par { A }; B } into par { A; B }.

Collapse static par {static par {A; B;}} into static par {A; B; }

Collase static seq {static seq {A; B; }} into static seq {A; B;}

Collapse

static repeat 0 { ** body ** }

into empty control and

static repeat 1 {** body **}
into

** body **

Executed after visiting the children of a ir::Repeat node.
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
Transform the ir::Context before visiting the components.
Transform the ir::Context after visiting the components.
Define the iteration order in which components should be visited
Define the traversal over a component. Calls Visitor::start, visits each control node, and finally calls Visitor::finish. Read more
Run the visitor on a given program ir::Context. The function mutably borrows the control program in each component and traverses it. Read more
Build a Default implementation of this pass and call Visitor::do_pass using it. Read more
Executed before the traversal begins.
Executed after the traversal ends. This method is always invoked regardless of the Action returned from the children. Read more
Executed before visiting the children of a ir::Seq node.
Executed before visiting the children of a ir::Par node.
Executed before visiting the children of a ir::If node.
Executed after visiting the children of a ir::If node.
Executed before visiting the children of a ir::While node.
Executed after visiting the children of a ir::While node.
Executed before visiting the children of a ir::Repeat node.
Executed before visiting the contents of an ir::StaticControl node.
Executed after visiting the conetnts of an ir::StaticControl node.
Executed at an ir::Enable node.
Executed at an ir::StaticEnable node.
Executed before visiting the children of a ir::StaticIf node.
Executed after visiting the children of a ir::StaticIf node.
Executed before visiting the children of a ir::StaticRepeat node.
Executed at an ir::Invoke node.
Executed at a ir::StaticInvoke node.
Executed at an ir::Empty node.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.