CIRCT 20.0.0git
Loading...
Searching...
No Matches
PrintHWModuleGraph.cpp
Go to the documentation of this file.
1//===- PrintHWModuleGraph.cpp - Print the 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// Prints an HW module as a .dot graph.
9//
10//===----------------------------------------------------------------------===//
11
15#include "mlir/Pass/Pass.h"
16#include "llvm/Support/GraphWriter.h"
17#include "llvm/Support/raw_ostream.h"
18
19namespace circt {
20namespace hw {
21#define GEN_PASS_DEF_PRINTHWMODULEGRAPH
22#include "circt/Dialect/HW/Passes.h.inc"
23} // namespace hw
24} // namespace circt
25
26using namespace circt;
27using namespace hw;
28
29namespace {
30struct PrintHWModuleGraphPass
31 : public circt::hw::impl::PrintHWModuleGraphBase<PrintHWModuleGraphPass> {
32 PrintHWModuleGraphPass(raw_ostream &os) : os(os) {}
33 void runOnOperation() override {
34 getOperation().walk([&](hw::HWModuleOp module) {
35 // We don't really have any other way of forwarding draw arguments to the
36 // DOTGraphTraits for HWModule except through the module itself - as an
37 // attribute.
38 module->setAttr("dot_verboseEdges",
39 BoolAttr::get(module.getContext(), verboseEdges));
40
41 llvm::WriteGraph(os, module, /*ShortNames=*/false);
42 });
43 }
44 raw_ostream &os;
45};
46} // end anonymous namespace
47
48std::unique_ptr<mlir::Pass> circt::hw::createPrintHWModuleGraphPass() {
49 return std::make_unique<PrintHWModuleGraphPass>(llvm::errs());
50}
std::unique_ptr< mlir::Pass > createPrintHWModuleGraphPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition hw.py:1