r191282 - [Mips] Support -mnan=2008 option. Define "__mips_nan2008" macros and pass
Simon Atanasyan
simon at atanasyan.com
Tue Sep 24 02:09:17 PDT 2013
Author: atanasyan
Date: Tue Sep 24 04:09:16 2013
New Revision: 191282
URL: http://llvm.org/viewvc/llvm-project?rev=191282&view=rev
Log:
[Mips] Support -mnan=2008 option. Define "__mips_nan2008" macros and pass
this option to the assembler.
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Preprocessor/init.c
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=191282&r1=191281&r2=191282&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Sep 24 04:09:16 2013
@@ -1062,6 +1062,7 @@ def mmsa : Flag<["-"], "mmsa">, Group<m_
HelpText<"Enable MSA ASE on MIPS processors">, Flags<[HelpHidden]>;
def mno_msa : Flag<["-"], "mno-msa">, Group<m_Group>,
HelpText<"Disable MSA ASE on MIPS processors">, Flags<[HelpHidden]>;
+def mnan_EQ : Joined<["-"], "mnan=">, Group<m_Group>;
def mips32 : Flag<["-"], "mips32">, Group<mips_CPUs_Group>,
HelpText<"Equivalent to -march=mips32">, Flags<[HelpHidden]>;
def mips32r2 : Flag<["-"], "mips32r2">, Group<mips_CPUs_Group>,
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=191282&r1=191281&r2=191282&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Sep 24 04:09:16 2013
@@ -4647,6 +4647,7 @@ class MipsTargetInfoBase : public Target
std::string CPU;
bool IsMips16;
bool IsMicromips;
+ bool IsNan2008;
bool IsSingleFloat;
enum MipsFloatABI {
HardFloat, SoftFloat
@@ -4663,8 +4664,8 @@ public:
MipsTargetInfoBase(const llvm::Triple &Triple, const std::string &ABIStr,
const std::string &CPUStr)
: TargetInfo(Triple), CPU(CPUStr), IsMips16(false), IsMicromips(false),
- IsSingleFloat(false), FloatABI(HardFloat), DspRev(NoDSP),
- HasMSA(false), ABI(ABIStr) {}
+ IsNan2008(false), IsSingleFloat(false), FloatABI(HardFloat),
+ DspRev(NoDSP), HasMSA(false), ABI(ABIStr) {}
virtual const char *getABI() const { return ABI.c_str(); }
virtual bool setABI(const std::string &Name) = 0;
@@ -4701,6 +4702,9 @@ public:
if (IsMicromips)
Builder.defineMacro("__mips_micromips", Twine(1));
+ if (IsNan2008)
+ Builder.defineMacro("__mips_nan2008", Twine(1));
+
switch (DspRev) {
default:
break;
@@ -4790,6 +4794,7 @@ public:
DiagnosticsEngine &Diags) {
IsMips16 = false;
IsMicromips = false;
+ IsNan2008 = false;
IsSingleFloat = false;
FloatABI = HardFloat;
DspRev = NoDSP;
@@ -4810,13 +4815,18 @@ public:
DspRev = std::max(DspRev, DSP2);
else if (*it == "+msa")
HasMSA = true;
+ else if (*it == "+nan2008")
+ IsNan2008 = true;
}
- // Remove front-end specific option.
+ // Remove front-end specific options.
std::vector<std::string>::iterator it =
std::find(Features.begin(), Features.end(), "+soft-float");
if (it != Features.end())
Features.erase(it);
+ it = std::find(Features.begin(), Features.end(), "+nan2008");
+ if (it != Features.end())
+ Features.erase(it);
return true;
}
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=191282&r1=191281&r2=191282&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Sep 24 04:09:16 2013
@@ -948,6 +948,11 @@ static void getMIPSTargetFeatures(const
Features.push_back("+soft-float");
}
+ if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
+ if (StringRef(A->getValue()) == "2008")
+ Features.push_back("+nan2008");
+ }
+
AddTargetFeature(Args, Features, options::OPT_msingle_float,
options::OPT_mdouble_float, "single-float");
AddTargetFeature(Args, Features, options::OPT_mips16, options::OPT_mno_mips16,
@@ -5942,6 +5947,11 @@ void gnutools::Assemble::ConstructJob(Co
else
CmdArgs.push_back("-EL");
+ if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
+ if (StringRef(A->getValue()) == "2008")
+ CmdArgs.push_back(Args.MakeArgString("-mnan=2008"));
+ }
+
Args.AddLastArg(CmdArgs, options::OPT_mips16, options::OPT_mno_mips16);
Args.AddLastArg(CmdArgs, options::OPT_mmicromips,
options::OPT_mno_micromips);
Modified: cfe/trunk/test/Driver/mips-as.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-as.c?rev=191282&r1=191281&r2=191282&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mips-as.c (original)
+++ cfe/trunk/test/Driver/mips-as.c Tue Sep 24 04:09:16 2013
@@ -115,3 +115,14 @@
// RUN: | FileCheck -check-prefix=MIPS-NDSPR2 %s
// MIPS-NDSPR2: as{{(.exe)?}}"
// MIPS-NDSPR2-NOT: "-mdspr2"
+//
+// RUN: %clang -target mips-linux-gnu -mnan=legacy -mnan=2008 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-NAN2008 %s
+// MIPS-NAN2008: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" "-mnan=2008"
+//
+// RUN: %clang -target mips-linux-gnu -mnan=2008 -mnan=legacy -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-NAN-LEGACY %s
+// MIPS-NAN-LEGACY: as{{(.exe)?}}"
+// MIPS-NAN_LEGACY-NOT: "-mnan={{.*}}"
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=191282&r1=191281&r2=191282&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Sep 24 04:09:16 2013
@@ -1229,6 +1229,11 @@
// RUN: | FileCheck -check-prefix MIPS-MSA %s
// MIPS-MSA:#define __mips_msa 1
//
+// RUN: %clang_cc1 -target-feature +nan2008 \
+// RUN: -E -dM -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-NAN2008 %s
+// MIPS-NAN2008:#define __mips_nan2008 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s
//
// MSP430:#define MSP430 1
More information about the cfe-commits
mailing list