Author: arichardson Date: Mon Jun 25 09:49:52 2018 New Revision: 335495 URL: http://llvm.org/viewvc/llvm-project?rev=335495&view=rev Log: Use Triple::isMIPS() instead of enumerating all Triples. NFC
Reviewed By: atanasyan Differential Revision: https://reviews.llvm.org/D48549 Modified: cfe/trunk/lib/Basic/Targets/Mips.cpp cfe/trunk/lib/Basic/Targets/Mips.h cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Modified: cfe/trunk/lib/Basic/Targets/Mips.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/Mips.cpp (original) +++ cfe/trunk/lib/Basic/Targets/Mips.cpp Mon Jun 25 09:49:52 2018 @@ -200,9 +200,7 @@ ArrayRef<Builtin::Info> MipsTargetInfo:: bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const { // microMIPS64R6 backend was removed. - if ((getTriple().getArch() == llvm::Triple::mips64 || - getTriple().getArch() == llvm::Triple::mips64el) && - IsMicromips && (ABI == "n32" || ABI == "n64")) { + if (getTriple().isMIPS64() && IsMicromips && (ABI == "n32" || ABI == "n64")) { Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU; return false; } @@ -222,9 +220,7 @@ bool MipsTargetInfo::validateTarget(Diag // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend // can't handle this yet. It's better to fail here than on the // backend assertion. - if ((getTriple().getArch() == llvm::Triple::mips64 || - getTriple().getArch() == llvm::Triple::mips64el) && - ABI == "o32") { + if (getTriple().isMIPS64() && ABI == "o32") { Diags.Report(diag::err_target_unsupported_abi_for_triple) << ABI << getTriple().str(); return false; @@ -233,9 +229,7 @@ bool MipsTargetInfo::validateTarget(Diag // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend // can't handle this yet. It's better to fail here than on the // backend assertion. - if ((getTriple().getArch() == llvm::Triple::mips || - getTriple().getArch() == llvm::Triple::mipsel) && - (ABI == "n32" || ABI == "n64")) { + if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) { Diags.Report(diag::err_target_unsupported_abi_for_triple) << ABI << getTriple().str(); return false; Modified: cfe/trunk/lib/Basic/Targets/Mips.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.h?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/Mips.h (original) +++ cfe/trunk/lib/Basic/Targets/Mips.h Mon Jun 25 09:49:52 2018 @@ -69,10 +69,7 @@ public: UseIndirectJumpHazard(false), HasFP64(false) { TheCXXABI.set(TargetCXXABI::GenericMIPS); - setABI((getTriple().getArch() == llvm::Triple::mips || - getTriple().getArch() == llvm::Triple::mipsel) - ? "o32" - : "n64"); + setABI(getTriple().isMIPS32() ? "o32" : "n64"); CPU = ABI == "o32" ? "mips32r2" : "mips64r2"; Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon Jun 25 09:49:52 2018 @@ -20,11 +20,6 @@ using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; -bool tools::isMipsArch(llvm::Triple::ArchType Arch) { - return Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel || - Arch == llvm::Triple::mips64 || Arch == llvm::Triple::mips64el; -} - // Get CPU and ABI names. They are not independent // so we have to calculate them together. void mips::getMipsCPUAndABI(const ArgList &Args, const llvm::Triple &Triple, @@ -106,11 +101,7 @@ void mips::getMipsCPUAndABI(const ArgLis if (ABIName.empty()) { // Deduce ABI name from the target triple. - if (Triple.getArch() == llvm::Triple::mips || - Triple.getArch() == llvm::Triple::mipsel) - ABIName = "o32"; - else - ABIName = "n64"; + ABIName = Triple.isMIPS32() ? "o32" : "n64"; } if (CPUName.empty()) { Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h Mon Jun 25 09:49:52 2018 @@ -21,8 +21,6 @@ namespace clang { namespace driver { namespace tools { -bool isMipsArch(llvm::Triple::ArchType Arch); - namespace mips { typedef enum { Legacy = 1, Std2008 = 2 } IEEE754Standard; Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon Jun 25 09:49:52 2018 @@ -1030,10 +1030,7 @@ tools::ParsePICArgs(const ToolChain &Too if ((ROPI || RWPI) && (PIC || PIE)) ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic); - if (Triple.getArch() == llvm::Triple::mips || - Triple.getArch() == llvm::Triple::mipsel || - Triple.getArch() == llvm::Triple::mips64 || - Triple.getArch() == llvm::Triple::mips64el) { + if (Triple.isMIPS()) { StringRef CPUName; StringRef ABIName; mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName); Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp Mon Jun 25 09:49:52 2018 @@ -57,11 +57,10 @@ void freebsd::Assembler::ConstructJob(Co CmdArgs.push_back("-mabi"); CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data()); - if (getToolChain().getArch() == llvm::Triple::mips || - getToolChain().getArch() == llvm::Triple::mips64) - CmdArgs.push_back("-EB"); - else + if (getToolChain().getTriple().isLittleEndian()) CmdArgs.push_back("-EL"); + else + CmdArgs.push_back("-EB"); if (Arg *A = Args.getLastArg(options::OPT_G)) { StringRef v = A->getValue(); @@ -179,10 +178,7 @@ void freebsd::Linker::ConstructJob(Compi } if (Arg *A = Args.getLastArg(options::OPT_G)) { - if (ToolChain.getArch() == llvm::Triple::mips || - ToolChain.getArch() == llvm::Triple::mipsel || - ToolChain.getArch() == llvm::Triple::mips64 || - ToolChain.getArch() == llvm::Triple::mips64el) { + if (ToolChain.getTriple().isMIPS()) { StringRef v = A->getValue(); CmdArgs.push_back(Args.MakeArgString("-G" + v)); A->claim(); @@ -322,9 +318,7 @@ FreeBSD::FreeBSD(const Driver &D, const // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall // back to '/usr/lib' if it doesn't exist. - if ((Triple.getArch() == llvm::Triple::x86 || - Triple.getArch() == llvm::Triple::mips || - Triple.getArch() == llvm::Triple::mipsel || + if ((Triple.getArch() == llvm::Triple::x86 || Triple.isMIPS32() || Triple.getArch() == llvm::Triple::ppc) && D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o")) getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32"); @@ -389,8 +383,7 @@ bool FreeBSD::isPIEDefault() const { ret SanitizerMask FreeBSD::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; - const bool IsMIPS64 = getTriple().getArch() == llvm::Triple::mips64 || - getTriple().getArch() == llvm::Triple::mips64el; + const bool IsMIPS64 = getTriple().isMIPS32(); SanitizerMask Res = ToolChain::getSupportedSanitizers(); Res |= SanitizerKind::Address; Res |= SanitizerKind::Vptr; Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Jun 25 09:49:52 2018 @@ -707,11 +707,10 @@ void tools::gnutools::Assembler::Constru if (ABIName != "64" && !Args.hasArg(options::OPT_mno_abicalls)) CmdArgs.push_back("-call_nonpic"); - if (getToolChain().getArch() == llvm::Triple::mips || - getToolChain().getArch() == llvm::Triple::mips64) - CmdArgs.push_back("-EB"); - else + if (getToolChain().getTriple().isLittleEndian()) CmdArgs.push_back("-EL"); + else + CmdArgs.push_back("-EB"); if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) { if (StringRef(A->getValue()) == "2008") @@ -835,14 +834,6 @@ static bool isArmOrThumbArch(llvm::Tripl return Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb; } -static bool isMips32(llvm::Triple::ArchType Arch) { - return Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel; -} - -static bool isMips64(llvm::Triple::ArchType Arch) { - return Arch == llvm::Triple::mips64 || Arch == llvm::Triple::mips64el; -} - static bool isMipsEL(llvm::Triple::ArchType Arch) { return Arch == llvm::Triple::mipsel || Arch == llvm::Triple::mips64el; } @@ -1305,8 +1296,8 @@ bool clang::driver::findMIPSMultilibs(co llvm::Triple::ArchType TargetArch = TargetTriple.getArch(); Multilib::flags_list Flags; - addMultilibFlag(isMips32(TargetArch), "m32", Flags); - addMultilibFlag(isMips64(TargetArch), "m64", Flags); + addMultilibFlag(TargetTriple.isMIPS32(), "m32", Flags); + addMultilibFlag(TargetTriple.isMIPS64(), "m64", Flags); addMultilibFlag(isMips16(Args), "mips16", Flags); addMultilibFlag(CPUName == "mips32", "march=mips32", Flags); addMultilibFlag(CPUName == "mips32r2" || CPUName == "mips32r3" || @@ -2151,7 +2142,7 @@ bool Generic_GCC::GCCInstallationDetecto if (isArmOrThumbArch(TargetArch) && TargetTriple.isAndroid()) { // It should also work without multilibs in a simplified toolchain. findAndroidArmMultilibs(D, TargetTriple, Path, Args, Detected); - } else if (tools::isMipsArch(TargetArch)) { + } else if (TargetTriple.isMIPS()) { if (!findMIPSMultilibs(D, TargetTriple, Path, Args, Detected)) return false; } else if (isRISCV(TargetArch)) { Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Mon Jun 25 09:49:52 2018 @@ -156,7 +156,7 @@ static std::string getMultiarchTriple(co } static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { - if (tools::isMipsArch(Triple.getArch())) { + if (Triple.isMIPS()) { if (Triple.isAndroid()) { StringRef CPUName; StringRef ABIName; @@ -242,7 +242,7 @@ Linux::Linux(const Driver &D, const llvm ExtraOpts.push_back("-X"); const bool IsAndroid = Triple.isAndroid(); - const bool IsMips = tools::isMipsArch(Arch); + const bool IsMips = Triple.isMIPS(); const bool IsHexagon = Arch == llvm::Triple::hexagon; const bool IsRISCV = Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64; @@ -438,7 +438,7 @@ std::string Linux::computeSysRoot() cons return AndroidSysRootPath; } - if (!GCCInstallation.isValid() || !tools::isMipsArch(getTriple().getArch())) + if (!GCCInstallation.isValid() || !getTriple().isMIPS()) return std::string(); // Standalone MIPS toolchains use different names for sysroot folder @@ -530,8 +530,6 @@ std::string Linux::getDynamicLinker(cons case llvm::Triple::mipsel: case llvm::Triple::mips64: case llvm::Triple::mips64el: { - bool LE = (Triple.getArch() == llvm::Triple::mipsel) || - (Triple.getArch() == llvm::Triple::mips64el); bool IsNaN2008 = tools::mips::isNaN2008(Args, Triple); LibDir = "lib" + tools::mips::getMipsABILibSuffix(Args, Triple); @@ -540,7 +538,8 @@ std::string Linux::getDynamicLinker(cons Loader = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0"; else if (!Triple.hasEnvironment() && Triple.getVendor() == llvm::Triple::VendorType::MipsTechnologies) - Loader = LE ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1"; + Loader = + Triple.isLittleEndian() ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1"; else Loader = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1"; @@ -894,10 +893,8 @@ bool Linux::isPIEDefault() const { SanitizerMask Linux::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; - const bool IsMIPS = getTriple().getArch() == llvm::Triple::mips || - getTriple().getArch() == llvm::Triple::mipsel; - const bool IsMIPS64 = getTriple().getArch() == llvm::Triple::mips64 || - getTriple().getArch() == llvm::Triple::mips64el; + const bool IsMIPS = getTriple().isMIPS32(); + const bool IsMIPS64 = getTriple().isMIPS64(); const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || getTriple().getArch() == llvm::Triple::ppc64le; const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 || Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Mon Jun 25 09:49:52 2018 @@ -64,11 +64,10 @@ void netbsd::Assembler::ConstructJob(Com CmdArgs.push_back("-mabi"); CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data()); - if (getToolChain().getArch() == llvm::Triple::mips || - getToolChain().getArch() == llvm::Triple::mips64) - CmdArgs.push_back("-EB"); - else + if (getToolChain().getTriple().isLittleEndian()) CmdArgs.push_back("-EL"); + else + CmdArgs.push_back("-EB"); AddAssemblerKPIC(getToolChain(), Args, CmdArgs); break; Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=335495&r1=335494&r2=335495&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Mon Jun 25 09:49:52 2018 @@ -68,10 +68,10 @@ void openbsd::Assembler::ConstructJob(Co CmdArgs.push_back("-mabi"); CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data()); - if (getToolChain().getArch() == llvm::Triple::mips64) - CmdArgs.push_back("-EB"); - else + if (getToolChain().getTriple().isLittleEndian()) CmdArgs.push_back("-EL"); + else + CmdArgs.push_back("-EB"); AddAssemblerKPIC(getToolChain(), Args, CmdArgs); break; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits