CIRCT 20.0.0git
Loading...
Searching...
No Matches
HWInstanceGraph.cpp
Go to the documentation of this file.
1//===- HWInstanceGraph.cpp - Instance Graph ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11using namespace circt;
12using namespace hw;
13
14InstanceGraph::InstanceGraph(Operation *operation)
15 : igraph::InstanceGraph(operation) {
16 for (auto &node : nodes) {
17 // Note: we dyn_cast here because we cannot assume that _all_ nodes are
18 // HWModuleLike - there may be cases where hw.module's are mixed with
19 // other ops that implement the igraph::ModuleOpInterface.
20 auto hwModuleLikeNode =
21 dyn_cast<HWModuleLike>(node.getModule().getOperation());
22 if (hwModuleLikeNode && hwModuleLikeNode.isPublic())
23 entry.addInstance({}, &node);
24 }
25}
26
29 cast<igraph::ModuleOpInterface>(module.getOperation()));
30 if (module.isPublic())
31 entry.addInstance({}, node);
32 return node;
33}
34
36 for (auto *instance : llvm::make_early_inc_range(entry)) {
37 if (instance->getTarget() == node)
38 instance->erase();
39 }
41}
HW-specific instance graph with a virtual entry node linking to all publicly visible modules.
igraph::InstanceGraphNode * addHWModule(HWModuleLike module)
Adds a module, updating links to entry.
void erase(igraph::InstanceGraphNode *node) override
Erases a module, updating links to entry.
InstanceGraph(Operation *operation)
igraph::InstanceGraphNode entry
This is a Node in the InstanceGraph.
InstanceRecord * addInstance(InstanceOpInterface instance, InstanceGraphNode *target)
Record a new instance op in the body of this module.
virtual InstanceGraphNode * addModule(ModuleOpInterface module)
Add a newly created module to the instance graph.
NodeList nodes
The storage for graph nodes, with deterministic iteration.
virtual void erase(InstanceGraphNode *node)
Remove this module from the instance graph.
void erase()
Erase this instance record, removing it from the parent module and the target's use-list.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition hw.py:1