[PATCH] D137861: [MLIR] Move JitRunner Options to header, pass to mlirTransformer

Renato Golin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 12 13:50:42 PST 2022


rengolin updated this revision to Diff 474961.
rengolin added a comment.

Simplified what's exposed to the methods, keeping the Options on the CPP file. Rebased and all tests pass.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137861/new/

https://reviews.llvm.org/D137861

Files:
  mlir/include/mlir/ExecutionEngine/JitRunner.h
  mlir/lib/ExecutionEngine/JitRunner.cpp
  mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
  mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp


Index: mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
===================================================================
--- mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
+++ mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
@@ -41,7 +41,7 @@
 
 using namespace mlir;
 
-static LogicalResult runMLIRPasses(Operation *op) {
+static LogicalResult runMLIRPasses(Operation *op, JitRunnerOptions &options) {
   auto module = dyn_cast<ModuleOp>(op);
   if (!module)
     return op->emitOpError("expected a 'builtin.module' op");
Index: mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
===================================================================
--- mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
+++ mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
@@ -74,7 +74,8 @@
   return mainModule;
 }
 
-static LogicalResult runMLIRPasses(Operation *module) {
+static LogicalResult runMLIRPasses(Operation *module,
+                                   JitRunnerOptions &options) {
   PassManager passManager(module->getContext(),
                           module->getName().getStringRef());
   applyPassManagerCLOptions(passManager);
Index: mlir/lib/ExecutionEngine/JitRunner.cpp
===================================================================
--- mlir/lib/ExecutionEngine/JitRunner.cpp
+++ mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -364,8 +364,9 @@
     return 1;
   }
 
+  JitRunnerOptions runnerOptions{options.mainFuncName, options.mainFuncType};
   if (config.mlirTransformer)
-    if (failed(config.mlirTransformer(m.get())))
+    if (failed(config.mlirTransformer(m.get(), runnerOptions)))
       return EXIT_FAILURE;
 
   auto tmBuilderOrError = llvm::orc::JITTargetMachineBuilder::detectHost();
Index: mlir/include/mlir/ExecutionEngine/JitRunner.h
===================================================================
--- mlir/include/mlir/ExecutionEngine/JitRunner.h
+++ mlir/include/mlir/ExecutionEngine/JitRunner.h
@@ -36,11 +36,21 @@
 class Operation;
 struct LogicalResult;
 
+/// JitRunner command line options used by JitRunnerConfig methods
+struct JitRunnerOptions {
+  /// The name of the main function
+  llvm::StringRef mainFuncName;
+  /// The type of the main function (as string, from cmd-line)
+  llvm::StringRef mainFuncType;
+};
+
+/// Configuration to override functionality of the JitRunner
 struct JitRunnerConfig {
   /// MLIR transformer applied after parsing the input into MLIR IR and before
   /// passing the MLIR IR to the ExecutionEngine.
-  llvm::function_ref<LogicalResult(mlir::Operation *)> mlirTransformer =
-      nullptr;
+  llvm::function_ref<LogicalResult(mlir::Operation *,
+                                   JitRunnerOptions &options)>
+      mlirTransformer = nullptr;
 
   /// A custom function that is passed to ExecutionEngine. It processes MLIR and
   /// creates an LLVM IR module.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137861.474961.patch
Type: text/x-patch
Size: 2882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221112/70c72d10/attachment.bin>


More information about the llvm-commits mailing list