Index: include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- include/clang/Basic/DiagnosticDriverKinds.td +++ include/clang/Basic/DiagnosticDriverKinds.td @@ -285,6 +285,12 @@ def warn_target_unsupported_nanlegacy : Warning< "ignoring '-mnan=legacy' option because the '%0' architecture does not support it">, InGroup; +def warn_target_unsupported_abslegacy : Warning< + "ignoring '-mabs=legacy' option because the '%0' architecture does not support it">, + InGroup; +def warn_target_unsupported_abs2008 : Warning< + "ignoring '-mabs=2008' option because the '%0' architecture does not support it">, + InGroup; def warn_target_unsupported_compact_branches : Warning< "ignoring '-mcompact-branches=' option because the '%0' architecture does not" " support it">, InGroup; Index: include/clang/Basic/DiagnosticGroups.td =================================================================== --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -61,6 +61,7 @@ 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">; Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2066,6 +2066,7 @@ HelpText<"Do not place constants in the .rodata section instead of the " ".sdata if they meet the -G threshold (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; +def mabs_EQ : Joined<["-"], "mabs=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; def mno_abicalls : Flag<["-"], "mno-abicalls">, Group, Index: lib/Basic/Targets/Mips.h =================================================================== --- lib/Basic/Targets/Mips.h +++ lib/Basic/Targets/Mips.h @@ -46,6 +46,7 @@ bool IsMips16; bool IsMicromips; bool IsNan2008; + bool IsAbs2008; bool IsSingleFloat; bool IsNoABICalls; bool CanUseBSDABICalls; @@ -61,9 +62,9 @@ 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 @@ IsMips16 = false; IsMicromips = false; IsNan2008 = isIEEE754_2008Default(); + IsAbs2008 = isIEEE754_2008Default(); IsSingleFloat = false; FloatABI = HardFloat; DspRev = NoDSP; @@ -330,6 +332,10 @@ 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; } Index: lib/Basic/Targets/Mips.cpp =================================================================== --- lib/Basic/Targets/Mips.cpp +++ lib/Basic/Targets/Mips.cpp @@ -149,6 +149,9 @@ if (IsNan2008) Builder.defineMacro("__mips_nan2008", Twine(1)); + if (IsAbs2008) + Builder.defineMacro("__mips_abs2008", Twine(1)); + switch (DspRev) { default: break; Index: lib/Driver/ToolChains/Arch/Mips.cpp =================================================================== --- lib/Driver/ToolChains/Arch/Mips.cpp +++ lib/Driver/ToolChains/Arch/Mips.cpp @@ -283,6 +283,28 @@ << 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, Index: test/Driver/mips-features.c =================================================================== --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -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 \ Index: test/Driver/mips-mabs-warning.c =================================================================== --- /dev/null +++ test/Driver/mips-mabs-warning.c @@ -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] Index: test/Preprocessor/init.c =================================================================== --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -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