|
CIRCT 24.0.0git
|
Iterative Tarjan SCC analysis on a sparse subgraph of MLIR operations. More...
#include <SparseOpSCC.h>

Classes | |
| struct | ForwardFrame |
| struct | BackwardFrame |
Public Member Functions | |
| SparseOpSCC (OpSCCFilter shouldTraverseFn={}) | |
| void | reset () |
| Clear all accumulated state. | |
| void | visit (mlir::Operation *op) |
| Seed op into the DFS if it has not already been discovered. | |
| void | visit (llvm::ArrayRef< mlir::Operation * > ops) |
| Visit each operation in ops, skipping already-discovered ones. | |
| bool | hasDiscovered (mlir::Operation *op) const |
| Return true if op was discovered (as a seed or transitively) by any previous visit() call. | |
| OpSCC | getSCC (mlir::Operation *op) const |
| Return the SCC that op belongs to. | |
| unsigned | getNumDiscovered () const |
| Number of operations discovered so far across all visit() calls. | |
| unsigned | getNumSCCs () const |
| Total number of SCC entries emitted (trivial ops + cyclic groups). | |
| unsigned | getNumCyclicSCCs () const |
| Number of cyclic SCC groups (excludes trivial ops). | |
| auto | topological () const |
| Iterate over SCCs in topological order (sources/seeds first, leaves last). | |
| auto | topological_begin () const |
| auto | topological_end () const |
| auto | reverseTopological () const |
| Iterate over SCCs in reverse topological order (leaves first). | |
| auto | reverseTopological_begin () const |
| auto | reverseTopological_end () const |
Private Types | |
| using | FrameT |
Private Member Functions | |
| void | tarjanImpl (mlir::Operation *startOp) |
Private Attributes | |
| OpSCCFilter | shouldTraverseFn |
| Optional edge filter supplied at construction time. | |
| llvm::SmallDenseMap< mlir::Operation *, unsigned, NumInlineElts > | opToSccIndex |
| Maps each visited op to the index of its SCC in sccs. | |
| llvm::SmallVector< detail::OpOrIndex, NumInlineElts > | sccs |
| Flat list of SCC entries emitted by Tarjan, in emission order. | |
| llvm::SmallVector< detail::CyclicOpSCCStorage, 0 > | cyclicSccs |
| Backing storage for cyclic SCCs; CyclicOpSCC holds a pointer into here. | |
Iterative Tarjan SCC analysis on a sparse subgraph of MLIR operations.
Call visit() with one or more seed operations to trigger the DFS. Results accumulate across multiple visit() calls, so the discovered subgraph can be expanded incrementally.
The optional filter passed to the constructor is applied to every discovered edge before it is traversed. An edge that fails the filter is treated as if it did not exist in the graph.
Iterators obtained from topological() and reverseTopological() hold a reference into this object and are invalidated by calling visit() or
Definition at line 270 of file SparseOpSCC.h.
|
private |
Definition at line 425 of file SparseOpSCC.h.
|
inlineexplicit |
Definition at line 272 of file SparseOpSCC.h.
References shouldTraverseFn.
|
inline |
Number of cyclic SCC groups (excludes trivial ops).
Definition at line 318 of file SparseOpSCC.h.
References cyclicSccs.
|
inline |
Number of operations discovered so far across all visit() calls.
Definition at line 314 of file SparseOpSCC.h.
References opToSccIndex.
|
inline |
Total number of SCC entries emitted (trivial ops + cyclic groups).
Definition at line 316 of file SparseOpSCC.h.
References sccs.
|
inline |
Return the SCC that op belongs to.
If the operation has not been discovered, it returns a nullptr sentinel.
Definition at line 302 of file SparseOpSCC.h.
References cyclicSccs, opToSccIndex, and sccs.
|
inline |
Return true if op was discovered (as a seed or transitively) by any previous visit() call.
Definition at line 296 of file SparseOpSCC.h.
References opToSccIndex.
|
inline |
Clear all accumulated state.
Definition at line 276 of file SparseOpSCC.h.
References cyclicSccs, opToSccIndex, and sccs.
|
inline |
Iterate over SCCs in reverse topological order (leaves first).
Definition at line 348 of file SparseOpSCC.h.
References reverseTopological_begin(), and reverseTopological_end().
|
inline |
Definition at line 354 of file SparseOpSCC.h.
References cyclicSccs, circt::Forward, and sccs.
Referenced by reverseTopological().
|
inline |
Definition at line 365 of file SparseOpSCC.h.
References cyclicSccs, circt::Forward, and sccs.
Referenced by reverseTopological().
|
inlineprivate |
Definition at line 428 of file SparseOpSCC.h.
References assert(), cyclicSccs, opToSccIndex, sccs, and shouldTraverseFn.
Referenced by visit().
|
inline |
Iterate over SCCs in topological order (sources/seeds first, leaves last).
Definition at line 321 of file SparseOpSCC.h.
References topological_begin(), and topological_end().
|
inline |
Definition at line 326 of file SparseOpSCC.h.
References circt::Backward, cyclicSccs, and sccs.
Referenced by topological().
|
inline |
Definition at line 337 of file SparseOpSCC.h.
References circt::Backward, cyclicSccs, and sccs.
Referenced by topological().
|
inline |
Visit each operation in ops, skipping already-discovered ones.
Definition at line 289 of file SparseOpSCC.h.
References visit().
|
inline |
Seed op into the DFS if it has not already been discovered.
Definition at line 283 of file SparseOpSCC.h.
References opToSccIndex, and tarjanImpl().
Referenced by visit().
|
private |
Backing storage for cyclic SCCs; CyclicOpSCC holds a pointer into here.
Definition at line 519 of file SparseOpSCC.h.
Referenced by getNumCyclicSCCs(), getSCC(), reset(), reverseTopological_begin(), reverseTopological_end(), tarjanImpl(), topological_begin(), and topological_end().
|
private |
Maps each visited op to the index of its SCC in sccs.
Persists across visit() calls and is the authoritative "already visited" guard.
Definition at line 513 of file SparseOpSCC.h.
Referenced by getNumDiscovered(), getSCC(), hasDiscovered(), reset(), tarjanImpl(), and visit().
|
private |
Flat list of SCC entries emitted by Tarjan, in emission order.
Trivial SCCs are stored directly. Cyclic SCCs are stored as index into the cyclicSccs vector.
Definition at line 517 of file SparseOpSCC.h.
Referenced by getNumSCCs(), getSCC(), reset(), reverseTopological_begin(), reverseTopological_end(), tarjanImpl(), topological_begin(), and topological_end().
|
private |
Optional edge filter supplied at construction time.
Definition at line 509 of file SparseOpSCC.h.
Referenced by circt::SparseOpSCC< Direction, NumInlineElts >::BackwardFrame::nextChild(), circt::SparseOpSCC< Direction, NumInlineElts >::ForwardFrame::nextChild(), SparseOpSCC(), and tarjanImpl().