CIRCT  20.0.0git
PrintFSMGraph.cpp
Go to the documentation of this file.
1 //===- FSMPrintFSMGraph.cpp - Print the instance graph ------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 //
9 // Print the module hierarchy.
10 //
11 //===----------------------------------------------------------------------===//
12 
17 #include "mlir/Pass/Pass.h"
18 #include "llvm/Support/GraphWriter.h"
19 #include "llvm/Support/raw_ostream.h"
20 
21 namespace circt {
22 namespace fsm {
23 #define GEN_PASS_DEF_PRINTFSMGRAPH
24 #include "circt/Dialect/FSM/Passes.h.inc"
25 } // namespace fsm
26 } // namespace circt
27 
28 using namespace circt;
29 using namespace fsm;
30 
31 namespace {
32 struct PrintFSMGraphPass
33  : public circt::fsm::impl::PrintFSMGraphBase<PrintFSMGraphPass> {
34  PrintFSMGraphPass(raw_ostream &os) : os(os) {}
35  void runOnOperation() override {
36  getOperation().walk([&](fsm::MachineOp machine) {
37  auto fsmGraph = fsm::FSMGraph(machine);
38  llvm::WriteGraph(os, &fsmGraph, /*ShortNames=*/false);
39  });
40  }
41  raw_ostream &os;
42 };
43 } // end anonymous namespace
44 
45 std::unique_ptr<mlir::Pass> circt::fsm::createPrintFSMGraphPass() {
46  return std::make_unique<PrintFSMGraphPass>(llvm::errs());
47 }
std::unique_ptr< mlir::Pass > createPrintFSMGraphPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: fsm.py:1