[all-commits] [llvm/llvm-project] 03d1c9: [mlir][ODS] Add `OptionalTypesMatchWith` and remov...
Benjamin Maxwell via All-commits
all-commits at lists.llvm.org
Thu Oct 19 09:00:16 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 03d1c99d99d7918115b993f14dcb6fc39cf09f72
https://github.com/llvm/llvm-project/commit/03d1c99d99d7918115b993f14dcb6fc39cf09f72
Author: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: 2023-10-19 (Thu, 19 Oct 2023)
Changed paths:
M mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
M mlir/include/mlir/IR/OpBase.td
M mlir/include/mlir/IR/Utils.td
M mlir/lib/Dialect/Vector/IR/VectorOps.cpp
M mlir/test/Dialect/Vector/invalid.mlir
A mlir/test/mlir-tblgen/utils.td
Log Message:
-----------
[mlir][ODS] Add `OptionalTypesMatchWith` and remove a custom assemblyFormat (#68876)
This is just a slight specialization of `TypesMatchWith` that returns
success if an optional parameter is missing.
There may be other places this could help e.g.:
https://github.com/llvm/llvm-project/blob/eb21049b4b904b072679ece60e73c6b0dc0d1ebf/mlir/include/mlir/Dialect/X86Vector/X86Vector.td#L58-L59
...but I'm leaving those to avoid some churn.
This constraint will be handy for us in some later patches, it's a
formalization of a short circuiting trick with the `comparator` of the
`TypesMatchWith` constraint (devised for #69195).
```
TypesMatchWith<
"padding type matches element type of result (if present)",
"result", "padding",
"::llvm::cast<VectorType>($_self).getElementType()",
// This returns true if no padding is present, or it's present with a type that matches the element type of `result`.
"!getPadding() || std::equal_to<>()">
```
This is a little non-obvious, so after this patch you can instead do:
```
OptionalTypesMatchWith<
"padding type matches element type of result (if present)",
"result", "padding",
"::llvm::cast<VectorType>($_self).getElementType()">
```
More information about the All-commits
mailing list