[clang] [PPC] Disable vsx and altivec when -msoft-float is used (PR #100450)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 12:06:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-backend-powerpc
Author: Zaara Syeda (syzaara)
<details>
<summary>Changes</summary>
We emit an error when -msoft-float and -maltivec/-mvsx is used together, but when -msoft-float is used on its own, there is still +altivec and +vsx in the IR attributes. This patch disables altivec and vsx when -msoft-float is used.
---
Full diff: https://github.com/llvm/llvm-project/pull/100450.diff
2 Files Affected:
- (modified) clang/lib/Basic/Targets/PPC.cpp (+5)
- (added) clang/test/Driver/ppc-soft-float.c (+13)
``````````diff
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 9ff54083c923b..2b25cb189279a 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -690,6 +690,11 @@ bool PPCTargetInfo::initFeatureMap(
return false;
}
+ if (llvm::is_contained(FeaturesVec, "-hard-float")) {
+ Features["altivec"] = false;
+ Features["vsx"] = false;
+ }
+
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
diff --git a/clang/test/Driver/ppc-soft-float.c b/clang/test/Driver/ppc-soft-float.c
new file mode 100644
index 0000000000000..7b9205662ffeb
--- /dev/null
+++ b/clang/test/Driver/ppc-soft-float.c
@@ -0,0 +1,13 @@
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr10 -msoft-float -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECKSOFT
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECKNOSOFT
+
+int main () {
+ return 0;
+}
+
+// CHECKSOFT-DAG: -hard-float
+// CHECKSOFT-DAG: -vsx
+// CHECKSOFT-DAG: -altivec
+
+// CHECKNOSOFT-DAG: +vsx
+// CHECKNOSOFT-DAG: +altivec
``````````
</details>
https://github.com/llvm/llvm-project/pull/100450
More information about the cfe-commits
mailing list