pub trait Visitor {
Show 17 methods fn require_postorder() -> bool
    where
        Self: Sized
, { ... }
fn traverse_component(
        &mut self,
        comp: &mut Component,
        signatures: &LibrarySignatures,
        components: &[Component]
    ) -> CalyxResult<()>
    where
        Self: Sized
, { ... }
fn do_pass(&mut self, context: &mut Context) -> CalyxResult<()>
    where
        Self: Sized + ConstructVisitor
, { ... }
fn do_pass_default(context: &mut Context) -> CalyxResult<Self>
    where
        Self: ConstructVisitor + Sized
, { ... }
fn start(
        &mut self,
        _comp: &mut Component,
        _sigs: &LibrarySignatures,
        _comps: &[Component]
    ) -> VisResult { ... }
fn finish(
        &mut self,
        _comp: &mut Component,
        _sigs: &LibrarySignatures,
        _comps: &[Component]
    ) -> VisResult { ... }
fn start_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 { ... }
fn start_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 { ... }
fn start_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 { ... }
fn start_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 { ... }
fn enable(
        &mut self,
        _s: &mut Enable,
        _comp: &mut Component,
        _sigs: &LibrarySignatures,
        _comps: &[Component]
    ) -> VisResult { ... }
fn invoke(
        &mut self,
        _s: &mut Invoke,
        _comp: &mut Component,
        _sigs: &LibrarySignatures,
        _comps: &[Component]
    ) -> VisResult { ... }
fn empty(
        &mut self,
        _s: &mut Empty,
        _comp: &mut Component,
        _sigs: &LibrarySignatures,
        _comps: &[Component]
    ) -> VisResult { ... }
}
Expand description

The visiting interface for a ir::Control program. Contains two kinds of functions:

  1. start_: Called when visiting top-down.
  2. finish_: Called when visiting bottow-up.

A pass will usually override one or more function and rely on the default visitors to automatically visit the children.

Provided methods

Returns true if this pass requires a post-order traversal of the components. In a post-order traversal, if component B uses a component A, then A is guaranteed to be traversed before B.

Define the traversal over a component. Calls Visitor::start, visits each control node, and finally calls Visitor::finish.

Run the visitor on a given program ir::Context. The function mutably borrows the control program in each component and traverses it.

After visiting a component, it called ConstructVisitor::clear_data to reset the struct.

Panics

Panics if the pass attempts to use the control program mutably.

Build a Default implementation of this pass and call Visitor::do_pass using it.

Executed before the traversal begins.

Executed after the traversal ends. This method is always invoked regardless of the Action returned from the children.

Executed before visiting the children of a ir::Seq node.

Executed after visiting the children of a ir::Seq node.

Executed before visiting the children of a ir::Par node.

Executed after 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 at an ir::Enable node.

Executed at an ir::Invoke node.

Executed at an ir::Empty node.

Implementors

The algorithm that runs is:

  • instantiate conflict graph using all component cells that satisfy cell_filter
  • use [ScheduleConflicts] to find groups/invokes that run in parallel with each other
  • for each tuple combination of cells that return true on cell_filter(), c1 and c2
  • first determine if their live ranges overlap. If so, then insert a conflict between c1 and c2
  • if c1 and c2 don’t have overlapping live ranges, check if c1 and c2 are ever live at within the same par block, and they are live at different children of the par block, then add a conflict.
  • perform graph coloring using self.ordering to define the order of the greedy coloring
  • use coloring to rewrite group assignments, continuous assignments, and conditional ports.