1 //===------ OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "OrcLazyJIT.h"
11 #include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
15 std::unique_ptr<OrcLazyJIT::CompileCallbackMgr>
16 OrcLazyJIT::createCallbackMgr(Triple T, LLVMContext &Context) {
17 switch (T.getArch()) {
23 case Triple::x86_64: {
24 typedef orc::JITCompileCallbackManager<CompileLayerT,
25 orc::OrcX86_64> CCMgrT;
26 return make_unique<CCMgrT>(CompileLayer, Context, 0, 64);
31 int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
32 OrcLazyJIT J(std::unique_ptr<TargetMachine>(EngineBuilder().selectTarget()),
36 errs() << "Could not construct JIT.\n";
40 auto MainHandle = J.addModule(std::move(M));
41 auto MainSym = J.findSymbolIn(MainHandle, "main");
44 errs() << "Could not find main function.\n";
48 typedef int (*MainFnPtr)(int, char*[]);
49 auto Main = reinterpret_cast<MainFnPtr>(
50 static_cast<uintptr_t>(MainSym.getAddress()));
52 return Main(ArgC, ArgV);