blob: 10f6692e9ffd39dc73fd52d7c88f4d0314727240 [file] [log] [blame]
Lang Hames130a7c42015-10-28 02:40:04 +00001//===-------- 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
Lang Hames70b24062016-01-11 00:56:15 +000012#include "llvm/ExecutionEngine/Orc/OrcArchitectureSupport.h"
Lang Hames130a7c42015-10-28 02:40:04 +000013#include "llvm/Support/Debug.h"
14#include "llvm/Support/DynamicLibrary.h"
15#include <cstdio>
16#include <system_error>
17
18using namespace llvm;
19
Rafael Espindolae63e0182015-11-03 16:40:37 +000020std::unique_ptr<OrcCBindingsStack::CompileCallbackMgr>
21OrcCBindingsStack::createCompileCallbackMgr(Triple T) {
Lang Hames130a7c42015-10-28 02:40:04 +000022 switch (T.getArch()) {
Lang Hames1fa0e0e2016-04-25 21:21:20 +000023 default:
24 return nullptr;
Lang Hames130a7c42015-10-28 02:40:04 +000025
Lang Hames1fa0e0e2016-04-25 21:21:20 +000026 case Triple::x86: {
27 typedef orc::LocalJITCompileCallbackManager<orc::OrcI386> CCMgrT;
28 return llvm::make_unique<CCMgrT>(0);
29 };
Lang Hames4f8194e2016-02-10 01:02:33 +000030
Lang Hames1fa0e0e2016-04-25 21:21:20 +000031 case Triple::x86_64: {
32 typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64> CCMgrT;
33 return llvm::make_unique<CCMgrT>(0);
34 }
Lang Hames130a7c42015-10-28 02:40:04 +000035 }
36}
37
38OrcCBindingsStack::IndirectStubsManagerBuilder
39OrcCBindingsStack::createIndirectStubsMgrBuilder(Triple T) {
40 switch (T.getArch()) {
Lang Hames1fa0e0e2016-04-25 21:21:20 +000041 default:
42 return nullptr;
Lang Hames130a7c42015-10-28 02:40:04 +000043
Lang Hames1fa0e0e2016-04-25 21:21:20 +000044 case Triple::x86:
45 return []() {
46 return llvm::make_unique<orc::LocalIndirectStubsManager<orc::OrcI386>>();
47 };
Lang Hames4f8194e2016-02-10 01:02:33 +000048
Lang Hames1fa0e0e2016-04-25 21:21:20 +000049 case Triple::x86_64:
50 return []() {
51 return llvm::make_unique<
52 orc::LocalIndirectStubsManager<orc::OrcX86_64>>();
53 };
Lang Hames130a7c42015-10-28 02:40:04 +000054 }
55}