MLIR  19.0.0git
JitRunner.h
Go to the documentation of this file.
1 //===- JitRunner.h - MLIR CPU Execution Driver Library ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This is a library that provides a shared implementation for command line
10 // utilities that execute an MLIR file on the CPU by translating MLIR to LLVM
11 // IR before JIT-compiling and executing the latter.
12 //
13 // The translation can be customized by providing an MLIR to MLIR
14 // transformation.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef MLIR_EXECUTIONENGINE_JITRUNNER_H
19 #define MLIR_EXECUTIONENGINE_JITRUNNER_H
20 
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ExecutionEngine/Orc/Core.h"
23 
24 namespace llvm {
25 class Module;
26 class LLVMContext;
27 
28 namespace orc {
29 class MangleAndInterner;
30 } // namespace orc
31 } // namespace llvm
32 
33 namespace mlir {
34 
35 class DialectRegistry;
36 class Operation;
37 struct LogicalResult;
38 
39 /// JitRunner command line options used by JitRunnerConfig methods
41  /// The name of the main function
42  llvm::StringRef mainFuncName;
43  /// The type of the main function (as string, from cmd-line)
44  llvm::StringRef mainFuncType;
45 };
46 
47 /// Configuration to override functionality of the JitRunner
49  /// MLIR transformer applied after parsing the input into MLIR IR and before
50  /// passing the MLIR IR to the ExecutionEngine.
53  mlirTransformer = nullptr;
54 
55  /// A custom function that is passed to ExecutionEngine. It processes MLIR and
56  /// creates an LLVM IR module.
58  llvm::LLVMContext &)>
59  llvmModuleBuilder = nullptr;
60 
61  /// A callback to register symbols with ExecutionEngine at runtime.
62  llvm::function_ref<llvm::orc::SymbolMap(llvm::orc::MangleAndInterner)>
63  runtimesymbolMap = nullptr;
64 };
65 
66 /// Entry point for all CPU runners. Expects the common argc/argv arguments for
67 /// standard C++ main functions. The supplied dialect registry is expected to
68 /// contain any registers that appear in the input IR, they will be loaded
69 /// on-demand by the parser.
70 int JitRunnerMain(int argc, char **argv, const DialectRegistry &registry,
71  JitRunnerConfig config = {});
72 
73 } // namespace mlir
74 
75 #endif // MLIR_EXECUTIONENGINE_JITRUNNER_H
static llvm::ManagedStatic< PassManagerOptions > options
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
Include the generated interface declarations.
Definition: CallGraph.h:229
Include the generated interface declarations.
int JitRunnerMain(int argc, char **argv, const DialectRegistry &registry, JitRunnerConfig config={})
Entry point for all CPU runners.
Definition: JitRunner.cpp:300
Configuration to override functionality of the JitRunner.
Definition: JitRunner.h:48
llvm::function_ref< LogicalResult(mlir::Operation *, JitRunnerOptions &options)> mlirTransformer
MLIR transformer applied after parsing the input into MLIR IR and before passing the MLIR IR to the E...
Definition: JitRunner.h:53
llvm::function_ref< std::unique_ptr< llvm::Module >Operation *, llvm::LLVMContext &)> llvmModuleBuilder
A custom function that is passed to ExecutionEngine.
Definition: JitRunner.h:59
llvm::function_ref< llvm::orc::SymbolMap(llvm::orc::MangleAndInterner)> runtimesymbolMap
A callback to register symbols with ExecutionEngine at runtime.
Definition: JitRunner.h:63
JitRunner command line options used by JitRunnerConfig methods.
Definition: JitRunner.h:40
llvm::StringRef mainFuncType
The type of the main function (as string, from cmd-line)
Definition: JitRunner.h:44
llvm::StringRef mainFuncName
The name of the main function.
Definition: JitRunner.h:42
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26