CIRCT  19.0.0git
Public Member Functions | Private Attributes | List of all members
circt::firrtl::InstanceGraph Class Reference

This graph tracks modules and where they are instantiated. More...

#include <FIRRTLInstanceGraph.h>

Inheritance diagram for circt::firrtl::InstanceGraph:
Inheritance graph
[legend]
Collaboration diagram for circt::firrtl::InstanceGraph:
Collaboration graph
[legend]

Public Member Functions

 InstanceGraph (Operation *operation)
 Create a new module graph of a circuit. More...
 
igraph::InstanceGraphNodegetTopLevelNode () override
 Get the node corresponding to the top-level module of a circuit. More...
 
FModuleLike getTopLevelModule ()
 Get the module corresponding to the top-level module of a circuit. More...
 
- Public Member Functions inherited from circt::igraph::InstanceGraph
 InstanceGraph (Operation *parent)
 Create a new module graph of a circuit. More...
 
 InstanceGraph (const InstanceGraph &)=delete
 
virtual ~InstanceGraph ()=default
 
InstanceGraphNodelookup (ModuleOpInterface op)
 Look up an InstanceGraphNode for a module. More...
 
InstanceGraphNodelookup (StringAttr name)
 Lookup an module by name. More...
 
InstanceGraphNodeoperator[] (ModuleOpInterface op)
 Lookup an InstanceGraphNode for a module. More...
 
bool isAncestor (ModuleOpInterface child, ModuleOpInterface parent, llvm::function_ref< bool(InstanceRecord *)> skipInstance=[](InstanceRecord *_) { return false;})
 Check if child is instantiated by a parent. More...
 
FailureOr< llvm::ArrayRef< InstanceGraphNode * > > getInferredTopLevelNodes ()
 Get the nodes corresponding to the inferred top-level modules of a circuit. More...
 
Operation * getParent ()
 Return the parent under which all nodes are nested. More...
 
iterator begin ()
 
iterator end ()
 
virtual InstanceGraphNodeaddModule (ModuleOpInterface module)
 Add a newly created module to the instance graph. More...
 
virtual void erase (InstanceGraphNode *node)
 Remove this module from the instance graph. More...
 
virtual void replaceInstance (InstanceOpInterface inst, InstanceOpInterface newInst)
 Replaces an instance of a module with another instance. More...
 

Private Attributes

InstanceGraphNodetopLevelNode
 

Additional Inherited Members

- Public Types inherited from circt::igraph::InstanceGraph
using iterator = detail::AddressIterator< NodeList::iterator >
 Iterate through all modules. More...
 
- Static Public Member Functions inherited from circt::igraph::InstanceGraph
static NodeList InstanceGraph::* getSublistAccess (Operation *)
 Returns pointer to member of operation list. More...
 
- Protected Member Functions inherited from circt::igraph::InstanceGraph
ModuleOpInterface getReferencedModuleImpl (InstanceOpInterface op)
 
InstanceGraphNodegetOrAddNode (StringAttr name)
 Get the node corresponding to the module. More...
 
- Protected Attributes inherited from circt::igraph::InstanceGraph
Operation * parent
 The node under which all modules are nested. More...
 
NodeList nodes
 The storage for graph nodes, with deterministic iteration. More...
 
llvm::DenseMap< Attribute, InstanceGraphNode * > nodeMap
 This maps each operation to its graph node. More...
 
llvm::SmallVector< InstanceGraphNode * > inferredTopLevelNodes
 A caching of the inferred top level module(s). More...
 

Detailed Description

This graph tracks modules and where they are instantiated.

This is intended to be used as a cached analysis on FIRRTL circuits. This class can be used to walk the modules efficiently in a bottom-up or top-down order.

To use this class, retrieve a cached copy from the analysis manager: auto &instanceGraph = getAnalysis<InstanceGraph>(getOperation());

Definition at line 35 of file FIRRTLInstanceGraph.h.

Constructor & Destructor Documentation

◆ InstanceGraph()

InstanceGraph::InstanceGraph ( Operation *  operation)
explicit

Create a new module graph of a circuit.

This must be called on a FIRRTL CircuitOp or MLIR ModuleOp.

Definition at line 23 of file FIRRTLInstanceGraph.cpp.

References circt::igraph::InstanceGraph::getParent(), circt::igraph::InstanceGraph::lookup(), and topLevelNode.

Member Function Documentation

◆ getTopLevelModule()

FModuleLike circt::firrtl::InstanceGraph::getTopLevelModule ( )
inline

Get the module corresponding to the top-level module of a circuit.

Definition at line 45 of file FIRRTLInstanceGraph.h.

References getTopLevelNode().

Referenced by ModuleNameSanitizer::rewrite().

◆ getTopLevelNode()

igraph::InstanceGraphNode* circt::firrtl::InstanceGraph::getTopLevelNode ( )
inlineoverridevirtual

Get the node corresponding to the top-level module of a circuit.

Reimplemented from circt::igraph::InstanceGraph.

Definition at line 42 of file FIRRTLInstanceGraph.h.

References topLevelNode.

Referenced by getTopLevelModule().

Member Data Documentation

◆ topLevelNode

InstanceGraphNode* circt::firrtl::InstanceGraph::topLevelNode
private

Definition at line 50 of file FIRRTLInstanceGraph.h.

Referenced by getTopLevelNode(), and InstanceGraph().


The documentation for this class was generated from the following files: