[all-commits] [llvm/llvm-project] ea6482: [mlir:PDL] Expand how native constraint/rewrite fu...
River Riddle via All-commits
all-commits at lists.llvm.org
Wed Apr 6 17:42:15 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ea64828a10e304f8131e40dfef062173fe606e6a
https://github.com/llvm/llvm-project/commit/ea64828a10e304f8131e40dfef062173fe606e6a
Author: River Riddle <riddleriver at gmail.com>
Date: 2022-04-06 (Wed, 06 Apr 2022)
Changed paths:
M llvm/include/llvm/ADT/STLExtras.h
M mlir/docs/PDLL.md
M mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
M mlir/include/mlir/IR/Builders.h
M mlir/include/mlir/IR/PatternMatch.h
M mlir/include/mlir/Transforms/DialectConversion.h
M mlir/lib/Rewrite/ByteCode.cpp
M mlir/lib/Tools/PDLL/CodeGen/CPPGen.cpp
M mlir/lib/Transforms/Utils/DialectConversion.cpp
M mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
M mlir/test/Rewrite/pdl-bytecode.mlir
M mlir/test/lib/Rewrite/TestPDLByteCode.cpp
M mlir/test/mlir-pdll/CodeGen/CPP/general.pdll
Log Message:
-----------
[mlir:PDL] Expand how native constraint/rewrite functions can be defined
This commit refactors the expected form of native constraint and rewrite
functions, and greatly reduces the necessary user complexity required when
defining a native function. Namely, this commit adds in automatic processing
of the necessary PDLValue glue code, and allows for users to define
constraint/rewrite functions using the C++ types that they actually want to
use.
As an example, lets see a simple example rewrite defined today:
```
static void rewriteFn(PatternRewriter &rewriter, PDLResultList &results,
ArrayRef<PDLValue> args) {
ValueRange operandValues = args[0].cast<ValueRange>();
TypeRange typeValues = args[1].cast<TypeRange>();
...
// Create an operation at some point and pass it back to PDL.
Operation *op = rewriter.create<SomeOp>(...);
results.push_back(op);
}
```
After this commit, that same rewrite could be defined as:
```
static Operation *rewriteFn(PatternRewriter &rewriter ValueRange operandValues,
TypeRange typeValues) {
...
// Create an operation at some point and pass it back to PDL.
return rewriter.create<SomeOp>(...);
}
```
Differential Revision: https://reviews.llvm.org/D122086
More information about the All-commits
mailing list