calyx_opt::traversal

Trait Visitor

Source
pub trait Visitor {
Show 34 methods // Provided methods fn precondition(_ctx: &Context) -> Option<String> where Self: Sized { ... } fn start_context(&mut self, _ctx: &mut Context) -> VisResult { ... } fn finish_context(&mut self, _ctx: &mut Context) -> VisResult { ... } fn iteration_order() -> Order 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 + Named { ... } fn do_pass_default(context: &mut Context) -> CalyxResult<Self> where Self: ConstructVisitor + Sized + Named { ... } 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 start_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 { ... } fn start_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 { ... } fn enable( &mut self, _s: &mut Enable, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult { ... } fn static_enable( &mut self, _s: &mut StaticEnable, _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 { ... } fn finish_static_if( &mut self, _s: &mut StaticIf, _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 { ... } fn finish_static_repeat( &mut self, _s: &mut StaticRepeat, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult { ... } 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 { ... } fn invoke( &mut self, _s: &mut Invoke, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult { ... } fn static_invoke( &mut self, _s: &mut StaticInvoke, _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§

Source

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

Transform the ir::Context before visiting the components.

Source

fn finish_context(&mut self, _ctx: &mut Context) -> VisResult

Transform the ir::Context after visiting the components.

Source

fn iteration_order() -> Order
where 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,

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<()>
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.

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.

Source

fn do_pass_default(context: &mut Context) -> CalyxResult<Self>
where Self: ConstructVisitor + Sized + Named,

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

Source

fn start( &mut self, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult

Executed before the traversal begins.

Source

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

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

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

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

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

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

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

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

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

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

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

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

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

Executed at an ir::Enable node.

Source

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

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

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

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

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

Source

fn start_static_seq( &mut self, _s: &mut StaticSeq, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult

Source

fn finish_static_seq( &mut self, _s: &mut StaticSeq, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult

Source

fn start_static_par( &mut self, _s: &mut StaticPar, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult

Source

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

Executed at an ir::Invoke node.

Source

fn static_invoke( &mut self, _s: &mut StaticInvoke, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult

Executed at a ir::StaticInvoke node.

Source

fn empty( &mut self, _s: &mut Empty, _comp: &mut Component, _sigs: &LibrarySignatures, _comps: &[Component], ) -> VisResult

Executed at an ir::Empty node.

Implementors§

Source§

impl Visitor for AddGuard

Source§

impl Visitor for Canonicalize

Source§

impl Visitor for CellShare

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. If the parent par is not static, then add a conflict. If the parent par is static, then we can use the static_par_timing analysis to check whether the cells’ liveness actually overlaps.
  • 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.
Source§

impl Visitor for ClkInsertion

Source§

impl Visitor for CollapseControl

Source§

impl Visitor for CombProp

Source§

impl Visitor for CompileInvoke

Source§

impl Visitor for CompileRepeat

Source§

impl Visitor for CompileStatic

Source§

impl Visitor for ComponentInliner

Source§

impl Visitor for ConstantPortProp

Source§

impl Visitor for DataPathInfer

Source§

impl Visitor for DeadAssignmentRemoval

Source§

impl Visitor for DeadCellRemoval

Source§

impl Visitor for DeadGroupRemoval

Source§

impl Visitor for DefaultAssigns

Source§

impl Visitor for Externalize

Source§

impl Visitor for GoInsertion

Source§

impl Visitor for GroupToInvoke

Source§

impl Visitor for GroupToSeq

Source§

impl Visitor for InferShare

Source§

impl Visitor for LowerGuards

Source§

impl Visitor for MergeAssign

Source§

impl Visitor for Papercut

Source§

impl Visitor for ProfilerInstrumentation

Source§

impl Visitor for RemoveIds

Source§

impl Visitor for ResetInsertion

Source§

impl Visitor for SimplifyStaticGuards

Source§

impl Visitor for SimplifyWithControl

Source§

impl Visitor for StaticFSMOpts

Source§

impl Visitor for StaticInference

Source§

impl Visitor for StaticInliner

Source§

impl Visitor for StaticPromotion

Source§

impl Visitor for SynthesisPapercut

Source§

impl Visitor for TopDownCompileControl

Source§

impl Visitor for UnrollBounded

Source§

impl Visitor for WellFormed

Source§

impl Visitor for WireInliner

Source§

impl Visitor for WrapMain

Source§

impl Visitor for CompileSync

Source§

impl Visitor for CompileSyncWithoutSyncReg

Source§

impl Visitor for DiscoverExternal

Source§

impl Visitor for ExternalToRef

Source§

impl Visitor for HoleInliner

Source§

impl Visitor for Metadata

Source§

impl Visitor for ParToSeq

Source§

impl Visitor for RegisterUnsharing