forked from OSchip/llvm-project
Use Triple::isMIPS() instead of enumerating all Triples. NFC
Reviewed By: atanasyan Differential Revision: https://reviews.llvm.org/D48549 llvm-svn: 335495
This commit is contained in:
parent
65c50074c2
commit
742553da13
|
@ -200,9 +200,7 @@ ArrayRef<Builtin::Info> MipsTargetInfo::getTargetBuiltins() const {
|
|||
|
||||
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(DiagnosticsEngine &Diags) const {
|
|||
// 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(DiagnosticsEngine &Diags) const {
|
|||
// 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;
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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 ArgList &Args, const llvm::Triple &Triple,
|
|||
|
||||
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()) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1030,10 +1030,7 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) {
|
|||
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);
|
||||
|
|
|
@ -57,11 +57,10 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
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(Compilation &C, const JobAction &JA,
|
|||
}
|
||||
|
||||
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 llvm::Triple &Triple,
|
|||
|
||||
// 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 { return getSanitizerArgs().requiresPIE(); }
|
|||
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;
|
||||
|
|
|
@ -707,11 +707,10 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
|
|||
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::Triple::ArchType Arch) {
|
|||
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(const Driver &D,
|
|||
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::GCCInstallationDetector::ScanGCCForMultilibs(
|
|||
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)) {
|
||||
|
|
|
@ -156,7 +156,7 @@ static std::string getMultiarchTriple(const Driver &D,
|
|||
}
|
||||
|
||||
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::Triple &Triple, const ArgList &Args)
|
|||
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() const {
|
|||
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(const ArgList &Args) const {
|
|||
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(const ArgList &Args) const {
|
|||
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 ||
|
||||
|
|
|
@ -64,11 +64,10 @@ void netbsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
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;
|
||||
|
|
|
@ -68,10 +68,10 @@ void openbsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue