diff options
author | River Riddle <riddleriver@gmail.com> | 2022-03-08 14:20:08 -0800 |
---|---|---|
committer | River Riddle <riddleriver@gmail.com> | 2022-03-15 14:55:51 -0700 |
commit | f96a8675cd29776ca39bb76133ee9167f5001f17 (patch) | |
tree | bef017755b812a23cb22ca02e3216fdbe5a1433f /mlir/lib/Rewrite/ByteCode.cpp | |
parent | e9c9ee9fe694067ee96643d05d6ac378349386bb (diff) | |
download | llvm-f96a8675cd29776ca39bb76133ee9167f5001f17.zip llvm-f96a8675cd29776ca39bb76133ee9167f5001f17.tar.gz llvm-f96a8675cd29776ca39bb76133ee9167f5001f17.tar.bz2 |
[mlir][PDL] Define a new PDLInterp::FuncOp operation and drop uses of FuncOp
Defining our own function operation allows for the PDL interpreter
to be more self contained, and also removes any dependency on FuncOp;
which is moving out of the Builtin dialect.
Differential Revision: https://reviews.llvm.org/D121253
Diffstat (limited to 'mlir/lib/Rewrite/ByteCode.cpp')
-rw-r--r-- | mlir/lib/Rewrite/ByteCode.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mlir/lib/Rewrite/ByteCode.cpp b/mlir/lib/Rewrite/ByteCode.cpp index c8bc206..477d713 100644 --- a/mlir/lib/Rewrite/ByteCode.cpp +++ b/mlir/lib/Rewrite/ByteCode.cpp @@ -239,7 +239,8 @@ public: private: /// Allocate memory indices for the results of operations within the matcher /// and rewriters. - void allocateMemoryIndices(FuncOp matcherFunc, ModuleOp rewriterModule); + void allocateMemoryIndices(pdl_interp::FuncOp matcherFunc, + ModuleOp rewriterModule); /// Generate the bytecode for the given operation. void generate(Region *region, ByteCodeWriter &writer); @@ -482,7 +483,7 @@ struct ByteCodeLiveRange { } // namespace void Generator::generate(ModuleOp module) { - FuncOp matcherFunc = module.lookupSymbol<FuncOp>( + auto matcherFunc = module.lookupSymbol<pdl_interp::FuncOp>( pdl_interp::PDLInterpDialect::getMatcherFunctionName()); ModuleOp rewriterModule = module.lookupSymbol<ModuleOp>( pdl_interp::PDLInterpDialect::getRewriterModuleName()); @@ -494,7 +495,7 @@ void Generator::generate(ModuleOp module) { // Generate code for the rewriter functions. ByteCodeWriter rewriterByteCodeWriter(rewriterByteCode, *this); - for (FuncOp rewriterFunc : rewriterModule.getOps<FuncOp>()) { + for (auto rewriterFunc : rewriterModule.getOps<pdl_interp::FuncOp>()) { rewriterToAddr.try_emplace(rewriterFunc.getName(), rewriterByteCode.size()); for (Operation &op : rewriterFunc.getOps()) generate(&op, rewriterByteCodeWriter); @@ -514,11 +515,11 @@ void Generator::generate(ModuleOp module) { } } -void Generator::allocateMemoryIndices(FuncOp matcherFunc, +void Generator::allocateMemoryIndices(pdl_interp::FuncOp matcherFunc, ModuleOp rewriterModule) { // Rewriters use simplistic allocation scheme that simply assigns an index to // each result. - for (FuncOp rewriterFunc : rewriterModule.getOps<FuncOp>()) { + for (auto rewriterFunc : rewriterModule.getOps<pdl_interp::FuncOp>()) { ByteCodeField index = 0, typeRangeIndex = 0, valueRangeIndex = 0; auto processRewriterValue = [&](Value val) { valueToMemIndex.try_emplace(val, index++); |