aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Transforms/PrintIR.cpp
blob: 439e55da0293fb2e3604eda835d581a4b019575c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//===- PrintIR.cpp - Pass to dump IR on debug stream ----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/Passes.h"
#include "llvm/Support/Debug.h"

namespace mlir {
namespace {

#define GEN_PASS_DEF_PRINTIRPASS
#include "mlir/Transforms/Passes.h.inc"

struct PrintIRPass : public impl::PrintIRPassBase<PrintIRPass> {
  using impl::PrintIRPassBase<PrintIRPass>::PrintIRPassBase;

  void runOnOperation() override {
    llvm::dbgs() << "// -----// IR Dump";
    if (!this->label.empty())
      llvm::dbgs() << " " << this->label;
    llvm::dbgs() << " //----- //\n";
    getOperation()->dump();
    markAllAnalysesPreserved();
  }
};

} // namespace

std::unique_ptr<Pass> createPrintIRPass(const PrintIRPassOptions &options) {
  return std::make_unique<PrintIRPass>(options);
}

} // namespace mlir