[PowerPC] [Clang] Define macros to identify quad-fp semantics

We have option -mabi=ieeelongdouble to set current long double to
IEEEquad semantics. Like what GCC does, we need to define
__LONG_DOUBLE_IEEE128__ macro in this case, and __LONG_DOUBLE_IBM128__
if using PPCDoubleDouble.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D90208
This commit is contained in:
Qiu Chaofan 2020-11-12 10:19:52 +08:00
parent c7e64df445
commit 2abc33683b
2 changed files with 18 additions and 0 deletions

View File

@ -122,6 +122,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
if (LongDoubleWidth == 128) { if (LongDoubleWidth == 128) {
Builder.defineMacro("__LONG_DOUBLE_128__"); Builder.defineMacro("__LONG_DOUBLE_128__");
Builder.defineMacro("__LONGDOUBLE128"); Builder.defineMacro("__LONGDOUBLE128");
if (Opts.PPCIEEELongDouble)
Builder.defineMacro("__LONG_DOUBLE_IEEE128__");
else
Builder.defineMacro("__LONG_DOUBLE_IBM128__");
} }
// Define this for elfv2 (64-bit only) or 64-bit darwin. // Define this for elfv2 (64-bit only) or 64-bit darwin.

View File

@ -16,6 +16,20 @@
// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \ // RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
// RUN: FileCheck --check-prefix=IBM128 %s // RUN: FileCheck --check-prefix=IBM128 %s
// Check IBM-quad and IEEE-quad macros are defined.
// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
// RUN: -mabi=ibmlongdouble | FileCheck -check-prefix=CHECK-DEF-IBM128 %s
// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
// RUN: -mabi=ieeelongdouble | FileCheck -check-prefix=CHECK-DEF-IEEE128 %s
// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
// RUN: -mlong-double-64 | FileCheck -check-prefix=CHECK-DEF-F64 %s
// CHECK-DEF-IBM128: #define __LONG_DOUBLE_128__
// CHECK-DEF-IBM128: #define __LONG_DOUBLE_IBM128__
// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_128__
// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_IEEE128__
// CHECK-DEF-F64-NOT: #define __LONG_DOUBLE_128__
long double x = 0; long double x = 0;
int size = sizeof(x); int size = sizeof(x);