r374154 - [mips] Set default float ABI to "soft" on FreeBSD
Simon Atanasyan via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 9 03:38:03 PDT 2019
Author: atanasyan
Date: Wed Oct 9 03:38:03 2019
New Revision: 374154
URL: http://llvm.org/viewvc/llvm-project?rev=374154&view=rev
Log:
[mips] Set default float ABI to "soft" on FreeBSD
Initial patch by Kyle Evans.
Fix PR43596
Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/mips-float.c
Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=374154&r1=374153&r2=374154&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Oct 9 03:38:03 2019
@@ -149,7 +149,8 @@ StringRef mips::getGnuCompatibleMipsABIN
// Select the MIPS float ABI as determined by -msoft-float, -mhard-float,
// and -mfloat-abi=.
-mips::FloatABI mips::getMipsFloatABI(const Driver &D, const ArgList &Args) {
+mips::FloatABI mips::getMipsFloatABI(const Driver &D, const ArgList &Args,
+ const llvm::Triple &Triple) {
mips::FloatABI ABI = mips::FloatABI::Invalid;
if (Arg *A =
Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float,
@@ -172,10 +173,15 @@ mips::FloatABI mips::getMipsFloatABI(con
// If unspecified, choose the default based on the platform.
if (ABI == mips::FloatABI::Invalid) {
- // Assume "hard", because it's a default value used by gcc.
- // When we start to recognize specific target MIPS processors,
- // we will be able to select the default more correctly.
- ABI = mips::FloatABI::Hard;
+ if (Triple.isOSFreeBSD()) {
+ // For FreeBSD, assume "soft" on all flavors of MIPS.
+ ABI = mips::FloatABI::Soft;
+ } else {
+ // Assume "hard", because it's a default value used by gcc.
+ // When we start to recognize specific target MIPS processors,
+ // we will be able to select the default more correctly.
+ ABI = mips::FloatABI::Hard;
+ }
}
assert(ABI != mips::FloatABI::Invalid && "must select an ABI");
@@ -274,7 +280,7 @@ void mips::getMIPSTargetFeatures(const D
Features.push_back("-xgot");
}
- mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
+ mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args, Triple);
if (FloatABI == mips::FloatABI::Soft) {
// FIXME: Note, this is a hack. We need to pass the selected float
// mode to the MipsTargetInfoBase to define appropriate macros there.
Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h?rev=374154&r1=374153&r2=374154&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h Wed Oct 9 03:38:03 2019
@@ -38,7 +38,8 @@ void getMIPSTargetFeatures(const Driver
const llvm::opt::ArgList &Args,
std::vector<StringRef> &Features);
StringRef getGnuCompatibleMipsABIName(StringRef ABI);
-mips::FloatABI getMipsFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+mips::FloatABI getMipsFloatABI(const Driver &D, const llvm::opt::ArgList &Args,
+ const llvm::Triple &Triple);
std::string getMipsABILibSuffix(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple);
bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=374154&r1=374153&r2=374154&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Oct 9 03:38:03 2019
@@ -1672,7 +1672,7 @@ void Clang::AddMIPSTargetArgs(const ArgL
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName.data());
- mips::FloatABI ABI = mips::getMipsFloatABI(D, Args);
+ mips::FloatABI ABI = mips::getMipsFloatABI(D, Args, Triple);
if (ABI == mips::FloatABI::Soft) {
// Floating point operations and argument passing are soft.
CmdArgs.push_back("-msoft-float");
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=374154&r1=374153&r2=374154&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Oct 9 03:38:03 2019
@@ -823,7 +823,8 @@ void tools::gnutools::Assembler::Constru
A->render(Args, CmdArgs);
} else if (mips::shouldUseFPXX(
Args, getToolChain().getTriple(), CPUName, ABIName,
- mips::getMipsFloatABI(getToolChain().getDriver(), Args)))
+ mips::getMipsFloatABI(getToolChain().getDriver(), Args,
+ getToolChain().getTriple())))
CmdArgs.push_back("-mfpxx");
// Pass on -mmips16 or -mno-mips16. However, the assembler equivalent of
Modified: cfe/trunk/test/Driver/mips-float.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-float.c?rev=374154&r1=374153&r2=374154&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mips-float.c (original)
+++ cfe/trunk/test/Driver/mips-float.c Wed Oct 9 03:38:03 2019
@@ -7,6 +7,14 @@
// RUN: | FileCheck --check-prefix=CHECK-DEF %s
// CHECK-DEF: "-mfloat-abi" "hard"
//
+// Default on FreeBSD
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-freebsd12 \
+// RUN: | FileCheck --check-prefix=DEF-FREEBSD %s
+// DEF-FREEBSD: "-target-feature" "+soft-float"
+// DEF-FREEBSD: "-msoft-float"
+// DEF-FREEBSD: "-mfloat-abi" "soft"
+//
// -mhard-float
// RUN: %clang -c %s -### -o %t.o 2>&1 \
// RUN: -target mips-linux-gnu -mhard-float \
More information about the cfe-commits
mailing list