93c698da104afc2f42635abb060097ef8e6b9a40
[oota-llvm.git] / lib / ExecutionEngine / Orc / OrcCBindingsStack.cpp
1 //===-------- OrcCBindingsStack.cpp - Orc JIT stack for C bindings --------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "OrcCBindingsStack.h"
11
12 #include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
13 #include "llvm/Support/Debug.h"
14 #include "llvm/Support/DynamicLibrary.h"
15 #include <cstdio>
16 #include <system_error>
17
18 using namespace llvm;
19
20 OrcCBindingsStack::CallbackManagerBuilder
21 OrcCBindingsStack::createCallbackManagerBuilder(Triple T) {
22   switch (T.getArch()) {
23     default: return nullptr;
24
25     case Triple::x86_64: {
26       typedef orc::JITCompileCallbackManager<CompileLayerT,
27                                              orc::OrcX86_64> CCMgrT;
28       return [](CompileLayerT &CompileLayer, RuntimeDyld::MemoryManager &MemMgr,
29                 LLVMContext &Context) {
30                return llvm::make_unique<CCMgrT>(CompileLayer, MemMgr, Context, 0,
31                                                 64);
32              };
33     }
34   }
35 }
36
37 OrcCBindingsStack::IndirectStubsManagerBuilder
38 OrcCBindingsStack::createIndirectStubsMgrBuilder(Triple T) {
39   switch (T.getArch()) {
40     default: return nullptr;
41
42     case Triple::x86_64:
43       return [](){
44         return llvm::make_unique<orc::IndirectStubsManager<orc::OrcX86_64>>();
45       };
46   }
47 }