[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 01:47:55 PDT 2026


================
@@ -777,3 +819,59 @@ class OpWithAttr(TestAttrInOp.Operation, name="op_with_attr"):
         # CHECK: "ext_attr_in_op.op_with_attr"() {a = 42 : i32, b = i32} : () -> ()
         # CHECK: "ext_attr_in_op.op_with_attr"() {a = "hello", b = i64} : () -> ()
         print(module)
+
+
+ at run
+def testExtDialectFieldSpecifiers():
+    class TestFieldSpecifiers(Dialect, name="ext_field_specifiers"):
+        pass
+
+    class OperandSpecifierOp(TestFieldSpecifiers.Operation, name="operand_specifier"):
+        a: Operand[IntegerType[32]] = operand()
+        b: Optional[Operand[IntegerType[32]]] = None
+        c: Operand[IntegerType[32]] = operand(kw_only=True)
+
+    class ResultSpecifierOp(TestFieldSpecifiers.Operation, name="result_specifier"):
+        a: Result[IntegerType[32]] = result()
+        b: Result[IntegerType[16]] = result(infer_type=True)
+        c: Result[IntegerType] = result(
+            default_factory=lambda: IntegerType.get_signless(8)
+        )
+        d: Sequence[Result[IntegerType]] = result(default_factory=list)
+        e: Result[IntegerType[32]] = result(kw_only=True)
+
+    class AttributeSpecifierOp(
+        TestFieldSpecifiers.Operation, name="attribute_specifier"
+    ):
+        a: IntegerAttr = attribute()
+        b: IntegerAttr = attribute(
+            default_factory=lambda: IntegerAttr.get(IntegerType.get_signless(32), 42)
+        )
+        b: StringAttr["a"] | StringAttr["b"] = attribute(
----------------
PragmaTwice wrote:

Fixed.

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


More information about the Mlir-commits mailing list