forked from OSchip/llvm-project
Change Darwin toolchain lookup to use llvm::Triple.
- -2+1 FIXMEs. llvm-svn: 81282
This commit is contained in:
parent
9c3f7c4a4b
commit
faabdc3b81
|
@ -47,7 +47,7 @@ class DarwinHostInfo : public HostInfo {
|
|||
unsigned GCCVersion[3];
|
||||
|
||||
/// Cache of tool chains we have created.
|
||||
mutable llvm::StringMap<ToolChain *> ToolChains;
|
||||
mutable llvm::DenseMap<unsigned, ToolChain*> ToolChains;
|
||||
|
||||
public:
|
||||
DarwinHostInfo(const Driver &D, const llvm::Triple &Triple);
|
||||
|
@ -73,20 +73,14 @@ public:
|
|||
DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple)
|
||||
: HostInfo(D, Triple) {
|
||||
|
||||
assert((getArchName() == "i386" || getArchName() == "x86_64" ||
|
||||
getArchName() == "powerpc" || getArchName() == "powerpc64" ||
|
||||
getArchName() == "arm") &&
|
||||
"Unknown Darwin arch.");
|
||||
|
||||
assert(Triple.getArch() != llvm::Triple::UnknownArch && "Invalid arch!");
|
||||
assert(memcmp(&getOSName()[0], "darwin", 6) == 0 &&
|
||||
"Unknown Darwin platform.");
|
||||
bool HadExtra;
|
||||
if (!Driver::GetReleaseVersion(&getOSName()[6],
|
||||
DarwinVersion[0], DarwinVersion[1],
|
||||
DarwinVersion[2], HadExtra)) {
|
||||
D.Diag(clang::diag::err_drv_invalid_darwin_version)
|
||||
<< getOSName();
|
||||
}
|
||||
DarwinVersion[2], HadExtra))
|
||||
D.Diag(clang::diag::err_drv_invalid_darwin_version) << getOSName();
|
||||
|
||||
// We can only call 4.2.1 for now.
|
||||
GCCVersion[0] = 4;
|
||||
|
@ -95,7 +89,7 @@ DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple)
|
|||
}
|
||||
|
||||
DarwinHostInfo::~DarwinHostInfo() {
|
||||
for (llvm::StringMap<ToolChain*>::iterator
|
||||
for (llvm::DenseMap<unsigned, ToolChain*>::iterator
|
||||
it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
|
||||
delete it->second;
|
||||
}
|
||||
|
@ -106,66 +100,57 @@ bool DarwinHostInfo::useDriverDriver() const {
|
|||
|
||||
ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
|
||||
const char *ArchName) const {
|
||||
std::string Arch;
|
||||
llvm::Triple::ArchType Arch;
|
||||
|
||||
if (!ArchName) {
|
||||
// If we aren't looking for a specific arch, infer the default architecture
|
||||
// based on -arch and -m32/-m64 command line options.
|
||||
if (Arg *A = Args.getLastArg(options::OPT_arch)) {
|
||||
// The gcc driver behavior with multiple -arch flags wasn't consistent for
|
||||
// things which rely on a default architecture. We just use the last -arch
|
||||
// to find the default tool chain.
|
||||
Arch = A->getValue(Args);
|
||||
// to find the default tool chain (assuming it is valid..
|
||||
Arch = llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args));
|
||||
|
||||
// Normalize arch name; we shouldn't be doing this here.
|
||||
//
|
||||
// FIXME: This should be unnecessary once everything moves over to using
|
||||
// the ID based Triple interface.
|
||||
if (Arch == "ppc")
|
||||
Arch = "powerpc";
|
||||
else if (Arch == "ppc64")
|
||||
Arch = "powerpc64";
|
||||
// If it was invalid just use the host, we will reject this command line
|
||||
// later.
|
||||
if (Arch == llvm::Triple::UnknownArch)
|
||||
Arch = getTriple().getArch();
|
||||
} else {
|
||||
// Otherwise default to the arch of the host.
|
||||
Arch = getArchName();
|
||||
Arch = getTriple().getArch();
|
||||
}
|
||||
ArchName = Arch.c_str();
|
||||
|
||||
// Honor -m32 and -m64 when finding the default tool chain.
|
||||
//
|
||||
// FIXME: Should this information be in llvm::Triple?
|
||||
if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
|
||||
if (Arch == "i386" || Arch == "x86_64") {
|
||||
ArchName = (A->getOption().getId() == options::OPT_m32) ? "i386" :
|
||||
"x86_64";
|
||||
} else if (Arch == "powerpc" || Arch == "powerpc64") {
|
||||
ArchName = (A->getOption().getId() == options::OPT_m32) ? "powerpc" :
|
||||
"powerpc64";
|
||||
if (A->getOption().getId() == options::OPT_m32) {
|
||||
if (Arch == llvm::Triple::x86_64)
|
||||
Arch = llvm::Triple::x86;
|
||||
if (Arch == llvm::Triple::ppc64)
|
||||
Arch = llvm::Triple::ppc;
|
||||
} else {
|
||||
if (Arch == llvm::Triple::x86)
|
||||
Arch = llvm::Triple::x86_64;
|
||||
if (Arch == llvm::Triple::ppc)
|
||||
Arch = llvm::Triple::ppc64;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Normalize arch name; we shouldn't be doing this here.
|
||||
//
|
||||
// FIXME: This should be unnecessary once everything moves over to using the
|
||||
// ID based Triple interface.
|
||||
if (strcmp(ArchName, "ppc") == 0)
|
||||
ArchName = "powerpc";
|
||||
else if (strcmp(ArchName, "ppc64") == 0)
|
||||
ArchName = "powerpc64";
|
||||
}
|
||||
} else
|
||||
Arch = llvm::Triple::getArchTypeForDarwinArchName(ArchName);
|
||||
|
||||
ToolChain *&TC = ToolChains[ArchName];
|
||||
assert(Arch != llvm::Triple::UnknownArch && "Unexpected arch!");
|
||||
ToolChain *&TC = ToolChains[Arch];
|
||||
if (!TC) {
|
||||
llvm::Triple TCTriple(getTriple());
|
||||
TCTriple.setArchName(ArchName);
|
||||
TCTriple.setArch(Arch);
|
||||
|
||||
if (strcmp(ArchName, "i386") == 0 || strcmp(ArchName, "x86_64") == 0)
|
||||
TC = new toolchains::Darwin(*this, TCTriple,
|
||||
DarwinVersion,
|
||||
GCCVersion,
|
||||
// If we recognized the arch, match it to the toolchains we support.
|
||||
if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64)
|
||||
TC = new toolchains::Darwin(*this, TCTriple, DarwinVersion, GCCVersion,
|
||||
false);
|
||||
else if (strncmp(ArchName, "arm", 3) == 0 ||
|
||||
strncmp(ArchName, "thumb", 5) == 0)
|
||||
TC = new toolchains::Darwin(*this, TCTriple,
|
||||
DarwinVersion,
|
||||
GCCVersion,
|
||||
else if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
|
||||
TC = new toolchains::Darwin(*this, TCTriple, DarwinVersion, GCCVersion,
|
||||
true);
|
||||
else
|
||||
TC = new toolchains::Darwin_GCC(*this, TCTriple);
|
||||
|
|
Loading…
Reference in New Issue