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" 
   32class JITEventListener;
 
   44                            llvm::MemoryBufferRef objBuffer) 
override;
 
   45  std::unique_ptr<llvm::MemoryBuffer> 
getObject(
const llvm::Module *m) 
override;
 
   54  llvm::StringMap<std::unique_ptr<llvm::MemoryBuffer>> cachedObjects;
 
 
  120      "__mlir_execution_engine_init";
 
  126      "__mlir_execution_engine_destroy";
 
  137  ExecutionEngine(
bool enableObjectDump, 
bool enableGDBNotificationListener,
 
  138                  bool enablePerfNotificationListener);
 
  147         std::unique_ptr<llvm::TargetMachine> tm = 
nullptr);
 
  164  template <
typename T>
 
  167      args.push_back(&val);
 
 
 
  172  template <
typename T>
 
  180  template <
typename T>
 
  187  template <
typename T>
 
  190      args.push_back(&
result.value);
 
 
 
  205  template <
typename... Args>
 
  206  llvm::Error 
invoke(StringRef funcName, Args... args) {
 
  207    const std::string adapterName =
 
  208        std::string(
"_mlir_ciface_") + funcName.str();
 
 
  220                                             llvm::TargetMachine *tm);
 
  240  llvm::LLVMContext llvmContext;
 
  243  std::unique_ptr<llvm::orc::LLJIT> jit;
 
  246  std::unique_ptr<SimpleObjectCache> cache;
 
  249  std::vector<std::string> functionNames;
 
  252  llvm::JITEventListener *gdbListener;
 
  255  llvm::JITEventListener *perfListener;
 
  261  bool isInitialized = 
false;
 
 
static llvm::ManagedStatic< PassManagerOptions > options
 
JIT-backed execution engine for MLIR.
 
llvm::Error invoke(StringRef funcName, Args... args)
Invokes the function with the given name passing it the list of arguments by value.
 
llvm::Expected< void(*)(void **)> lookupPacked(StringRef name) const
Looks up a packed-argument function wrapping the function with the given name and returns a pointer t...
 
void(*)(llvm::StringMap< void * > &) LibraryInitFn
Function type for init functions of shared libraries.
 
void(*)() LibraryDestroyFn
Function type for destroy functions of shared libraries.
 
void registerSymbols(llvm::function_ref< llvm::orc::SymbolMap(llvm::orc::MangleAndInterner)> symbolMap)
Register symbols with this ExecutionEngine.
 
llvm::Expected< void * > lookup(StringRef name) const
Looks up the original function with the given name and returns a pointer to it.
 
static llvm::Expected< std::unique_ptr< ExecutionEngine > > create(Operation *op, const ExecutionEngineOptions &options={}, std::unique_ptr< llvm::TargetMachine > tm=nullptr)
Creates an execution engine for the given MLIR IR.
 
void dumpToObjectFile(StringRef filename)
Dump object code to output file filename.
 
static Result< T > result(T &t)
Helper function to wrap an output operand when using ExecutionEngine::invoke.
 
static constexpr const char *const kLibraryInitFnName
Name of init functions of shared libraries.
 
static constexpr const char *const kLibraryDestroyFnName
Name of destroy functions of shared libraries.
 
llvm::Error invokePacked(StringRef name, MutableArrayRef< void * > args={})
Invokes the function with the given name passing it the list of opaque pointers to the actual argumen...
 
ExecutionEngine(bool enableObjectDump, bool enableGDBNotificationListener, bool enablePerfNotificationListener)
 
static void setupTargetTripleAndDataLayout(llvm::Module *llvmModule, llvm::TargetMachine *tm)
Set the target triple and the data layout for the input module based on the input TargetMachine.
 
void initialize()
Initialize the ExecutionEngine.
 
Operation is the basic unit of execution within MLIR.
 
A simple object cache following Lang's LLJITWithObjectCache example.
 
bool isEmpty()
Returns true if cache hasn't been populated yet.
 
void notifyObjectCompiled(const llvm::Module *m, llvm::MemoryBufferRef objBuffer) override
 
void dumpToObjectFile(StringRef filename)
Dump cached object to output file filename.
 
std::unique_ptr< llvm::MemoryBuffer > getObject(const llvm::Module *m) override
 
The OpAsmOpInterface, see OpAsmInterface.td for more details.
 
Include the generated interface declarations.
 
llvm::function_ref< std::unique_ptr< llvm::Module >(Operation *, llvm::LLVMContext &)> llvmModuleBuilder
If llvmModuleBuilder is provided, it will be used to create an LLVM module from the given MLIR IR.
 
std::optional< llvm::CodeGenOptLevel > jitCodeGenOptLevel
jitCodeGenOptLevel, when provided, is used as the optimization level for target code generation.
 
ArrayRef< StringRef > sharedLibPaths
If sharedLibPaths are provided, the underlying JIT-compilation will open and link the shared librarie...
 
bool enableObjectDump
If enableObjectCache is set, the JIT compiler will create one to store the object generated for the g...
 
bool enablePerfNotificationListener
If enablePerfNotificationListener is set, the JIT compiler will notify the llvm's global Perf notific...
 
llvm::function_ref< llvm::Error(llvm::Module *)> transformer
If transformer is provided, it will be called on the LLVM module during JIT-compilation and can be us...
 
llvm::SectionMemoryManager::MemoryMapper * sectionMemoryMapper
Specifies an existing sectionMemoryMapper to be associated with the compiled code.
 
bool enableGDBNotificationListener
If enable enableGDBNotificationListener is set, the JIT compiler will notify the llvm's global GDB no...
 
static void pack(SmallVectorImpl< void * > &args, Result< T > &result)
 
Trait that defines how a given type is passed to the JIT code.
 
static void pack(SmallVectorImpl< void * > &args, T &val)
 
Tag to wrap an output parameter when invoking a jitted function.