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