mirror of https://github.com/microsoft/clang.git
[mips] Introducing option -mabs=[legacy/2008]
In patch r205628 using abs.[ds] instruction is forced, as they should behave in accordance with flags Has2008 and ABS2008. Unfortunately for revisions prior mips32r6 and mips64r6, abs.[ds] is not generating correct result when working with NaNs. To generate a sequence which always produce a correct result but also to allow user more control on how his code is compiled, option -mabs is added where user can choose legacy or 2008. By default legacy mode is used on revisions prior R6. Mips32r6 and mips64r6 use abs2008 mode by default. Patch by Aleksandar Beserminji Differential Revision: https://reviews.llvm.org/D35982 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
13e76633bb
commit
0fc3c2a547
|
@ -285,6 +285,12 @@ def warn_target_unsupported_nan2008 : Warning<
|
|||
def warn_target_unsupported_nanlegacy : Warning<
|
||||
"ignoring '-mnan=legacy' option because the '%0' architecture does not support it">,
|
||||
InGroup<UnsupportedNan>;
|
||||
def warn_target_unsupported_abslegacy : Warning<
|
||||
"ignoring '-mabs=legacy' option because the '%0' architecture does not support it">,
|
||||
InGroup<UnsupportedAbs>;
|
||||
def warn_target_unsupported_abs2008 : Warning<
|
||||
"ignoring '-mabs=2008' option because the '%0' architecture does not support it">,
|
||||
InGroup<UnsupportedAbs>;
|
||||
def warn_target_unsupported_compact_branches : Warning<
|
||||
"ignoring '-mcompact-branches=' option because the '%0' architecture does not"
|
||||
" support it">, InGroup<UnsupportedCB>;
|
||||
|
|
|
@ -61,6 +61,7 @@ def FloatConversion :
|
|||
def DoublePromotion : DiagGroup<"double-promotion">;
|
||||
def EnumTooLarge : DiagGroup<"enum-too-large">;
|
||||
def UnsupportedNan : DiagGroup<"unsupported-nan">;
|
||||
def UnsupportedAbs : DiagGroup<"unsupported-abs">;
|
||||
def UnsupportedCB : DiagGroup<"unsupported-cb">;
|
||||
def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
|
||||
def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
|
||||
|
|
|
@ -2066,6 +2066,7 @@ def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group<m_Group>,
|
|||
HelpText<"Do not place constants in the .rodata section instead of the "
|
||||
".sdata if they meet the -G <size> threshold (MIPS)">;
|
||||
def mnan_EQ : Joined<["-"], "mnan=">, Group<m_Group>;
|
||||
def mabs_EQ : Joined<["-"], "mabs=">, Group<m_Group>;
|
||||
def mabicalls : Flag<["-"], "mabicalls">, Group<m_Group>,
|
||||
HelpText<"Enable SVR4-style position-independent code (Mips only)">;
|
||||
def mno_abicalls : Flag<["-"], "mno-abicalls">, Group<m_Group>,
|
||||
|
|
|
@ -149,6 +149,9 @@ void MipsTargetInfo::getTargetDefines(const LangOptions &Opts,
|
|||
if (IsNan2008)
|
||||
Builder.defineMacro("__mips_nan2008", Twine(1));
|
||||
|
||||
if (IsAbs2008)
|
||||
Builder.defineMacro("__mips_abs2008", Twine(1));
|
||||
|
||||
switch (DspRev) {
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -46,6 +46,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
|
|||
bool IsMips16;
|
||||
bool IsMicromips;
|
||||
bool IsNan2008;
|
||||
bool IsAbs2008;
|
||||
bool IsSingleFloat;
|
||||
bool IsNoABICalls;
|
||||
bool CanUseBSDABICalls;
|
||||
|
@ -61,9 +62,9 @@ protected:
|
|||
public:
|
||||
MipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
|
||||
: TargetInfo(Triple), IsMips16(false), IsMicromips(false),
|
||||
IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
|
||||
CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
|
||||
HasMSA(false), DisableMadd4(false), HasFP64(false) {
|
||||
IsNan2008(false), IsAbs2008(false), IsSingleFloat(false),
|
||||
IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat),
|
||||
DspRev(NoDSP), HasMSA(false), DisableMadd4(false), HasFP64(false) {
|
||||
TheCXXABI.set(TargetCXXABI::GenericMIPS);
|
||||
|
||||
setABI((getTriple().getArch() == llvm::Triple::mips ||
|
||||
|
@ -300,6 +301,7 @@ public:
|
|||
IsMips16 = false;
|
||||
IsMicromips = false;
|
||||
IsNan2008 = isIEEE754_2008Default();
|
||||
IsAbs2008 = isIEEE754_2008Default();
|
||||
IsSingleFloat = false;
|
||||
FloatABI = HardFloat;
|
||||
DspRev = NoDSP;
|
||||
|
@ -330,6 +332,10 @@ public:
|
|||
IsNan2008 = true;
|
||||
else if (Feature == "-nan2008")
|
||||
IsNan2008 = false;
|
||||
else if (Feature == "+abs2008")
|
||||
IsAbs2008 = true;
|
||||
else if (Feature == "-abs2008")
|
||||
IsAbs2008 = false;
|
||||
else if (Feature == "+noabicalls")
|
||||
IsNoABICalls = true;
|
||||
}
|
||||
|
|
|
@ -283,6 +283,28 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
|||
<< A->getOption().getName() << Val;
|
||||
}
|
||||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_mabs_EQ)) {
|
||||
StringRef Val = StringRef(A->getValue());
|
||||
if (Val == "2008") {
|
||||
if (mips::getIEEE754Standard(CPUName) & mips::Std2008) {
|
||||
Features.push_back("+abs2008");
|
||||
} else {
|
||||
Features.push_back("-abs2008");
|
||||
D.Diag(diag::warn_target_unsupported_abs2008) << CPUName;
|
||||
}
|
||||
} else if (Val == "legacy") {
|
||||
if (mips::getIEEE754Standard(CPUName) & mips::Legacy) {
|
||||
Features.push_back("-abs2008");
|
||||
} else {
|
||||
Features.push_back("+abs2008");
|
||||
D.Diag(diag::warn_target_unsupported_abslegacy) << CPUName;
|
||||
}
|
||||
} else {
|
||||
D.Diag(diag::err_drv_unsupported_option_argument)
|
||||
<< A->getOption().getName() << Val;
|
||||
}
|
||||
}
|
||||
|
||||
AddTargetFeature(Args, Features, options::OPT_msingle_float,
|
||||
options::OPT_mdouble_float, "single-float");
|
||||
AddTargetFeature(Args, Features, options::OPT_mips16, options::OPT_mno_mips16,
|
||||
|
|
|
@ -221,6 +221,31 @@
|
|||
// RUN: | FileCheck --check-prefix=CHECK-NANLEGACY %s
|
||||
// CHECK-NANLEGACY: "-target-feature" "-nan2008"
|
||||
//
|
||||
// -mabs=2008 on pre R2
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32 -### -c %s \
|
||||
// RUN: -mabs=2008 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ABSLEGACY %s
|
||||
//
|
||||
// -mabs=2008
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
|
||||
// RUN: -mabs=2008 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ABS2008 %s
|
||||
//
|
||||
// -mabs=legacy
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
|
||||
// RUN: -mabs=legacy 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ABSLEGACY %s
|
||||
//
|
||||
// -mabs=legacy on R6
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r6 -### -c %s \
|
||||
// RUN: -mabs=legacy 2>&1 \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ABS2008 %s
|
||||
//
|
||||
// CHECK-ABSLEGACY: "-target-feature" "-abs2008"
|
||||
// CHECK-ABSLEGACY-NOT: "-target-feature" "+abs2008"
|
||||
// CHECK-ABS2008: "-target-feature" "+abs2008"
|
||||
// CHECK-ABS2008-NOT: "-target-feature" "-abs2008"
|
||||
//
|
||||
// -mcompact-branches=never
|
||||
// RUN: %clang -target mips-linux-gnu -march=mips32r6 -### -c %s \
|
||||
// RUN: -mcompact-branches=never 2>&1 \
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// REQUIRES: mips-registered-target
|
||||
// RUN: %clang -c -target mips-unknown-gnu -mcpu=mips32 -mabs=2008 %s 2>&1 | FileCheck -check-prefix=NO2008 %s
|
||||
// NO2008: warning: ignoring '-mabs=2008' option because the 'mips32' architecture does not support it [-Wunsupported-abs]
|
||||
|
||||
// RUN: %clang -c -target mips-unknown-gnu -mcpu=mips32r6 -mabs=legacy %s 2>&1 | FileCheck -check-prefix=NOLEGACY %s
|
||||
// NOLEGACY: warning: ignoring '-mabs=legacy' option because the 'mips32r6' architecture does not support it [-Wunsupported-abs]
|
|
@ -4860,6 +4860,16 @@
|
|||
// RUN: | FileCheck -match-full-lines -check-prefix NOMIPS-NAN2008 %s
|
||||
// NOMIPS-NAN2008-NOT:#define __mips_nan2008 1
|
||||
//
|
||||
// RUN: %clang_cc1 -target-cpu mips32r3 -target-feature +abs2008 \
|
||||
// RUN: -E -dM -triple=mips-none-none < /dev/null \
|
||||
// RUN: | FileCheck -match-full-lines -check-prefix MIPS-ABS2008 %s
|
||||
// MIPS-ABS2008:#define __mips_abs2008 1
|
||||
//
|
||||
// RUN: %clang_cc1 -target-cpu mips32r3 -target-feature -abs2008 \
|
||||
// RUN: -E -dM -triple=mips-none-none < /dev/null \
|
||||
// RUN: | FileCheck -match-full-lines -check-prefix NOMIPS-ABS2008 %s
|
||||
// NOMIPS-ABS2008-NOT:#define __mips_abs2008 1
|
||||
//
|
||||
// RUN: %clang_cc1 -target-feature -fp64 \
|
||||
// RUN: -E -dM -triple=mips-none-none < /dev/null \
|
||||
// RUN: | FileCheck -match-full-lines -check-prefix MIPS32-MFP32 %s
|
||||
|
|
Loading…
Reference in New Issue