]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: Implement math acceleration via builtins
authorMichael Collison <michael.collison@arm.com>
Mon, 23 Oct 2017 09:28:01 +0000 (10:28 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Mon, 23 Oct 2017 09:32:56 +0000 (10:32 +0100)
This patch converts asm statements into builtins for AArch64.  As an
example for the file sysdeps/aarch64/fpu/s_ceil.c, we convert the
function from

double
__ceil (double x)
{
  double result;
  asm ("frintp\t%d0, %d1" :
       "=w" (result) : "w" (x) );
  return result;
}

into

double
__ceil (double x)
{
  return __builtin_ceil (x);
}

Tested on aarch64-linux-gnu with gcc-4.9.4 and gcc-6.

* sysdeps/aarch64/fpu/e_sqrt.c (ieee754_sqrt): Replace asm statements
with __builtin_sqrt.
* sysdeps/aarch64/fpu/e_sqrtf.c (ieee754_sqrtf): Replace asm statements
with __builtin_sqrtf.
* sysdeps/aarch64/fpu/s_ceil.c (__ceil): Replace asm statements
with __builtin_ceil.
* sysdeps/aarch64/fpu/s_ceilf.c (__ceilf): Replace asm statements
with __builtin_ceilf.
* sysdeps/aarch64/fpu/s_floor.c (__floor): Replace asm statements
with __builtin_floor.
* sysdeps/aarch64/fpu/s_floorf.c (__floorf): Replace asm statements
with __builtin_floorf.
* sysdeps/aarch64/fpu/s_fma.c (__fma): Replace asm statements
with __builtin_fma.
* sysdeps/aarch64/fpu/s_fmaf.c (__fmaf): Replace asm statements
with __builtin_fmaf.
* sysdeps/aarch64/fpu/s_fmax.c (__fmax): Replace asm statements
with __builtin_fmax.
* sysdeps/aarch64/fpu/s_fmaxf.c (__fmaxf): Replace asm statements
with __builtin_fmaxf.
* sysdeps/aarch64/fpu/s_fmin.c (__fmin): Replace asm statements
with __builtin_fmin.
* sysdeps/aarch64/fpu/s_fminf.c (__fminf): Replace asm statements
with __builtin_fminf.
* sysdeps/aarch64/fpu/s_frint.c: Delete file.
* sysdeps/aarch64/fpu/s_frintf.c: Delete file.
* sysdeps/aarch64/fpu/s_llrint.c (__llrint): Replace asm statements
with builtin_rint and conversion to int.
* sysdeps/aarch64/fpu/s_llrintf.c (__llrintf): Likewise.
* sysdeps/aarch64/fpu/s_llround.c (__llround): Replace asm statements
with builtin_llround.
* sysdeps/aarch64/fpu/s_llroundf.c (__llroundf): Likewise.
* sysdeps/aarch64/fpu/s_lrint.c (__lrint): Replace asm statements
with builtin_rint and conversion to long int.
* sysdeps/aarch64/fpu/s_lrintf.c (__lrintf): Likewise.
* sysdeps/aarch64/fpu/s_lround.c (__lround): Replace asm statements
with builtin_lround.
* sysdeps/aarch64/fpu/s_lroundf.c (__lroundf): Replace asm statements
with builtin_lroundf.
* sysdeps/aarch64/fpu/s_nearbyint.c (__nearbyint): Replace asm
statements with __builtin_nearbyint.
* sysdeps/aarch64/fpu/s_nearbyintf.c (__nearbyintf): Replace asm
statements with __builtin_nearbyintf.
* sysdeps/aarch64/fpu/s_rint.c (__rint): Replace asm statements
with __builtin_rint.
* sysdeps/aarch64/fpu/s_rintf.c (__rintf): Replace asm statements
with __builtin_rintf.
* sysdeps/aarch64/fpu/s_round.c (__round): Replace asm statements
with __builtin_round.
* sysdeps/aarch64/fpu/s_roundf.c (__roundf): Replace asm statements
with __builtin_roundf.
* sysdeps/aarch64/fpu/s_trunc.c (__trunc): Replace asm statements
with __builtin_trunc.
* sysdeps/aarch64/fpu/s_truncf.c (__truncf): Replace asm statements
with __builtin_truncf.
* sysdeps/aarch64/fpu/Makefile: Build e_sqrt[f].c with -fno-math-errno.

31 files changed:
ChangeLog
sysdeps/aarch64/fpu/e_sqrt.c
sysdeps/aarch64/fpu/e_sqrtf.c
sysdeps/aarch64/fpu/s_ceil.c
sysdeps/aarch64/fpu/s_ceilf.c
sysdeps/aarch64/fpu/s_floor.c
sysdeps/aarch64/fpu/s_floorf.c
sysdeps/aarch64/fpu/s_fma.c
sysdeps/aarch64/fpu/s_fmaf.c
sysdeps/aarch64/fpu/s_fmax.c
sysdeps/aarch64/fpu/s_fmaxf.c
sysdeps/aarch64/fpu/s_fmin.c
sysdeps/aarch64/fpu/s_fminf.c
sysdeps/aarch64/fpu/s_frint.c [deleted file]
sysdeps/aarch64/fpu/s_frintf.c [deleted file]
sysdeps/aarch64/fpu/s_llrint.c
sysdeps/aarch64/fpu/s_llrintf.c
sysdeps/aarch64/fpu/s_llround.c
sysdeps/aarch64/fpu/s_llroundf.c
sysdeps/aarch64/fpu/s_lrint.c
sysdeps/aarch64/fpu/s_lrintf.c
sysdeps/aarch64/fpu/s_lround.c
sysdeps/aarch64/fpu/s_lroundf.c
sysdeps/aarch64/fpu/s_nearbyint.c
sysdeps/aarch64/fpu/s_nearbyintf.c
sysdeps/aarch64/fpu/s_rint.c
sysdeps/aarch64/fpu/s_rintf.c
sysdeps/aarch64/fpu/s_round.c
sysdeps/aarch64/fpu/s_roundf.c
sysdeps/aarch64/fpu/s_trunc.c
sysdeps/aarch64/fpu/s_truncf.c

index 677f46d61accca7790bd0edffa6bbe27c97560aa..4a011b136b6187ed3485f69a4fd305a71ab15eba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,62 @@
+2017-10-23  Michael Collison  <michael.collison@arm.com>
+
+       * sysdeps/aarch64/fpu/e_sqrt.c (ieee754_sqrt): Replace asm statements
+       with __builtin_sqrt.
+       * sysdeps/aarch64/fpu/e_sqrtf.c (ieee754_sqrtf): Replace asm statements
+       with __builtin_sqrtf.
+       * sysdeps/aarch64/fpu/s_ceil.c (__ceil): Replace asm statements
+       with __builtin_ceil.
+       * sysdeps/aarch64/fpu/s_ceilf.c (__ceilf): Replace asm statements
+       with __builtin_ceilf.
+       * sysdeps/aarch64/fpu/s_floor.c (__floor): Replace asm statements
+       with __builtin_floor.
+       * sysdeps/aarch64/fpu/s_floorf.c (__floorf): Replace asm statements
+       with __builtin_floorf.
+       * sysdeps/aarch64/fpu/s_fma.c (__fma): Replace asm statements
+       with __builtin_fma.
+       * sysdeps/aarch64/fpu/s_fmaf.c (__fmaf): Replace asm statements
+       with __builtin_fmaf.
+       * sysdeps/aarch64/fpu/s_fmax.c (__fmax): Replace asm statements
+       with __builtin_fmax.
+       * sysdeps/aarch64/fpu/s_fmaxf.c (__fmaxf): Replace asm statements
+       with __builtin_fmaxf.
+       * sysdeps/aarch64/fpu/s_fmin.c (__fmin): Replace asm statements
+       with __builtin_fmin.
+       * sysdeps/aarch64/fpu/s_fminf.c (__fminf): Replace asm statements
+       with __builtin_fminf.
+       * sysdeps/aarch64/fpu/s_frint.c: Delete file.
+       * sysdeps/aarch64/fpu/s_frintf.c: Delete file.
+       * sysdeps/aarch64/fpu/s_llrint.c (__llrint): Replace asm statements
+       with builtin_rint and conversion to int.
+       * sysdeps/aarch64/fpu/s_llrintf.c (__llrintf): Likewise.
+       * sysdeps/aarch64/fpu/s_llround.c (__llround): Replace asm statements
+       with builtin_llround.
+       * sysdeps/aarch64/fpu/s_llroundf.c (__llroundf): Likewise.
+       * sysdeps/aarch64/fpu/s_lrint.c (__lrint): Replace asm statements
+       with builtin_rint and conversion to long int.
+       * sysdeps/aarch64/fpu/s_lrintf.c (__lrintf): Likewise.
+       * sysdeps/aarch64/fpu/s_lround.c (__lround): Replace asm statements
+       with builtin_lround.
+       * sysdeps/aarch64/fpu/s_lroundf.c (__lroundf): Replace asm statements
+       with builtin_lroundf.
+       * sysdeps/aarch64/fpu/s_nearbyint.c (__nearbyint): Replace asm
+       statements with __builtin_nearbyint.
+       * sysdeps/aarch64/fpu/s_nearbyintf.c (__nearbyintf): Replace asm
+       statements with __builtin_nearbyintf.
+       * sysdeps/aarch64/fpu/s_rint.c (__rint): Replace asm statements
+       with __builtin_rint.
+       * sysdeps/aarch64/fpu/s_rintf.c (__rintf): Replace asm statements
+       with __builtin_rintf.
+       * sysdeps/aarch64/fpu/s_round.c (__round): Replace asm statements
+       with __builtin_round.
+       * sysdeps/aarch64/fpu/s_roundf.c (__roundf): Replace asm statements
+       with __builtin_roundf.
+       * sysdeps/aarch64/fpu/s_trunc.c (__trunc): Replace asm statements
+       with __builtin_trunc.
+       * sysdeps/aarch64/fpu/s_truncf.c (__truncf): Replace asm statements
+       with __builtin_truncf.
+       * sysdeps/aarch64/fpu/Makefile: Build e_sqrt[f].c with -fno-math-errno.
+
 2017-10-23  Alan Modra  <amodra@gmail.com>
 
        * sysdeps/powerpc/powerpc64/power8/strncpy.S: Move LR cfi.
index f984d877b64eea72e23b8c099c41923bf60911f7..b80ac272611ebf8d4959f366ea7e5e8207ddbe22 100644 (file)
@@ -21,8 +21,6 @@
 double
 __ieee754_sqrt (double d)
 {
-  double res;
-  asm ("fsqrt   %d0, %d1" : "=w" (res) : "w" (d));
-  return res;
+  return __builtin_sqrt (d);
 }
 strong_alias (__ieee754_sqrt, __sqrt_finite)
index 67707ef83374fdb2b330d0c9b0cfb8770036a98b..73804542c812f28de96ce68a6fe64f44284856eb 100644 (file)
@@ -21,8 +21,6 @@
 float
 __ieee754_sqrtf (float s)
 {
-  float res;
-  asm ("fsqrt   %s0, %s1" : "=w" (res) : "w" (s));
-  return res;
+  return __builtin_sqrtf (s);
 }
 strong_alias (__ieee754_sqrtf, __sqrtf_finite)
index d0a8bd89817991b7eb9fd3b95c2dcea1a4c0dc28..bc90ab98db4e5bbbc19779672d7544f8a95619ac 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define        FUNC ceil
-#define INSN "frintp"
-#include <s_frint.c>
+#include <math.h>
+
+double
+__ceil (double x)
+{
+  return __builtin_ceil (x);
+}
+
+weak_alias (__ceil, ceil)
index b9c2e7c3e567f2a85e4da3f3625f9d46d541b3b9..d5c438335eb03fea49220c2be3ee10f08b8d47d6 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define        FUNC ceilf
-#define INSN "frintp"
-#include <s_frintf.c>
+#include <math.h>
+
+float
+__ceilf (float x)
+{
+  return __builtin_ceilf (x);
+}
+
+weak_alias (__ceilf, ceilf)
index f7f8731d98d5b6b440abd2b7303efdb82b345fc6..049535c8bfeb8af8bde340741e0387ff549a4bc2 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC floor
-#define INSN "frintm"
-#include <s_frint.c>
+#include <math.h>
+
+double
+__floor (double x)
+{
+  return __builtin_floor (x);
+}
+
+weak_alias (__floor, floor)
index 7be63b5a047ccbb9e9c9a1d9b6fbed03656202fb..fa6fa17907d7c7b8a8e47cf48c5a659c9f8196ff 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC floorf
-#define INSN "frintm"
-#include <s_frintf.c>
+#include <math.h>
+
+float
+__floorf (float x)
+{
+  return __builtin_floorf (x);
+}
+
+weak_alias (__floorf, floorf)
index 6f62ce2365cb5690b204db8ff678ca090e008bf4..e496ec64380479f299b3ed746c8f26e13cdd50ee 100644 (file)
 
 #include <math.h>
 
-#ifndef FUNC
-# define FUNC fma
-#endif
-
-#ifndef TYPE
-# define TYPE double
-# define REGS "d"
-#else
-# ifndef REGS
-#  error REGS not defined
-# endif
-#endif
-
-#define __CONCATX(a,b) __CONCAT(a,b)
-
-TYPE
-__CONCATX(__,FUNC) (TYPE x, TYPE y, TYPE z)
+double
+__fma (double x, double y, double z)
 {
-  TYPE result;
-  asm ( "fmadd" "\t%" REGS "0, %" REGS "1, %" REGS "2, %" REGS "3"
-        : "=w" (result) : "w" (x), "w" (y), "w" (z) );
-  return result;
+  return __builtin_fma (x, y, z);
 }
 
-weak_alias (__CONCATX(__,FUNC), FUNC)
+weak_alias (__fma, fma)
index 880a22dfd4dc83ce4cfbad98de9f28d4f62b23d4..ff1abbf5b4b63c042a4ef491906bee6d972a8ba7 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC fmaf
-#define TYPE float
-#define REGS "s"
-#include <s_fma.c>
+#include <math.h>
+
+float
+__fmaf (float x, float y, float z)
+{
+  return __builtin_fmaf (x, y, z);
+}
+
+weak_alias (__fmaf, fmaf)
index 395a9bacfd56b16de0e5d1d2d5dcc4c293357a2d..d7a82f89808649004eac7afba3ad76a09bd8bd97 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC fmax
-#define INSN "fmaxnm"
-#include <fpu/s_fmin.c>
+#include <math.h>
+
+double
+__fmax (double x, double y)
+{
+  return __builtin_fmax (x, y);
+}
+
+weak_alias (__fmax, fmax)
index f450d9fe829da9b3104e0d9c521b29d3d47c45f1..ec4dcdd8c06307f59e6ca69b6297bb2a8bfd58b6 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC fmaxf
-#define INSN "fmaxnm"
-#define TYPE float
-#define REGS "s"
-#include <fpu/s_fmin.c>
+#include <math.h>
+
+float
+__fmaxf (float x, float y)
+{
+  return __builtin_fmaxf (x, y);
+}
+
+weak_alias (__fmaxf, fmaxf)
index b6d32d5050c088b4092b9635107ddd7390475a1e..bba894e9b00ad1ec96a454655dc506dbfc907cf3 100644 (file)
 
 #include <math.h>
 
-#ifndef FUNC
-# define FUNC fmin
-#endif
-
-#ifndef INSN
-# define INSN "fminnm"
-#endif
-
-#ifndef TYPE
-# define TYPE double
-# define REGS "d"
-#else
-# ifndef REGS
-#  error REGS not defined
-# endif
-#endif
-
-#define __CONCATX(a,b) __CONCAT(a,b)
-
-TYPE
-__CONCATX(__,FUNC) (TYPE x, TYPE y)
+double
+__fmin (double x, double y)
 {
-  TYPE result;
-  asm ( INSN "\t%" REGS "0, %" REGS "1, %" REGS "2"
-        : "=w" (result) : "w" (x), "w" (y) );
-  return result;
+  return __builtin_fmin (x, y);
 }
 
-weak_alias (__CONCATX(__,FUNC), FUNC)
+weak_alias (__fmin, fmin)
index 032262d9530576b252324abb726db2162e3a347b..7d3a3a3a323d0063de6d723c204aeed52133f5d0 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC fminf
-#define TYPE float
-#define REGS "s"
-#include <fpu/s_fmin.c>
+#include <math.h>
+
+float
+__fminf (float x, float y)
+{
+  return __builtin_fminf (x, y);
+}
+
+weak_alias (__fminf, fminf)
diff --git a/sysdeps/aarch64/fpu/s_frint.c b/sysdeps/aarch64/fpu/s_frint.c
deleted file mode 100644 (file)
index 48881f5..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-
-#ifndef FUNC
-# error FUNC not defined
-#endif
-
-#ifndef TYPE
-# define TYPE double
-# define REGS "d"
-#else
-# ifndef REGS
-#  error REGS not defined
-# endif
-#endif
-
-#ifndef INSN
-# error INSN not defined
-#endif
-
-#define __CONCATX(a,b) __CONCAT(a,b)
-
-TYPE
-__CONCATX(__,FUNC) (TYPE x)
-{
-  TYPE result;
-  asm ( INSN "\t%" REGS "0, %" REGS "1" :
-       "=w" (result) : "w" (x) );
-  return result;
-}
-
-weak_alias (__CONCATX(__,FUNC), FUNC)
diff --git a/sysdeps/aarch64/fpu/s_frintf.c b/sysdeps/aarch64/fpu/s_frintf.c
deleted file mode 100644 (file)
index dae99d7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef FUNC
-# error FUNC not defined
-#endif
-#define TYPE float
-#define REGS "s"
-#include <s_frint.c>
index 57821c02f86e7cd89ffcdbf68c5ce58546cf8e48..f0e0b09b52de1a9ec33cd026efb19204e80b7d7c 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC llrint
-#define OTYPE long long int
-#define OREG_SIZE 64
-#include <s_lrint.c>
+#include <math.h>
+#include <math_private.h>
+
+long long int
+__llrint (double x)
+{
+  double r = __builtin_rint (x);
+
+  /* Prevent gcc from calling llrint directly when compiled with
+     -fno-math-errno by inserting a barrier.  */
+
+  math_opt_barrier (r);
+  return r;
+}
+
+weak_alias (__llrint, llrint)
index 98ed4f864ef75e523427f6cf8cdd4401f5da2f41..dac73f20582a9b18308f995657b5855e4febcd15 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC llrintf
-#define ITYPE float
-#define IREG_SIZE 32
-#define OTYPE long long int
-#define OREG_SIZE 64
-#include <s_lrint.c>
+#include <math.h>
+#include <math_private.h>
+
+long long int
+__llrintf (float x)
+{
+  float r = __builtin_rintf (x);
+
+  /* Prevent gcc from calling llrintf directly when compiled with
+     -fno-math-errno by inserting a barrier.  */
+
+
+  math_opt_barrier (r);
+  return r;
+}
+
+weak_alias (__llrintf, llrintf)
index ef7aedf36b64984f785616aca5a033c72ee6cd29..2902946bcd7f2bbfa88fecb7eebe6d1d4ffd176d 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC llround
-#define OTYPE long long int
-#define OREG_SIZE 64
-#include <s_lround.c>
+#include <math.h>
+
+long long int
+__llround (double x)
+{
+  return __builtin_llround (x);
+}
+
+weak_alias (__llround, llround)
index 294f0f4761454f3e015da3f482af4952b4a736e3..0ca390baec798568fe9cd07aa7b9405bccf3c29c 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC llroundf
-#define ITYPE float
-#define IREG_SIZE 32
-#define OTYPE long long int
-#define OREG_SIZE 64
-#include <s_lround.c>
+#include <math.h>
+
+long long int
+__llroundf (float x)
+{
+  return __builtin_llroundf (x);
+}
+
+weak_alias (__llroundf, llroundf)
index 6ef64e22bfeda20a2bfa52167145d638c37e265b..ee645ad29e6e37facf56b14728f75d5755f77d6c 100644 (file)
 #include <math.h>
 #include <get-rounding-mode.h>
 #include <stdint.h>
+#include <math_private.h>
 
-#ifndef FUNC
-# define FUNC lrint
-#endif
-
-#ifndef ITYPE
-# define ITYPE double
 # define IREG_SIZE 64
-#else
-# ifndef IREG_SIZE
-#  error IREG_SIZE not defined
-# endif
-#endif
 
-#ifndef OTYPE
-# define OTYPE long int
 # ifdef __ILP32__
 #  define OREG_SIZE 32
 # else
 #  define OREG_SIZE 64
 # endif
-#else
-# ifndef OREG_SIZE
-#  error OREG_SIZE not defined
-# endif
-#endif
 
-#if IREG_SIZE == 32
-# define IREGS "s"
-#else
 # define IREGS "d"
-#endif
 
 #if OREG_SIZE == 32
 # define OREGS "w"
 # define OREGS "x"
 #endif
 
-#define __CONCATX(a,b) __CONCAT(a,b)
 
-OTYPE
-__CONCATX(__,FUNC) (ITYPE x)
+long int
+__lrint (double x)
 {
-  OTYPE result;
-  ITYPE temp;
 
 #if IREG_SIZE == 64 && OREG_SIZE == 32
+  long int result;
+
   if (__builtin_fabs (x) > INT32_MAX)
     {
       /* Converting large values to a 32 bit int may cause the frintx/fcvtza
@@ -96,10 +74,14 @@ __CONCATX(__,FUNC) (ITYPE x)
       return result;
     }
 #endif
-  asm ( "frintx" "\t%" IREGS "1, %" IREGS "2\n\t"
-        "fcvtzs" "\t%" OREGS "0, %" IREGS "1"
-        : "=r" (result), "=w" (temp) : "w" (x) );
-  return result;
+
+  double r =  __builtin_rint (x);
+
+  /* Prevent gcc from calling lrint directly when compiled with
+     -fno-math-errno by inserting a barrier.  */
+
+  math_opt_barrier (r);
+  return r;
 }
 
-weak_alias (__CONCATX(__,FUNC), FUNC)
+weak_alias (__lrint, lrint)
index 2e7327149781e830e57eead00d651ed1f197487e..5b6a42693790fc58e6258532094049aad7b72a2b 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC lrintf
-#define ITYPE float
-#define IREG_SIZE 32
-#include <s_lrint.c>
+#include <math.h>
+#include <math_private.h>
+
+long int
+__lrintf (float x)
+{
+  float r = __builtin_rintf (x);
+
+  /* Prevent gcc from calling lrintf directly when compiled with
+     -fno-math-errno by inserting a barrier.  */
+
+  math_opt_barrier (r);
+  return r;
+}
+
+weak_alias (__lrintf, lrintf)
index 1f77d82e338b97902f1811233eb372924dcd88ac..90c3163e8e209d3fea2b9fac9b29c1dabc259b84 100644 (file)
 
 #include <math.h>
 
-#ifndef FUNC
-# define FUNC lround
-#endif
+long int
+__lround (double x)
+ {
+  return __builtin_lround (x);
+ }
 
-#ifndef ITYPE
-# define ITYPE double
-# define IREG_SIZE 64
-#else
-# ifndef IREG_SIZE
-#  error IREG_SIZE not defined
-# endif
-#endif
-
-#ifndef OTYPE
-# define OTYPE long int
-# ifdef __ILP32__
-#  define OREG_SIZE 32
-# else
-#  define OREG_SIZE 64
-# endif
-#else
-# ifndef OREG_SIZE
-#  error OREG_SIZE not defined
-# endif
-#endif
-
-#if IREG_SIZE == 32
-# define IREGS "s"
-#else
-# define IREGS "d"
-#endif
-
-#if OREG_SIZE == 32
-# define OREGS "w"
-#else
-# define OREGS "x"
-#endif
-
-#define __CONCATX(a,b) __CONCAT(a,b)
-
-OTYPE
-__CONCATX(__,FUNC) (ITYPE x)
-{
-  OTYPE result;
-  asm ( "fcvtas" "\t%" OREGS "0, %" IREGS "1"
-        : "=r" (result) : "w" (x) );
-  return result;
-}
-
-weak_alias (__CONCATX(__,FUNC), FUNC)
+weak_alias (__lround, lround)
index b30ddb6dbb7d705cc956b24966beec4d4e45f17f..baf06938be0209e70ebb0a84e67cd6dfdb2218c6 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC lroundf
-#define ITYPE float
-#define IREG_SIZE 32
-#include <s_lround.c>
+#include <math.h>
+
+long int
+__lroundf (float x)
+{
+  return __builtin_lroundf (x);
+}
+
+weak_alias (__lroundf, lroundf)
index 51067f23c85f646fc84bb01029dbe88110ecc5d3..6ba5de11e71853861e4b774f0ac7c740d80dcf15 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define        FUNC nearbyint
-#define INSN "frinti"
-#include <s_frint.c>
+#include <math.h>
+
+double
+__nearbyint (double x)
+{
+  return __builtin_nearbyint (x);
+}
+
+weak_alias (__nearbyint, nearbyint)
index 8125646c2e17642fe276256b0ca0566caa37250a..de69fd9b82772cc5cf31d442f44f6104040dbad2 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC nearbyintf
-#define INSN "frinti"
-#include <s_frintf.c>
+#include <math.h>
+
+float
+__nearbyintf (float x)
+{
+  return __builtin_nearbyintf (x);
+}
+
+weak_alias (__nearbyintf, nearbyintf)
index 73b4e2678698837d1460160658598631ad159580..b4ac349fc0dbb4e7bae179d59d3e32f729e6a125 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC rint
-#define INSN "frintx"
-#include <s_frint.c>
+#include <math.h>
+
+double
+__rint (double x)
+{
+  return __builtin_rint (x);
+}
+
+weak_alias (__rint, rint)
index 3560dc28274885efd6b44a2b9f731d82d8d6c317..d0f70ce9256cc5d86910021578b9d25a9ff81c46 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC rintf
-#define INSN "frintx"
-#include <s_frintf.c>
+#include <math.h>
+
+float
+__rintf (float x)
+{
+  return __builtin_rintf (x);
+}
+
+weak_alias (__rintf, rintf)
index 67817485c3e5c672dbbbfc2b28ee5d488f87d8dc..a34fca11967f980abc1696f059e6c046ff35909a 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC round
-#define INSN "frinta"
-#include <s_frint.c>
+#include <math.h>
+
+double
+__round (double x)
+{
+  return __builtin_round (x);
+}
+
+weak_alias (__round, round)
index ef6f672c7d9ded659d490be2365254f13db500fe..66c8ee6d09ce76fbed3f80211913243d76dfda14 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC roundf
-#define INSN "frinta"
-#include <s_frintf.c>
+#include <math.h>
+
+float
+__roundf (float x)
+{
+  return __builtin_roundf (x);
+}
+
+weak_alias (__roundf, roundf)
index 2bf5474a7e19ec7090e0366381b3b8c1cb92ff36..6550dfcdb696166652c6d6ef065b535a3125e7f3 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC trunc
-#define INSN "frintz"
-#include <s_frint.c>
+#include <math.h>
+
+double
+__trunc (double x)
+{
+  return __builtin_trunc (x);
+}
+
+weak_alias (__trunc, trunc)
index 94865a470bba0109d2a8dba4e7fda47a2f1f38b9..b7890a2d945f1cff988fe0b4a0a9a78dd64f4d93 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define FUNC truncf
-#define INSN "frintz"
-#include <s_frintf.c>
+#include <math.h>
+
+float
+__truncf (float x)
+{
+  return __builtin_truncf (x);
+}
+
+weak_alias (__truncf, truncf)