[Mlir-commits] [mlir] [mlir] Add IR printing flag to skip regions (PR #77726)
Jakub Kuderski
llvmlistbot at llvm.org
Thu Jan 11 14:41:24 PST 2024
https://github.com/kuhar updated https://github.com/llvm/llvm-project/pull/77726
>From 9560cd2e8f2b19bf57430dffe92d57495c28212e Mon Sep 17 00:00:00 2001
From: Jakub Kuderski <jakub at nod-labs.com>
Date: Thu, 11 Jan 2024 17:41:08 -0500
Subject: [PATCH] Use AsmPrinter flag instead
---
mlir/lib/IR/AsmPrinter.cpp | 5 +++++
mlir/test/IR/print-skip-regions.mlir | 18 ++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 mlir/test/IR/print-skip-regions.mlir
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 8fe8c78efecf9f..da417945b57fac 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -183,6 +183,10 @@ struct AsmPrinterOptions {
llvm::cl::desc("Print with local scope and inline information (eliding "
"aliases for attributes, types, and locations")};
+ llvm::cl::opt<bool> skipRegionsOpt{
+ "mlir-print-skip-regions", llvm::cl::init(false),
+ llvm::cl::desc("Skip regions when printing ops.")};
+
llvm::cl::opt<bool> printValueUsers{
"mlir-print-value-users", llvm::cl::init(false),
llvm::cl::desc(
@@ -217,6 +221,7 @@ OpPrintingFlags::OpPrintingFlags()
printGenericOpFormFlag = clOptions->printGenericOpFormOpt;
assumeVerifiedFlag = clOptions->assumeVerifiedOpt;
printLocalScope = clOptions->printLocalScopeOpt;
+ skipRegionsFlag = clOptions->skipRegionsOpt;
printValueUsersFlag = clOptions->printValueUsers;
}
diff --git a/mlir/test/IR/print-skip-regions.mlir b/mlir/test/IR/print-skip-regions.mlir
new file mode 100644
index 00000000000000..19a66e94f7f0b0
--- /dev/null
+++ b/mlir/test/IR/print-skip-regions.mlir
@@ -0,0 +1,18 @@
+// RUN: mlir-opt --no-implicit-module --mlir-print-skip-regions \
+// RUN: --split-input-file %s | FileCheck %s
+
+// CHECK-LABEL: func.func @foo(%{{.+}}: i32, %{{.+}}: i32, %{{.+}}: i32) -> i32 {...}
+// CHECK-NOT: return
+func.func @foo(%arg0: i32, %arg1: i32, %arg3: i32) -> i32 {
+ return %arg0: i32
+}
+
+// -----
+
+// CHECK: module {...}
+// CHECK-NOT: func.func
+module {
+ func.func @foo(%arg0: i32, %arg1: i32, %arg3: i32) -> i32 {
+ return %arg0: i32
+ }
+}
More information about the Mlir-commits
mailing list