CIRCT  19.0.0git
Print.cpp
Go to the documentation of this file.
1 //===- Print.cpp - Print pass -----------------------------------*- 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 //
9 // Implements the Print (as a DOT graph) pass.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "PassDetails.h"
14 
16 
17 using namespace circt;
18 using namespace scheduling;
19 using namespace ssp;
20 
21 namespace {
22 struct PrintPass : public PrintBase<PrintPass> {
23  explicit PrintPass(raw_ostream &os) : os(os) {}
24  void runOnOperation() override;
25  raw_ostream &os;
26 };
27 } // end anonymous namespace
28 
29 template <typename ProblemT>
30 static void printInstance(InstanceOp instOp, raw_ostream &os) {
31  auto prob = loadProblem<ProblemT>(instOp);
32  dumpAsDOT(prob, os);
33 }
34 
35 void PrintPass::runOnOperation() {
36  auto moduleOp = getOperation();
37  for (auto instOp : moduleOp.getOps<InstanceOp>()) {
38  StringRef probName = instOp.getProblemName();
39  if (probName == "Problem")
40  printInstance<Problem>(instOp, os);
41  else if (probName == "CyclicProblem")
42  printInstance<CyclicProblem>(instOp, os);
43  else if (probName == "ChainingProblem")
44  printInstance<ChainingProblem>(instOp, os);
45  else if (probName == "SharedOperatorsProblem")
46  printInstance<SharedOperatorsProblem>(instOp, os);
47  else if (probName == "ModuloProblem")
48  printInstance<ModuloProblem>(instOp, os);
49  else if (probName == "ChainingCyclicProblem")
50  printInstance<ChainingCyclicProblem>(instOp, os);
51  else {
52  auto instName = instOp.getSymName().value_or("unnamed");
53  llvm::errs() << "ssp-print-instance: Unknown problem class '" << probName
54  << "' in instance '" << instName << "'\n";
55  return signalPassFailure();
56  }
57  }
58 }
59 
60 std::unique_ptr<mlir::Pass> circt::ssp::createPrintPass() {
61  return std::make_unique<PrintPass>(llvm::errs());
62 }
static void printInstance(InstanceOp instOp, raw_ostream &os)
Definition: Print.cpp:30
void dumpAsDOT(Problem &prob, StringRef fileName)
Export prob as a DOT graph into fileName.
Definition: Utilities.cpp:55
std::unique_ptr< mlir::Pass > createPrintPass()
Definition: Print.cpp:60
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21