#define GEN_PASS_DECL_CANONICALIZER
#define GEN_PASS_DECL_CONTROLFLOWSINK
#define GEN_PASS_DECL_CSEPASS
+#define GEN_PASS_DECL_INLINER
#define GEN_PASS_DECL_LOOPINVARIANTCODEMOTION
-#define GEN_PASS_DECL_STRIPDEBUGINFO
+#define GEN_PASS_DECL_PRINTIRPASS
#define GEN_PASS_DECL_PRINTOPSTATS
-#define GEN_PASS_DECL_INLINER
+#define GEN_PASS_DECL_STRIPDEBUGINFO
#define GEN_PASS_DECL_SCCP
#define GEN_PASS_DECL_SYMBOLDCE
#define GEN_PASS_DECL_SYMBOLPRIVATIZE
std::unique_ptr<Pass> createCSEPass();
/// Creates a pass to print IR on the debug stream.
-std::unique_ptr<Pass> createPrintIRPass();
+std::unique_ptr<Pass> createPrintIRPass(const PrintIRPassOptions & = {});
/// Creates a pass that generates IR to verify ops at runtime.
std::unique_ptr<Pass> createGenerateRuntimeVerificationPass();
purposes to inspect the IR at a specific point in the pipeline.
}];
let constructor = "mlir::createPrintIRPass()";
+ let options = [
+ Option<"label", "label", "std::string", /*default=*/"", "Label">,
+ ];
}
def GenerateRuntimeVerification : Pass<"generate-runtime-verification"> {
//===----------------------------------------------------------------------===//
#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/Passes.h"
+#include "llvm/Support/Debug.h"
namespace mlir {
namespace {
#include "mlir/Transforms/Passes.h.inc"
struct PrintIRPass : public impl::PrintIRPassBase<PrintIRPass> {
- PrintIRPass() = default;
-
- void runOnOperation() override { getOperation()->dump(); }
+ 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();
+ }
};
} // namespace
-std::unique_ptr<Pass> createPrintIRPass() {
- return std::make_unique<PrintIRPass>();
+std::unique_ptr<Pass> createPrintIRPass(const PrintIRPassOptions &options) {
+ return std::make_unique<PrintIRPass>(options);
}
} // namespace mlir
\ No newline at end of file