CIRCT  20.0.0git
HWPrintInstanceGraph.cpp
Go to the documentation of this file.
1 //===- HWPrintInstanceGraph.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 // Print the module hierarchy.
9 //
10 //===----------------------------------------------------------------------===//
11 
13 #include "circt/Dialect/HW/HWOps.h"
15 #include "mlir/Pass/Pass.h"
16 #include "llvm/Support/GraphWriter.h"
17 #include "llvm/Support/raw_ostream.h"
18 
19 namespace circt {
20 namespace hw {
21 #define GEN_PASS_DEF_PRINTINSTANCEGRAPH
22 #include "circt/Dialect/HW/Passes.h.inc"
23 } // namespace hw
24 } // namespace circt
25 
26 using namespace circt;
27 using namespace hw;
28 
29 namespace {
30 struct PrintInstanceGraphPass
31  : public circt::hw::impl::PrintInstanceGraphBase<PrintInstanceGraphPass> {
32  PrintInstanceGraphPass(raw_ostream &os) : os(os) {}
33  void runOnOperation() override {
34  InstanceGraph &instanceGraph = getAnalysis<InstanceGraph>();
35  llvm::WriteGraph(os, &instanceGraph, /*ShortNames=*/false);
36  markAllAnalysesPreserved();
37  }
38  raw_ostream &os;
39 };
40 } // end anonymous namespace
41 
42 std::unique_ptr<mlir::Pass> circt::hw::createPrintInstanceGraphPass() {
43  return std::make_unique<PrintInstanceGraphPass>(llvm::errs());
44 }
HW-specific instance graph with a virtual entry node linking to all publicly visible modules.
std::unique_ptr< mlir::Pass > createPrintInstanceGraphPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: hw.py:1