https://github.com/alexrp updated https://github.com/llvm/llvm-project/pull/106012
From acd4bd9406969926ed7b87c764f02ad072847aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= <a...@alexrp.com> Date: Sun, 25 Aug 2024 22:47:37 +0200 Subject: [PATCH] [clang][Driver] Define soft float macros for PPC. Fixes #105972. Co-authored-by: Qiu Chaofan <q...@ecnelises.com> --- clang/lib/Basic/Targets/PPC.cpp | 13 ++++++++----- clang/test/Preprocessor/init-ppc.c | 10 ++++++++++ clang/test/Preprocessor/init-ppc64.c | 10 ++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp index 04dc436eb1b9cd..61b35f7ecd49d6 100644 --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -402,9 +402,16 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__VEC__", "10206"); Builder.defineMacro("__ALTIVEC__"); } - if (HasSPE) { + if (HasSPE) Builder.defineMacro("__SPE__"); + if (HasSPE || FloatABI == SoftFloat) Builder.defineMacro("__NO_FPRS__"); + if (FloatABI == SoftFloat) { + Builder.defineMacro("_SOFT_FLOAT"); + Builder.defineMacro("_SOFT_DOUBLE"); + } else { + Builder.defineMacro("__RSQRTE__"); + Builder.defineMacro("__RSQRTEF__"); } if (HasVSX) Builder.defineMacro("__VSX__"); @@ -439,14 +446,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, // FIXME: The following are not yet generated here by Clang, but are // generated by GCC: // - // _SOFT_FLOAT_ // __RECIP_PRECISION__ // __APPLE_ALTIVEC__ // __RECIP__ // __RECIPF__ - // __RSQRTE__ - // __RSQRTEF__ - // _SOFT_DOUBLE_ // __NO_LWSYNC__ // __CMODEL_MEDIUM__ // __CMODEL_LARGE__ diff --git a/clang/test/Preprocessor/init-ppc.c b/clang/test/Preprocessor/init-ppc.c index 3fb642af9d7420..3bf35bfeb307ee 100644 --- a/clang/test/Preprocessor/init-ppc.c +++ b/clang/test/Preprocessor/init-ppc.c @@ -325,6 +325,8 @@ // PPC:#define __PTRDIFF_TYPE__ long int // PPC:#define __PTRDIFF_WIDTH__ 32 // PPC:#define __REGISTER_PREFIX__ +// PPC:#define __RSQRTEF__ 1 +// PPC:#define __RSQRTE__ 1 // PPC:#define __SCHAR_MAX__ 127 // PPC:#define __SHRT_MAX__ 32767 // PPC:#define __SIG_ATOMIC_MAX__ 2147483647 @@ -977,3 +979,11 @@ // RUN: %clang_cc1 -E -dM -triple=powerpc-unknown-openbsd -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix PPC-OPENBSD-CXX %s // PPC-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL + +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-feature -hard-float < /dev/null | FileCheck -match-full-lines -check-prefix PPC-SOFTFLT %s +// +// PPC-SOFTFLT:#define _SOFT_DOUBLE 1 +// PPC-SOFTFLT:#define _SOFT_FLOAT 1 +// PPC-SOFTFLT:#define __NO_FPRS__ 1 +// PPC-SOFTFLT-NOT:#define __RSQRTE__ 1 +// PPC-SOFTFLT-NOT:#define __RSQRTEF__ 1 diff --git a/clang/test/Preprocessor/init-ppc64.c b/clang/test/Preprocessor/init-ppc64.c index 56164beb913d5c..02ea8312b1db6e 100644 --- a/clang/test/Preprocessor/init-ppc64.c +++ b/clang/test/Preprocessor/init-ppc64.c @@ -137,6 +137,8 @@ // PPC64:#define __PTRDIFF_TYPE__ long int // PPC64:#define __PTRDIFF_WIDTH__ 64 // PPC64:#define __REGISTER_PREFIX__ +// PPC64:#define __RSQRTEF__ 1 +// PPC64:#define __RSQRTE__ 1 // PPC64:#define __SCHAR_MAX__ 127 // PPC64:#define __SHRT_MAX__ 32767 // PPC64:#define __SIG_ATOMIC_MAX__ 2147483647 @@ -1110,3 +1112,11 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s // PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1 + +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -target-feature -hard-float -xc /dev/null | FileCheck --check-prefix=PPC64-SOFTFLT %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-linux-gnu -target-feature -hard-float -xc /dev/null | FileCheck --check-prefix=PPC64-SOFTFLT %s +// PPC64-SOFTFLT:#define _SOFT_DOUBLE 1 +// PPC64-SOFTFLT:#define _SOFT_FLOAT 1 +// PPC64-SOFTFLT:#define __NO_FPRS__ 1 +// PPC64-SOFTFLT-NOT:#define __RSQRTE__ 1 +// PPC64-SOFTFLT-NOT:#define __RSQRTEF__ 1 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits