| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fpu_sqrt.c,v 1.8 2020/06/27 04:17:51 rin Exp $ */ | | 1 | /* $NetBSD: fpu_sqrt.c,v 1.9 2020/06/27 04:29:27 rin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1992, 1993 | | 4 | * Copyright (c) 1992, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This software was developed by the Computer Systems Engineering group | | 7 | * This software was developed by the Computer Systems Engineering group |
8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | | 8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and |
9 | * contributed to Berkeley. | | 9 | * contributed to Berkeley. |
10 | * | | 10 | * |
11 | * All advertising materials mentioning features or use of this software | | 11 | * All advertising materials mentioning features or use of this software |
12 | * must display the following acknowledgement: | | 12 | * must display the following acknowledgement: |
13 | * This product includes software developed by the University of | | 13 | * This product includes software developed by the University of |
14 | * California, Lawrence Berkeley Laboratory. | | 14 | * California, Lawrence Berkeley Laboratory. |
| @@ -35,27 +35,27 @@ | | | @@ -35,27 +35,27 @@ |
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
38 | * SUCH DAMAGE. | | 38 | * SUCH DAMAGE. |
39 | * | | 39 | * |
40 | * @(#)fpu_sqrt.c 8.1 (Berkeley) 6/11/93 | | 40 | * @(#)fpu_sqrt.c 8.1 (Berkeley) 6/11/93 |
41 | */ | | 41 | */ |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * Perform an FPU square root (return sqrt(x)). | | 44 | * Perform an FPU square root (return sqrt(x)). |
45 | */ | | 45 | */ |
46 | | | 46 | |
47 | #include <sys/cdefs.h> | | 47 | #include <sys/cdefs.h> |
48 | __KERNEL_RCSID(0, "$NetBSD: fpu_sqrt.c,v 1.8 2020/06/27 04:17:51 rin Exp $"); | | 48 | __KERNEL_RCSID(0, "$NetBSD: fpu_sqrt.c,v 1.9 2020/06/27 04:29:27 rin Exp $"); |
49 | | | 49 | |
50 | #include <sys/types.h> | | 50 | #include <sys/types.h> |
51 | #if defined(DIAGNOSTIC)||defined(DEBUG) | | 51 | #if defined(DIAGNOSTIC)||defined(DEBUG) |
52 | #include <sys/systm.h> | | 52 | #include <sys/systm.h> |
53 | #endif | | 53 | #endif |
54 | | | 54 | |
55 | #include <machine/fpu.h> | | 55 | #include <machine/fpu.h> |
56 | #include <machine/reg.h> | | 56 | #include <machine/reg.h> |
57 | | | 57 | |
58 | #include <powerpc/fpu/fpu_arith.h> | | 58 | #include <powerpc/fpu/fpu_arith.h> |
59 | #include <powerpc/fpu/fpu_emu.h> | | 59 | #include <powerpc/fpu/fpu_emu.h> |
60 | | | 60 | |
61 | /* | | 61 | /* |
| @@ -220,29 +220,28 @@ fpu_sqrt(struct fpemu *fe) | | | @@ -220,29 +220,28 @@ fpu_sqrt(struct fpemu *fe) |
220 | return (x); | | 220 | return (x); |
221 | } | | 221 | } |
222 | if (ISZERO(x)) { | | 222 | if (ISZERO(x)) { |
223 | fe->fe_cx |= FPSCR_ZX; | | 223 | fe->fe_cx |= FPSCR_ZX; |
224 | x->fp_class = FPC_INF; | | 224 | x->fp_class = FPC_INF; |
225 | DUMPFPN(FPE_REG, x); | | 225 | DUMPFPN(FPE_REG, x); |
226 | return (x); | | 226 | return (x); |
227 | } | | 227 | } |
228 | if (x->fp_sign) { | | 228 | if (x->fp_sign) { |
229 | fe->fe_cx |= FPSCR_VXSQRT; | | 229 | fe->fe_cx |= FPSCR_VXSQRT; |
230 | return (fpu_newnan(fe)); | | 230 | return (fpu_newnan(fe)); |
231 | } | | 231 | } |
232 | if (ISINF(x)) { | | 232 | if (ISINF(x)) { |
233 | fe->fe_cx |= FPSCR_VXSQRT; | | 233 | DUMPFPN(FPE_REG, x); |
234 | DUMPFPN(FPE_REG, 0); | | 234 | return (x); |
235 | return (0); | | | |
236 | } | | 235 | } |
237 | | | 236 | |
238 | /* | | 237 | /* |
239 | * Calculate result exponent. As noted above, this may involve | | 238 | * Calculate result exponent. As noted above, this may involve |
240 | * doubling the mantissa. We will also need to double x each | | 239 | * doubling the mantissa. We will also need to double x each |
241 | * time around the loop, so we define a macro for this here, and | | 240 | * time around the loop, so we define a macro for this here, and |
242 | * we break out the multiword mantissa. | | 241 | * we break out the multiword mantissa. |
243 | */ | | 242 | */ |
244 | #ifdef FPU_SHL1_BY_ADD | | 243 | #ifdef FPU_SHL1_BY_ADD |
245 | #define DOUBLE_X { \ | | 244 | #define DOUBLE_X { \ |
246 | FPU_ADDS(x3, x3, x3); FPU_ADDCS(x2, x2, x2); \ | | 245 | FPU_ADDS(x3, x3, x3); FPU_ADDCS(x2, x2, x2); \ |
247 | FPU_ADDCS(x1, x1, x1); FPU_ADDC(x0, x0, x0); \ | | 246 | FPU_ADDCS(x1, x1, x1); FPU_ADDC(x0, x0, x0); \ |
248 | } | | 247 | } |