summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-02-05 16:19:36 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-02-05 16:19:36 +0000
commit31faefff92597d8689b6650ed9f2d21870b7f5f8 (patch)
treef97ada0f7757538916a14f767b47bcf6a2c72ced /llvm/lib
parentaf77cd220a45ae9445b5e6d464d8dd019af6d2ea (diff)
downloadbcm5719-llvm-31faefff92597d8689b6650ed9f2d21870b7f5f8.tar.gz
bcm5719-llvm-31faefff92597d8689b6650ed9f2d21870b7f5f8.zip
Move --march, --mcpu, and --mattr from JIT/TargetSelect.cpp to lli.cpp.
llc.cpp also defined these flags, meaning that when I linked all of LLVM's libraries into a single shared library, llc crashed on startup with duplicate flag definitions. This patch passes them through the EngineBuilder into JIT::selectTarget(). llvm-svn: 95390
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp19
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JIT.cpp17
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JIT.h13
-rw-r--r--llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp22
4 files changed, 40 insertions, 31 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 7d629af83cb..3e684e116d0 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -35,12 +35,16 @@ using namespace llvm;
STATISTIC(NumInitBytes, "Number of bytes of global vars initialized");
STATISTIC(NumGlobals , "Number of global vars initialized");
-ExecutionEngine *(*ExecutionEngine::JITCtor)(Module *M,
- std::string *ErrorStr,
- JITMemoryManager *JMM,
- CodeGenOpt::Level OptLevel,
- bool GVsWithCode,
- CodeModel::Model CMM) = 0;
+ExecutionEngine *(*ExecutionEngine::JITCtor)(
+ Module *M,
+ std::string *ErrorStr,
+ JITMemoryManager *JMM,
+ CodeGenOpt::Level OptLevel,
+ bool GVsWithCode,
+ CodeModel::Model CMM,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs) = 0;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
std::string *ErrorStr) = 0;
ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0;
@@ -412,7 +416,8 @@ ExecutionEngine *EngineBuilder::create() {
if (ExecutionEngine::JITCtor) {
ExecutionEngine *EE =
ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel,
- AllocateGVsWithCode, CMModel);
+ AllocateGVsWithCode, CMModel,
+ MArch, MCPU, MAttrs);
if (EE) return EE;
}
}
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
index 15627675a56..56a0bdde6bb 100644
--- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
@@ -198,8 +198,14 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel,
bool GVsWithCode,
- CodeModel::Model CMM) {
- return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, CMM);
+ CodeModel::Model CMM) {
+ // Use the defaults for extra parameters. Users can use EngineBuilder to
+ // set them.
+ StringRef MArch = "";
+ StringRef MCPU = "";
+ SmallVector<std::string, 1> MAttrs;
+ return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, CMM,
+ MArch, MCPU, MAttrs);
}
ExecutionEngine *JIT::createJIT(Module *M,
@@ -207,14 +213,17 @@ ExecutionEngine *JIT::createJIT(Module *M,
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel,
bool GVsWithCode,
- CodeModel::Model CMM) {
+ CodeModel::Model CMM,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs) {
// Make sure we can resolve symbols in the program as well. The zero arg
// to the function tells DynamicLibrary to load the program, not a library.
if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
return 0;
// Pick a target either via -march or by guessing the native arch.
- TargetMachine *TM = JIT::selectTarget(M, ErrorStr);
+ TargetMachine *TM = JIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
TM->setCodeModel(CMM);
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.h b/llvm/lib/ExecutionEngine/JIT/JIT.h
index 8aea5dfb261..bb8f851a537 100644
--- a/llvm/lib/ExecutionEngine/JIT/JIT.h
+++ b/llvm/lib/ExecutionEngine/JIT/JIT.h
@@ -70,7 +70,7 @@ public:
~JIT();
static void Register() {
- JITCtor = create;
+ JITCtor = createJIT;
}
/// getJITInfo - Return the target JIT information structure.
@@ -164,14 +164,21 @@ public:
/// selectTarget - Pick a target either via -march or by guessing the native
/// arch. Add any CPU features specified via -mcpu or -mattr.
- static TargetMachine *selectTarget(Module *M, std::string *Err);
+ static TargetMachine *selectTarget(Module *M,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs,
+ std::string *Err);
static ExecutionEngine *createJIT(Module *M,
std::string *ErrorStr,
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel,
bool GVsWithCode,
- CodeModel::Model CMM);
+ CodeModel::Model CMM,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs);
// Run the JIT on F and return information about the generated code
void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0);
diff --git a/llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp b/llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp
index b462ee73695..3349c338052 100644
--- a/llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp
@@ -24,25 +24,13 @@
#include "llvm/Target/TargetRegistry.h"
using namespace llvm;
-static cl::opt<std::string>
-MArch("march",
- cl::desc("Architecture to generate assembly for (see --version)"));
-
-static cl::opt<std::string>
-MCPU("mcpu",
- cl::desc("Target a specific cpu type (-mcpu=help for details)"),
- cl::value_desc("cpu-name"),
- cl::init(""));
-
-static cl::list<std::string>
-MAttrs("mattr",
- cl::CommaSeparated,
- cl::desc("Target specific attributes (-mattr=help for details)"),
- cl::value_desc("a1,+a2,-a3,..."));
-
/// selectTarget - Pick a target either via -march or by guessing the native
/// arch. Add any CPU features specified via -mcpu or -mattr.
-TargetMachine *JIT::selectTarget(Module *Mod, std::string *ErrorStr) {
+TargetMachine *JIT::selectTarget(Module *Mod,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs,
+ std::string *ErrorStr) {
Triple TheTriple(Mod->getTargetTriple());
if (TheTriple.getTriple().empty())
TheTriple.setTriple(sys::getHostTriple());
OpenPOWER on IntegriCloud