[PATCH] D77416: [mlir] DialectConversion: support block creation in ConversionPatternRewriter
Alex Zinenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 11:20:22 PDT 2020
ftynse created this revision.
Herald added subscribers: llvm-commits, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.
ftynse updated this revision to Diff 254857.
ftynse added a comment.
ftynse added a child revision: D77418: [mlir] LoopToStandard conversion: support "if/else" with results.
rriddle accepted this revision.
This revision is now accepted and ready to land.
upd
rriddle added a comment.
Nice!
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77416
Files:
mlir/include/mlir/IR/Builders.h
mlir/include/mlir/Transforms/DialectConversion.h
mlir/lib/IR/Builders.cpp
mlir/lib/Transforms/DialectConversion.cpp
mlir/test/Transforms/test-legalizer.mlir
mlir/test/lib/Dialect/Test/TestPatterns.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77416.254857.patch
Type: text/x-patch
Size: 9986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200403/12a64322/attachment-0001.bin>
More information about the llvm-commits
mailing list