From: Simon Atanasyan Date: Sat, 2 Jun 2012 15:06:29 +0000 (+0000) Subject: MIPS: Factor out code selects the float ABI as determined by -msoft-float, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e62779634ba002d7112a66efc8e075de9b8a3f1;p=clang MIPS: Factor out code selects the float ABI as determined by -msoft-float, -mhard-float, and -mfloat-abi= to the new function getMipsFloatABI. That simplifies reuse of this code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157888 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index f3c8026ced..31626b3976 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -828,19 +828,9 @@ static void getMipsCPUAndABI(const ArgList &Args, ABIName = getMipsABIFromArch(ArchName); } -void Clang::AddMIPSTargetArgs(const ArgList &Args, - ArgStringList &CmdArgs) const { - const Driver &D = getToolChain().getDriver(); - StringRef CPUName; - StringRef ABIName; - getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName); - - CmdArgs.push_back("-target-cpu"); - CmdArgs.push_back(CPUName.data()); - - CmdArgs.push_back("-target-abi"); - CmdArgs.push_back(ABIName.data()); - +// Select the MIPS float ABI as determined by -msoft-float, -mhard-float, +// and -mfloat-abi=. +static StringRef getMipsFloatABI(const Driver &D, const ArgList &Args) { // Select the float ABI as determined by -msoft-float, -mhard-float, // and -mfloat-abi=. StringRef FloatABI; @@ -854,8 +844,7 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, else { FloatABI = A->getValue(Args); if (FloatABI != "soft" && FloatABI != "single" && FloatABI != "hard") { - D.Diag(diag::err_drv_invalid_mfloat_abi) - << A->getAsString(Args); + D.Diag(diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args); FloatABI = "hard"; } } @@ -869,6 +858,24 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, FloatABI = "hard"; } + return FloatABI; +} + +void Clang::AddMIPSTargetArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + const Driver &D = getToolChain().getDriver(); + StringRef CPUName; + StringRef ABIName; + getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName); + + CmdArgs.push_back("-target-cpu"); + CmdArgs.push_back(CPUName.data()); + + CmdArgs.push_back("-target-abi"); + CmdArgs.push_back(ABIName.data()); + + StringRef FloatABI = getMipsFloatABI(D, Args); + if (FloatABI == "soft") { // Floating point operations and argument passing are soft. CmdArgs.push_back("-msoft-float");