Lines Matching +full:0 +full:- +full:127

1 // SPDX-License-Identifier: GPL-2.0
25 0x800000,
26 0x8b95c2,
27 0x9837f0,
28 0xa5fed7,
29 0xb504f3,
30 0xc5672a,
31 0xd744fd,
32 0xeac0c7
36 * Computes an estimate of 2^x. The `s' argument is the 32-bit
37 * single-precision floating-point representation of x.
45 exp = ((s >> 23) & 0xff) - 127; in eexp2()
48 if (exp == 128 && (s & 0x7fffff) != 0) in eexp2()
49 return s | 0x400000; /* return QNaN */ in eexp2()
50 /* 2^-big = 0, 2^+big = +Inf */ in eexp2()
51 return (s & 0x80000000)? 0: 0x7f800000; /* 0 or +Inf */ in eexp2()
53 if (exp < -23) in eexp2()
54 return 0x3f800000; /* 1.0 */ in eexp2()
57 pwr = (s & 0x7fffff) | 0x800000; in eexp2()
58 if (exp > 0) in eexp2()
61 pwr >>= -exp; in eexp2()
62 if (s & 0x80000000) in eexp2()
63 pwr = -pwr; in eexp2()
68 return 0x7f800000; in eexp2()
69 if (exp < -23) in eexp2()
70 return 0; in eexp2()
76 asm("mulhwu %0,%1,%2" : "=r" (frac) in eexp2()
77 : "r" (pwr << 12), "r" (0x172b83ff)); in eexp2()
78 asm("mulhwu %0,%1,%2" : "=r" (frac) : "r" (frac), "r" (mant)); in eexp2()
81 if (exp >= 0) in eexp2()
85 exp = -exp; in eexp2()
86 mant += 1 << (exp - 1); in eexp2()
91 * Computes an estimate of log_2(x). The `s' argument is the 32-bit
92 * single-precision floating-point representation of x.
98 exp = s & 0x7f800000; in elog2()
99 mant = s & 0x7fffff; in elog2()
100 if (exp == 0x7f800000) { /* Inf or NaN */ in elog2()
101 if (mant != 0) in elog2()
102 s |= 0x400000; /* turn NaN into QNaN */ in elog2()
105 if ((exp | mant) == 0) /* +0 or -0 */ in elog2()
106 return 0xff800000; /* return -Inf */ in elog2()
108 if (exp == 0) { in elog2()
110 asm("cntlzw %0,%1" : "=r" (lz) : "r" (mant)); in elog2()
111 mant <<= lz - 8; in elog2()
112 exp = (-118 - lz) << 23; in elog2()
114 mant |= 0x800000; in elog2()
115 exp -= 127 << 23; in elog2()
118 if (mant >= 0xb504f3) { /* 2^0.5 * 2^23 */ in elog2()
119 exp |= 0x400000; /* 0.5 * 2^23 */ in elog2()
120 asm("mulhwu %0,%1,%2" : "=r" (mant) in elog2()
121 : "r" (mant), "r" (0xb504f334)); /* 2^-0.5 * 2^32 */ in elog2()
123 if (mant >= 0x9837f0) { /* 2^0.25 * 2^23 */ in elog2()
124 exp |= 0x200000; /* 0.25 * 2^23 */ in elog2()
125 asm("mulhwu %0,%1,%2" : "=r" (mant) in elog2()
126 : "r" (mant), "r" (0xd744fccb)); /* 2^-0.25 * 2^32 */ in elog2()
128 if (mant >= 0x8b95c2) { /* 2^0.125 * 2^23 */ in elog2()
129 exp |= 0x100000; /* 0.125 * 2^23 */ in elog2()
130 asm("mulhwu %0,%1,%2" : "=r" (mant) in elog2()
131 : "r" (mant), "r" (0xeac0c6e8)); /* 2^-0.125 * 2^32 */ in elog2()
133 if (mant > 0x800000) { /* 1.0 * 2^23 */ in elog2()
134 /* calculate (mant - 1) * 1.381097463 */ in elog2()
135 /* 1.381097463 == 0.125 / (2^0.125 - 1) */ in elog2()
136 asm("mulhwu %0,%1,%2" : "=r" (frac) in elog2()
137 : "r" ((mant - 0x800000) << 1), "r" (0xb0c7cd3a)); in elog2()
140 s = exp & 0x80000000; in elog2()
141 if (exp != 0) { in elog2()
143 exp = -exp; in elog2()
144 asm("cntlzw %0,%1" : "=r" (lz) : "r" (exp)); in elog2()
145 lz = 8 - lz; in elog2()
146 if (lz > 0) in elog2()
148 else if (lz < 0) in elog2()
149 exp <<= -lz; in elog2()
161 exp = (x >> 23) & 0xff; in ctsxs()
162 mant = x & 0x7fffff; in ctsxs()
163 if (exp == 255 && mant != 0) in ctsxs()
164 return 0; /* NaN -> 0 */ in ctsxs()
165 exp = exp - 127 + scale; in ctsxs()
166 if (exp < 0) in ctsxs()
167 return 0; /* round towards zero */ in ctsxs()
169 /* saturate, unless the result would be -2^31 */ in ctsxs()
170 if (x + (scale << 23) != 0xcf000000) in ctsxs()
172 return (x & 0x80000000)? 0x80000000: 0x7fffffff; in ctsxs()
174 mant |= 0x800000; in ctsxs()
175 mant = (mant << 7) >> (30 - exp); in ctsxs()
176 return (x & 0x80000000)? -mant: mant; in ctsxs()
184 exp = (x >> 23) & 0xff; in ctuxs()
185 mant = x & 0x7fffff; in ctuxs()
186 if (exp == 255 && mant != 0) in ctuxs()
187 return 0; /* NaN -> 0 */ in ctuxs()
188 exp = exp - 127 + scale; in ctuxs()
189 if (exp < 0) in ctuxs()
190 return 0; /* round towards zero */ in ctuxs()
191 if (x & 0x80000000) { in ctuxs()
192 /* negative => saturate to 0 */ in ctuxs()
194 return 0; in ctuxs()
199 return 0xffffffff; in ctuxs()
201 mant |= 0x800000; in ctuxs()
202 mant = (mant << 8) >> (31 - exp); in ctuxs()
206 /* Round to floating integer, towards 0 */
211 exp = ((x >> 23) & 0xff) - 127; in rfiz()
212 if (exp == 128 && (x & 0x7fffff) != 0) in rfiz()
213 return x | 0x400000; /* NaN -> make it a QNaN */ in rfiz()
216 if (exp < 0) in rfiz()
217 return x & 0x80000000; /* |x| < 1.0 rounds to 0 */ in rfiz()
218 return x & ~(0x7fffff >> exp); in rfiz()
221 /* Round to floating integer, towards +/- Inf */
226 exp = ((x >> 23) & 0xff) - 127; in rfii()
227 if (exp == 128 && (x & 0x7fffff) != 0) in rfii()
228 return x | 0x400000; /* NaN -> make it a QNaN */ in rfii()
231 if ((x & 0x7fffffff) == 0) in rfii()
232 return x; /* +/-0 -> +/-0 */ in rfii()
233 if (exp < 0) in rfii()
234 /* 0 < |x| < 1.0 rounds to +/- 1.0 */ in rfii()
235 return (x & 0x80000000) | 0x3f800000; in rfii()
236 mask = 0x7fffff >> exp; in rfii()
237 /* mantissa overflows into exponent - that's OK, in rfii()
247 exp = ((x >> 23) & 0xff) - 127; in rfin()
248 if (exp == 128 && (x & 0x7fffff) != 0) in rfin()
249 return x | 0x400000; /* NaN -> make it a QNaN */ in rfin()
252 if (exp < -1) in rfin()
253 return x & 0x80000000; /* |x| < 0.5 -> +/-0 */ in rfin()
254 if (exp == -1) in rfin()
255 /* 0.5 <= |x| < 1.0 rounds to +/- 1.0 */ in rfin()
256 return (x & 0x80000000) | 0x3f800000; in rfin()
257 half = 0x400000 >> exp; in rfin()
259 return (x + half) & ~(0x7fffff >> exp); in rfin()
269 if (get_user_instr(instr, (void __user *)regs->nip)) in emulate_altivec()
270 return -EFAULT; in emulate_altivec()
274 return -EINVAL; /* not an altivec instruction */ in emulate_altivec()
275 vd = (word >> 21) & 0x1f; in emulate_altivec()
276 va = (word >> 16) & 0x1f; in emulate_altivec()
277 vb = (word >> 11) & 0x1f; in emulate_altivec()
278 vc = (word >> 6) & 0x1f; in emulate_altivec()
280 vrs = current->thread.vr_state.vr; in emulate_altivec()
281 switch (word & 0x3f) { in emulate_altivec()
284 case 0: /* vaddfp */ in emulate_altivec()
297 for (i = 0; i < 4; ++i) in emulate_altivec()
301 for (i = 0; i < 4; ++i) in emulate_altivec()
305 for (i = 0; i < 4; ++i) in emulate_altivec()
309 for (i = 0; i < 4; ++i) in emulate_altivec()
313 for (i = 0; i < 4; ++i) { in emulate_altivec()
315 x = (x & 0x80000000)? rfiz(x): rfii(x); in emulate_altivec()
320 for (i = 0; i < 4; ++i) { in emulate_altivec()
322 x = (x & 0x80000000)? rfii(x): rfiz(x); in emulate_altivec()
327 for (i = 0; i < 4; ++i) in emulate_altivec()
329 &current->thread.vr_state.vscr.u[3]); in emulate_altivec()
332 for (i = 0; i < 4; ++i) in emulate_altivec()
334 &current->thread.vr_state.vscr.u[3]); in emulate_altivec()
337 return -EINVAL; in emulate_altivec()
347 return -EINVAL; in emulate_altivec()
350 return 0; in emulate_altivec()