| 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 | |
| 13 | namespace mlir { |
| 14 | #define GEN_PASS_DEF_PRINTIRPASS |
| 15 | #include "mlir/Transforms/Passes.h.inc" |
| 16 | } // namespace mlir |
| 17 | |
| 18 | namespace mlir { |
| 19 | namespace { |
| 20 | |
| 21 | struct PrintIRPass : public impl::PrintIRPassBase<PrintIRPass> { |
| 22 | using impl::PrintIRPassBase<PrintIRPass>::PrintIRPassBase; |
| 23 | |
| 24 | void runOnOperation() override { |
| 25 | llvm::dbgs() << "// -----// IR Dump"; |
| 26 | if (!this->label.empty()) |
| 27 | llvm::dbgs() << " "<< this->label; |
| 28 | llvm::dbgs() << " //----- //\n"; |
| 29 | getOperation()->print(os&: llvm::dbgs(), flags: OpPrintingFlags().useLocalScope()); |
| 30 | llvm::dbgs() << "\n"; |
| 31 | markAllAnalysesPreserved(); |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | } // namespace |
| 36 | |
| 37 | } // namespace mlir |
| 38 |