[Mlir-commits] [mlir] [MLIR][Python] Add a DSL for defining IRDL dialects in Python bindings (PR #169045)
Sasha Lopoukhine
llvmlistbot at llvm.org
Sun Dec 7 07:51:11 PST 2025
================
@@ -0,0 +1,308 @@
+# RUN: %PYTHON %s 2>&1 | FileCheck %s
+
+from mlir.ir import *
+from mlir.dialects.irdl import dsl as irdsl
+from mlir.dialects import arith
+import sys
+
+
+def run(f):
+ print("\nTEST:", f.__name__, file=sys.stderr)
+ with Context():
+ f()
+
+
+# CHECK: TEST: testMyInt
+ at run
+def testMyInt():
+ myint = irdsl.Dialect("myint")
+ iattr = irdsl.BaseName("#builtin.integer")
+ i32 = irdsl.IsType(IntegerType.get_signless(32))
+
+ @myint.op("constant")
+ class ConstantOp:
----------------
superlopuh wrote:
In xDSL, we use `__init__` for the pretty parameters, and `build` for the full parameter list. This seems better to me than overloading, as it's explicit which function is being called, and uses the more convenient function call syntax for the convenience init.
https://github.com/llvm/llvm-project/pull/169045
More information about the Mlir-commits
mailing list