From f53edbb006df3bc205bf38008d96de510b2adddd Mon Sep 17 00:00:00 2001
From: Simon Atanasyan <simon@atanasyan.com>
Date: Fri, 7 Jul 2017 10:35:33 +0000
Subject: [PATCH] [driver][mips] Pass long-calls feature flag to the MIPS
 backend

Check the `-mlong-calls` command line option and pass the `long-calls`
feature flag to the backend. Handling of this feature flag in the backend
needs to be implemented by a separate commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307386 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Driver/ToolChains/Arch/Mips.cpp |  2 ++
 test/Driver/mips-features.c         | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/lib/Driver/ToolChains/Arch/Mips.cpp b/lib/Driver/ToolChains/Arch/Mips.cpp
index 66fa05c595f..c336bb17f02 100644
--- a/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -299,6 +299,8 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
                    options::OPT_modd_spreg, "nooddspreg");
   AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4,
                    "nomadd4");
+  AddTargetFeature(Args, Features, options::OPT_mlong_calls,
+                   options::OPT_mno_long_calls, "long-calls");
 }
 
 mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) {
diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c
index 69fc20e1f24..9305f99051d 100644
--- a/test/Driver/mips-features.c
+++ b/test/Driver/mips-features.c
@@ -247,3 +247,14 @@
 // RUN:   | FileCheck --check-prefix=CHECK-IMG-SINGLEFLOAT-FPXX %s
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+single-float"
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx"
+
+// -mlong-call
+// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-ON %s
+// RUN: %clang -target mips-img-linux-gnu -### -c %s -mno-long-calls 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-OFF %s
+// RUN: %clang -target mips-img-linux-gnu -### -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
+// LONG-CALLS-ON: "-target-feature" "+long-calls"
+// LONG-CALLS-OFF: "-target-feature" "-long-calls"
+// LONG-CALLS-DEF-NOT: "long-calls"
-- 
GitLab