llvm.org GIT mirror llvm / 69bb605
[Orc] Merge some common code for creating CompileCallbackManagers and IndirectStubsManagers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270874 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 4 years ago
8 changed file(s) with 68 addition(s) and 128 deletion(s). Raw diff Collapse all Expand all
327327 StringMap> StubIndexes;
328328 };
329329
330 /// @brief Create a local compile callback manager.
331 ///
332 /// The given target triple will determine the ABI, and the given
333 /// ErrorHandlerAddress will be used by the resulting compile callback
334 /// manager if a compile callback fails.
335 std::unique_ptr
336 createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress);
337
338 /// @brief Create a local indriect stubs manager builder.
339 ///
340 /// The given target triple will determine the ABI.
341 std::function()>
342 createLocalIndirectStubsManagerBuilder(Triple T);
343
330344 /// @brief Build a function pointer of FunctionType with the given constant
331345 /// address.
332346 ///
33 NullResolver.cpp
44 OrcABISupport.cpp
55 OrcCBindings.cpp
6 OrcCBindingsStack.cpp
76 OrcError.cpp
87 OrcMCJITReplacement.cpp
98 OrcRemoteTargetRPCAPI.cpp
99 #include "llvm/ADT/STLExtras.h"
1010 #include "llvm/ADT/Triple.h"
1111 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
12 #include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
1213 #include "llvm/IR/CallSite.h"
1314 #include "llvm/IR/IRBuilder.h"
1415 #include "llvm/Transforms/Utils/Cloning.h"
1920
2021 void JITCompileCallbackManager::anchor() {}
2122 void IndirectStubsManager::anchor() {}
23
24 std::unique_ptr
25 createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress) {
26 switch (T.getArch()) {
27 default: return nullptr;
28
29 case Triple::x86: {
30 typedef orc::LocalJITCompileCallbackManager CCMgrT;
31 return llvm::make_unique(ErrorHandlerAddress);
32 }
33
34 case Triple::x86_64: {
35 if ( T.getOS() == Triple::OSType::Win32 ) {
36 typedef orc::LocalJITCompileCallbackManager CCMgrT;
37 return llvm::make_unique(ErrorHandlerAddress);
38 } else {
39 typedef orc::LocalJITCompileCallbackManager CCMgrT;
40 return llvm::make_unique(ErrorHandlerAddress);
41 }
42 }
43 }
44 }
45
46 std::function()>
47 createLocalIndirectStubsManagerBuilder(Triple T) {
48 switch (T.getArch()) {
49 default: return nullptr;
50
51 case Triple::x86:
52 return [](){
53 return llvm::make_unique<
54 orc::LocalIndirectStubsManager>();
55 };
56
57 case Triple::x86_64:
58 if (T.getOS() == Triple::OSType::Win32) {
59 return [](){
60 return llvm::make_unique<
61 orc::LocalIndirectStubsManager>();
62 };
63 } else {
64 return [](){
65 return llvm::make_unique<
66 orc::LocalIndirectStubsManager>();
67 };
68 }
69 }
70 }
2271
2372 Constant* createIRTypedAddress(FunctionType &FT, TargetAddress Addr) {
2473 Constant *AddrIntVal =
1616
1717 Triple T(TM2->getTargetTriple());
1818
19 auto CompileCallbackMgr = OrcCBindingsStack::createCompileCallbackMgr(T);
19 auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
2020 auto IndirectStubsMgrBuilder =
21 OrcCBindingsStack::createIndirectStubsMgrBuilder(T);
21 orc::createLocalIndirectStubsManagerBuilder(T);
2222
2323 OrcCBindingsStack *JITStack = new OrcCBindingsStack(
2424 *TM2, std::move(CompileCallbackMgr), IndirectStubsMgrBuilder);
+0
-67
lib/ExecutionEngine/Orc/OrcCBindingsStack.cpp less more
None //===-------- OrcCBindingsStack.cpp - Orc JIT stack for C bindings --------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "OrcCBindingsStack.h"
10
11 #include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
12 #include "llvm/Support/Debug.h"
13 #include "llvm/Support/DynamicLibrary.h"
14 #include
15 #include
16
17 using namespace llvm;
18
19 std::unique_ptr
20 OrcCBindingsStack::createCompileCallbackMgr(Triple T) {
21 switch (T.getArch()) {
22 default:
23 return nullptr;
24
25 case Triple::x86: {
26 typedef orc::LocalJITCompileCallbackManager CCMgrT;
27 return llvm::make_unique(0);
28 };
29
30 case Triple::x86_64: {
31 if ( T.getOS() == Triple::OSType::Win32 ) {
32 typedef orc::LocalJITCompileCallbackManager CCMgrT;
33 return llvm::make_unique(0);
34 } else {
35 typedef orc::LocalJITCompileCallbackManager CCMgrT;
36 return llvm::make_unique(0);
37 }
38 }
39 }
40 }
41
42 OrcCBindingsStack::IndirectStubsManagerBuilder
43 OrcCBindingsStack::createIndirectStubsMgrBuilder(Triple T) {
44 switch (T.getArch()) {
45 default:
46 return nullptr;
47
48 case Triple::x86:
49 return []() {
50 return llvm::make_unique>();
51 };
52
53 case Triple::x86_64:
54 if (T.getOS() == Triple::OSType::Win32) {
55 return [](){
56 return llvm::make_unique<
57 orc::LocalIndirectStubsManager>();
58 };
59 } else {
60 return [](){
61 return llvm::make_unique<
62 orc::LocalIndirectStubsManager>();
63 };
64 }
65 }
66 }
7777 typedef unsigned ModuleSetHandleT;
7878
7979 typedef unsigned ModuleHandleT;
80
81 static std::unique_ptr createCompileCallbackMgr(Triple T);
82 static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);
8380
8481 OrcCBindingsStack(TargetMachine &TM,
8582 std::unique_ptr CCMgr,
4343 cl::opt OrcInlineStubs("orc-lazy-inline-stubs",
4444 cl::desc("Try to inline stubs"),
4545 cl::init(true), cl::Hidden);
46 }
47
48 std::unique_ptr
49 OrcLazyJIT::createCompileCallbackMgr(Triple T) {
50 switch (T.getArch()) {
51 default: return nullptr;
52
53 case Triple::x86: {
54 typedef orc::LocalJITCompileCallbackManager CCMgrT;
55 return llvm::make_unique(0);
56 }
57
58 case Triple::x86_64: {
59 if ( T.getOS() == Triple::OSType::Win32 ) {
60 typedef orc::LocalJITCompileCallbackManager CCMgrT;
61 return llvm::make_unique(0);
62 } else {
63 typedef orc::LocalJITCompileCallbackManager CCMgrT;
64 return llvm::make_unique(0);
65 }
66 }
67 }
68 }
69
70 OrcLazyJIT::IndirectStubsManagerBuilder
71 OrcLazyJIT::createIndirectStubsMgrBuilder(Triple T) {
72 switch (T.getArch()) {
73 default: return nullptr;
74
75 case Triple::x86:
76 return [](){
77 return llvm::make_unique<
78 orc::LocalIndirectStubsManager>();
79 };
80
81 case Triple::x86_64:
82 if (T.getOS() == Triple::OSType::Win32) {
83 return [](){
84 return llvm::make_unique<
85 orc::LocalIndirectStubsManager>();
86 };
87 } else {
88 return [](){
89 return llvm::make_unique<
90 orc::LocalIndirectStubsManager>();
91 };
92 }
93 }
9446 }
9547
9648 OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() {
164116 EngineBuilder EB;
165117 EB.setOptLevel(getOptLevel());
166118 auto TM = std::unique_ptr(EB.selectTarget());
167 auto CompileCallbackMgr =
168 OrcLazyJIT::createCompileCallbackMgr(Triple(TM->getTargetTriple()));
119 Triple T(TM->getTargetTriple());
120 auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
169121
170122 // If we couldn't build the factory function then there must not be a callback
171123 // manager for this target. Bail out.
175127 return 1;
176128 }
177129
178 auto IndirectStubsMgrBuilder =
179 OrcLazyJIT::createIndirectStubsMgrBuilder(Triple(TM->getTargetTriple()));
130 auto IndirectStubsMgrBuilder = orc::createLocalIndirectStubsManagerBuilder(T);
180131
181132 // If we couldn't build a stubs-manager-builder for this target then bail out.
182133 if (!IndirectStubsMgrBuilder) {
6060 for (auto &DtorRunner : IRStaticDestructorRunners)
6161 DtorRunner.runViaLayer(CODLayer);
6262 }
63
64 static std::unique_ptr createCompileCallbackMgr(Triple T);
65 static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T);
6663
6764 ModuleHandleT addModule(std::unique_ptr M) {
6865 // Attach a data-layout if one isn't already present.