aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-22 02:53:45 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-22 02:53:45 +0000
commitcb8ab23f7c800b041aeb6fc38c341d1aa0da86bf (patch)
tree45914778234d72e4e73e18a1461257b4c918d401 /lib/Driver/Driver.cpp
parent7cfe31a713d8fcfc2a1328e8fbd8efdeb0aec51b (diff)
(llvm up) Use llvm::Triple for storing target triples.
- This commit has some messy stuff in it to extend string lifetimes, but that will go away once we switch to using the enum'd Triple interfaces. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72243 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp69
1 files changed, 29 insertions, 40 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 3be083eb7e..76dc46cfa8 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -917,8 +917,11 @@ void Driver::BuildJobsForAction(Compilation &C,
if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
const char *ArchName = BAA->getArchName();
- if (!ArchName)
- ArchName = C.getDefaultToolChain().getArchName().c_str();
+ std::string Arch;
+ if (!ArchName) {
+ Arch = C.getDefaultToolChain().getArchName();
+ ArchName = Arch.c_str();
+ }
BuildJobsForAction(C,
*BAA->begin(),
Host->getToolChain(C.getArgs(), ArchName),
@@ -1133,48 +1136,34 @@ std::string Driver::GetTemporaryPath(const char *Suffix) const {
return P.toString();
}
-const HostInfo *Driver::GetHostInfo(const char *Triple) const {
+const HostInfo *Driver::GetHostInfo(const char *TripleStr) const {
llvm::PrettyStackTraceString CrashInfo("Constructing host");
- // Dice into arch, platform, and OS. This matches
- // arch,platform,os = '(.*?)-(.*?)-(.*?)'
- // and missing fields are left empty.
- std::string Arch, Platform, OS;
-
- if (const char *ArchEnd = strchr(Triple, '-')) {
- Arch = std::string(Triple, ArchEnd);
-
- if (const char *PlatformEnd = strchr(ArchEnd+1, '-')) {
- Platform = std::string(ArchEnd+1, PlatformEnd);
- OS = PlatformEnd+1;
- } else
- Platform = ArchEnd+1;
- } else
- Arch = Triple;
+ llvm::Triple Triple(TripleStr);
// Normalize Arch a bit.
//
- // FIXME: This is very incomplete.
- if (Arch == "i686")
- Arch = "i386";
- else if (Arch == "amd64")
- Arch = "x86_64";
- else if (Arch == "ppc" || Arch == "Power Macintosh")
- Arch = "powerpc";
- else if (Arch == "ppc64")
- Arch = "powerpc64";
-
- if (memcmp(&OS[0], "darwin", 6) == 0)
- return createDarwinHostInfo(*this, Arch.c_str(), Platform.c_str(),
- OS.c_str());
- if (memcmp(&OS[0], "freebsd", 7) == 0)
- return createFreeBSDHostInfo(*this, Arch.c_str(), Platform.c_str(),
- OS.c_str());
- if (memcmp(&OS[0], "dragonfly", 9) == 0)
- return createDragonFlyHostInfo(*this, Arch.c_str(), Platform.c_str(),
- OS.c_str());
-
- return createUnknownHostInfo(*this, Arch.c_str(), Platform.c_str(),
- OS.c_str());
+ // FIXME: We shouldn't need to do this once everything goes through the triple
+ // interface.
+ if (Triple.getArchName() == "i686")
+ Triple.setArchName("i386");
+ else if (Triple.getArchName() == "amd64")
+ Triple.setArchName("x86_64");
+ else if (Triple.getArchName() == "ppc" ||
+ Triple.getArchName() == "Power Macintosh")
+ Triple.setArchName("powerpc");
+ else if (Triple.getArchName() == "ppc64")
+ Triple.setArchName("powerpc64");
+
+ switch (Triple.getOS()) {
+ case llvm::Triple::Darwin:
+ return createDarwinHostInfo(*this, Triple);
+ case llvm::Triple::DragonFly:
+ return createDragonFlyHostInfo(*this, Triple);
+ case llvm::Triple::FreeBSD:
+ return createFreeBSDHostInfo(*this, Triple);
+ default:
+ return createUnknownHostInfo(*this, Triple);
+ }
}
bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,