[mlir] Implement pass utils for 1:N type conversions.
authorIngo Müller <ingomueller@google.com>
Tue, 21 Feb 2023 11:21:25 +0000 (11:21 +0000)
committerIngo Müller <ingomueller@google.com>
Mon, 27 Mar 2023 16:04:26 +0000 (16:04 +0000)
commit0ceb7a12dbfd2035959d3791b96c923c0e1e89fc
tree10c4a7ef3e354cf488a287fc754a8c82fd43639b
parent258b5424edcf72063561ef7bb2ba6e5fbf24181a
[mlir] Implement pass utils for 1:N type conversions.

The current dialect conversion does not support 1:N type conversions.
This commit implements a (poor-man's) dialect conversion pass that does
just that. To keep the pass independent of the "real" dialect conversion
infrastructure, it provides a specialization of the TypeConverter class
that allows for N:1 target materializations, a specialization of the
RewritePattern and PatternRewriter classes that automatically add
appropriate unrealized casts supporting 1:N type conversions and provide
converted operands for implementing subclasses, and a conversion driver
that applies the provided patterns and replaces the unrealized casts
that haven't folded away with user-provided materializations.

The current pass is powerful enough to express many existing manual
solutions for 1:N type conversions or extend transforms that previously
didn't support them, out of which this patch implements call graph type
decomposition (which is currently implemented with a ValueDecomposer
that is only used there).

The goal of this pass is to illustrate the effect that 1:N type
conversions could have, gain experience in how patterns should be
written that achieve that effect, and get feedback on how the APIs of
the dialect conversion should be extended or changed to support such
patterns. The hope is that the "real" dialect conversion eventually
supports such patterns, at which point, this pass could be removed
again.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D144469
12 files changed:
mlir/include/mlir/Dialect/Func/Transforms/OneToNFuncConversions.h [new file with mode: 0644]
mlir/include/mlir/Transforms/OneToNTypeConversion.h [new file with mode: 0644]
mlir/lib/Dialect/Func/Transforms/CMakeLists.txt
mlir/lib/Dialect/Func/Transforms/OneToNFuncConversions.cpp [new file with mode: 0644]
mlir/lib/Transforms/Utils/CMakeLists.txt
mlir/lib/Transforms/Utils/OneToNTypeConversion.cpp [new file with mode: 0644]
mlir/test/Transforms/decompose-call-graph-types.mlir
mlir/test/lib/Conversion/CMakeLists.txt
mlir/test/lib/Conversion/OneToNTypeConversion/CMakeLists.txt [new file with mode: 0644]
mlir/test/lib/Conversion/OneToNTypeConversion/TestOneToNTypeConversionPass.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/CMakeLists.txt
mlir/tools/mlir-opt/mlir-opt.cpp