[Mlir-commits] [mlir] [MLIR][Func] Enable strict property assembly format (PR #217300)
Mehdi Amini
llvmlistbot at llvm.org
Wed Aug 26 03:58:20 PDT 2026
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/217300
>From b64b8b05dfbd265272b286ce9457c92a2f006868 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] [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
---
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 a31b860276099..549c01efe67a2 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
}
More information about the Mlir-commits
mailing list