|
|
a2cf7d |
From dd8bfb911e89f3ad1da5cfa5618a8c52c62bb095 Mon Sep 17 00:00:00 2001
|
|
|
a2cf7d |
From: Stefan Liebler <stli@linux.ibm.com>
|
|
|
a2cf7d |
Date: Wed, 11 Dec 2019 15:09:31 +0100
|
|
|
a2cf7d |
Subject: [PATCH 23/28] S390: Use convert-to-fixed instruction for llround
|
|
|
a2cf7d |
functions.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
If compiled with z196 zarch support, the convert-to-fixed instruction
|
|
|
a2cf7d |
is used to implement llround, llroundf, llroundl.
|
|
|
a2cf7d |
Otherwise the common-code implementation is used.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
(cherry picked from commit 7d42d614fdc2c9d9f6ad46111bd6130501d50460)
|
|
|
a2cf7d |
---
|
|
|
a2cf7d |
sysdeps/s390/fpu/s_llround.c | 42 ++++++++++++++++++++++++++++++++++
|
|
|
a2cf7d |
sysdeps/s390/fpu/s_llroundf.c | 42 ++++++++++++++++++++++++++++++++++
|
|
|
a2cf7d |
sysdeps/s390/fpu/s_llroundl.c | 43 +++++++++++++++++++++++++++++++++++
|
|
|
a2cf7d |
3 files changed, 127 insertions(+)
|
|
|
a2cf7d |
create mode 100644 sysdeps/s390/fpu/s_llround.c
|
|
|
a2cf7d |
create mode 100644 sysdeps/s390/fpu/s_llroundf.c
|
|
|
a2cf7d |
create mode 100644 sysdeps/s390/fpu/s_llroundl.c
|
|
|
a2cf7d |
|
|
|
a2cf7d |
diff --git a/sysdeps/s390/fpu/s_llround.c b/sysdeps/s390/fpu/s_llround.c
|
|
|
a2cf7d |
new file mode 100644
|
|
|
a2cf7d |
index 0000000000..f4a1b21637
|
|
|
a2cf7d |
--- /dev/null
|
|
|
a2cf7d |
+++ b/sysdeps/s390/fpu/s_llround.c
|
|
|
a2cf7d |
@@ -0,0 +1,42 @@
|
|
|
a2cf7d |
+/* llround() - S390 version.
|
|
|
a2cf7d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ This file is part of the GNU C Library.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
a2cf7d |
+ modify it under the terms of the GNU Lesser General Public License as
|
|
|
a2cf7d |
+ published by the Free Software Foundation; either version 2.1 of the
|
|
|
a2cf7d |
+ License, or (at your option) any later version.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
a2cf7d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a2cf7d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
a2cf7d |
+ Lesser General Public License for more details.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
a2cf7d |
+ License along with the GNU C Library; if not, see
|
|
|
a2cf7d |
+ <https://www.gnu.org/licenses/>. */
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#if defined __s390x__ && defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
|
|
|
a2cf7d |
+/* We only support s390x as on s390 a long long int refers to a register pair
|
|
|
a2cf7d |
+ of two 4byte registers instead of a 8byte register which is produced by the
|
|
|
a2cf7d |
+ instruction.
|
|
|
a2cf7d |
+ Note: On s390 this instruction would only be used if build with -mzarch. */
|
|
|
a2cf7d |
+# include <math.h>
|
|
|
a2cf7d |
+# include <libm-alias-double.h>
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+long long int
|
|
|
a2cf7d |
+__llround (double x)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ long long int y;
|
|
|
a2cf7d |
+ /* The z196 zarch "convert to fixed" (cgdbra) instruction is rounding
|
|
|
a2cf7d |
+ x to the nearest integer with "ties away from 0" rounding mode
|
|
|
a2cf7d |
+ (M3-field: 1) where inexact exceptions are suppressed (M4-field: 4). */
|
|
|
a2cf7d |
+ __asm__ ("cgdbra %0,1,%1,4" : "=d" (y) : "f" (x) : "cc");
|
|
|
a2cf7d |
+ return y;
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libm_alias_double (__llround, llround)
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+# include <sysdeps/ieee754/dbl-64/s_llround.c>
|
|
|
a2cf7d |
+#endif
|
|
|
a2cf7d |
diff --git a/sysdeps/s390/fpu/s_llroundf.c b/sysdeps/s390/fpu/s_llroundf.c
|
|
|
a2cf7d |
new file mode 100644
|
|
|
a2cf7d |
index 0000000000..d202f4be8c
|
|
|
a2cf7d |
--- /dev/null
|
|
|
a2cf7d |
+++ b/sysdeps/s390/fpu/s_llroundf.c
|
|
|
a2cf7d |
@@ -0,0 +1,42 @@
|
|
|
a2cf7d |
+/* llroundf() - S390 version.
|
|
|
a2cf7d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ This file is part of the GNU C Library.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
a2cf7d |
+ modify it under the terms of the GNU Lesser General Public License as
|
|
|
a2cf7d |
+ published by the Free Software Foundation; either version 2.1 of the
|
|
|
a2cf7d |
+ License, or (at your option) any later version.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
a2cf7d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a2cf7d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
a2cf7d |
+ Lesser General Public License for more details.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
a2cf7d |
+ License along with the GNU C Library; if not, see
|
|
|
a2cf7d |
+ <https://www.gnu.org/licenses/>. */
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#if defined __s390x__ && defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
|
|
|
a2cf7d |
+/* We only support s390x as on s390 a long long int refers to a register pair
|
|
|
a2cf7d |
+ of two 4byte registers instead of a 8byte register which is produced by the
|
|
|
a2cf7d |
+ instruction.
|
|
|
a2cf7d |
+ Note: On s390 this instruction would only be used if build with -mzarch. */
|
|
|
a2cf7d |
+# include <math.h>
|
|
|
a2cf7d |
+# include <libm-alias-float.h>
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+long long int
|
|
|
a2cf7d |
+__llroundf (float x)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ long long int y;
|
|
|
a2cf7d |
+ /* The z196 zarch "convert to fixed" (cgebra) instruction is rounding
|
|
|
a2cf7d |
+ x to the nearest integer with "ties away from 0" rounding mode
|
|
|
a2cf7d |
+ (M3-field: 1) where inexact exceptions are suppressed (M4-field: 4). */
|
|
|
a2cf7d |
+ __asm__ ("cgebra %0,1,%1,4" : "=d" (y) : "f" (x) : "cc");
|
|
|
a2cf7d |
+ return y;
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libm_alias_float (__llround, llround)
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+# include <sysdeps/ieee754/flt-32/s_llroundf.c>
|
|
|
a2cf7d |
+#endif
|
|
|
a2cf7d |
diff --git a/sysdeps/s390/fpu/s_llroundl.c b/sysdeps/s390/fpu/s_llroundl.c
|
|
|
a2cf7d |
new file mode 100644
|
|
|
a2cf7d |
index 0000000000..58976cd5c5
|
|
|
a2cf7d |
--- /dev/null
|
|
|
a2cf7d |
+++ b/sysdeps/s390/fpu/s_llroundl.c
|
|
|
a2cf7d |
@@ -0,0 +1,43 @@
|
|
|
a2cf7d |
+/* llroundl() - S390 version.
|
|
|
a2cf7d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ This file is part of the GNU C Library.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
a2cf7d |
+ modify it under the terms of the GNU Lesser General Public License as
|
|
|
a2cf7d |
+ published by the Free Software Foundation; either version 2.1 of the
|
|
|
a2cf7d |
+ License, or (at your option) any later version.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
a2cf7d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a2cf7d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
a2cf7d |
+ Lesser General Public License for more details.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
a2cf7d |
+ License along with the GNU C Library; if not, see
|
|
|
a2cf7d |
+ <https://www.gnu.org/licenses/>. */
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#if defined __s390x__ && defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
|
|
|
a2cf7d |
+/* We only support s390x as on s390 a long long int refers to a register pair
|
|
|
a2cf7d |
+ of two 4byte registers instead of a 8byte register which is produced by the
|
|
|
a2cf7d |
+ instruction.
|
|
|
a2cf7d |
+ Note: On s390 this instruction would only be used if build with -mzarch. */
|
|
|
a2cf7d |
+# include <math.h>
|
|
|
a2cf7d |
+# include <math_private.h>
|
|
|
a2cf7d |
+# include <libm-alias-ldouble.h>
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+long long int
|
|
|
a2cf7d |
+__llroundl (_Float128 x)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ long long int y;
|
|
|
a2cf7d |
+ /* The z196 zarch "convert to fixed" (cgxbra) instruction is rounding
|
|
|
a2cf7d |
+ x to the nearest integer with "ties away from 0" rounding mode
|
|
|
a2cf7d |
+ (M3-field: 1) where inexact exceptions are suppressed (M4-field: 4). */
|
|
|
a2cf7d |
+ __asm__ ("cgxbra %0,1,%1,4" : "=d" (y) : "f" (x) : "cc");
|
|
|
a2cf7d |
+ return y;
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libm_alias_ldouble (__llround, llround)
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+# include <sysdeps/ieee754/ldbl-128/s_llroundl.c>
|
|
|
a2cf7d |
+#endif
|
|
|
a2cf7d |
--
|
|
|
a2cf7d |
2.18.2
|
|
|
a2cf7d |
|