[Mlir-commits] [mlir] [MLIR][Python] Add more field specifiers to Python-defined operations (PR #188064)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Mar 26 09:16:28 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:
Yah the first version is `only 'region' field specifier can be used for attribute fields`. It can avoid this problem but it's weird -- we don't have a function named `region` now 🤣
https://github.com/llvm/llvm-project/pull/188064
More information about the Mlir-commits
mailing list