[mlir][irdl] Add `irdl.any_of` operation
authorMathieu Fehr <mathieu.fehr@gmail.com>
Wed, 8 Mar 2023 20:21:54 +0000 (21:21 +0100)
committerMathieu Fehr <mathieu.fehr@gmail.com>
Wed, 17 May 2023 20:57:16 +0000 (21:57 +0100)
commit42987dfa3a85e0cec987b9f07a8ffe61073ddc52
treeb560ec140543acdd22a79a7f8ff1e46436d2a4e7
parent6dcad42acbd5d047ac276ca73f1dc0012a39e99e
[mlir][irdl] Add `irdl.any_of` operation

The `irdl.any_of` operation represent a constraint that is satisfied
if any of its subconstraint is satisfied.

For instance, in the following example:
```
%0 = irdl.is f32
%1 = irdl.is f64
%2 = irdl.any_of(f32, f64)
```

`%2` can only be satisfied by `f32` or `f64`.

Note that the verification algorithm required by `irdl.any_of` is
non-trivial, since we want that the order of arguments of
`irdl.any_of` to not matter. For this reason, our registration
algorithm fails if two constraints used by `any_of` might be
satisfied by the same `Attribute`. This is approximated by checking
the possible `Attribute` bases of each constraints.

Depends on D145734

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D145735
mlir/include/mlir/Dialect/IRDL/IR/IRDLInterfaces.td
mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
mlir/lib/Dialect/IRDL/IR/IRDLOps.cpp
mlir/lib/Dialect/IRDL/IRDLLoading.cpp
mlir/test/Dialect/IRDL/cmath.irdl.mlir
mlir/test/Dialect/IRDL/cyclic-types.irdl.mlir [new file with mode: 0644]
mlir/test/Dialect/IRDL/cyclic-types.mlir [new file with mode: 0644]
mlir/test/Dialect/IRDL/test-type.irdl.mlir [new file with mode: 0644]
mlir/test/Dialect/IRDL/test-type.mlir [new file with mode: 0644]
mlir/test/Dialect/IRDL/testd.irdl.mlir
mlir/test/Dialect/IRDL/testd.mlir