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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Jan 10 04:50:06 PST 2026


PragmaTwice wrote:

> how you would express "all operands and results of this op have the same type"

Ahh I think it can be expressed by reuse the same type hint? e.g.

```python
T = TypeVar("T")
U = TypeVar("U")

class AOp(Test.Operation, name="a"):
    in1: OpOperand[T]
    in2: OpOperand[T]
    in3: OpOperand[U]
```

Then it will generate IRDL like this:
```
%1 = any
%2 = any
operands(in1: %1, in2: %1, in3: %2)
```

So that `in1.type` should be the same as `in2.type` otherwise the verifier will complain.

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


More information about the Mlir-commits mailing list