Trait hugr::algorithms::nest_cfgs::CfgNodeMap

source ·
pub trait CfgNodeMap<T> {
    type Iterator<'c>: Iterator<Item = T>
       where Self: 'c;

    // Required methods
    fn entry_node(&self) -> T;
    fn exit_node(&self) -> T;
    fn successors(&self, node: T) -> Self::Iterator<'_>;
    fn predecessors(&self, node: T) -> Self::Iterator<'_>;
}
Expand description

A “view” of a CFG in a Hugr which allows basic blocks in the underlying CFG to be split into multiple blocks in the view (or merged together). T is the type of basic block; this can just be a BasicBlock (e.g. Node) in the Hugr, or an IdentityCfgMap if the extra level of indirection is not required. However, since SESE regions are bounded by edges between pairs of such T, such splitting may allow the algorithm to identify more regions than existed in the underlying CFG, without mutating the underlying CFG just for the analysis - the splitting (and/or merging) can then be performed by CfgNester::nest_sese_region only as necessary for regions actually nested.

Required Associated Types§

source

type Iterator<'c>: Iterator<Item = T> where Self: 'c

Allows the trait implementor to define a type of iterator it will return from successors and predecessors.

Required Methods§

source

fn entry_node(&self) -> T

The unique entry node of the CFG. It may any n>=0 of incoming edges; we assume control arrives here from “outside”.

source

fn exit_node(&self) -> T

The unique exit node of the CFG. The only node to have no successors.

source

fn successors(&self, node: T) -> Self::Iterator<'_>

Returns an iterator over the successors of the specified basic block.

source

fn predecessors(&self, node: T) -> Self::Iterator<'_>

Returns an iterator over the predecessors of the specified basic block.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<H> CfgNodeMap<Node> for IdentityCfgMap<H>
where H: HugrView,

source§

type Iterator<'c> = <H as HugrView>::Neighbours<'c> where IdentityCfgMap<H>: 'c