1 /* Private inline math functions for powerpc.
2 Copyright (C) 2006-2014 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 <fenv_private.h>
26 #include_next <math_private.h>
28 # if __WORDSIZE == 64 || defined _ARCH_PWR4
29 # define __CPU_HAS_FSQRT 1
31 # define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0)
34 extern double __slow_ieee754_sqrt (double);
35 extern __always_inline
double
36 __ieee754_sqrt (double __x
)
42 /* Volatile is required to prevent the compiler from moving the
43 fsqrt instruction above the branch. */
44 __asm
__volatile ("fsqrt %0,%1" : "=f" (__z
) : "f" (__x
));
47 __z
= __slow_ieee754_sqrt(__x
);
52 extern float __slow_ieee754_sqrtf (float);
53 extern __always_inline
float
54 __ieee754_sqrtf (float __x
)
60 /* Volatile is required to prevent the compiler from moving the
61 fsqrts instruction above the branch. */
62 __asm
__volatile ("fsqrts %0,%1" : "=f" (__z
) : "f" (__x
));
65 __z
= __slow_ieee754_sqrtf(__x
);
70 #if defined _ARCH_PWR5X
82 # define __roundf(x) \
102 # define __truncf(x) \
122 # define __ceilf(x) \
133 # define __floor(x) \
142 # define __floorf(x) \
152 #endif /* defined _ARCH_PWR5X */
155 #if defined _ARCH_PWR6
158 # define __copysign(x, y) \
161 " fcpsgn %0,%1,%2\n" \
163 : "f" (y), "f" (x)); \
167 # define __copysignf(x, y) \
170 " fcpsgn %0,%1,%2\n" \
173 : "f" (y), "f" (x)); \
177 #endif /* defined _ARCH_PWR6 */
179 #endif /* _PPC_MATH_PRIVATE_H_ */