1 /* Private inline math functions for powerpc.
2 Copyright (C) 2006, 2011
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _PPC_MATH_PRIVATE_H_
21 #define _PPC_MATH_PRIVATE_H_
25 #include <dl-procinfo.h>
27 #include <math/math_private.h>
29 # if __WORDSIZE == 64 || defined _ARCH_PWR4
30 # define __CPU_HAS_FSQRT 1
32 #ifndef __ieee754_sqrt
33 # define __ieee754_sqrt(x) \
41 #ifndef __ieee754_sqrtf
42 # define __ieee754_sqrtf(x) \
52 # define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0)
53 # endif // __WORDSIZE == 64 || defined _ARCH_PWR4
56 #if defined _ARCH_PWR5X
68 # define __roundf(x) \
88 # define __truncf(x) \
108 # define __ceilf(x) \
119 # define __floor(x) \
128 # define __floorf(x) \
138 #endif /* defined _ARCH_PWR5X */
141 #if defined _ARCH_PWR6
144 # define __copysign(x, y) \
147 " fcpsgn %0,%1,%2\n" \
149 : "f" (y), "f" (x)); \
153 # define __copysignf(x, y) \
156 " fcpsgn %0,%1,%2\n" \
159 : "f" (y), "f" (x)); \
163 #endif /* defined _ARCH_PWR6 */
166 # ifndef __LIBC_INTERNAL_MATH_INLINES
167 extern double __slow_ieee754_sqrt (double);
169 __ieee754_sqrt (double __x
)
173 /* If the CPU is 64-bit we can use the optional FP instructions. */
176 /* Volatile is required to prevent the compiler from moving the
177 fsqrt instruction above the branch. */
184 __z
= __slow_ieee754_sqrt(__x
);
189 extern float __slow_ieee754_sqrtf (float);
192 __ieee754_sqrtf (float __x
)
196 /* If the CPU is 64-bit we can use the optional FP instructions. */
199 /* Volatile is required to prevent the compiler from moving the
200 fsqrts instruction above the branch. */
207 __z
= __slow_ieee754_sqrtf(__x
);
211 #endif /* __LIBC_INTERNAL_MATH_INLINES */
213 #endif /* _PPC_MATH_PRIVATE_H_ */