CIRCT  19.0.0git
PrintNLATable.cpp
Go to the documentation of this file.
1 //===- PrintNLATable.cpp - Print the NLA Table ------------------*- 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 NLA Table. This is primarily a debugging pass.
9 //
10 //===----------------------------------------------------------------------===//
11 
15 #include "mlir/Pass/Pass.h"
16 #include "llvm/Support/raw_ostream.h"
17 
18 namespace circt {
19 namespace firrtl {
20 #define GEN_PASS_DEF_PRINTNLATABLE
21 #include "circt/Dialect/FIRRTL/Passes.h.inc"
22 } // namespace firrtl
23 } // namespace circt
24 
25 using namespace circt;
26 using namespace firrtl;
27 
28 namespace {
29 struct PrintNLATablePass
30  : public circt::firrtl::impl::PrintNLATableBase<PrintNLATablePass> {
31  PrintNLATablePass(raw_ostream &os) : os(os) {}
32  void runOnOperation() override {
33  auto circuitOp = getOperation();
34  auto &nlaTable = getAnalysis<NLATable>();
35  markAllAnalysesPreserved();
36 
37  for (auto &mop : *cast<CircuitOp>(circuitOp).getBodyBlock()) {
38  auto mod = dyn_cast<FModuleLike>(mop);
39  if (!mod)
40  continue;
41  os << mod.getModuleName() << ": ";
42  for (auto nla : nlaTable.lookup(mod))
43  os << nla.getSymName() << ", ";
44  os << '\n';
45  }
46  }
47  raw_ostream &os;
48 };
49 } // end anonymous namespace
50 
51 std::unique_ptr<mlir::Pass> circt::firrtl::createPrintNLATablePass() {
52  return std::make_unique<PrintNLATablePass>(llvm::errs());
53 }
static Block * getBodyBlock(FModuleLike mod)
std::unique_ptr< mlir::Pass > createPrintNLATablePass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21