[llvm-commits] [llvm] r75890 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h lib/ExecutionEngine/JIT/TargetSelect.cpp tools/llc/llc.cpp
Daniel Dunbar
daniel at zuster.org
Wed Jul 15 19:23:54 PDT 2009
Author: ddunbar
Date: Wed Jul 15 21:23:53 2009
New Revision: 75890
URL: http://llvm.org/viewvc/llvm-project?rev=75890&view=rev
Log:
Switch llc and createJIT to use simpler command line parsing for -march.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp
llvm/trunk/tools/llc/llc.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=75890&r1=75889&r2=75890&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Wed Jul 15 21:23:53 2009
@@ -139,6 +139,9 @@
/// createJIT - This is the factory method for creating a JIT for the current
/// machine, it does not fall back to the interpreter. This takes ownership
/// of the ModuleProvider and JITMemoryManager if successful.
+ ///
+ /// Clients should make sure to initialize targets prior to calling this
+ /// function.
static ExecutionEngine *createJIT(ModuleProvider *MP,
std::string *ErrorStr = 0,
JITMemoryManager *JMM = 0,
Modified: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp?rev=75890&r1=75889&r2=75890&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp Wed Jul 15 21:23:53 2009
@@ -7,8 +7,9 @@
//
//===----------------------------------------------------------------------===//
//
-// This just asks the TargetMachineRegistry for the appropriate JIT to use, and
-// allows the user to specify a specific one on the commandline with -march=x.
+// This just asks the TargetRegistry for the appropriate JIT to use, and allows
+// the user to specify a specific one on the commandline with -march=x. Clients
+// should initialize targets prior to calling createJIT.
//
//===----------------------------------------------------------------------===//
@@ -19,12 +20,11 @@
#include "llvm/Support/Streams.h"
#include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetRegistry.h"
using namespace llvm;
-static cl::opt<const TargetMachineRegistry::entry*, false,
- RegistryParser<TargetMachine> >
-MArch("march", cl::desc("Architecture to generate assembly for:"));
+static cl::opt<std::string>
+MArch("march", cl::desc("Architecture to generate assembly for (see --version)"));
static cl::opt<std::string>
MCPU("mcpu",
@@ -45,8 +45,8 @@
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel,
bool AllocateGVsWithCode) {
- const Target *TheTarget;
- if (MArch == 0) {
+ const Target *TheTarget = 0;
+ if (MArch.empty()) {
std::string Error;
TheTarget = TargetRegistry::getClosestTargetForJIT(Error);
if (TheTarget == 0) {
@@ -55,7 +55,20 @@
return 0;
}
} else {
- TheTarget = &MArch->TheTarget;
+ for (TargetRegistry::iterator it = TargetRegistry::begin(),
+ ie = TargetRegistry::end(); it != ie; ++it) {
+ if (MArch == it->getName()) {
+ TheTarget = &*it;
+ break;
+ }
+ }
+
+ if (TheTarget == 0) {
+ if (ErrorStr)
+ *ErrorStr = std::string("invalid target '" + MArch + "'.\n");
+ return 0;
+ }
+
if (TheTarget->getJITMatchQuality() == 0) {
cerr << "WARNING: This target JIT is not designed for the host you are"
<< " running. If bad things happen, please choose a different "
Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=75890&r1=75889&r2=75890&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Wed Jul 15 21:23:53 2009
@@ -21,7 +21,7 @@
#include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetRegistry.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
@@ -35,7 +35,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
-#include "llvm/Support/RegistryParser.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
@@ -68,9 +67,8 @@
static cl::opt<std::string>
TargetTriple("mtriple", cl::desc("Override target triple for module"));
-static cl::opt<const TargetMachineRegistry::entry*, false,
- RegistryParser<TargetMachine> >
-MArch("march", cl::desc("Architecture to generate code for:"));
+static cl::opt<std::string>
+MArch("march", cl::desc("Architecture to generate code for (see --version)"));
static cl::opt<std::string>
MCPU("mcpu",
@@ -238,9 +236,20 @@
// Allocate target machine. First, check whether the user has
// explicitly specified an architecture to compile for.
- const Target *TheTarget;
- if (MArch) {
- TheTarget = &MArch->TheTarget;
+ const Target *TheTarget = 0;
+ if (!MArch.empty()) {
+ for (TargetRegistry::iterator it = TargetRegistry::begin(),
+ ie = TargetRegistry::end(); it != ie; ++it) {
+ if (MArch == it->getName()) {
+ TheTarget = &*it;
+ break;
+ }
+ }
+
+ if (!TheTarget) {
+ errs() << argv[0] << ": error: invalid target '" << MArch << "'.\n";
+ return 1;
+ }
} else {
std::string Err;
TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
More information about the llvm-commits
mailing list