CIRCT  19.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 
12 #include "PassDetails.h"
15 #include "llvm/Support/DOTGraphTraits.h"
16 #include "llvm/Support/GraphWriter.h"
17 #include "llvm/Support/raw_ostream.h"
18 
19 using namespace circt;
20 using namespace firrtl;
21 
22 namespace {
23 struct PrintInstanceGraphPass
24  : public PrintInstanceGraphBase<PrintInstanceGraphPass> {
25  PrintInstanceGraphPass(raw_ostream &os) : os(os) {}
26  void runOnOperation() override {
27  auto circuitOp = getOperation();
28  auto &instanceGraph = getAnalysis<InstanceGraph>();
29  llvm::WriteGraph(os, &instanceGraph, /*ShortNames=*/false,
30  circuitOp.getName());
31  markAllAnalysesPreserved();
32  }
33  raw_ostream &os;
34 };
35 } // end anonymous namespace
36 
37 std::unique_ptr<mlir::Pass> circt::firrtl::createPrintInstanceGraphPass() {
38  return std::make_unique<PrintInstanceGraphPass>(llvm::errs());
39 }
std::unique_ptr< mlir::Pass > createPrintInstanceGraphPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21