[Mlir-commits] [mlir] [MLIR][Python] Add more field specifiers to Python-defined operations (PR #188064)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Mar 28 02:05:09 PDT 2026


================
@@ -173,46 +227,72 @@ def from_type_hint(name, type_, specifier) -> "FieldDef":
 
         origin = get_origin(type_)
         if origin is ir.OpResult:
+            if specifier.type_ and specifier.type_ is not Result:
+                raise TypeError(
+                    f"only `result` field specifier can be used for result fields"
+                )
             constraint = get_args(type_)[0]
             return ResultDef(
                 name,
                 variadicity,
                 constraint,
-                kw_only=specifier.kw_only(),
+                param_kind=specifier.param_kind(),
+                default_factory=specifier.default_factory,
+                default_is_none=specifier.default_is_none,
                 infer_type=(
                     infer_type_impl(constraint) if specifier.infer_type else None
                 ),
             )
         elif origin is ir.Value:
+            if specifier.type_ and specifier.type_ is not Operand:
+                raise TypeError(
+                    f"only `operand` field specifier can be used for operand fields"
+                )
             return OperandDef(
                 name,
                 variadicity,
                 get_args(type_)[0],
-                kw_only=specifier.kw_only(),
+                param_kind=specifier.param_kind(),
+                default_is_none=specifier.default_is_none,
             )
         elif type_ is ir.Region:
+            if specifier.type_ and specifier.type_ is not Region:
+                raise TypeError(
+                    f"currently no field specifier can be used for region fields"
----------------
PragmaTwice wrote:

Fixed.

https://github.com/llvm/llvm-project/pull/188064


More information about the Mlir-commits mailing list