1 /* Private inline math functions for powerpc.
2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _PPC_MATH_PRIVATE_H_
20 #define _PPC_MATH_PRIVATE_H_
24 #include <dl-procinfo.h>
25 #include_next <math_private.h>
27 # if __WORDSIZE == 64 || defined _ARCH_PWR4
28 # define __CPU_HAS_FSQRT 1
30 # define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0)
33 extern double __slow_ieee754_sqrt (double);
34 extern __always_inline double
35 __ieee754_sqrt (double __x)
41 /* Volatile is required to prevent the compiler from moving the
42 fsqrt instruction above the branch. */
43 __asm __volatile ("fsqrt %0,%1" : "=f" (__z) : "f" (__x));
46 __z = __slow_ieee754_sqrt(__x);
51 extern float __slow_ieee754_sqrtf (float);
52 extern __always_inline float
53 __ieee754_sqrtf (float __x)
59 /* Volatile is required to prevent the compiler from moving the
60 fsqrts instruction above the branch. */
61 __asm __volatile ("fsqrts %0,%1" : "=f" (__z) : "f" (__x));
64 __z = __slow_ieee754_sqrtf(__x);
69 #if defined _ARCH_PWR5X
81 # define __roundf(x) \
101 # define __truncf(x) \
121 # define __ceilf(x) \
132 # define __floor(x) \
141 # define __floorf(x) \
151 #endif /* defined _ARCH_PWR5X */
154 #if defined _ARCH_PWR6
157 # define __copysign(x, y) \
160 " fcpsgn %0,%1,%2\n" \
162 : "f" (y), "f" (x)); \
166 # define __copysignf(x, y) \
169 " fcpsgn %0,%1,%2\n" \
172 : "f" (y), "f" (x)); \
176 #endif /* defined _ARCH_PWR6 */
178 #endif /* _PPC_MATH_PRIVATE_H_ */