[clang] [PPC] Disable vsx and altivec when -msoft-float is used (PR #100450)
Zaara Syeda via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 12:06:08 PDT 2024
https://github.com/syzaara created https://github.com/llvm/llvm-project/pull/100450
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.
>From eac208b559feb3ccdfbd1d2ee6bcdd20db32f6a7 Mon Sep 17 00:00:00 2001
From: Zaara Syeda <syzaara at cpap8104.rtp.raleigh.ibm.com>
Date: Wed, 24 Jul 2024 14:58:53 -0400
Subject: [PATCH] [PPC] Disable vsx and altivec when -msoft-float is used
---
clang/lib/Basic/Targets/PPC.cpp | 5 +++++
clang/test/Driver/ppc-soft-float.c | 13 +++++++++++++
2 files changed, 18 insertions(+)
create mode 100644 clang/test/Driver/ppc-soft-float.c
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
More information about the cfe-commits
mailing list