[mlir][PatternRewriter] Add a new hook to selectively replace uses of an operation
authorRiver Riddle <riddleriver@gmail.com>
Thu, 14 Jan 2021 19:57:17 +0000 (11:57 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Thu, 14 Jan 2021 19:58:21 +0000 (11:58 -0800)
commitc8fb6ee34151b18bcc9ed1a6b8f502a0b40a414e
treef9ba4f6cb1cdadfced1ba059d49e6ccbf5b75305
parent387d3c24792f7ab5f2f8aab37d64948f42523825
[mlir][PatternRewriter] Add a new hook to selectively replace uses of an operation

This revision adds a new `replaceOpWithIf` hook that replaces uses of an operation that satisfy a given functor. If all uses are replaced, the operation gets erased in a similar manner to `replaceOp`. DialectConversion support will be added in a followup as this requires adjusting how replacements are tracked there.

Differential Revision: https://reviews.llvm.org/D94632
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/Transforms/DialectConversion.h
mlir/lib/IR/PatternMatch.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/test/Transforms/test-pattern-selective-replacement.mlir [new file with mode: 0644]
mlir/test/lib/Dialect/Test/TestPatterns.cpp