From ec4b1c194b5ba1961f1da88af1a1b06b8d170f1c Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Mon, 27 Aug 2012 20:55:56 +0000 Subject: [PATCH] MIPS: Use -G option to specify MIPS section threshold. Translate it to the -mllvm -mips-ssection-threshold= pair and pass to the frontend. The patch suggested by Carl Norum. llvm-svn: 162697 --- clang/lib/Driver/Tools.cpp | 7 +++++++ clang/test/Driver/mips-features.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 11429131d768..ccfa69a739b4 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -941,6 +941,13 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, AddTargetFeature(Args, CmdArgs, options::OPT_mdspr2, options::OPT_mno_dspr2, "dspr2"); + + if (Arg *A = Args.getLastArg(options::OPT_G)) { + StringRef v = A->getValue(Args); + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back(Args.MakeArgString("-mips-ssection-threshold=" + v)); + A->claim(); + } } /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. diff --git a/clang/test/Driver/mips-features.c b/clang/test/Driver/mips-features.c index 5be268318886..28048e7740f2 100644 --- a/clang/test/Driver/mips-features.c +++ b/clang/test/Driver/mips-features.c @@ -37,3 +37,9 @@ // RUN: -mdspr2 -mno-dspr2 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOMDSPR2 %s // CHECK-NOMDSPR2: "-target-feature" "-dspr2" +// +// -G +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -G 16 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-G %s +// CHECK-MIPS-G: "-mllvm" "-mips-ssection-threshold=16"