]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/powerpc/fpu/math_private.h
37e7456bac65bcb0d4f7779c5ff0c26063a15deb
[thirdparty/glibc.git] / sysdeps / powerpc / fpu / math_private.h
1 /* Private inline math functions for powerpc.
2 Copyright (C) 2006-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19 #ifndef _PPC_MATH_PRIVATE_H_
20 #define _PPC_MATH_PRIVATE_H_
21
22 #include <sysdep.h>
23 #include <ldsodefs.h>
24 #include <dl-procinfo.h>
25 #include <fenv_private.h>
26 #include_next <math_private.h>
27
28 extern double __slow_ieee754_sqrt (double);
29 extern __always_inline double
30 __ieee754_sqrt (double __x)
31 {
32 double __z;
33
34 #ifdef _ARCH_PPCSQ
35 asm ("fsqrt %0,%1" : "=f" (__z) : "f" (__x));
36 #else
37 __z = __slow_ieee754_sqrt(__x);
38 #endif
39
40 return __z;
41 }
42
43 extern float __slow_ieee754_sqrtf (float);
44 extern __always_inline float
45 __ieee754_sqrtf (float __x)
46 {
47 float __z;
48
49 #ifdef _ARCH_PPCSQ
50 asm ("fsqrts %0,%1" : "=f" (__z) : "f" (__x));
51 #else
52 __z = __slow_ieee754_sqrtf(__x);
53 #endif
54
55 return __z;
56 }
57
58 #if defined _ARCH_PWR5X
59
60 # ifndef __round
61 # define __round(x) \
62 ({ double __z; \
63 __asm __volatile ( \
64 " frin %0,%1\n" \
65 : "=f" (__z) \
66 : "f" (x)); \
67 __z; })
68 # endif
69 # ifndef __roundf
70 # define __roundf(x) \
71 ({ float __z; \
72 __asm __volatile ( \
73 " frin %0,%1\n" \
74 " frsp %0,%0\n" \
75 : "=f" (__z) \
76 : "f" (x)); \
77 __z; })
78 # endif
79
80 # ifndef __trunc
81 # define __trunc(x) \
82 ({ double __z; \
83 __asm __volatile ( \
84 " friz %0,%1\n" \
85 : "=f" (__z) \
86 : "f" (x)); \
87 __z; })
88 # endif
89 # ifndef __truncf
90 # define __truncf(x) \
91 ({ float __z; \
92 __asm __volatile ( \
93 " friz %0,%1\n" \
94 " frsp %0,%0\n" \
95 : "=f" (__z) \
96 : "f" (x)); \
97 __z; })
98 # endif
99
100 # ifndef __ceil
101 # define __ceil(x) \
102 ({ double __z; \
103 __asm __volatile ( \
104 " frip %0,%1\n" \
105 : "=f" (__z) \
106 : "f" (x)); \
107 __z; })
108 # endif
109 # ifndef __ceilf
110 # define __ceilf(x) \
111 ({ float __z; \
112 __asm __volatile ( \
113 " frip %0,%1\n" \
114 " frsp %0,%0\n" \
115 : "=f" (__z) \
116 : "f" (x)); \
117 __z; })
118 # endif
119
120 # ifndef __floor
121 # define __floor(x) \
122 ({ double __z; \
123 __asm __volatile ( \
124 " frim %0,%1\n" \
125 : "=f" (__z) \
126 : "f" (x)); \
127 __z; })
128 # endif
129 # ifndef __floorf
130 # define __floorf(x) \
131 ({ float __z; \
132 __asm __volatile ( \
133 " frim %0,%1\n" \
134 " frsp %0,%0\n" \
135 : "=f" (__z) \
136 : "f" (x)); \
137 __z; })
138 # endif
139
140 #endif /* defined _ARCH_PWR5X */
141
142 #endif /* _PPC_MATH_PRIVATE_H_ */