CIRCT  19.0.0git
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
circt::igraph::InstanceGraphNode Class Reference

This is a Node in the InstanceGraph. More...

#include <InstanceGraph.h>

Inheritance diagram for circt::igraph::InstanceGraphNode:
Inheritance graph
[legend]
Collaboration diagram for circt::igraph::InstanceGraphNode:
Collaboration graph
[legend]

Classes

struct  UseIterator
 Iterator for module uses. More...
 

Public Types

using iterator = detail::AddressIterator< InstanceList::iterator >
 Iterate the instance records in this module. More...
 

Public Member Functions

 InstanceGraphNode ()
 
template<typename TTarget = ModuleOpInterface>
auto getModule ()
 Get the module that this node is tracking. More...
 
iterator begin ()
 
iterator end ()
 
bool noUses ()
 Return true if there are no more instances of this module. More...
 
bool hasOneUse ()
 Return true if this module has exactly one use. More...
 
size_t getNumUses ()
 Get the number of direct instantiations of this module. More...
 
UseIterator usesBegin ()
 Iterate the instance records which instantiate this module. More...
 
UseIterator usesEnd ()
 
llvm::iterator_range< UseIteratoruses ()
 
InstanceRecordaddInstance (InstanceOpInterface instance, InstanceGraphNode *target)
 Record a new instance op in the body of this module. More...
 

Private Types

using InstanceList = llvm::iplist< InstanceRecord >
 

Private Member Functions

 InstanceGraphNode (const InstanceGraphNode &)=delete
 
void recordUse (InstanceRecord *record)
 Record that a module instantiates this module. More...
 

Private Attributes

ModuleOpInterface module
 The module. More...
 
InstanceList instances
 List of instance operations in this module. More...
 
InstanceRecordfirstUse = nullptr
 List of instances which instantiate this module. More...
 

Friends

class InstanceRecord
 
class InstanceGraph
 Iterates over the handshake::FuncOp's in the program to build an instance graph. More...
 

Detailed Description

This is a Node in the InstanceGraph.

Each node represents a Module in a Circuit. Both external modules and regular modules can be represented by this class. It is possible to efficiently iterate all modules instantiated by this module, as well as all instantiations of this module.

Definition at line 101 of file InstanceGraph.h.

Member Typedef Documentation

◆ InstanceList

Definition at line 102 of file InstanceGraph.h.

◆ iterator

Iterate the instance records in this module.

Definition at line 116 of file InstanceGraph.h.

Constructor & Destructor Documentation

◆ InstanceGraphNode() [1/2]

circt::igraph::InstanceGraphNode::InstanceGraphNode ( )
inline

Definition at line 105 of file InstanceGraph.h.

◆ InstanceGraphNode() [2/2]

circt::igraph::InstanceGraphNode::InstanceGraphNode ( const InstanceGraphNode )
privatedelete

Member Function Documentation

◆ addInstance()

InstanceRecord * InstanceGraphNode::addInstance ( InstanceOpInterface  instance,
InstanceGraphNode target 
)

Record a new instance op in the body of this module.

Returns a newly allocated InstanceRecord which will be owned by this node.

Definition at line 28 of file InstanceGraph.cpp.

References InstanceRecord, instances, and recordUse().

Referenced by circt::hw::InstanceGraph::addHWModule(), inlineInputOnly(), circt::hw::InstanceGraph::InstanceGraph(), and migrateOps().

◆ begin()

iterator circt::igraph::InstanceGraphNode::begin ( )
inline

◆ end()

iterator circt::igraph::InstanceGraphNode::end ( )
inline

◆ getModule()

template<typename TTarget = ModuleOpInterface>
auto circt::igraph::InstanceGraphNode::getModule ( )
inline

◆ getNumUses()

size_t circt::igraph::InstanceGraphNode::getNumUses ( )
inline

Get the number of direct instantiations of this module.

Definition at line 127 of file InstanceGraph.h.

References usesBegin(), and usesEnd().

◆ hasOneUse()

bool circt::igraph::InstanceGraphNode::hasOneUse ( )
inline

Return true if this module has exactly one use.

Definition at line 124 of file InstanceGraph.h.

References uses().

◆ noUses()

bool circt::igraph::InstanceGraphNode::noUses ( )
inline

Return true if there are no more instances of this module.

Definition at line 121 of file InstanceGraph.h.

References firstUse.

Referenced by inlineInputOnly().

◆ recordUse()

void InstanceGraphNode::recordUse ( InstanceRecord record)
private

Record that a module instantiates this module.

Definition at line 36 of file InstanceGraph.cpp.

References firstUse, circt::igraph::InstanceRecord::nextUse, and circt::igraph::InstanceRecord::prevUse.

Referenced by addInstance().

◆ uses()

llvm::iterator_range<UseIterator> circt::igraph::InstanceGraphNode::uses ( )
inline

◆ usesBegin()

UseIterator circt::igraph::InstanceGraphNode::usesBegin ( )
inline

Iterate the instance records which instantiate this module.

Definition at line 152 of file InstanceGraph.h.

Referenced by llvm::GraphTraits< llvm::Inverse< circt::igraph::InstanceGraphNode * > >::child_begin(), getNumUses(), circt::firrtl::OwningModuleCache::lookup(), and uses().

◆ usesEnd()

UseIterator circt::igraph::InstanceGraphNode::usesEnd ( )
inline

Friends And Related Function Documentation

◆ InstanceGraph

friend class InstanceGraph
friend

Iterates over the handshake::FuncOp's in the program to build an instance graph.

In doing so, we detect whether there are any cycles in this graph, as well as infer a top function for the design by performing a topological sort of the instance graph. The result of this sort is placed in sortedFuncs.

Definition at line 183 of file InstanceGraph.h.

◆ InstanceRecord

friend class InstanceRecord
friend

Definition at line 164 of file InstanceGraph.h.

Referenced by addInstance().

Member Data Documentation

◆ firstUse

InstanceRecord* circt::igraph::InstanceGraphNode::firstUse = nullptr
private

List of instances which instantiate this module.

Definition at line 180 of file InstanceGraph.h.

Referenced by circt::igraph::InstanceRecord::erase(), noUses(), and recordUse().

◆ instances

InstanceList circt::igraph::InstanceGraphNode::instances
private

List of instance operations in this module.

This member owns the InstanceRecords, which may be pointed to by other InstanceGraphNode's use lists.

Definition at line 177 of file InstanceGraph.h.

Referenced by addInstance(), begin(), end(), and circt::igraph::InstanceRecord::erase().

◆ module

ModuleOpInterface circt::igraph::InstanceGraphNode::module
private

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