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 
12 #include "PassDetails.h"
15 #include "llvm/Support/raw_ostream.h"
16 
17 using namespace circt;
18 using namespace firrtl;
19 
20 namespace {
21 struct PrintNLATablePass : public PrintNLATableBase<PrintNLATablePass> {
22  PrintNLATablePass(raw_ostream &os) : os(os) {}
23  void runOnOperation() override {
24  auto circuitOp = getOperation();
25  auto &nlaTable = getAnalysis<NLATable>();
26  markAllAnalysesPreserved();
27 
28  for (auto &mop : *cast<CircuitOp>(circuitOp).getBodyBlock()) {
29  auto mod = dyn_cast<FModuleLike>(mop);
30  if (!mod)
31  continue;
32  os << mod.getModuleName() << ": ";
33  for (auto nla : nlaTable.lookup(mod))
34  os << nla.getSymName() << ", ";
35  os << '\n';
36  }
37  }
38  raw_ostream &os;
39 };
40 } // end anonymous namespace
41 
42 std::unique_ptr<mlir::Pass> circt::firrtl::createPrintNLATablePass() {
43  return std::make_unique<PrintNLATablePass>(llvm::errs());
44 }
std::unique_ptr< mlir::Pass > createPrintNLATablePass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21