Skip to content

Commit 1756faa

Browse files
committed
ExecutionEngine: fix JIT/MCJIT selectTarget() duplication (v2)
This prepares for making JITCtor/MCJITCtor take a TargetMachine* directly from clients like EngineBuilder. llvm-svn: 131316
1 parent 8255d1e commit 1756faa

File tree

10 files changed

+26
-117
lines changed

10 files changed

+26
-117
lines changed

llvm/include/llvm/ExecutionEngine/ExecutionEngine.h

+8
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,14 @@ class EngineBuilder {
569569
return *this;
570570
}
571571

572+
/// selectTarget - Pick a target either via -march or by guessing the native
573+
/// arch. Add any CPU features specified via -mcpu or -mattr.
574+
static TargetMachine *selectTarget(Module *M,
575+
StringRef MArch,
576+
StringRef MCPU,
577+
const SmallVectorImpl<std::string>& MAttrs,
578+
std::string *Err);
579+
572580
ExecutionEngine *create();
573581
};
574582

llvm/lib/ExecutionEngine/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_llvm_library(LLVMExecutionEngine
22
ExecutionEngine.cpp
33
ExecutionEngineBindings.cpp
4+
TargetSelect.cpp
45
)
56

67
add_subdirectory(Interpreter)

llvm/lib/ExecutionEngine/JIT/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ add_llvm_library(LLVMJIT
99
JITEmitter.cpp
1010
JITMemoryManager.cpp
1111
OProfileJITEventListener.cpp
12-
TargetSelect.cpp
1312
)

llvm/lib/ExecutionEngine/JIT/JIT.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,21 @@ ExecutionEngine *JIT::createJIT(Module *M,
228228
StringRef MCPU,
229229
const SmallVectorImpl<std::string>& MAttrs) {
230230
// Try to register the program as a source of symbols to resolve against.
231+
//
232+
// FIXME: Don't do this here.
231233
sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
232234

233235
// Pick a target either via -march or by guessing the native arch.
234-
TargetMachine *TM = JIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
236+
//
237+
// FIXME: This should be lifted out of here, it isn't something which should
238+
// be part of the JIT policy, rather the burden for this selection should be
239+
// pushed to clients.
240+
TargetMachine *TM =
241+
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
235242
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
236243
TM->setCodeModel(CMM);
237244

238-
// If the target supports JIT code generation, create a the JIT.
245+
// If the target supports JIT code generation, create the JIT.
239246
if (TargetJITInfo *TJ = TM->getJITInfo()) {
240247
return new JIT(M, *TM, *TJ, JMM, OptLevel, GVsWithCode);
241248
} else {

llvm/lib/ExecutionEngine/JIT/JIT.h

-8
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,6 @@ class JIT : public ExecutionEngine {
181181
///
182182
JITCodeEmitter *getCodeEmitter() const { return JCE; }
183183

184-
/// selectTarget - Pick a target either via -march or by guessing the native
185-
/// arch. Add any CPU features specified via -mcpu or -mattr.
186-
static TargetMachine *selectTarget(Module *M,
187-
StringRef MArch,
188-
StringRef MCPU,
189-
const SmallVectorImpl<std::string>& MAttrs,
190-
std::string *Err);
191-
192184
static ExecutionEngine *createJIT(Module *M,
193185
std::string *ErrorStr,
194186
JITMemoryManager *JMM,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
add_llvm_library(LLVMMCJIT
22
MCJIT.cpp
3-
TargetSelect.cpp
43
Intercept.cpp
54
)

llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ ExecutionEngine *MCJIT::createJIT(Module *M,
5252
// FIXME: This should be lifted out of here, it isn't something which should
5353
// be part of the JIT policy, rather the burden for this selection should be
5454
// pushed to clients.
55-
TargetMachine *TM = MCJIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
55+
TargetMachine *TM =
56+
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
5657
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
5758
TM->setCodeModel(CMM);
5859

llvm/lib/ExecutionEngine/MCJIT/MCJIT.h

-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ class MCJIT : public ExecutionEngine {
7676
MCJITCtor = createJIT;
7777
}
7878

79-
// FIXME: This routine is scheduled for termination. Do not use it.
80-
static TargetMachine *selectTarget(Module *M,
81-
StringRef MArch,
82-
StringRef MCPU,
83-
const SmallVectorImpl<std::string>& MAttrs,
84-
std::string *Err);
85-
8679
static ExecutionEngine *createJIT(Module *M,
8780
std::string *ErrorStr,
8881
JITMemoryManager *JMM,

llvm/lib/ExecutionEngine/MCJIT/TargetSelect.cpp

-91
This file was deleted.

llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp llvm/lib/ExecutionEngine/TargetSelect.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//
1414
//===----------------------------------------------------------------------===//
1515

16-
#include "JIT.h"
16+
#include "llvm/ExecutionEngine/ExecutionEngine.h"
1717
#include "llvm/Module.h"
1818
#include "llvm/ADT/Triple.h"
1919
#include "llvm/Support/CommandLine.h"
@@ -26,11 +26,11 @@ using namespace llvm;
2626

2727
/// selectTarget - Pick a target either via -march or by guessing the native
2828
/// arch. Add any CPU features specified via -mcpu or -mattr.
29-
TargetMachine *JIT::selectTarget(Module *Mod,
30-
StringRef MArch,
31-
StringRef MCPU,
32-
const SmallVectorImpl<std::string>& MAttrs,
33-
std::string *ErrorStr) {
29+
TargetMachine *EngineBuilder::selectTarget(Module *Mod,
30+
StringRef MArch,
31+
StringRef MCPU,
32+
const SmallVectorImpl<std::string>& MAttrs,
33+
std::string *ErrorStr) {
3434
Triple TheTriple(Mod->getTargetTriple());
3535
if (TheTriple.getTriple().empty())
3636
TheTriple.setTriple(sys::getHostTriple());

0 commit comments

Comments
 (0)