[all-commits] [llvm/llvm-project] f27f1e: [mlir] DialectConversion: support block creation i...
ftynse via All-commits
all-commits at lists.llvm.org
Fri Apr 3 11:30:34 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: f27f1e8c27b1d7cf624877e798999244a72adb41
https://github.com/llvm/llvm-project/commit/f27f1e8c27b1d7cf624877e798999244a72adb41
Author: Alex Zinenko <zinenko at google.com>
Date: 2020-04-03 (Fri, 03 Apr 2020)
Changed paths:
M mlir/include/mlir/IR/Builders.h
M mlir/include/mlir/Transforms/DialectConversion.h
M mlir/lib/IR/Builders.cpp
M mlir/lib/Transforms/DialectConversion.cpp
M mlir/test/Transforms/test-legalizer.mlir
M mlir/test/lib/Dialect/Test/TestPatterns.cpp
Log Message:
-----------
[mlir] DialectConversion: support block creation in ConversionPatternRewriter
PatternRewriter and derived classes provide a set of virtual methods to
manipulate blocks, which ConversionPatternRewriter overrides to keep track of
the manipulations and undo them in case the conversion fails. However, one can
currently create a block only by splitting another block into two. This not
only makes the API inconsistent (`splitBlock` is allowed in conversion
patterns, but `createBlock` is not), but it also make it impossible for one to
create blocks with argument lists different from those of already existing
blocks since in-place block updates are not supported either. Such
functionality precludes dialect conversion infrastructure from being used more
extensively on region-containing ops, for example, for value-returning "if"
operations. At the same time, ConversionPatternRewriter already allows one to
undo block creation as block creation is one of the primitive operations in
already supported region inlining.
Support block creation in conversion patterns by hooking `createBlock` on the
block action undo mechanism. This requires to make `Builder::createBlock`
virtual, similarly to Op insertion. This is a minimal change to the Builder
infrastructure that will later help support additional use cases such as block
signature changes. `createBlock` now additionally takes the types of the block
arguments that are added immediately so as to avoid in-place argument list
manipulation that would be illegal in conversion patterns.
More information about the All-commits
mailing list