CIRCT  20.0.0git
PrintInstanceGraph.cpp
Go to the documentation of this file.
1 //===- PrintInstanceGraph.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 
15 #include "mlir/Pass/Pass.h"
16 #include "llvm/Support/DOTGraphTraits.h"
17 #include "llvm/Support/GraphWriter.h"
18 #include "llvm/Support/raw_ostream.h"
19 
20 namespace circt {
21 namespace firrtl {
22 #define GEN_PASS_DEF_PRINTINSTANCEGRAPH
23 #include "circt/Dialect/FIRRTL/Passes.h.inc"
24 } // namespace firrtl
25 } // namespace circt
26 
27 using namespace circt;
28 using namespace firrtl;
29 
30 namespace {
31 struct PrintInstanceGraphPass
32  : public circt::firrtl::impl::PrintInstanceGraphBase<
33  PrintInstanceGraphPass> {
34  PrintInstanceGraphPass(raw_ostream &os) : os(os) {}
35  void runOnOperation() override {
36  auto circuitOp = getOperation();
37  auto &instanceGraph = getAnalysis<InstanceGraph>();
38  llvm::WriteGraph(os, &instanceGraph, /*ShortNames=*/false,
39  circuitOp.getName());
40  markAllAnalysesPreserved();
41  }
42  raw_ostream &os;
43 };
44 } // end anonymous namespace
45 
46 std::unique_ptr<mlir::Pass> circt::firrtl::createPrintInstanceGraphPass() {
47  return std::make_unique<PrintInstanceGraphPass>(llvm::errs());
48 }
std::unique_ptr< mlir::Pass > createPrintInstanceGraphPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21