]> granicus.if.org Git - clang/commitdiff
Propagate a terrible hack to the sparc target feature handling code
authorEric Christopher <echristo@gmail.com>
Wed, 29 Apr 2015 23:32:17 +0000 (23:32 +0000)
committerEric Christopher <echristo@gmail.com>
Wed, 29 Apr 2015 23:32:17 +0000 (23:32 +0000)
by erasing the soft-float target feature if the rest of the front
end added it because of defaults or the soft float option.

Add some testing for some of the targets that implement this hack.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236179 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/CodeGen/function-target-features.c

index 047cf0d5b5c04686940bfd8c4bb53a2ebb01d200..fed879323e81b8f6f47e4decce88f031934dac82 100644 (file)
@@ -5319,9 +5319,11 @@ public:
   bool handleTargetFeatures(std::vector<std::string> &Features,
                             DiagnosticsEngine &Diags) override {
     SoftFloat = false;
-    for (unsigned i = 0, e = Features.size(); i != e; ++i)
-      if (Features[i] == "+soft-float")
-        SoftFloat = true;
+    auto Feature = std::find(Features.begin(), Features.end(), "+soft-float");
+    if (Feature != Features.end()) {
+      SoftFloat = true;
+      Features.erase(Feature);
+    }
     return true;
   }
   void getTargetDefines(const LangOptions &Opts,
index 4f8265d73435e56158acdd2026336b83471f501f..b6cd4ca7a6d4205e7b35bf6bfe8ea8e30a5e812a 100644 (file)
@@ -9,6 +9,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7 -target-feature +avx | FileCheck %s -check-prefix=CORE-CPU-AND-FEATURES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu x86-64 | FileCheck %s -check-prefix=X86-64-CPU
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7-avx -target-feature -avx | FileCheck %s -check-prefix=AVX-MINUS-FEATURE
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
+// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
+// RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 
 void foo() {}
 
@@ -19,3 +22,4 @@ void foo() {}
 // CORE-CPU-AND-FEATURES: "target-cpu"="corei7" "target-features"={{.*}}+avx
 // X86-64-CPU: "target-cpu"="x86-64"
 // AVX-MINUS-FEATURE: "target-features"={{.*}}-avx
+// SOFT-FLOAT-NOT: "target-features"={{.*}}+soft-float