From: Rafael Espindola Date: Sun, 7 Oct 2012 04:44:33 +0000 (+0000) Subject: Use getArch instead of getArchName + string compare. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64f7ad9328e877779ec63638f39de4e10d2ff276;p=clang Use getArch instead of getArchName + string compare. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165370 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 54f8c42294..7b6e2082bc 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -713,11 +713,11 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, if (A->getOption().matches(options::OPT_Xarch__)) { // Skip this argument unless the architecture matches either the toolchain // triple arch, or the arch being bound. - // - // FIXME: Canonicalize name. - StringRef XarchArch = A->getValue(Args, 0); - if (!(XarchArch == getArchName() || - (BoundArch && XarchArch == BoundArch))) + llvm::Triple::ArchType XarchArch = + llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args, 0)); + if (!(XarchArch == getArch() || + (BoundArch && XarchArch == + llvm::Triple::getArchTypeForDarwinArchName(BoundArch)))) continue; Arg *OriginalArg = A; @@ -975,14 +975,14 @@ const char *Darwin::GetDefaultRelocationModel() const { } const char *Darwin::GetForcedPicModel() const { - if (getArchName() == "x86_64") + if (getArch() == llvm::Triple::x86_64) return "pic"; return 0; } bool Darwin::SupportsProfiling() const { // Profiling instrumentation is only supported on x86. - return getArchName() == "i386" || getArchName() == "x86_64"; + return getArch() == llvm::Triple::x86 || getArch() == llvm::Triple::x86_64; } bool Darwin::SupportsObjCGC() const { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 9f068b9d7c..71c7ca201c 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -3194,17 +3194,17 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, RenderExtraToolArgs(JA, CmdArgs); // If using a driver driver, force the arch. - const std::string &Arch = getToolChain().getArchName(); + llvm::Triple::ArchType Arch = getToolChain().getArch(); if (getToolChain().getTriple().isOSDarwin()) { CmdArgs.push_back("-arch"); // FIXME: Remove these special cases. - if (Arch == "powerpc") + if (Arch == llvm::Triple::ppc) CmdArgs.push_back("ppc"); - else if (Arch == "powerpc64") + else if (Arch == llvm::Triple::ppc64) CmdArgs.push_back("ppc64"); else - CmdArgs.push_back(Args.MakeArgString(Arch)); + CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName())); } // Try to force gcc to match the tool chain we want, if we recognize @@ -3212,9 +3212,9 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, // // FIXME: The triple class should directly provide the information we want // here. - if (Arch == "i386" || Arch == "powerpc") + if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::ppc) CmdArgs.push_back("-m32"); - else if (Arch == "x86_64" || Arch == "powerpc64") + else if (Arch == llvm::Triple::x86_64 || Arch == llvm::Triple::x86_64) CmdArgs.push_back("-m64"); if (Output.isFilename()) { @@ -3874,7 +3874,7 @@ void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args, Args.AddLastArg(CmdArgs, options::OPT_P); // FIXME: Handle %I properly. - if (getToolChain().getArchName() == "x86_64") { + if (getToolChain().getArch() == llvm::Triple::x86_64) { CmdArgs.push_back("-imultilib"); CmdArgs.push_back("x86_64"); } @@ -4552,7 +4552,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, !Args.hasArg(options::OPT_nodefaultlibs)) { // Avoid linking compatibility stubs on i386 mac. if (!getDarwinToolChain().isTargetMacOS() || - getDarwinToolChain().getArchName() != "i386") { + getDarwinToolChain().getArch() != llvm::Triple::x86) { // If we don't have ARC or subscripting runtime support, link in the // runtime stubs. We have to do this *before* adding any of the normal // linker inputs so that its initializer gets run first. @@ -5301,12 +5301,12 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, // When building 32-bit code on FreeBSD/amd64, we have to explicitly // instruct ld in the base system to link 32-bit code. - if (ToolChain.getArchName() == "i386") { + if (ToolChain.getArch() == llvm::Triple::x86) { CmdArgs.push_back("-m"); CmdArgs.push_back("elf_i386_fbsd"); } - if (ToolChain.getArchName() == "powerpc") { + if (ToolChain.getArch() == llvm::Triple::ppc) { CmdArgs.push_back("-m"); CmdArgs.push_back("elf32ppc_fbsd"); } @@ -5442,9 +5442,9 @@ void netbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("--32"); // Set byte order explicitly - if (getToolChain().getArchName() == "mips") + if (getToolChain().getArch() == llvm::Triple::mips) CmdArgs.push_back("-EB"); - else if (getToolChain().getArchName() == "mipsel") + else if (getToolChain().getArch() == llvm::Triple::mipsel) CmdArgs.push_back("-EL"); Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, @@ -6002,7 +6002,7 @@ void dragonfly::Assemble::ConstructJob(Compilation &C, const JobAction &JA, // When building 32-bit code on DragonFly/pc64, we have to explicitly // instruct as in the base system to assemble 32-bit code. - if (getToolChain().getArchName() == "i386") + if (getToolChain().getArch() == llvm::Triple::x86) CmdArgs.push_back("--32"); Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, @@ -6046,7 +6046,7 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, // When building 32-bit code on DragonFly/pc64, we have to explicitly // instruct ld in the base system to link 32-bit code. - if (getToolChain().getArchName() == "i386") { + if (getToolChain().getArch() == llvm::Triple::x86) { CmdArgs.push_back("-m"); CmdArgs.push_back("elf_i386"); } diff --git a/lib/Driver/WindowsToolChain.cpp b/lib/Driver/WindowsToolChain.cpp index 080e0d6504..ac6518712f 100644 --- a/lib/Driver/WindowsToolChain.cpp +++ b/lib/Driver/WindowsToolChain.cpp @@ -89,7 +89,7 @@ const char *Windows::GetDefaultRelocationModel() const { } const char *Windows::GetForcedPicModel() const { - if (getArchName() == "x86_64") + if (getArch() == llvm::Triple::x86_64) return "pic"; return 0; }