We need to parse mArch ourselves now

Build fix for LLVM r75890
This commit is contained in:
Benjamin Kramer 2009-07-17 19:23:20 +02:00
parent 7359448063
commit ac5bd294ca
3 changed files with 22 additions and 12 deletions

View file

@ -205,8 +205,7 @@ cl::opt<std::string> moduleDepsFile("deps",
cl::value_desc("filename")); cl::value_desc("filename"));
cl::opt<const llvm::TargetMachineRegistry::entry*, false, cl::opt<std::string> mArch("march",
llvm::RegistryParser<llvm::TargetMachine> > mArch("march",
cl::desc("Architecture to generate code for:")); cl::desc("Architecture to generate code for:"));
cl::opt<bool> m32bits("m32", cl::opt<bool> m32bits("m32",

View file

@ -6,8 +6,6 @@
#include <deque> #include <deque>
#include <vector> #include <vector>
#include "llvm/Support/RegistryParser.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
namespace opts { namespace opts {
@ -37,8 +35,7 @@ namespace opts {
extern cl::list<std::string> versions; extern cl::list<std::string> versions;
extern cl::opt<std::string> moduleDepsFile; extern cl::opt<std::string> moduleDepsFile;
extern cl::opt<const llvm::TargetMachineRegistry::entry*, false, extern cl::opt<std::string> mArch;
llvm::RegistryParser<llvm::TargetMachine> > mArch;
extern cl::opt<bool> m32bits; extern cl::opt<bool> m32bits;
extern cl::opt<bool> m64bits; extern cl::opt<bool> m64bits;
extern cl::opt<std::string> mCPU; extern cl::opt<std::string> mCPU;

View file

@ -12,7 +12,7 @@
#include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetSelect.h" #include "llvm/Target/TargetSelect.h"
#include <stdio.h> #include <stdio.h>
@ -397,7 +397,7 @@ int main(int argc, char** argv)
// check -m32/64 sanity // check -m32/64 sanity
if (m32bits && m64bits) if (m32bits && m64bits)
error("cannot use both -m32 and -m64 options"); error("cannot use both -m32 and -m64 options");
else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty())) else if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty()))
error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches"); error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches");
if (global.errors) if (global.errors)
fatal(); fatal();
@ -415,7 +415,7 @@ int main(int argc, char** argv)
// did the user override the target triple? // did the user override the target triple?
if (mTargetTriple.empty()) if (mTargetTriple.empty())
{ {
if (mArch != 0) if (!mArch.empty())
{ {
error("you must specify a target triple as well with -mtriple when using the -march option"); error("you must specify a target triple as well with -mtriple when using the -march option");
fatal(); fatal();
@ -437,9 +437,9 @@ int main(int argc, char** argv)
LDC_TARGETS LDC_TARGETS
#undef LLVM_TARGET #undef LLVM_TARGET
const llvm::Target *theTarget; const llvm::Target *theTarget = NULL;
// Check whether the user has explicitly specified an architecture to compile for. // Check whether the user has explicitly specified an architecture to compile for.
if (mArch == 0) if (mArch.empty())
{ {
std::string Err; std::string Err;
theTarget = llvm::TargetRegistry::getClosestStaticTargetForModule(mod, Err); theTarget = llvm::TargetRegistry::getClosestStaticTargetForModule(mod, Err);
@ -451,7 +451,21 @@ LDC_TARGETS
} }
else else
{ {
theTarget = &mArch->TheTarget; for (llvm::TargetRegistry::iterator it = llvm::TargetRegistry::begin(),
ie = llvm::TargetRegistry::end(); it != ie; ++it)
{
if (mArch == it->getName())
{
theTarget = &*it;
break;
}
}
if (!theTarget)
{
error("invalid target '%s'", mArch.c_str());
fatal();
}
} }
// Package up features to be passed to target/subtarget // Package up features to be passed to target/subtarget