abeserminji created this revision. As function getSupportedNanEncoding() relies on IEEE 754 Standard, new suggested name is getIEEE754Standard() which is more convenient to use in decision non related to NaN encoding.
Repository: rL LLVM https://reviews.llvm.org/D36824 Files: lib/Basic/Targets/Mips.h lib/Driver/ToolChains/Arch/Mips.cpp lib/Driver/ToolChains/Arch/Mips.h
Index: lib/Driver/ToolChains/Arch/Mips.h =================================================================== --- lib/Driver/ToolChains/Arch/Mips.h +++ lib/Driver/ToolChains/Arch/Mips.h @@ -24,15 +24,15 @@ bool isMipsArch(llvm::Triple::ArchType Arch); namespace mips { -typedef enum { NanLegacy = 1, Nan2008 = 2 } NanEncoding; +typedef enum { Legacy = 1, Std2008 = 2 } IEEE754Standard; enum class FloatABI { Invalid, Soft, Hard, }; -NanEncoding getSupportedNanEncoding(StringRef &CPU); +IEEE754Standard getIEEE754Standard(StringRef &CPU); bool hasCompactBranches(StringRef &CPU); void getMipsCPUAndABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple, StringRef &CPUName, Index: lib/Driver/ToolChains/Arch/Mips.cpp =================================================================== --- lib/Driver/ToolChains/Arch/Mips.cpp +++ lib/Driver/ToolChains/Arch/Mips.cpp @@ -266,14 +266,14 @@ if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) { StringRef Val = StringRef(A->getValue()); if (Val == "2008") { - if (mips::getSupportedNanEncoding(CPUName) & mips::Nan2008) + if (mips::getIEEE754Standard(CPUName) & mips::Std2008) Features.push_back("+nan2008"); else { Features.push_back("-nan2008"); D.Diag(diag::warn_target_unsupported_nan2008) << CPUName; } } else if (Val == "legacy") { - if (mips::getSupportedNanEncoding(CPUName) & mips::NanLegacy) + if (mips::getIEEE754Standard(CPUName) & mips::Legacy) Features.push_back("-nan2008"); else { Features.push_back("+nan2008"); @@ -324,27 +324,27 @@ AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt"); } -mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) { - // Strictly speaking, mips32r2 and mips64r2 are NanLegacy-only since Nan2008 - // was first introduced in Release 3. However, other compilers have - // traditionally allowed it for Release 2 so we should do the same. - return (NanEncoding)llvm::StringSwitch<int>(CPU) - .Case("mips1", NanLegacy) - .Case("mips2", NanLegacy) - .Case("mips3", NanLegacy) - .Case("mips4", NanLegacy) - .Case("mips5", NanLegacy) - .Case("mips32", NanLegacy) - .Case("mips32r2", NanLegacy | Nan2008) - .Case("mips32r3", NanLegacy | Nan2008) - .Case("mips32r5", NanLegacy | Nan2008) - .Case("mips32r6", Nan2008) - .Case("mips64", NanLegacy) - .Case("mips64r2", NanLegacy | Nan2008) - .Case("mips64r3", NanLegacy | Nan2008) - .Case("mips64r5", NanLegacy | Nan2008) - .Case("mips64r6", Nan2008) - .Default(NanLegacy); +mips::IEEE754Standard mips::getIEEE754Standard(StringRef &CPU) { + // Strictly speaking, mips32r2 and mips64r2 are not in accordance to standard + // from 2008, it was first introduced in Release 3. However, other compilers + // have traditionally allowed it for Release 2 so we should do the same. + return (IEEE754Standard)llvm::StringSwitch<int>(CPU) + .Case("mips1", Legacy) + .Case("mips2", Legacy) + .Case("mips3", Legacy) + .Case("mips4", Legacy) + .Case("mips5", Legacy) + .Case("mips32", Legacy) + .Case("mips32r2", Legacy | Std2008) + .Case("mips32r3", Legacy | Std2008) + .Case("mips32r5", Legacy | Std2008) + .Case("mips32r6", Std2008) + .Case("mips64", Legacy) + .Case("mips64r2", Legacy | Std2008) + .Case("mips64r3", Legacy | Std2008) + .Case("mips64r5", Legacy | Std2008) + .Case("mips64r6", Std2008) + .Default(Std2008); } bool mips::hasCompactBranches(StringRef &CPU) { Index: lib/Basic/Targets/Mips.h =================================================================== --- lib/Basic/Targets/Mips.h +++ lib/Basic/Targets/Mips.h @@ -77,7 +77,7 @@ Triple.getOS() == llvm::Triple::OpenBSD; } - bool isNaN2008Default() const { + bool isIEEE754_2008Default() const { return CPU == "mips32r6" || CPU == "mips64r6"; } @@ -299,7 +299,7 @@ DiagnosticsEngine &Diags) override { IsMips16 = false; IsMicromips = false; - IsNan2008 = isNaN2008Default(); + IsNan2008 = isIEEE754_2008Default(); IsSingleFloat = false; FloatABI = HardFloat; DspRev = NoDSP;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits