Skip to content

Commit

Permalink
Pull in r374154 from upstream clang trunk (by Simon Atanasyan):
Browse files Browse the repository at this point in the history
  [mips] Set default float ABI to "soft" on FreeBSD

  Initial patch by Kyle Evans.

  Fix PR43596

Requested by:	kevans
MFC after:	1 month
X-MFC-With:	r353358
  • Loading branch information
DimitryAndric committed Oct 18, 2019
1 parent 1a7f2b1 commit 5ac7c2c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
18 changes: 12 additions & 6 deletions contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ StringRef mips::getGnuCompatibleMipsABIName(StringRef ABI) {

// 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,
Expand All @@ -172,10 +173,15 @@ mips::FloatABI mips::getMipsFloatABI(const Driver &D, const ArgList &Args) {

// 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");
Expand Down Expand Up @@ -267,7 +273,7 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
D.Diag(diag::warn_drv_unsupported_longcalls) << (ABICallsArg ? 0 : 1);
}

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.
Expand Down
3 changes: 2 additions & 1 deletion contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
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);
Expand Down
2 changes: 1 addition & 1 deletion contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
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");
Expand Down
3 changes: 2 additions & 1 deletion contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
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
Expand Down

0 comments on commit 5ac7c2c

Please sign in to comment.