Skip to content

Commit 885a183

Browse files
alexrpecnelises
andcommitted
[clang][Driver] Define soft float macros for PPC.
Fixes #105972. Co-authored-by: Qiu Chaofan <[email protected]>
1 parent 675c748 commit 885a183

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,13 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
402402
Builder.defineMacro("__VEC__", "10206");
403403
Builder.defineMacro("__ALTIVEC__");
404404
}
405-
if (HasSPE) {
405+
if (HasSPE)
406406
Builder.defineMacro("__SPE__");
407+
if (HasSPE || FloatABI == SoftFloat)
407408
Builder.defineMacro("__NO_FPRS__");
409+
if (FloatABI == SoftFloat) {
410+
Builder.defineMacro("_SOFT_FLOAT");
411+
Builder.defineMacro("_SOFT_DOUBLE");
408412
}
409413
if (HasVSX)
410414
Builder.defineMacro("__VSX__");
@@ -439,14 +443,12 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
439443
// FIXME: The following are not yet generated here by Clang, but are
440444
// generated by GCC:
441445
//
442-
// _SOFT_FLOAT_
443446
// __RECIP_PRECISION__
444447
// __APPLE_ALTIVEC__
445448
// __RECIP__
446449
// __RECIPF__
447450
// __RSQRTE__
448451
// __RSQRTEF__
449-
// _SOFT_DOUBLE_
450452
// __NO_LWSYNC__
451453
// __CMODEL_MEDIUM__
452454
// __CMODEL_LARGE__

clang/test/Preprocessor/init-ppc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,3 +977,9 @@
977977

978978
// RUN: %clang_cc1 -E -dM -triple=powerpc-unknown-openbsd -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix PPC-OPENBSD-CXX %s
979979
// PPC-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
980+
981+
// 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
982+
//
983+
// PPC-SOFTFLT:#define _SOFT_DOUBLE 1
984+
// PPC-SOFTFLT:#define _SOFT_FLOAT 1
985+
// PPC-SOFTFLT:#define __NO_FPRS__ 1

clang/test/Preprocessor/init-ppc64.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,3 +1110,9 @@
11101110
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s
11111111
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s
11121112
// PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1
1113+
1114+
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -target-feature -hard-float -xc /dev/null | FileCheck --check-prefix=PPC64-SOFTFLT %s
1115+
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-linux-gnu -target-feature -hard-float -xc /dev/null | FileCheck --check-prefix=PPC64-SOFTFLT %s
1116+
// PPC64-SOFTFLT:#define _SOFT_DOUBLE 1
1117+
// PPC64-SOFTFLT:#define _SOFT_FLOAT 1
1118+
// PPC64-SOFTFLT:#define __NO_FPRS__ 1

0 commit comments

Comments
 (0)