llvm.org GIT mirror llvm / 1d92921
Switch llc and createJIT to use simpler command line parsing for -march. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75890 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
3 changed file(s) with 42 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
138138 /// createJIT - This is the factory method for creating a JIT for the current
139139 /// machine, it does not fall back to the interpreter. This takes ownership
140140 /// of the ModuleProvider and JITMemoryManager if successful.
141 ///
142 /// Clients should make sure to initialize targets prior to calling this
143 /// function.
141144 static ExecutionEngine *createJIT(ModuleProvider *MP,
142145 std::string *ErrorStr = 0,
143146 JITMemoryManager *JMM = 0,
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This just asks the TargetMachineRegistry for the appropriate JIT to use, and
10 // allows the user to specify a specific one on the commandline with -march=x.
9 // This just asks the TargetRegistry for the appropriate JIT to use, and allows
10 // the user to specify a specific one on the commandline with -march=x. Clients
11 // should initialize targets prior to calling createJIT.
1112 //
1213 //===----------------------------------------------------------------------===//
1314
1819 #include "llvm/Support/Streams.h"
1920 #include "llvm/Target/SubtargetFeature.h"
2021 #include "llvm/Target/TargetMachine.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
22 #include "llvm/Target/TargetRegistry.h"
2223 using namespace llvm;
2324
24 static cl::opt
25 RegistryParser >
26 MArch("march", cl::desc("Architecture to generate assembly for:"));
25 static cl::opt
26 MArch("march", cl::desc("Architecture to generate assembly for (see --version)"));
2727
2828 static cl::opt
2929 MCPU("mcpu",
4444 JITMemoryManager *JMM,
4545 CodeGenOpt::Level OptLevel,
4646 bool AllocateGVsWithCode) {
47 const Target *TheTarget;
48 if (MArch == 0) {
47 const Target *TheTarget = 0;
48 if (MArch.empty()) {
4949 std::string Error;
5050 TheTarget = TargetRegistry::getClosestTargetForJIT(Error);
5151 if (TheTarget == 0) {
5454 return 0;
5555 }
5656 } else {
57 TheTarget = &MArch->TheTarget;
57 for (TargetRegistry::iterator it = TargetRegistry::begin(),
58 ie = TargetRegistry::end(); it != ie; ++it) {
59 if (MArch == it->getName()) {
60 TheTarget = &*it;
61 break;
62 }
63 }
64
65 if (TheTarget == 0) {
66 if (ErrorStr)
67 *ErrorStr = std::string("invalid target '" + MArch + "'.\n");
68 return 0;
69 }
70
5871 if (TheTarget->getJITMatchQuality() == 0) {
5972 cerr << "WARNING: This target JIT is not designed for the host you are"
6073 << " running. If bad things happen, please choose a different "
2020 #include "llvm/Target/SubtargetFeature.h"
2121 #include "llvm/Target/TargetData.h"
2222 #include "llvm/Target/TargetMachine.h"
23 #include "llvm/Target/TargetMachineRegistry.h"
23 #include "llvm/Target/TargetRegistry.h"
2424 #include "llvm/Transforms/Scalar.h"
2525 #include "llvm/LLVMContext.h"
2626 #include "llvm/Module.h"
3434 #include "llvm/Support/MemoryBuffer.h"
3535 #include "llvm/Support/PluginLoader.h"
3636 #include "llvm/Support/PrettyStackTrace.h"
37 #include "llvm/Support/RegistryParser.h"
3837 #include "llvm/Analysis/Verifier.h"
3938 #include "llvm/System/Signals.h"
4039 #include "llvm/Config/config.h"
6766 static cl::opt
6867 TargetTriple("mtriple", cl::desc("Override target triple for module"));
6968
70 static cl::opt
71 RegistryParser >
72 MArch("march", cl::desc("Architecture to generate code for:"));
69 static cl::opt
70 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
7371
7472 static cl::opt
7573 MCPU("mcpu",
237235
238236 // Allocate target machine. First, check whether the user has
239237 // explicitly specified an architecture to compile for.
240 const Target *TheTarget;
241 if (MArch) {
242 TheTarget = &MArch->TheTarget;
238 const Target *TheTarget = 0;
239 if (!MArch.empty()) {
240 for (TargetRegistry::iterator it = TargetRegistry::begin(),
241 ie = TargetRegistry::end(); it != ie; ++it) {
242 if (MArch == it->getName()) {
243 TheTarget = &*it;
244 break;
245 }
246 }
247
248 if (!TheTarget) {
249 errs() << argv[0] << ": error: invalid target '" << MArch << "'.\n";
250 return 1;
251 }
243252 } else {
244253 std::string Err;
245254 TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);