[Mlir-commits] [mlir] [MLIR][Python] Add a DSL for defining dialects in Python bindings (PR #169045)

Sasha Lopoukhine llvmlistbot at llvm.org
Sun Jan 11 03:28:47 PST 2026


superlopuh wrote:

Here's the [built-in constraints definition file](https://github.com/xdslproject/xdsl/blob/main/xdsl/irdl/constraints.py), it's got some constraints that aren't expressible in Python's type system, such as "and" constraints, constraints that customize error strings, bounded constraints, range constraints (although if the fields are tuples then Python can probably express them, length of range constraints (especially useful if you want to say that the ranges of the inputs and outpus must have the same length. There are also more throughout the project. It's important to highlight that the IRDL constraints and xDSL constraints have somewhat distinct models, where `irdl` constraints are operations, so it's possible that the constraints expressible in the Python type system are more akin to what `irdl` can express. I'm not sure if it's much of a consideration, but as we iterate on `irdl` and Python APIs, it might make sense to keep the xDSL and MLIR bindings not too different in order to make it easier for them to keep in sync given they're doing something quite similar?

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


More information about the Mlir-commits mailing list