mirror of
https://github.com/intel/llvm.git
synced 2026-01-21 04:14:03 +08:00
Clang/MIPS: Use -mnan value for -mabs if not specified (#71157)
On most hardware, FCSR.ABS2008 is set the value same with FCSR.NAN2008. Let's use this behaivor by default. With this commit, `clang -target mips -mnan=2008 -c fabs.c` will imply `-mabs=2008`. And of course, `clang -mnan=2008 -mabs=legacy` can continue workable like previous. Co-authored-by: YunQiang Su <yunqiang.su@cipunited.com>
This commit is contained in:
@@ -221,6 +221,7 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
||||
bool IsN64 = ABIName == "64";
|
||||
bool IsPIC = false;
|
||||
bool NonPIC = false;
|
||||
bool HasNaN2008Opt = false;
|
||||
|
||||
Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
|
||||
options::OPT_fpic, options::OPT_fno_pic,
|
||||
@@ -285,9 +286,10 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
||||
if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
|
||||
StringRef Val = StringRef(A->getValue());
|
||||
if (Val == "2008") {
|
||||
if (mips::getIEEE754Standard(CPUName) & mips::Std2008)
|
||||
if (mips::getIEEE754Standard(CPUName) & mips::Std2008) {
|
||||
Features.push_back("+nan2008");
|
||||
else {
|
||||
HasNaN2008Opt = true;
|
||||
} else {
|
||||
Features.push_back("-nan2008");
|
||||
D.Diag(diag::warn_target_unsupported_nan2008) << CPUName;
|
||||
}
|
||||
@@ -323,6 +325,8 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
||||
D.Diag(diag::err_drv_unsupported_option_argument)
|
||||
<< A->getSpelling() << Val;
|
||||
}
|
||||
} else if (HasNaN2008Opt) {
|
||||
Features.push_back("+abs2008");
|
||||
}
|
||||
|
||||
AddTargetFeature(Args, Features, options::OPT_msingle_float,
|
||||
|
||||
@@ -213,7 +213,13 @@
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
|
||||
// RUN: -mnan=legacy -mnan=2008 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-NAN2008 %s
|
||||
// CHECK-NAN2008: "-target-feature" "+nan2008"
|
||||
// CHECK-NAN2008: "-target-feature" "+nan2008" "-target-feature" "+abs2008"
|
||||
//
|
||||
// -mnan=2008 -mabs=legacy
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
|
||||
// RUN: -mabs=legacy -mnan=2008 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ABSLEGACYNAN2008 %s
|
||||
// CHECK-ABSLEGACYNAN2008: "-target-feature" "+nan2008" "-target-feature" "-abs2008"
|
||||
//
|
||||
// -mnan=legacy
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
|
||||
|
||||
Reference in New Issue
Block a user