[Mlir-commits] [mlir] [MLIR][Func] Enable strict property assembly format (PR #217300)
Mehdi Amini
llvmlistbot at llvm.org
Thu Aug 27 13:59:28 PDT 2026
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/217300
>From e3fc8a8eef3c8767afd6338cba5ecd27c158ca4d Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Wed, 6 May 2026 14:04:33 -0700
Subject: [PATCH 1/2] [MLIR][Func] Enable strict property assembly format
Enable the strict properties assembly format mode for the Func dialect. Spell
inherent call attributes directly in the call formats so they are no longer
parsed from attr-dict in strict mode.
Assisted-by: Codex
(cherry picked from commit 5ee84e11bbbdf9840cbbf63251272e8e9ae511b5)
---
mlir/include/mlir/Dialect/Func/IR/FuncOps.td | 17 +++++++++++++++--
mlir/test/IR/core-ops.mlir | 12 ++++++++++++
mlir/test/Transforms/inlining.mlir | 2 +-
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
index 7d984092f5e33..ff48f6ab557e6 100644
--- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
+++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
@@ -22,6 +22,7 @@ def Func_Dialect : Dialect {
let name = "func";
let cppNamespace = "::mlir::func";
let hasConstantMaterializer = 1;
+ let useStrictPropertiesInAssemblyFormat = 1;
}
// Base class for Func dialect ops.
@@ -120,7 +121,14 @@ def CallOp : Func_Op<"call",
}];
let assemblyFormat = [{
- $callee `(` $operands `)` attr-dict `:` functional-type($operands, results)
+ $callee `(` $operands `)`
+ oilist<`,`>(
+ `arg_attrs` `=` $arg_attrs
+ | `res_attrs` `=` $res_attrs
+ | `no_inline` $no_inline
+ )
+ attr-dict `:`
+ functional-type($operands, results)
}];
}
@@ -197,7 +205,12 @@ def CallIndirectOp : Func_Op<"call_indirect", [
let hasCanonicalizeMethod = 1;
let assemblyFormat = [{
- $callee `(` $callee_operands `)` attr-dict `:` type($callee)
+ $callee `(` $callee_operands `)`
+ oilist<`,`>(
+ `arg_attrs` `=` $arg_attrs
+ | `res_attrs` `=` $res_attrs
+ )
+ attr-dict `:` type($callee)
}];
}
diff --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir
index 5d1583111541c..8ea5d45ae0526 100644
--- a/mlir/test/IR/core-ops.mlir
+++ b/mlir/test/IR/core-ops.mlir
@@ -201,6 +201,18 @@ func.func @calls(%arg0: i32) {
// CHECK: %4 = call_indirect %f_0(%arg0) : (i32) -> i32
%3 = "func.call_indirect"(%f_0, %arg0) : ((i32) -> i32, i32) -> i32
+ // CHECK: %{{.*}} = call @return_op(%arg0)
+ // CHECK-SAME: arg_attrs = [{test.arg}],
+ // CHECK-SAME: res_attrs = [{test.res = 42 : i64}], no_inline : (i32) -> i32
+ %4 = call @return_op(%arg0) res_attrs = [{test.res = 42 : i64}],
+ no_inline, arg_attrs = [{test.arg}] : (i32) -> i32
+
+ // CHECK: %{{.*}} = call_indirect %f_0(%arg0)
+ // CHECK-SAME: arg_attrs = [{test.arg}],
+ // CHECK-SAME: res_attrs = [{test.res = 42 : i64}] : (i32) -> i32
+ %5 = call_indirect %f_0(%arg0) res_attrs = [{test.res = 42 : i64}],
+ arg_attrs = [{test.arg}] : (i32) -> i32
+
return
}
diff --git a/mlir/test/Transforms/inlining.mlir b/mlir/test/Transforms/inlining.mlir
index da3f1a28deaac..56c17f263e172 100644
--- a/mlir/test/Transforms/inlining.mlir
+++ b/mlir/test/Transforms/inlining.mlir
@@ -28,7 +28,7 @@ func.func @noinline_with_arg(%arg0 : i32) -> i32 {
// CHECK-NEXT: func_with_arg
// CHECK-NEXT: return
- %0 = call @func_with_arg(%arg0) {no_inline} : (i32) -> i32
+ %0 = call @func_with_arg(%arg0) no_inline : (i32) -> i32
return %0 : i32
}
>From 847b522142ab42313849288c16b8febb849671e1 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Thu, 27 Aug 2026 13:55:26 -0700
Subject: [PATCH 2/2] Fix func.call strict property syntax
Switch func.call to prop-dict syntax and update the bufferization
inlining test to use the property-dictionary form for no_inline.
Assisted-by: Codex
(cherry picked from commit c5218c4a270be1da778314ae65ea674d99bbd2f8)
---
mlir/include/mlir/Dialect/Func/IR/FuncOps.td | 8 +-------
.../Transforms/one-shot-module-bufferize.mlir | 4 ++--
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
index ff48f6ab557e6..d7a0d5fc4f277 100644
--- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
+++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td
@@ -121,13 +121,7 @@ def CallOp : Func_Op<"call",
}];
let assemblyFormat = [{
- $callee `(` $operands `)`
- oilist<`,`>(
- `arg_attrs` `=` $arg_attrs
- | `res_attrs` `=` $res_attrs
- | `no_inline` $no_inline
- )
- attr-dict `:`
+ $callee `(` $operands `)` prop-dict attr-dict `:`
functional-type($operands, results)
}];
}
diff --git a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
index d20f06fd3278a..9a7e2274ab43d 100644
--- a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
+++ b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
@@ -599,8 +599,8 @@ func.func @equivalent_func_arg(%t0: tensor<?xf32> {bufferization.writable = true
// CHECK: scf.for {{.*}} iter_args(%[[t1:.*]] = %[[arg0]])
%1 = scf.for %iv = %c0 to %c10 step %c1 iter_args(%t1 = %t0) -> (tensor<?xf32>) {
// CHECK: call @inner_func(%[[t1]])
- // INHERENT: call @inner_func({{.*}}) {no_inline}
- %3 = func.call @inner_func(%t1) {no_inline} : (tensor<?xf32>) -> tensor<?xf32>
+ // INHERENT: call @inner_func({{.*}}) <{no_inline}>
+ %3 = func.call @inner_func(%t1) <{no_inline}> : (tensor<?xf32>) -> tensor<?xf32>
// CHECK: scf.yield %[[t1]]
scf.yield %3 : tensor<?xf32>
}
More information about the Mlir-commits
mailing list