forked from OSchip/llvm-project
[Mips] Support -mnan=2008 option. Define "__mips_nan2008" macros and pass
this option to the assembler. llvm-svn: 191282
This commit is contained in:
parent
c63c30c9a2
commit
22127cee34
|
@ -1062,6 +1062,7 @@ def mmsa : Flag<["-"], "mmsa">, Group<m_Group>,
|
|||
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>,
|
||||
|
|
|
@ -4647,6 +4647,7 @@ class MipsTargetInfoBase : public TargetInfo {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -948,6 +948,11 @@ static void getMIPSTargetFeatures(const Driver &D, const ArgList &Args,
|
|||
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(Compilation &C, const JobAction &JA,
|
|||
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);
|
||||
|
|
|
@ -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={{.*}}"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue