Struct calyx_opt::analysis::GraphAnalysis
source · [−]pub struct GraphAnalysis { /* private fields */ }
Expand description
Constructs a graph based representation of a component. Each node represents
a ir::Port
and each directed edge (X -> Y
) means
that X
’s value written to Y
.
Example
c.in = G[done] & b.done ? add.out
creates the edges:
add.out -> c.in
G[done] -> c.in
b.done -> c.in
This representation is useful for asking graph based queries such as all the reads from a port or all the write to a port.
Implementations
sourceimpl GraphAnalysis
impl GraphAnalysis
sourcepub fn reads_from(&self, port: &Port) -> PortIterator<'_>
pub fn reads_from(&self, port: &Port) -> PortIterator<'_>
Returns an iterator over all the reads from a port. Returns an empty iterator if this is an Input port.
sourcepub fn writes_to(&self, port: &Port) -> PortIterator<'_>
pub fn writes_to(&self, port: &Port) -> PortIterator<'_>
Returns an iterator over all the writes to this port. Returns an empty iterator if this is an Output port.
sourcepub fn add_edges(self, edges: &[(RRC<Port>, RRC<Port>)]) -> Self
pub fn add_edges(self, edges: &[(RRC<Port>, RRC<Port>)]) -> Self
Add each edge in edges
to the graph.
sourcepub fn toposort(&self) -> PortIterator<'_>
pub fn toposort(&self) -> PortIterator<'_>
Return a topological sort of this graph.
sourcepub fn paths(&self, start: &Port, finish: &Port) -> Vec<Vec<RRC<Port>>>
pub fn paths(&self, start: &Port, finish: &Port) -> Vec<Vec<RRC<Port>>>
Return a Vec of paths from start
to finish
, each path a Vec of ports.
sourcepub fn edge_induced_subgraph<F>(self, filter: F) -> Selfwhere
F: FnMut(&Port, &Port) -> bool,
pub fn edge_induced_subgraph<F>(self, filter: F) -> Selfwhere
F: FnMut(&Port, &Port) -> bool,
Restricts the analysis graph to only include edges
that are specified by the filter
.
filter
is passed references to the src
and dst
of each
edge. When filter(src, dst)
is true
, then the edge between
src
and dst
is kept. Otherwise, it is removed.
sourcepub fn remove_isolated_vertices(self) -> Self
pub fn remove_isolated_vertices(self) -> Self
Remove all vertices that have no undirected neighbors from the analysis graph.
sourcepub fn has_cycles(&self) -> bool
pub fn has_cycles(&self) -> bool
Checks if there are cycles in the analysis graph.
Trait Implementations
sourceimpl Clone for GraphAnalysis
impl Clone for GraphAnalysis
sourcefn clone(&self) -> GraphAnalysis
fn clone(&self) -> GraphAnalysis
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more