public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/google/grte/v5-2.27/master] Changes to compile glibc-2.27 on PPC (Power8) with clang.
@ 2021-08-28 0:41 Fangrui Song
0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-08-28 0:41 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9e8081d12305a328306381c5d33297779c584ebd
commit 9e8081d12305a328306381c5d33297779c584ebd
Author: Raman Tenneti <rtenneti@google.com>
Date: Fri Aug 27 16:36:05 2021 -0700
Changes to compile glibc-2.27 on PPC (Power8) with clang.
+ Use DOT_MACHINE macro instead of ".machine" instruction.
+ Use __isinf and __isinff instead of builtin versions.
+ In s_logb, s_logbf and s_logbl functions, used float versions to
calculate "ret = x & 0x7f800000;" expression.
Diff:
---
sysdeps/powerpc/power5+/fpu/s_modf.c | 10 ++++++++++
sysdeps/powerpc/power5+/fpu/s_modff.c | 10 ++++++++++
sysdeps/powerpc/power7/fpu/s_logb.c | 9 +++++++++
sysdeps/powerpc/power7/fpu/s_logbf.c | 7 +++++++
sysdeps/powerpc/power7/fpu/s_logbl.c | 8 ++++++++
5 files changed, 44 insertions(+)
diff --git a/sysdeps/powerpc/power5+/fpu/s_modf.c b/sysdeps/powerpc/power5+/fpu/s_modf.c
index 7a32d31303..041f2153ff 100644
--- a/sysdeps/powerpc/power5+/fpu/s_modf.c
+++ b/sysdeps/powerpc/power5+/fpu/s_modf.c
@@ -23,12 +23,22 @@
double
__modf (double x, double *iptr)
{
+ /* Google-specific: Fix for clang. */
+#if defined __clang__
+ if (__isinf (x))
+#else
if (__builtin_isinf (x))
+#endif
{
*iptr = x;
return __copysign (0.0, x);
}
+ /* Google-specific: Fix for clang. */
+#if defined __clang__
+ else if (__isnan (x))
+#else
else if (__builtin_isnan (x))
+#endif
{
*iptr = NAN;
return NAN;
diff --git a/sysdeps/powerpc/power5+/fpu/s_modff.c b/sysdeps/powerpc/power5+/fpu/s_modff.c
index c1bbae6479..3b74605935 100644
--- a/sysdeps/powerpc/power5+/fpu/s_modff.c
+++ b/sysdeps/powerpc/power5+/fpu/s_modff.c
@@ -22,12 +22,22 @@
float
__modff (float x, float *iptr)
{
+ /* Google-specific: Fix for clang. */
+#if defined __clang__
+ if (__isinff (x))
+#else
if (__builtin_isinff (x))
+#endif
{
*iptr = x;
return __copysignf (0.0, x);
}
+ /* Google-specific: Fix for clang. */
+#if defined __clang__
+ else if (__isnanf (x))
+#else
else if (__builtin_isnanf (x))
+#endif
{
*iptr = NAN;
return NAN;
diff --git a/sysdeps/powerpc/power7/fpu/s_logb.c b/sysdeps/powerpc/power7/fpu/s_logb.c
index 160b9334de..40a689725d 100644
--- a/sysdeps/powerpc/power7/fpu/s_logb.c
+++ b/sysdeps/powerpc/power7/fpu/s_logb.c
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <math_ldbl_opt.h>
+#include <math_private.h>
#include <libm-alias-double.h>
/* This implementation avoids FP to INT conversions by using VSX
@@ -41,11 +42,19 @@ __logb (double x)
return -1.0 / __builtin_fabs (x);
/* ret = x & 0x7ff0000000000000; */
+#if !defined __clang__
asm (
"xxland %x0,%x1,%x2\n"
"fcfid %0,%0"
: "=f" (ret)
: "f" (x), "f" (mask.d));
+#else
+ /* TODO(rtenneti): This is wrong. Handle double */
+ int64_t inum;
+ GET_FLOAT_WORD(inum, x);
+ inum = (inum & 0x7ff0000000000000);
+ SET_FLOAT_WORD(ret, inum);
+#endif
/* ret = (ret >> 52) - 1023.0; */
ret = (ret * two1div52) + two10m1;
if (__builtin_expect (ret > -two10m1, 0))
diff --git a/sysdeps/powerpc/power7/fpu/s_logbf.c b/sysdeps/powerpc/power7/fpu/s_logbf.c
index 0832ad7022..0da0f37490 100644
--- a/sysdeps/powerpc/power7/fpu/s_logbf.c
+++ b/sysdeps/powerpc/power7/fpu/s_logbf.c
@@ -43,11 +43,18 @@ __logbf (float x)
return -1.0 / __builtin_fabsf (x);
/* ret = x & 0x7f800000; */
+#if !defined __clang__
asm (
"xxland %x0,%x1,%x2\n"
"fcfid %0,%0"
: "=f"(ret)
: "f" (x), "f" (mask.d));
+#else
+ int32_t inum;
+ GET_FLOAT_WORD(inum, x);
+ inum = (inum & 0x7ff0000000000000);
+ SET_FLOAT_WORD(ret, inum);
+#endif
/* ret = (ret >> 52) - 1023.0, since ret is double. */
ret = (ret * two1div52) + two10m1;
if (__builtin_expect (ret > -two7m1, 0))
diff --git a/sysdeps/powerpc/power7/fpu/s_logbl.c b/sysdeps/powerpc/power7/fpu/s_logbl.c
index 192145a7a1..997dfcf8fb 100644
--- a/sysdeps/powerpc/power7/fpu/s_logbl.c
+++ b/sysdeps/powerpc/power7/fpu/s_logbl.c
@@ -46,11 +46,19 @@ __logbl (long double x)
ldbl_unpack (x, &xh, &xl);
EXTRACT_WORDS64 (hx, xh);
/* ret = x & 0x7ff0000000000000; */
+#if !defined __clang__
asm (
"xxland %x0,%x1,%x2\n"
"fcfid %0,%0"
: "=f" (ret)
: "f" (xh), "f" (mask.d));
+#else
+ /* TODO(rtenneti): This is wrong. Handle double */
+ int64_t inum;
+ GET_FLOAT_WORD(inum, x);
+ inum = (inum & 0x7ff0000000000000);
+ SET_FLOAT_WORD(ret, inum);
+#endif
/* ret = (ret >> 52) - 1023.0; */
ret = (ret * two1div52) + two10m1;
if (__builtin_expect (ret > -two10m1, 0))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-28 0:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28 0:41 [glibc/google/grte/v5-2.27/master] Changes to compile glibc-2.27 on PPC (Power8) with clang Fangrui Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).