Loading [MathJax]/extensions/tex2jax.js
CIRCT 22.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 using Base::Base;
33
34 void runOnOperation() override {
35 getOperation().walk([&](hw::HWModuleOp module) {
36 // We don't really have any other way of forwarding draw arguments to the
37 // DOTGraphTraits for HWModule except through the module itself - as an
38 // attribute.
39 module->setAttr("dot_verboseEdges",
40 BoolAttr::get(module.getContext(), verboseEdges));
41
42 llvm::WriteGraph(llvm::errs(), module, /*ShortNames=*/false);
43 });
44 }
45};
46} // end anonymous namespace
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition hw.py:1