[pkg-d-commits] [ldc] 118/211: UseSoftFloat was removed from the TargetOptions in LLVM3.7. It's replacement (I believe) is the "+soft-float" target feature (in the target feature string). Inside LLVM, the "use-soft-float" attribute is upgraded to the "+soft-float" feature, so we can do that ourselves when creating the target machine. (at the point where we add the attributes to the function, we have no access to whether our TargetMachine was created with FloatABI:SoftFP or not)

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:15 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.1.0
in repository ldc.

commit ed3afed77ab94c7d2ea94dc4e0ada3fcc11af0ec
Author: Johan Engelen <jbc.engelen at gmail.com>
Date:   Fri Oct 28 17:12:40 2016 +0900

    UseSoftFloat was removed from the TargetOptions in LLVM3.7. It's replacement (I believe) is the "+soft-float" target feature (in the target feature string). Inside LLVM, the "use-soft-float" attribute is upgraded to the "+soft-float" feature, so we can do that ourselves when creating the target machine.
    (at the point where we add the attributes to the function, we have no access to whether our TargetMachine was created with FloatABI:SoftFP or not)
---
 driver/targetmachine.cpp              |  2 ++
 gen/functions.cpp                     | 11 -----------
 tests/codegen/attr_targetoptions.d    |  1 -
 tests/codegen/attr_targetoptions_fp.d | 17 +++++++++++++++++
 4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/driver/targetmachine.cpp b/driver/targetmachine.cpp
index 34e5fef..bfffaff 100644
--- a/driver/targetmachine.cpp
+++ b/driver/targetmachine.cpp
@@ -598,6 +598,8 @@ createTargetMachine(std::string targetTriple, std::string arch, std::string cpu,
   case FloatABI::Soft:
 #if LDC_LLVM_VER < 307
     targetOptions.UseSoftFloat = true;
+#else
+    features.AddFeature("+soft-float");
 #endif
     targetOptions.FloatABIType = llvm::FloatABI::Soft;
     break;
diff --git a/gen/functions.cpp b/gen/functions.cpp
index 366e90e..287eee7 100644
--- a/gen/functions.cpp
+++ b/gen/functions.cpp
@@ -451,17 +451,6 @@ void applyTargetMachineAttributes(llvm::Function &func,
   func.addFnAttr("no-nans-fp-math", TO.NoNaNsFPMath ? "true" : "false");
 #if LDC_LLVM_VER < 307
   func.addFnAttr("use-soft-float", TO.UseSoftFloat ? "true" : "false");
-#else
-  switch (TO.FloatABIType) {
-  case llvm::FloatABI::Default:
-    break;
-  case llvm::FloatABI::Soft:
-    func.addFnAttr("use-soft-float", "true");
-    break;
-  case llvm::FloatABI::Hard:
-    func.addFnAttr("use-soft-float", "false");
-    break;
-  }
 #endif
 
   // Frame pointer elimination
diff --git a/tests/codegen/attr_targetoptions.d b/tests/codegen/attr_targetoptions.d
index 8368ea3..0538cea 100644
--- a/tests/codegen/attr_targetoptions.d
+++ b/tests/codegen/attr_targetoptions.d
@@ -13,7 +13,6 @@ void foo()
 
 // DEFAULT: attributes #[[KEYVALUE]]
 // DEFAULT-DAG: "target-cpu"=
-// DEFAULT-DAG: "use-soft-float"="{{(true|false)}}"
 // DEFAULT-DAG: "no-frame-pointer-elim"="false"
 // DEFAULT-DAG: "unsafe-fp-math"="false"
 // DEFAULT-DAG: "less-precise-fpmad"="false"
diff --git a/tests/codegen/attr_targetoptions_fp.d b/tests/codegen/attr_targetoptions_fp.d
new file mode 100644
index 0000000..7114a8c
--- /dev/null
+++ b/tests/codegen/attr_targetoptions_fp.d
@@ -0,0 +1,17 @@
+// See Github issue #1860
+
+// REQUIRES: atleast_llvm307
+
+// RUN: %ldc -c -output-ll -of=%t.ll -float-abi=soft   %s && FileCheck --check-prefix=SOFT %s < %t.ll
+// RUN: %ldc -c -output-ll -of=%t.ll -float-abi=softfp %s && FileCheck --check-prefix=HARD %s < %t.ll
+
+// SOFT: define{{.*}} @{{.*}}3fooFZv{{.*}} #[[KEYVALUE:[0-9]+]]
+// HARD: define{{.*}} @{{.*}}3fooFZv{{.*}} #[[KEYVALUE:[0-9]+]]
+void foo()
+{
+}
+
+// SOFT: attributes #[[KEYVALUE]]
+// SOFT-DAG: "target-features"="{{.*}}+soft-float{{.*}}"
+// HARD: attributes #[[KEYVALUE]]
+// HARD-NOT: "target-features"="{{.*}}+soft-float{{.*}}"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list