diff options
author | River Riddle <riddleriver@gmail.com> | 2021-02-02 11:32:52 -0800 |
---|---|---|
committer | River Riddle <riddleriver@gmail.com> | 2021-02-02 12:04:51 -0800 |
commit | ec10f0660963c77413f31a9b232b453f09425387 (patch) | |
tree | 8a7f65e2f7c4f70d42bd3c5b140ef55de1b82f5d /llvm/utils/FileCheck/FileCheck.cpp | |
parent | e2bd29a0d680158a66472859a18af0f1d450bbe1 (diff) | |
download | llvm-ec10f0660963c77413f31a9b232b453f09425387.zip llvm-ec10f0660963c77413f31a9b232b453f09425387.tar.gz llvm-ec10f0660963c77413f31a9b232b453f09425387.tar.bz2 |
[mlir][Pattern] Create a new IRRewriter class to enable sharing code with pattern rewrites
This revision adds two new classes, RewriterBase and IRRewriter. RewriterBase is a new shared base class between IRRewriter and PatternRewriter. PatternRewriter will continue to be the base class used to perform rewrites within a rewrite pattern. IRRewriter on the other hand, is a new class that allows for tracking IR rewrites from outside of a rewrite pattern. In this revision all of the old API from PatternRewriter is moved to RewriterBase, but the distinction between IRRewriter and PatternRewriter is kept on the chance that a necessary API divergence happens in the future.
Currently if you want to have some utility that transforms a piece of IR and share it between pattern and non-pattern code, you have to duplicate it. This revision enables the creation of utilities that can be invoked from rewrite patterns and normal transformation code:
```c++
void someSharedUtility(RewriterBase &rewriter, ...) {
// Some interesting IR mutation here.
}
// Some RewritePattern
LogicalResult MyPattern::matchAndRewrite(Operation *op, PatternRewriter &rewriter) {
...
someSharedUtility(rewriter, ...);
...
}
// Some Pass
void MyPass::runOnOperation() {
...
IRRewriter rewriter(...);
someSharedUtility(rewriter, ...);
}
```
Differential Revision: https://reviews.llvm.org/D94638
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
0 files changed, 0 insertions, 0 deletions