From: James Y Knight Date: Mon, 15 Jun 2015 20:51:24 +0000 (+0000) Subject: [Sparc] Make soft-float emit an error. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c19a4e87de85a4afd9aeb29390ffdfd43899e149;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239755 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index a2f3c196d9..ed9df1207d 100644 --- a/lib/Driver/Tools.cpp +++ b/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"; - } - - // 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"; + SoftFloatABI = true; } - 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/test/Driver/sparc-float.c b/test/Driver/sparc-float.c index e84c487c73..6fa47f00cc 100644 --- a/test/Driver/sparc-float.c +++ b/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'