[PATCH] D122086: [mlir:PDL] Expand how native constraint/rewrite functions can be defined
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 19 15:09:41 PDT 2022
rriddle created this revision.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, cota, teijeong, dexonsmith, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, mehdi_amini, bollu.
Herald added a project: All.
rriddle requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: MLIR, LLVM.
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>(...);
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122086
Files:
llvm/include/llvm/ADT/STLExtras.h
mlir/docs/PDLL.md
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/Transforms/DialectConversion.h
mlir/lib/Rewrite/ByteCode.cpp
mlir/lib/Tools/PDLL/CodeGen/CPPGen.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
mlir/test/Rewrite/pdl-bytecode.mlir
mlir/test/lib/Rewrite/TestPDLByteCode.cpp
mlir/test/mlir-pdll/CodeGen/CPP/general.pdll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122086.416742.patch
Type: text/x-patch
Size: 62075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220319/e9f48696/attachment-0001.bin>
More information about the llvm-commits
mailing list