13 #ifndef MLIR_EXECUTIONENGINE_EXECUTIONENGINE_H_ 14 #define MLIR_EXECUTIONENGINE_EXECUTIONENGINE_H_ 17 #include "llvm/ExecutionEngine/ObjectCache.h" 18 #include "llvm/ExecutionEngine/Orc/LLJIT.h" 19 #include "llvm/ExecutionEngine/SectionMemoryManager.h" 20 #include "llvm/IR/LLVMContext.h" 21 #include "llvm/Support/Error.h" 29 class ExecutionEngine;
30 class JITEventListener;
41 void notifyObjectCompiled(
const llvm::Module *m,
42 llvm::MemoryBufferRef objBuffer)
override;
43 std::unique_ptr<llvm::MemoryBuffer> getObject(
const llvm::Module *m)
override;
46 void dumpToObjectFile(StringRef filename);
49 llvm::StringMap<std::unique_ptr<llvm::MemoryBuffer>> cachedObjects;
58 llvmModuleBuilder =
nullptr;
75 llvm::SectionMemoryManager::MemoryMapper *sectionMemoryMapper =
nullptr;
80 bool enableObjectCache =
false;
84 bool enableGDBNotificationListener =
true;
88 bool enablePerfNotificationListener =
true;
103 ExecutionEngine(
bool enableObjectCache,
bool enableGDBNotificationListener,
104 bool enablePerfNotificationListener);
121 llvm::Error invokePacked(StringRef name,
126 template <
typename T>
129 args.push_back(&val);
134 template <
typename T>
142 template <
typename T>
149 template <
typename T>
152 args.push_back(&result.
value);
167 template <
typename... Args>
168 llvm::Error
invoke(StringRef funcName, Args... args) {
169 const std::string adapterName =
170 std::string(
"_mlir_ciface_") + funcName.str();
177 return invokePacked(adapterName, argsArray);
182 static bool setupTargetTriple(llvm::Module *llvmModule);
185 void dumpToObjectFile(StringRef filename);
188 void registerSymbols(
195 llvm::LLVMContext llvmContext;
198 std::unique_ptr<llvm::orc::LLJIT> jit;
201 std::unique_ptr<SimpleObjectCache> cache;
204 llvm::JITEventListener *gdbListener;
207 llvm::JITEventListener *perfListener;
212 #endif // MLIR_EXECUTIONENGINE_EXECUTIONENGINE_H_ Include the generated interface declarations.
Explicitly register a set of "builtin" types.
static void pack(SmallVectorImpl< void *> &args, Result< T > &result)
static constexpr const bool value
A simple object cache following Lang's LLJITWithObjectCache example.
static void pack(SmallVectorImpl< void *> &args, T &val)
JIT-backed execution engine for MLIR modules.
Trait that defines how a given type is passed to the JIT code.
static llvm::ManagedStatic< PassManagerOptions > options
Tag to wrap an output parameter when invoking a jitted function.
llvm::Error invoke(StringRef funcName, Args... args)
Invokes the function with the given name passing it the list of arguments by value.
static Result< T > result(T &t)
Helper function to wrap an output operand when using ExecutionEngine::invoke.