Sync patch from openeuler/gcc - 20230829 (cherry picked from commit 5e9724992d967ef598d70c92c5c936ebbf828946)
198 lines
6.3 KiB
Diff
198 lines
6.3 KiB
Diff
From 52a810b4d8a725a7edb2988f6c3813a9938362a5 Mon Sep 17 00:00:00 2001
|
||
From: eastb233 <xiezhiheng@huawei.com>
|
||
Date: Fri, 14 Jul 2023 11:10:24 +0800
|
||
Subject: [PATCH 04/22] [libquadmath] Enable libquadmath on kunpeng
|
||
|
||
This enable libquadmath on kunpeng platform to convenient
|
||
users that migrating from x86 platform. libquadmath uses "__float128"
|
||
as quad precision floating point type and with math functions with "q"
|
||
suffix like "cosq". For those who do not need to adapt to x86 platform,
|
||
you can use "long double" as quad precision floating point type and math
|
||
functions with "l" suffix like "cosl" in libm for quad precision math.
|
||
---
|
||
libquadmath/Makefile.am | 4 ++++
|
||
libquadmath/Makefile.in | 3 ++-
|
||
libquadmath/configure | 28 ++++++++++++++++++++++++++--
|
||
libquadmath/configure.ac | 7 +++++++
|
||
libquadmath/quadmath.h | 13 +++++++++++--
|
||
5 files changed, 50 insertions(+), 5 deletions(-)
|
||
|
||
diff --git a/libquadmath/Makefile.am b/libquadmath/Makefile.am
|
||
index 35dffb46f..bf0398d9c 100644
|
||
--- a/libquadmath/Makefile.am
|
||
+++ b/libquadmath/Makefile.am
|
||
@@ -2,6 +2,10 @@
|
||
|
||
AUTOMAKE_OPTIONS = foreign info-in-builddir
|
||
|
||
+if ARCH_AARCH64
|
||
+DEFS += -D__float128="long double"
|
||
+endif
|
||
+
|
||
## Skip over everything if the quadlib is not available:
|
||
if BUILD_LIBQUADMATH
|
||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||
diff --git a/libquadmath/Makefile.in b/libquadmath/Makefile.in
|
||
index 8c0112122..449cc8a06 100644
|
||
--- a/libquadmath/Makefile.in
|
||
+++ b/libquadmath/Makefile.in
|
||
@@ -90,6 +90,7 @@ POST_UNINSTALL = :
|
||
build_triplet = @build@
|
||
host_triplet = @host@
|
||
target_triplet = @target@
|
||
+@ARCH_AARCH64_TRUE@am__append_1 = -D__float128="long double"
|
||
@BUILD_LIBQUADMATH_FALSE@libquadmath_la_DEPENDENCIES =
|
||
subdir = .
|
||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||
@@ -337,7 +338,7 @@ CFLAGS = @CFLAGS@
|
||
CPP = @CPP@
|
||
CPPFLAGS = @CPPFLAGS@
|
||
CYGPATH_W = @CYGPATH_W@
|
||
-DEFS = @DEFS@
|
||
+DEFS = @DEFS@ $(am__append_1)
|
||
DEPDIR = @DEPDIR@
|
||
DSYMUTIL = @DSYMUTIL@
|
||
DUMPBIN = @DUMPBIN@
|
||
diff --git a/libquadmath/configure b/libquadmath/configure
|
||
index 603f2f131..13a9088fb 100755
|
||
--- a/libquadmath/configure
|
||
+++ b/libquadmath/configure
|
||
@@ -633,6 +633,8 @@ am__EXEEXT_TRUE
|
||
LTLIBOBJS
|
||
LIBOBJS
|
||
get_gcc_base_ver
|
||
+ARCH_AARCH64_FALSE
|
||
+ARCH_AARCH64_TRUE
|
||
GENINSRC_FALSE
|
||
GENINSRC_TRUE
|
||
XCFLAGS
|
||
@@ -10806,7 +10808,7 @@ else
|
||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||
lt_status=$lt_dlunknown
|
||
cat > conftest.$ac_ext <<_LT_EOF
|
||
-#line 10809 "configure"
|
||
+#line 10811 "configure"
|
||
#include "confdefs.h"
|
||
|
||
#if HAVE_DLFCN_H
|
||
@@ -10912,7 +10914,7 @@ else
|
||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||
lt_status=$lt_dlunknown
|
||
cat > conftest.$ac_ext <<_LT_EOF
|
||
-#line 10915 "configure"
|
||
+#line 10917 "configure"
|
||
#include "confdefs.h"
|
||
|
||
#if HAVE_DLFCN_H
|
||
@@ -12705,6 +12707,11 @@ else
|
||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||
/* end confdefs.h. */
|
||
|
||
+ #if defined(__aarch64__)
|
||
+ typedef long double __float128;
|
||
+ #define __builtin_huge_valq() (__extension__ 0x1.0p32767Q)
|
||
+ #endif
|
||
+
|
||
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
|
||
typedef _Complex float __attribute__((mode(TC))) __complex128;
|
||
#else
|
||
@@ -12756,6 +12763,11 @@ fi
|
||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||
/* end confdefs.h. */
|
||
|
||
+ #if defined(__aarch64__)
|
||
+ typedef long double __float128;
|
||
+ #define __builtin_huge_valq() (__extension__ 0x1.0p32767Q)
|
||
+ #endif
|
||
+
|
||
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
|
||
typedef _Complex float __attribute__((mode(TC))) __complex128;
|
||
#else
|
||
@@ -13242,6 +13254,14 @@ else
|
||
GENINSRC_FALSE=
|
||
fi
|
||
|
||
+ if expr "$target_cpu" : "aarch64.*" > /dev/null; then
|
||
+ ARCH_AARCH64_TRUE=
|
||
+ ARCH_AARCH64_FALSE='#'
|
||
+else
|
||
+ ARCH_AARCH64_TRUE='#'
|
||
+ ARCH_AARCH64_FALSE=
|
||
+fi
|
||
+
|
||
|
||
# Determine what GCC version number to use in filesystem paths.
|
||
|
||
@@ -13425,6 +13445,10 @@ if test -z "${GENINSRC_TRUE}" && test -z "${GENINSRC_FALSE}"; then
|
||
as_fn_error $? "conditional \"GENINSRC\" was never defined.
|
||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||
fi
|
||
+if test -z "${ARCH_AARCH64_TRUE}" && test -z "${ARCH_AARCH64_FALSE}"; then
|
||
+ as_fn_error $? "conditional \"ARCH_AARCH64\" was never defined.
|
||
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||
+fi
|
||
|
||
: "${CONFIG_STATUS=./config.status}"
|
||
ac_write_fail=0
|
||
diff --git a/libquadmath/configure.ac b/libquadmath/configure.ac
|
||
index eec4084a4..507c247d6 100644
|
||
--- a/libquadmath/configure.ac
|
||
+++ b/libquadmath/configure.ac
|
||
@@ -218,6 +218,11 @@ AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
|
||
|
||
AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128],
|
||
[GCC_TRY_COMPILE_OR_LINK([
|
||
+ #if defined(__aarch64__)
|
||
+ typedef long double __float128;
|
||
+ #define __builtin_huge_valq() (__extension__ 0x1.0p32767Q)
|
||
+ #endif
|
||
+
|
||
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
|
||
typedef _Complex float __attribute__((mode(TC))) __complex128;
|
||
#else
|
||
@@ -393,6 +398,8 @@ AS_HELP_STRING([--enable-generated-files-in-srcdir],
|
||
[enable_generated_files_in_srcdir=no])
|
||
AC_MSG_RESULT($enable_generated_files_in_srcdir)
|
||
AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
|
||
+AM_CONDITIONAL(ARCH_AARCH64,
|
||
+ [expr "$target_cpu" : "aarch64.*" > /dev/null])
|
||
|
||
# Determine what GCC version number to use in filesystem paths.
|
||
GCC_BASE_VER
|
||
diff --git a/libquadmath/quadmath.h b/libquadmath/quadmath.h
|
||
index 81eb957d2..bb1b49df6 100644
|
||
--- a/libquadmath/quadmath.h
|
||
+++ b/libquadmath/quadmath.h
|
||
@@ -27,6 +27,12 @@ Boston, MA 02110-1301, USA. */
|
||
extern "C" {
|
||
#endif
|
||
|
||
+#if defined(__aarch64__)
|
||
+#ifndef __float128
|
||
+typedef long double __float128;
|
||
+#endif
|
||
+#endif
|
||
+
|
||
/* Define the complex type corresponding to __float128
|
||
("_Complex __float128" is not allowed) */
|
||
#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
|
||
@@ -160,10 +166,13 @@ extern int quadmath_snprintf (char *str, size_t size,
|
||
#define FLT128_MAX_10_EXP 4932
|
||
|
||
|
||
-#define HUGE_VALQ __builtin_huge_valq()
|
||
+#if defined(__aarch64__)
|
||
/* The following alternative is valid, but brings the warning:
|
||
(floating constant exceeds range of ‘__float128’) */
|
||
-/* #define HUGE_VALQ (__extension__ 0x1.0p32767Q) */
|
||
+# define HUGE_VALQ (__extension__ 0x1.0p32767Q)
|
||
+#else
|
||
+# define HUGE_VALQ __builtin_huge_valq()
|
||
+#endif
|
||
|
||
#define M_Eq 2.718281828459045235360287471352662498Q /* e */
|
||
#define M_LOG2Eq 1.442695040888963407359924681001892137Q /* log_2 e */
|
||
--
|
||
2.33.0
|
||
|