From b2406527467b05e8782b177e24f291ee1c7116ce Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Mon, 15 Jun 2015 20:51:24 +0000 Subject: [PATCH] [Sparc] Make soft-float emit an error. LLVM does not and has not ever supported a soft-float ABI mode on Sparc, so don't pretend that it does. Also switch the default from "soft-float" -- which was actually hard-float because soft-float is unimplemented -- to hard-float. Differential Revision: http://reviews.llvm.org/D10457 llvm-svn: 239755 --- clang/lib/Driver/Tools.cpp | 52 +++++++++------------------------ clang/test/Driver/sparc-float.c | 18 +++++------- 2 files changed, 21 insertions(+), 49 deletions(-) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index a2f3c196d9c4..ed9df1207df5 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1334,47 +1334,26 @@ static std::string getR600TargetGPU(const ArgList &Args) { return ""; } -static void getSparcTargetFeatures(const ArgList &Args, - std::vector &Features) { - bool SoftFloatABI = true; - if (Arg *A = - Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float)) { - if (A->getOption().matches(options::OPT_mhard_float)) - SoftFloatABI = false; - } - if (SoftFloatABI) - Features.push_back("+soft-float"); -} - void Clang::AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { const Driver &D = getToolChain().getDriver(); + std::string Triple = getToolChain().ComputeEffectiveClangTriple(Args); - // Select the float ABI as determined by -msoft-float and -mhard-float. - StringRef FloatABI; - if (Arg *A = Args.getLastArg(options::OPT_msoft_float, - options::OPT_mhard_float)) { + bool SoftFloatABI = false; + if (Arg *A = + Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float)) { if (A->getOption().matches(options::OPT_msoft_float)) - FloatABI = "soft"; - else if (A->getOption().matches(options::OPT_mhard_float)) - FloatABI = "hard"; + SoftFloatABI = true; } - // If unspecified, choose the default based on the platform. - if (FloatABI.empty()) { - // Assume "soft", but warn the user we are guessing. - FloatABI = "soft"; - D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft"; - } - - if (FloatABI == "soft") { - // Floating point operations and argument passing are soft. - // - // FIXME: This changes CPP defines, we need -target-soft-float. - CmdArgs.push_back("-msoft-float"); - } else { - assert(FloatABI == "hard" && "Invalid float abi!"); - CmdArgs.push_back("-mhard-float"); + // Only the hard-float ABI on Sparc is standardized, and it is the + // default. GCC also supports a nonstandard soft-float ABI mode, and + // perhaps LLVM should implement that, too. However, since llvm + // currently does not support Sparc soft-float, at all, display an + // error if it's requested. + if (SoftFloatABI) { + D.Diag(diag::err_drv_unsupported_opt_for_target) + << "-msoft-float" << Triple; } } @@ -1996,11 +1975,6 @@ static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, case llvm::Triple::ppc64le: getPPCTargetFeatures(Args, Features); break; - case llvm::Triple::sparc: - case llvm::Triple::sparcel: - case llvm::Triple::sparcv9: - getSparcTargetFeatures(Args, Features); - break; case llvm::Triple::systemz: getSystemZTargetFeatures(Args, Features); break; diff --git a/clang/test/Driver/sparc-float.c b/clang/test/Driver/sparc-float.c index e84c487c73c9..6fa47f00cc7a 100644 --- a/clang/test/Driver/sparc-float.c +++ b/clang/test/Driver/sparc-float.c @@ -5,38 +5,36 @@ // RUN: %clang -c %s -### -o %t.o 2>&1 \ // RUN: -target sparc-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-DEF %s -// CHECK-DEF: "-target-feature" "+soft-float" -// CHECK-DEF: "-msoft-float" +// CHECK-DEF-NOT: "-target-feature" "+soft-float" +// CHECK-DEF-NOT: "-msoft-float" // // -mhard-float // RUN: %clang -c %s -### -o %t.o 2>&1 \ // RUN: -target sparc-linux-gnu -mhard-float \ // RUN: | FileCheck --check-prefix=CHECK-HARD %s -// CHECK-HARD: "-mhard-float" +// CHECK-HARD-NOT: "-msoft-float" // // -msoft-float // RUN: %clang -c %s -### -o %t.o 2>&1 \ // RUN: -target sparc-linux-gnu -msoft-float \ // RUN: | FileCheck --check-prefix=CHECK-SOFT %s -// CHECK-SOFT: "-target-feature" "+soft-float" -// CHECK-SOFT: "-msoft-float" +// CHECK-SOFT: error: unsupported option '-msoft-float' // // Default sparc64 // RUN: %clang -c %s -### -o %t.o 2>&1 \ // RUN: -target sparc64-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-DEF-SPARC64 %s -// CHECK-DEF-SPARC64: "-target-feature" "+soft-float" -// CHECK-DEF-SPARC64: "-msoft-float" +// CHECK-DEF-SPARC64-NOT: "-target-feature" "+soft-float" +// CHECK-DEF-SPARC64-NOT: "-msoft-float" // // -mhard-float // RUN: %clang -c %s -### -o %t.o 2>&1 \ // RUN: -target sparc64-linux-gnu -mhard-float \ // RUN: | FileCheck --check-prefix=CHECK-HARD-SPARC64 %s -// CHECK-HARD-SPARC64: "-mhard-float" +// CHECK-HARD-SPARC64-NOT: "-msoft-float" // // -msoft-float // RUN: %clang -c %s -### -o %t.o 2>&1 \ // RUN: -target sparc64-linux-gnu -msoft-float \ // RUN: | FileCheck --check-prefix=CHECK-SOFT-SPARC64 %s -// CHECK-SOFT-SPARC64: "-target-feature" "+soft-float" -// CHECK-SOFT-SPARC64: "-msoft-float" +// CHECK-SOFT-SPARC64: error: unsupported option '-msoft-float'