CIRCT 24.0.0git
Loading...
Searching...
No Matches
circt::fsm::FSMGraph Class Reference

Graph representing FSM machines, their states and transitions between these. More...

#include <FSMGraph.h>

Collaboration diagram for circt::fsm::FSMGraph:

Public Types

using iterator = detail::AddressIterator<NodeList::iterator>
 Iterate through all states.

Public Member Functions

 FSMGraph (Operation *operation)
 Create a new graph of an FSM machine operation.
FSMStateNode * lookup (StateOp op)
 Look up a FSMStateNode for a state.
FSMStateNode * lookup (StringAttr name)
 Lookup a FSMStateNode by name.
FSMStateNode * operator[] (StateOp op)
 Lookup a FSMStateNode for a state.
FSMStateNode * getEntryNode ()
 Get the node corresponding to the entry state of the FSM.
MachineOp getMachine () const
 Return the FSM machine operation which this graph tracks.
FSMStateNode * getOrAddState (StateOp state)
 Retrieves the state node for a 'state'.
FSMStateNode * createState (OpBuilder &builder, Location loc, StringRef name)
 Creates a new StateOp operation in this machine and updates the graph.
FSMTransitionEdge * createTransition (OpBuilder &builder, Location loc, StateOp from, StateOp to)
 Creates a new transition operation between two states and updates the graph.
void eraseState (StateOp state)
 Removes this state from the graph.
void renameState (StateOp state, StringRef name)
 Renames the 'state' to the provided 'name', and updates all referencing transitions.
iterator begin ()
iterator end ()

Private Types

using NodeList = llvm::iplist<FSMStateNode>
 This is the list of FSMStateNodes in the graph.

Private Member Functions

 FSMGraph (const FSMGraph &)=delete

Private Attributes

MachineOp machine
 The node under which all states are nested.
NodeList nodes
 The storage for graph nodes, with deterministic iteration.
llvm::DenseMap< Attribute, FSMStateNode * > nodeMap
 This maps each StateOp to its graph node.

Detailed Description

Graph representing FSM machines, their states and transitions between these.

Definition at line 205 of file FSMGraph.h.

Member Typedef Documentation

◆ iterator

Iterate through all states.

Definition at line 249 of file FSMGraph.h.

◆ NodeList

using circt::fsm::FSMGraph::NodeList = llvm::iplist<FSMStateNode>
private

This is the list of FSMStateNodes in the graph.

Definition at line 207 of file FSMGraph.h.

Constructor & Destructor Documentation

◆ FSMGraph() [1/2]

circt::fsm::FSMGraph::FSMGraph ( Operation * operation)
explicit

Create a new graph of an FSM machine operation.

Referenced by FSMGraph().

◆ FSMGraph() [2/2]

circt::fsm::FSMGraph::FSMGraph ( const FSMGraph & )
privatedelete

References FSMGraph().

Member Function Documentation

◆ begin()

iterator circt::fsm::FSMGraph::begin ( )
inline

Definition at line 250 of file FSMGraph.h.

References nodes.

Referenced by llvm::GraphTraits< circt::fsm::FSMGraph * >::nodes_begin().

◆ createState()

FSMStateNode * FSMGraph::createState ( OpBuilder & builder,
Location loc,
StringRef name )

Creates a new StateOp operation in this machine and updates the graph.

Definition at line 84 of file FSMGraph.cpp.

References fsm.StateOp::create(), createState(), getMachine(), and getOrAddState().

Referenced by createState().

◆ createTransition()

FSMTransitionEdge * FSMGraph::createTransition ( OpBuilder & builder,
Location loc,
StateOp from,
StateOp to )

Creates a new transition operation between two states and updates the graph.

Definition at line 92 of file FSMGraph.cpp.

References fsm.TransitionOp::create(), createTransition(), and getOrAddState().

Referenced by createTransition().

◆ end()

iterator circt::fsm::FSMGraph::end ( )
inline

Definition at line 251 of file FSMGraph.h.

References nodes.

Referenced by llvm::GraphTraits< circt::fsm::FSMGraph * >::nodes_end().

◆ eraseState()

void FSMGraph::eraseState ( StateOp state)

Removes this state from the graph.

This will also remove the state in the underlying machine and all transitions to the state.

Definition at line 103 of file FSMGraph.cpp.

References eraseState(), getOrAddState(), nodeMap, and nodes.

Referenced by eraseState().

◆ getEntryNode()

FSMStateNode * circt::fsm::FSMGraph::getEntryNode ( )

Get the node corresponding to the entry state of the FSM.

Referenced by llvm::GraphTraits< circt::fsm::FSMGraph * >::getEntryNode().

◆ getMachine()

MachineOp circt::fsm::FSMGraph::getMachine ( ) const
inline

Return the FSM machine operation which this graph tracks.

Definition at line 226 of file FSMGraph.h.

References machine.

Referenced by llvm::DOTGraphTraits< circt::fsm::FSMGraph * >::addCustomGraphFeatures(), and createState().

◆ getOrAddState()

FSMStateNode * FSMGraph::getOrAddState ( StateOp state)

Retrieves the state node for a 'state'.

If the node does not yet exists, a new state node is created.

Definition at line 73 of file FSMGraph.cpp.

References getOrAddState(), nodeMap, and nodes.

Referenced by createState(), createTransition(), eraseState(), getOrAddState(), and renameState().

◆ lookup() [1/2]

FSMStateNode * circt::fsm::FSMGraph::lookup ( StateOp op)

Look up a FSMStateNode for a state.

Referenced by lookup(), and operator[]().

◆ lookup() [2/2]

FSMStateNode * FSMGraph::lookup ( StringAttr name)

Lookup a FSMStateNode by name.

Definition at line 62 of file FSMGraph.cpp.

References lookup(), and nodeMap.

◆ operator[]()

FSMStateNode * circt::fsm::FSMGraph::operator[] ( StateOp op)
inline

Lookup a FSMStateNode for a state.

Definition at line 220 of file FSMGraph.h.

References lookup().

◆ renameState()

void FSMGraph::renameState ( StateOp state,
StringRef name )

Renames the 'state' to the provided 'name', and updates all referencing transitions.

Definition at line 115 of file FSMGraph.cpp.

References getOrAddState(), nodeMap, and renameState().

Referenced by renameState().

Member Data Documentation

◆ machine

MachineOp circt::fsm::FSMGraph::machine
private

The node under which all states are nested.

Definition at line 257 of file FSMGraph.h.

Referenced by getMachine().

◆ nodeMap

llvm::DenseMap<Attribute, FSMStateNode *> circt::fsm::FSMGraph::nodeMap
private

This maps each StateOp to its graph node.

Definition at line 263 of file FSMGraph.h.

Referenced by eraseState(), getOrAddState(), lookup(), and renameState().

◆ nodes

NodeList circt::fsm::FSMGraph::nodes
private

The storage for graph nodes, with deterministic iteration.

Definition at line 260 of file FSMGraph.h.

Referenced by begin(), end(), eraseState(), and getOrAddState().


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