llvm-project
37 строк · 1.1 Кб
1//===- PrintIR.cpp - Pass to dump IR on debug stream ----------------------===//
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#include "mlir/Pass/Pass.h"
10#include "mlir/Transforms/Passes.h"
11#include "llvm/Support/Debug.h"
12
13namespace mlir {
14namespace {
15
16#define GEN_PASS_DEF_PRINTIRPASS
17#include "mlir/Transforms/Passes.h.inc"
18
19struct PrintIRPass : public impl::PrintIRPassBase<PrintIRPass> {
20using impl::PrintIRPassBase<PrintIRPass>::PrintIRPassBase;
21
22void runOnOperation() override {
23llvm::dbgs() << "// -----// IR Dump";
24if (!this->label.empty())
25llvm::dbgs() << " " << this->label;
26llvm::dbgs() << " //----- //\n";
27getOperation()->dump();
28}
29};
30
31} // namespace
32
33std::unique_ptr<Pass> createPrintIRPass(const PrintIRPassOptions &options) {
34return std::make_unique<PrintIRPass>(options);
35}
36
37} // namespace mlir