CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Mon Mar 8 14:37:55 UTC 2021 Modified Files: src/sys/arch/m68k/fpe: fpu_explode.c Log Message: Remove incorrect byte and word conversions from fpu_explode. The correct operation here is arithmetic right shift, but nobody calls it. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_explode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_explode.c diff -u src/sys/arch/m68k/fpe/fpu_explode.c:1.15 src/sys/arch/m68k/fpe/fpu_explode.c:1.16 --- src/sys/arch/m68k/fpe/fpu_explode.c:1.15 Thu Feb 5 12:23:27 2015 +++ src/sys/arch/m68k/fpe/fpu_explode.c Mon Mar 8 14:37:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_explode.c,v 1.15 2015/02/05 12:23:27 isaki Exp $ */ +/* $NetBSD: fpu_explode.c,v 1.16 2021/03/08 14:37:55 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_explode.c,v 1.15 2015/02/05 12:23:27 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_explode.c,v 1.16 2021/03/08 14:37:55 isaki Exp $"); #include #include @@ -230,11 +230,6 @@ fpu_explode(struct fpemu *fe, struct fpn fp->fp_sign = s >> 31; fp->fp_sticky = 0; switch (type) { - - case FTYPE_BYT: - s >>= 8; - case FTYPE_WRD: - s >>= 16; case FTYPE_LNG: s = fpu_itof(fp, s); break; @@ -251,6 +246,10 @@ fpu_explode(struct fpemu *fe, struct fpn s = fpu_xtof(fp, s, space[1], space[2]); break; + case FTYPE_BYT: + case FTYPE_WRD: + /* Caller must cast it to signed LNG instead of calling this */ + /* FALLTHROUGH */ default: panic("fpu_explode"); }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Mon Jan 16 12:05:40 UTC 2017 Modified Files: src/sys/arch/m68k/fpe: fpu_trig.c Log Message: FSINCOS: Fix register address which writes cosine value back. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.17 src/sys/arch/m68k/fpe/fpu_trig.c:1.18 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.17 Sat Aug 6 00:58:55 2016 +++ src/sys/arch/m68k/fpe/fpu_trig.c Mon Jan 16 12:05:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.17 2016/08/06 00:58:55 isaki Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.18 2017/01/16 12:05:40 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.17 2016/08/06 00:58:55 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.18 2017/01/16 12:05:40 isaki Exp $"); #include "fpu_emulate.h" @@ -438,7 +438,7 @@ fpu_sincos(struct fpemu *fe, int regc) __fpu_sincos_cordic(fe, >fe_f2); /* cos(x) */ - fpu_implode(fe, >fe_f2, FTYPE_EXT, >fe_fpframe->fpf_regs[regc]); + fpu_implode(fe, >fe_f2, FTYPE_EXT, >fe_fpframe->fpf_regs[regc * 3]); /* sin(x) */ return >fe_f1;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sun Jan 15 11:56:11 UTC 2017 Modified Files: src/sys/arch/m68k/fpe: fpu_exp.c Log Message: exp(>11356) is +inf even if extended precision. exp(<-11401) is 0 even if extended precision. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/fpe/fpu_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_exp.c diff -u src/sys/arch/m68k/fpe/fpu_exp.c:1.10 src/sys/arch/m68k/fpe/fpu_exp.c:1.11 --- src/sys/arch/m68k/fpe/fpu_exp.c:1.10 Wed Dec 7 11:27:18 2016 +++ src/sys/arch/m68k/fpe/fpu_exp.c Sun Jan 15 11:56:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_exp.c,v 1.10 2016/12/07 11:27:18 isaki Exp $ */ +/* $NetBSD: fpu_exp.c,v 1.11 2017/01/15 11:56:11 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.10 2016/12/07 11:27:18 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.11 2017/01/15 11:56:11 isaki Exp $"); #include @@ -109,7 +109,7 @@ struct fpn * fpu_etox(struct fpemu *fe) { struct fpn x, *fp; - int j, k; + int k; if (ISNAN(>fe_f2)) return >fe_f2; @@ -119,6 +119,20 @@ fpu_etox(struct fpemu *fe) return >fe_f2; } + /* + * return inf if x >= 2^14 + * return +0 if x <= -2^14 + */ + if (fe->fe_f2.fp_exp >= 14) { + if (fe->fe_f2.fp_sign) { + fe->fe_f2.fp_class = FPC_ZERO; + fe->fe_f2.fp_sign = 0; + } else { + fe->fe_f2.fp_class = FPC_INF; + } + return >fe_f2; + } + CPYFPN(, >fe_f2); /* k = round(x / ln2) */ @@ -134,17 +148,7 @@ fpu_etox(struct fpemu *fe) return fp; } /* extract k as integer format from fpn format */ - j = FP_LG - fp->fp_exp; - if (j < 0) { - if (fp->fp_sign) { - fp->fp_class = FPC_ZERO; /* k < -2^18 */ - fp->fp_sign = 0; - } else { - fp->fp_class = FPC_INF; /* k > 2^18 */ - } - return fp; - } - k = fp->fp_mant[0] >> j; + k = fp->fp_mant[0] >> (FP_LG - fp->fp_exp); if (fp->fp_sign) k *= -1;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Wed Dec 7 11:27:18 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_exp.c Log Message: Fix sign of zero in case of x > -(2^18). # By the way, I will modify this case later. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/fpe/fpu_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_exp.c diff -u src/sys/arch/m68k/fpe/fpu_exp.c:1.9 src/sys/arch/m68k/fpe/fpu_exp.c:1.10 --- src/sys/arch/m68k/fpe/fpu_exp.c:1.9 Mon Dec 5 15:31:01 2016 +++ src/sys/arch/m68k/fpe/fpu_exp.c Wed Dec 7 11:27:18 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_exp.c,v 1.9 2016/12/05 15:31:01 isaki Exp $ */ +/* $NetBSD: fpu_exp.c,v 1.10 2016/12/07 11:27:18 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.9 2016/12/05 15:31:01 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.10 2016/12/07 11:27:18 isaki Exp $"); #include @@ -136,10 +136,12 @@ fpu_etox(struct fpemu *fe) /* extract k as integer format from fpn format */ j = FP_LG - fp->fp_exp; if (j < 0) { - if (fp->fp_sign) + if (fp->fp_sign) { fp->fp_class = FPC_ZERO; /* k < -2^18 */ - else + fp->fp_sign = 0; + } else { fp->fp_class = FPC_INF; /* k > 2^18 */ + } return fp; } k = fp->fp_mant[0] >> j;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Tue Dec 6 06:41:14 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_mul.c Log Message: Fix sign of NAN. Found by XM6i. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/fpe/fpu_mul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_mul.c diff -u src/sys/arch/m68k/fpe/fpu_mul.c:1.8 src/sys/arch/m68k/fpe/fpu_mul.c:1.9 --- src/sys/arch/m68k/fpe/fpu_mul.c:1.8 Tue Mar 26 11:30:21 2013 +++ src/sys/arch/m68k/fpe/fpu_mul.c Tue Dec 6 06:41:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_mul.c,v 1.8 2013/03/26 11:30:21 isaki Exp $ */ +/* $NetBSD: fpu_mul.c,v 1.9 2016/12/06 06:41:14 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_mul.c,v 1.8 2013/03/26 11:30:21 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_mul.c,v 1.9 2016/12/06 06:41:14 isaki Exp $"); #include @@ -122,7 +122,6 @@ fpu_mul(struct fpemu *fe) */ ORDER(x, y); if (ISNAN(y)) { - y->fp_sign ^= x->fp_sign; return (y); } if (ISINF(y)) {
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Tue Dec 6 05:58:19 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_cordic.c fpu_emulate.h Log Message: Remove fpu_cordit2() and atanh_table[] completely. Since cordit1 (for trigonometric functions) and cordit2 (for hyperbolic functions) are very similar, so I implemented both at first, but I didn't use cordit2 after all :( To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/m68k/fpe/fpu_cordic.c cvs rdiff -u -r1.25 -r1.26 src/sys/arch/m68k/fpe/fpu_emulate.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_cordic.c diff -u src/sys/arch/m68k/fpe/fpu_cordic.c:1.3 src/sys/arch/m68k/fpe/fpu_cordic.c:1.4 --- src/sys/arch/m68k/fpe/fpu_cordic.c:1.3 Thu Aug 4 05:35:18 2016 +++ src/sys/arch/m68k/fpe/fpu_cordic.c Tue Dec 6 05:58:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_cordic.c,v 1.3 2016/08/04 05:35:18 isaki Exp $ */ +/* $NetBSD: fpu_cordic.c,v 1.4 2016/12/06 05:58:19 isaki Exp $ */ /* * Copyright (c) 2013 Tetsuya Isaki. All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_cordic.c,v 1.3 2016/08/04 05:35:18 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_cordic.c,v 1.4 2016/12/06 05:58:19 isaki Exp $"); #include @@ -46,7 +46,7 @@ struct sfpn { #if defined(CORDIC_BOOTSTRAP) /* * This is a bootstrap code to generate a pre-calculated tables such as - * atan_table[] and atanh_table[]. However, it's just for reference. + * atan_table[]. However, it's just for reference. * If you want to run the bootstrap, you will define CORDIC_BOOTSTRAP * and modify these files as a userland application. */ @@ -58,19 +58,13 @@ struct sfpn { static void prepare_cordic_const(struct fpemu *); static struct fpn *fpu_gain1_cordic(struct fpemu *); -static struct fpn *fpu_gain2_cordic(struct fpemu *); static struct fpn *fpu_atan_taylor(struct fpemu *); static void printf_fpn(const struct fpn *); static void printf_sfpn(const struct sfpn *); static void fpn_to_sfpn(struct sfpn *, const struct fpn *); static struct sfpn atan_table[EXT_FRACBITS]; -static struct sfpn atanh_table[EXT_FRACBITS]; static struct fpn inv_gain1; -static struct fpn inv_gain2; - -static void fpu_cordit2(struct fpemu *, - struct fpn *, struct fpn *, struct fpn *, const struct fpn *); int main(int argc, char *argv[]) @@ -91,21 +85,9 @@ main(int argc, char *argv[]) } printf("};\n\n"); - printf("static const struct sfpn atanh_table[] = {\n"); - for (i = 0; i < EXT_FRACBITS; i++) { - printf("\t"); - printf_sfpn(_table[i]); - printf(",\n"); - } - printf("};\n\n"); - printf("const struct fpn fpu_cordic_inv_gain1 =\n\t"); printf_fpn(_gain1); printf(";\n\n"); - - printf("const struct fpn fpu_cordic_inv_gain2 =\n\t"); - printf_fpn(_gain2); - printf(";\n\n"); } /* @@ -120,7 +102,7 @@ prepare_cordic_const(struct fpemu *fe) struct fpn *r; int i; - /* atan_table and atanh_table */ + /* atan_table */ fpu_const(, FPU_CONST_1); for (i = 0; i < EXT_FRACBITS; i++) { /* atan(t) */ @@ -130,32 +112,6 @@ prepare_cordic_const(struct fpemu *fe) /* t /= 2 */ t.fp_exp--; - - /* (1-t) */ - fpu_const(>fe_f1, FPU_CONST_1); - CPYFPN(>fe_f2, ); - fe->fe_f2.fp_sign = 1; - r = fpu_add(fe); - CPYFPN(, r); - - /* (1+t) */ - fpu_const(>fe_f1, FPU_CONST_1); - CPYFPN(>fe_f2, ); - r = fpu_add(fe); - - /* r = (1+t)/(1-t) */ - CPYFPN(>fe_f1, r); - CPYFPN(>fe_f2, ); - r = fpu_div(fe); - - /* r = log(r) */ - CPYFPN(>fe_f2, r); - r = fpu_logn(fe); - - /* r /= 2 */ - r->fp_exp--; - - fpn_to_sfpn(_table[i], r); } /* inv_gain1 = 1 / gain1cordic() */ @@ -164,13 +120,6 @@ prepare_cordic_const(struct fpemu *fe) fpu_const(>fe_f1, FPU_CONST_1); r = fpu_div(fe); CPYFPN(_gain1, r); - - /* inv_gain2 = 1 / gain2cordic() */ - r = fpu_gain2_cordic(fe); - CPYFPN(>fe_f2, r); - fpu_const(>fe_f1, FPU_CONST_1); - r = fpu_div(fe); - CPYFPN(_gain2, r); } static struct fpn * @@ -192,25 +141,6 @@ fpu_gain1_cordic(struct fpemu *fe) return >fe_f2; } -static struct fpn * -fpu_gain2_cordic(struct fpemu *fe) -{ - struct fpn x; - struct fpn y; - struct fpn z; - struct fpn v; - - fpu_const(, FPU_CONST_1); - fpu_const(, FPU_CONST_0); - fpu_const(, FPU_CONST_0); - CPYFPN(, ); - v.fp_sign = !v.fp_sign; - - fpu_cordit2(fe, , , , ); - CPYFPN(>fe_f2, ); - return >fe_f2; -} - /* * arctan(x) = pi/4 (for |x| = 1) * @@ -373,79 +303,9 @@ static const struct sfpn atan_table[] = { 0xc104, 0x, 0x, }, }; -static const struct sfpn atanh_table[] = { - { 0xff0464fa, 0x9eab40c2, 0xa5dc43f6, }, - { 0xfe04162b, 0xbea04514, 0x69ca8e4a, }, - { 0xfd040562, 0x4727abbd, 0xda654b67, }, - { 0xfc040156, 0x22b4dd6b, 0x372a679c, }, - { 0xfb040055, 0x62246bb8, 0x92d60b35, }, - { 0xfa040015, 0x56222b47, 0x2637d656, }, - { 0xf9040005, 0x55622246, 0xb4dcf86e, }, - { 0xf8040001,
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Mon Dec 5 15:31:01 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_exp.c fpu_hyperb.c Log Message: Improve the exponential and hyperbolic function's performance 10..100 times faster. PR port-m68k/51645 from rin@ (and modified by me) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/fpe/fpu_exp.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/m68k/fpe/fpu_hyperb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_exp.c diff -u src/sys/arch/m68k/fpe/fpu_exp.c:1.8 src/sys/arch/m68k/fpe/fpu_exp.c:1.9 --- src/sys/arch/m68k/fpe/fpu_exp.c:1.8 Sat Apr 20 04:54:22 2013 +++ src/sys/arch/m68k/fpe/fpu_exp.c Mon Dec 5 15:31:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_exp.c,v 1.8 2013/04/20 04:54:22 isaki Exp $ */ +/* $NetBSD: fpu_exp.c,v 1.9 2016/12/05 15:31:01 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.8 2013/04/20 04:54:22 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.9 2016/12/05 15:31:01 isaki Exp $"); #include @@ -100,12 +100,16 @@ fpu_etox_taylor(struct fpemu *fe) } /* - * exp(x) + * exp(x) = 2^k * exp(r) with k = round(x / ln2) and r = x - k * ln2 + * + * Algorithm partially taken from libm, where exp(r) is approximated by a + * rational function of r. We use the Taylor expansion instead. */ struct fpn * fpu_etox(struct fpemu *fe) { - struct fpn *fp; + struct fpn x, *fp; + int j, k; if (ISNAN(>fe_f2)) return >fe_f2; @@ -115,19 +119,47 @@ fpu_etox(struct fpemu *fe) return >fe_f2; } - if (fe->fe_f2.fp_sign == 0) { - /* exp(x) */ - fp = fpu_etox_taylor(fe); - } else { - /* 1/exp(-x) */ - fe->fe_f2.fp_sign = 0; - fp = fpu_etox_taylor(fe); + CPYFPN(, >fe_f2); - CPYFPN(>fe_f2, fp); - fpu_const(>fe_f1, FPU_CONST_1); - fp = fpu_div(fe); + /* k = round(x / ln2) */ + CPYFPN(>fe_f1, >fe_f2); + fpu_const(>fe_f2, FPU_CONST_LN_2); + fp = fpu_div(fe); + CPYFPN(>fe_f2, fp); + fp = fpu_int(fe); + if (ISZERO(fp)) { + /* k = 0 */ + CPYFPN(>fe_f2, ); + fp = fpu_etox_taylor(fe); + return fp; + } + /* extract k as integer format from fpn format */ + j = FP_LG - fp->fp_exp; + if (j < 0) { + if (fp->fp_sign) + fp->fp_class = FPC_ZERO; /* k < -2^18 */ + else + fp->fp_class = FPC_INF; /* k > 2^18 */ + return fp; } - + k = fp->fp_mant[0] >> j; + if (fp->fp_sign) + k *= -1; + + /* exp(r) = exp(x - k * ln2) */ + CPYFPN(>fe_f1, fp); + fpu_const(>fe_f2, FPU_CONST_LN_2); + fp = fpu_mul(fe); + fp->fp_sign = !fp->fp_sign; + CPYFPN(>fe_f1, fp); + CPYFPN(>fe_f2, ); + fp = fpu_add(fe); + CPYFPN(>fe_f2, fp); + fp = fpu_etox_taylor(fe); + + /* 2^k */ + fp->fp_exp += k; + return fp; } Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.16 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.17 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.16 Fri Oct 11 03:37:08 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Mon Dec 5 15:31:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.16 2013/10/11 03:37:08 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.17 2016/12/05 15:31:01 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,15 +57,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.16 2013/10/11 03:37:08 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.17 2016/12/05 15:31:01 isaki Exp $"); #include #include "fpu_emulate.h" -/* The number of items to terminate the Taylor expansion */ -#define MAX_ITEMS (2000) - /* * fpu_hyperb.c: defines the following functions * @@ -137,71 +134,14 @@ fpu_atanh(struct fpemu *fe) } /* - * taylor expansion used by sinh(), cosh(). + *exp(x) + exp(-x) + * cosh(x) = -- + * 2 */ -static struct fpn * -__fpu_sinhcosh_taylor(struct fpemu *fe, struct fpn *s0, uint32_t f) -{ - struct fpn res; - struct fpn x2; - struct fpn *s1; - struct fpn *r; - int sign; - uint32_t k; - - /* x2 := x * x */ - CPYFPN(>fe_f1, >fe_f2); - r = fpu_mul(fe); - CPYFPN(, r); - - /* res := s0 */ - CPYFPN(, s0); - - sign = 1; /* sign := (-1)^n */ - - for (; f < (2 * MAX_ITEMS); ) { - /* (f1 :=) s0 * x^2 */ - CPYFPN(>fe_f1, s0); - CPYFPN(>fe_f2, ); - r = fpu_mul(fe); - CPYFPN(>fe_f1, r); - - /* - * for sinh(), s1 := s0 * x^2 / (2n+1)2n - * for cosh(), s1 := s0 * x^2 / 2n(2n-1) - */ - k = f * (f + 1); - fpu_explode(fe, >fe_f2, FTYPE_LNG, ); - s1 = fpu_div(fe); - - /* break if s1 is enough small */ - if (ISZERO(s1)) - break; - if (res.fp_exp - s1->fp_exp >= EXT_FRACBITS) - break; - - /* s0 := s1 for next loop */ - CPYFPN(s0, s1); - - /* res += s1 */ - CPYFPN(>fe_f2, s1); - CPYFPN(>fe_f1, ); - r = fpu_add(fe); - CPYFPN(, r); - - f += 2; - sign ^= 1; - } - - CPYFPN(>fe_f2, ); - return >fe_f2; -} - struct fpn * fpu_cosh(struct fpemu *fe) { - struct
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Aug 6 00:58:55 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_trig.c Log Message: Modify fpu_sin()'s logic to avoid GCC's warning that has been pointed out in the previous commit. For fpu_cos() there is no such problem, but sync with fpu_sin(). To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.16 src/sys/arch/m68k/fpe/fpu_trig.c:1.17 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.16 Wed Mar 23 05:25:51 2016 +++ src/sys/arch/m68k/fpe/fpu_trig.c Sat Aug 6 00:58:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.16 2016/03/23 05:25:51 mrg Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.17 2016/08/06 00:58:55 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.16 2016/03/23 05:25:51 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.17 2016/08/06 00:58:55 isaki Exp $"); #include "fpu_emulate.h" @@ -229,11 +229,10 @@ fpu_cos(struct fpemu *fe) if (ISINF(>fe_f2)) return fpu_newnan(fe); - CPYFPN(, >fe_f2); - /* x = abs(input) */ - x.fp_sign = 0; sign = 0; + CPYFPN(, >fe_f2); + x.fp_sign = 0; /* p <- 2*pi */ fpu_const(, FPU_CONST_PI); @@ -334,13 +333,9 @@ fpu_sin(struct fpemu *fe) if (ISZERO(>fe_f2)) return >fe_f2; -#if defined(__GNUC__) && (__GNUC__ >= 5) && defined(__OPTIMIZE__) - x.fp_sign = 0; -#endif - CPYFPN(, >fe_f2); - /* x = abs(input) */ - sign = x.fp_sign; + sign = fe->fe_f2.fp_sign; + CPYFPN(, >fe_f2); x.fp_sign = 0; /* p <- 2*pi */
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Thu Aug 4 05:35:19 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_cordic.c fpu_emulate.h Log Message: Move fpu_cordit2() to #ifdef CORDIC_BOOTSTRAP section. This reduces ~2KB text segment. Reported by Krister Walfridsson on tech-kern two months ago. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/m68k/fpe/fpu_cordic.c cvs rdiff -u -r1.24 -r1.25 src/sys/arch/m68k/fpe/fpu_emulate.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_cordic.c diff -u src/sys/arch/m68k/fpe/fpu_cordic.c:1.2 src/sys/arch/m68k/fpe/fpu_cordic.c:1.3 --- src/sys/arch/m68k/fpe/fpu_cordic.c:1.2 Sat Apr 20 01:48:20 2013 +++ src/sys/arch/m68k/fpe/fpu_cordic.c Thu Aug 4 05:35:18 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_cordic.c,v 1.2 2013/04/20 01:48:20 isaki Exp $ */ +/* $NetBSD: fpu_cordic.c,v 1.3 2016/08/04 05:35:18 isaki Exp $ */ /* * Copyright (c) 2013 Tetsuya Isaki. All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_cordic.c,v 1.2 2013/04/20 01:48:20 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_cordic.c,v 1.3 2016/08/04 05:35:18 isaki Exp $"); #include @@ -69,6 +69,9 @@ static struct sfpn atanh_table[EXT_FRACB static struct fpn inv_gain1; static struct fpn inv_gain2; +static void fpu_cordit2(struct fpemu *, + struct fpn *, struct fpn *, struct fpn *, const struct fpn *); + int main(int argc, char *argv[]) { @@ -548,7 +551,8 @@ fpu_cordit1(struct fpemu *fe, struct fpn CPYFPN(z0, ); } -void +#if defined(CORDIC_BOOTSTRAP) +static void fpu_cordit2(struct fpemu *fe, struct fpn *x0, struct fpn *y0, struct fpn *z0, const struct fpn *vecmode) { @@ -644,3 +648,4 @@ fpu_cordit2(struct fpemu *fe, struct fpn CPYFPN(y0, ); CPYFPN(z0, ); } +#endif /* CORDIC_BOOTSTRAP */ Index: src/sys/arch/m68k/fpe/fpu_emulate.h diff -u src/sys/arch/m68k/fpe/fpu_emulate.h:1.24 src/sys/arch/m68k/fpe/fpu_emulate.h:1.25 --- src/sys/arch/m68k/fpe/fpu_emulate.h:1.24 Fri Apr 19 13:31:11 2013 +++ src/sys/arch/m68k/fpe/fpu_emulate.h Thu Aug 4 05:35:18 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.h,v 1.24 2013/04/19 13:31:11 isaki Exp $ */ +/* $NetBSD: fpu_emulate.h,v 1.25 2016/08/04 05:35:18 isaki Exp $ */ /* * Copyright (c) 1995 Gordon Ross @@ -251,8 +251,6 @@ extern const struct fpn fpu_cordic_inv_g extern const struct fpn fpu_cordic_inv_gain2; void fpu_cordit1(struct fpemu *, struct fpn *, struct fpn *, struct fpn *, const struct fpn *); -void fpu_cordit2(struct fpemu *, - struct fpn *, struct fpn *, struct fpn *, const struct fpn *); /* * "helper" functions
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: mrg Date: Wed Mar 23 05:25:51 UTC 2016 Modified Files: src/sys/arch/m68k/fpe: fpu_trig.c Log Message: avoid a GCC warning with this: +#if defined(__GNUC__) && (__GNUC__ >= 5) && defined(__OPTIMIZE__) + x.fp_sign = 0; +#endif (ridiculous, but seems better than disabling the warning entirely.) To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.15 src/sys/arch/m68k/fpe/fpu_trig.c:1.16 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.15 Sat Apr 20 07:32:45 2013 +++ src/sys/arch/m68k/fpe/fpu_trig.c Wed Mar 23 05:25:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.15 2013/04/20 07:32:45 isaki Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.16 2016/03/23 05:25:51 mrg Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.15 2013/04/20 07:32:45 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.16 2016/03/23 05:25:51 mrg Exp $"); #include "fpu_emulate.h" @@ -334,6 +334,9 @@ fpu_sin(struct fpemu *fe) if (ISZERO(>fe_f2)) return >fe_f2; +#if defined(__GNUC__) && (__GNUC__ >= 5) && defined(__OPTIMIZE__) + x.fp_sign = 0; +#endif CPYFPN(, >fe_f2); /* x = abs(input) */
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Thu Feb 5 12:22:06 UTC 2015 Modified Files: src/sys/arch/m68k/fpe: fpu_rem.c Log Message: Fix typo in comment. pointed out by Y.Sugahara. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/m68k/fpe/fpu_rem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_rem.c diff -u src/sys/arch/m68k/fpe/fpu_rem.c:1.16 src/sys/arch/m68k/fpe/fpu_rem.c:1.17 --- src/sys/arch/m68k/fpe/fpu_rem.c:1.16 Sat May 11 12:52:42 2013 +++ src/sys/arch/m68k/fpe/fpu_rem.c Thu Feb 5 12:22:06 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_rem.c,v 1.16 2013/05/11 12:52:42 isaki Exp $ */ +/* $NetBSD: fpu_rem.c,v 1.17 2015/02/05 12:22:06 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.16 2013/05/11 12:52:42 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.17 2015/02/05 12:22:06 isaki Exp $); #include sys/types.h #include sys/signal.h @@ -56,7 +56,7 @@ __KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v *endif * * Step 3. Perform MOD(X,Y) - *3.1 If R = Y, then { Q := Q + 1, R := 0, go to Step 8. } + *3.1 If R = Y, then { Q := Q + 1, R := 0, go to Step 7. } *3.2 If R Y, then { R := R - Y, Q := Q + 1} *3.3 If j = 0, go to Step 4. *3.4 k := k + 1, j := j - 1, Q := 2Q, R := 2R. Go to @@ -64,7 +64,7 @@ __KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v * * Step 4. R := signX*R. * - * Step 5. If MOD is requested, go to Step . + * Step 5. If MOD is requested, go to Step 7. * * Step 6. Now, R = MOD(X,Y), convert to REM(X,Y) is requested. *Do banker's rounding.
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Thu Feb 5 12:23:27 UTC 2015 Modified Files: src/sys/arch/m68k/fpe: fpu_explode.c Log Message: For the extended precision, the MSB of the mantissa is an integer part, and this bit must be ignored at Infinity. found by tests/lib/libc/stdlib/t_strtod.c::strtold_inf. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_explode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_explode.c diff -u src/sys/arch/m68k/fpe/fpu_explode.c:1.14 src/sys/arch/m68k/fpe/fpu_explode.c:1.15 --- src/sys/arch/m68k/fpe/fpu_explode.c:1.14 Tue Mar 26 11:30:20 2013 +++ src/sys/arch/m68k/fpe/fpu_explode.c Thu Feb 5 12:23:27 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_explode.c,v 1.14 2013/03/26 11:30:20 isaki Exp $ */ +/* $NetBSD: fpu_explode.c,v 1.15 2015/02/05 12:23:27 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -46,7 +46,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_explode.c,v 1.14 2013/03/26 11:30:20 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_explode.c,v 1.15 2015/02/05 12:23:27 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -183,18 +183,17 @@ static int fpu_xtof(struct fpn *fp, uint32_t i, uint32_t j, uint32_t k) { int exp; - uint32_t frac, f0, f1, f2; + uint32_t f0, f1, f2; #define EXT_SHIFT (EXT_FRACBITS - 1 - 32 - FP_LG) exp = (i (32 - 1 - EXT_EXPBITS)) mask(EXT_EXPBITS); f0 = j EXT_SHIFT; f1 = (j (32 - EXT_SHIFT)) | (k EXT_SHIFT); f2 = k (32 - EXT_SHIFT); - frac = j | k; /* m68k extended does not imply denormal by exp==0 */ if (exp == 0) { - if (frac == 0) + if ((j | k) == 0) return (FPC_ZERO); fp-fp_exp = - EXT_EXP_BIAS; fp-fp_mant[0] = f0; @@ -204,7 +203,8 @@ fpu_xtof(struct fpn *fp, uint32_t i, uin return (FPC_NUM); } if (exp == (2 * EXT_EXP_BIAS + 1)) { - if (frac == 0) + /* MSB is an integer part and don't care */ + if ((j 0x7fff) == 0 k == 0) return (FPC_INF); fp-fp_mant[0] = f0; fp-fp_mant[1] = f1;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Jan 4 13:23:22 UTC 2014 Modified Files: src/sys/arch/m68k/fpe: fpu_log.c Log Message: FLOGNP1(-0.0) is -0.0, not +0.0. Found by XM6i. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/m68k/fpe/fpu_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_log.c diff -u src/sys/arch/m68k/fpe/fpu_log.c:1.17 src/sys/arch/m68k/fpe/fpu_log.c:1.18 --- src/sys/arch/m68k/fpe/fpu_log.c:1.17 Sat Apr 20 05:27:05 2013 +++ src/sys/arch/m68k/fpe/fpu_log.c Sat Jan 4 13:23:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_log.c,v 1.17 2013/04/20 05:27:05 isaki Exp $ */ +/* $NetBSD: fpu_log.c,v 1.18 2014/01/04 13:23:22 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_log.c,v 1.17 2013/04/20 05:27:05 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_log.c,v 1.18 2014/01/04 13:23:22 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -593,6 +593,10 @@ fpu_lognp1(struct fpemu *fe) { struct fpn *fp; + /* if src is +0/-0, return +0/-0 */ + if (ISZERO(fe-fe_f2)) + return fe-fe_f2; + /* build a 1.0 */ fp = fpu_const(fe-fe_f1, FPU_CONST_1); /* fp = 1.0 + f2 */
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Wed Jan 1 05:22:22 UTC 2014 Modified Files: src/sys/arch/m68k/fpe: fpu_div.c Log Message: Fix a sign when a source or destination is either (plus/minus)zero or (plus/minus)infinity. Found by XM6i. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/fpe/fpu_div.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_div.c diff -u src/sys/arch/m68k/fpe/fpu_div.c:1.8 src/sys/arch/m68k/fpe/fpu_div.c:1.9 --- src/sys/arch/m68k/fpe/fpu_div.c:1.8 Tue Mar 26 11:30:20 2013 +++ src/sys/arch/m68k/fpe/fpu_div.c Wed Jan 1 05:22:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_div.c,v 1.8 2013/03/26 11:30:20 isaki Exp $ */ +/* $NetBSD: fpu_div.c,v 1.9 2014/01/01 05:22:22 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.8 2013/03/26 11:30:20 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.9 2014/01/01 05:22:22 isaki Exp $); #include sys/types.h @@ -166,10 +166,10 @@ fpu_div(struct fpemu *fe) * return it. Otherwise we have the following cases: * * Inf / Inf = NaN, plus NV exception - * Inf / num = Inf [i.e., return x] - * Inf / 0 = Inf [i.e., return x] - * 0 / Inf = 0 [i.e., return x] - * 0 / num = 0 [i.e., return x] + * Inf / num = Inf + * Inf / 0 = Inf + * 0 / Inf = 0 + * 0 / num = 0 * 0 / 0 = NaN, plus NV exception * num / Inf = 0 * num / num = num (do the divide) @@ -182,6 +182,8 @@ fpu_div(struct fpemu *fe) if (ISINF(x) || ISZERO(x)) { if (x-fp_class == y-fp_class) return (fpu_newnan(fe)); + /* all results at this point use XOR of operand signs */ + x-fp_sign ^= y-fp_sign; return (x); }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Wed Jan 1 05:23:40 UTC 2014 Modified Files: src/sys/arch/m68k/fpe: fpu_div.c Log Message: indent fix in a comment. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/fpe/fpu_div.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_div.c diff -u src/sys/arch/m68k/fpe/fpu_div.c:1.9 src/sys/arch/m68k/fpe/fpu_div.c:1.10 --- src/sys/arch/m68k/fpe/fpu_div.c:1.9 Wed Jan 1 05:22:22 2014 +++ src/sys/arch/m68k/fpe/fpu_div.c Wed Jan 1 05:23:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_div.c,v 1.9 2014/01/01 05:22:22 isaki Exp $ */ +/* $NetBSD: fpu_div.c,v 1.10 2014/01/01 05:23:40 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.9 2014/01/01 05:22:22 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.10 2014/01/01 05:23:40 isaki Exp $); #include sys/types.h @@ -168,9 +168,9 @@ fpu_div(struct fpemu *fe) * Inf / Inf = NaN, plus NV exception * Inf / num = Inf * Inf / 0 = Inf - * 0 / Inf = 0 - * 0 / num = 0 - * 0 / 0 = NaN, plus NV exception + * 0 / Inf = 0 + * 0 / num = 0 + * 0 / 0 = NaN, plus NV exception * num / Inf = 0 * num / num = num (do the divide) * num / 0 = Inf, plus DZ exception
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: martin Date: Fri Oct 25 21:32:46 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.c Log Message: Comment unused stuff (for documentation purposes) To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/arch/m68k/fpe/fpu_emulate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.c diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.37 src/sys/arch/m68k/fpe/fpu_emulate.c:1.38 --- src/sys/arch/m68k/fpe/fpu_emulate.c:1.37 Tue Mar 26 11:30:20 2013 +++ src/sys/arch/m68k/fpe/fpu_emulate.c Fri Oct 25 21:32:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.c,v 1.37 2013/03/26 11:30:20 isaki Exp $ */ +/* $NetBSD: fpu_emulate.c,v 1.38 2013/10/25 21:32:45 martin Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.37 2013/03/26 11:30:20 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.38 2013/10/25 21:32:45 martin Exp $); #include sys/param.h #include sys/types.h @@ -421,7 +421,7 @@ fpu_emul_fmovm(struct fpemu *fe, struct int word1, sig; int reglist, regmask, regnum; int fpu_to_mem, order; - int w1_post_incr; + /* int w1_post_incr; */ int *fpregs; insn-is_advance = 4; @@ -438,7 +438,7 @@ fpu_emul_fmovm(struct fpemu *fe, struct * 1,0: Static reg list, post-incr. * 1,1: Dynamic reg list, post-incr */ - w1_post_incr = word1 0x1000; + /* w1_post_incr = word1 0x1000; */ if (word1 0x0800) { /* dynamic reg list */ reglist = frame-f_regs[(word1 0x70) 4];
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Fri Oct 11 03:37:08 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_hyperb.c Log Message: FATANH(-0) is -0, not +0. This bug was introduced by the mistake of my test program. Last week, I talked about the probelm (my FATANH(-0) returns +0 ?) by NetBSD seminar at Open Source Conference 2013 Hiroshima, and tsutsui@ confirmed that returns -0. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_hyperb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.15 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.16 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.15 Sat Apr 20 07:33:05 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Fri Oct 11 03:37:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.15 2013/04/20 07:33:05 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.16 2013/10/11 03:37:08 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.15 2013/04/20 07:33:05 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.16 2013/10/11 03:37:08 isaki Exp $); #include machine/ieee.h @@ -89,14 +89,9 @@ fpu_atanh(struct fpemu *fe) if (ISINF(fe-fe_f2)) return fpu_newnan(fe); - /* - * if x is +0/-0, 68000PRM.pdf says it returns +0/-0 but - * my real 68882 returns +0 for both. - */ - if (ISZERO(fe-fe_f2)) { - fe-fe_f2.fp_sign = 0; + /* if x is +0/-0, return +0/-0 */ + if (ISZERO(fe-fe_f2)) return fe-fe_f2; - } /* * -INF if x == -1
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat May 11 12:52:43 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_rem.c Log Message: Revise the algorithm after Step3. almost written by Y.Sugahara and minor modify by me. This works for all input of FMOD/FREM and of course solves PR/47810. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_rem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_rem.c diff -u src/sys/arch/m68k/fpe/fpu_rem.c:1.15 src/sys/arch/m68k/fpe/fpu_rem.c:1.16 --- src/sys/arch/m68k/fpe/fpu_rem.c:1.15 Sun May 5 13:25:20 2013 +++ src/sys/arch/m68k/fpe/fpu_rem.c Sat May 11 12:52:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_rem.c,v 1.15 2013/05/05 13:25:20 isaki Exp $ */ +/* $NetBSD: fpu_rem.c,v 1.16 2013/05/11 12:52:42 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.15 2013/05/05 13:25:20 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.16 2013/05/11 12:52:42 isaki Exp $); #include sys/types.h #include sys/signal.h @@ -56,51 +56,68 @@ __KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v *endif * * Step 3. Perform MOD(X,Y) - *3.1 If R = Y, go to Step 9. + *3.1 If R = Y, then { Q := Q + 1, R := 0, go to Step 8. } *3.2 If R Y, then { R := R - Y, Q := Q + 1} *3.3 If j = 0, go to Step 4. *3.4 k := k + 1, j := j - 1, Q := 2Q, R := 2R. Go to *Step 3.1. * - * Step 4. At this point, R = X - QY = MOD(X,Y). Set - *Last_Subtract := false (used in Step 7 below). If - *MOD is requested, go to Step 6. - * - * Step 5. R = MOD(X,Y), but REM(X,Y) is requested. - *5.1 If R Y/2, then R = MOD(X,Y) = REM(X,Y). Go to - *Step 6. - *5.2 If R Y/2, then { set Last_Subtract := true, - *Q := Q + 1, Y := signY*Y }. Go to Step 6. - *5.3 This is the tricky case of R = Y/2. If Q is odd, - *then { Q := Q + 1, signX := -signX }. - * - * Step 6. R := signX*R. - * - * Step 7. If Last_Subtract = true, R := R - Y. - * - * Step 8. Return signQ, last 7 bits of Q, and R as required. - * - * Step 9. At this point, R = 2^(-j)*X - Q Y = Y. Thus, - *X = 2^(j)*(Q+1)Y. set Q := 2^(j)*(Q+1), - *R := 0. Return signQ, last 7 bits of Q, and R. + * Step 4. R := signX*R. + * + * Step 5. If MOD is requested, go to Step . + * + * Step 6. Now, R = MOD(X,Y), convert to REM(X,Y) is requested. + *Do banker's rounding. + *If abs(R) Y/2 + * || (abs(R) == Y/2 Q % 2 == 1) then + * { Q := Q + 1, R := R - signX * Y }. + * + * Step 7. Return signQ, last 7 bits of Q, and R as required. */ static struct fpn * __fpu_modrem(struct fpemu *fe, int is_mod); +static int abscmp3(const struct fpn *a, const struct fpn *b); + +/* Absolute FORTRAN Compare */ +static int +abscmp3(const struct fpn *a, const struct fpn *b) +{ + int i; + + if (a-fp_exp b-fp_exp) { + return -1; + } else if (a-fp_exp b-fp_exp) { + return 1; + } else { + for (i = 0; i 3; i++) { + if (a-fp_mant[i] b-fp_mant[i]) +return -1; + else if (a-fp_mant[i] b-fp_mant[i]) +return 1; + } + } + return 0; +} static struct fpn * __fpu_modrem(struct fpemu *fe, int is_mod) { static struct fpn X, Y; struct fpn *x, *y, *r; - struct fpn r_bkup; uint32_t signX, signY, signQ; int j, k, l, q; - int Last_Subtract; + int cmp; + + if (ISNAN(fe-fe_f1) || ISNAN(fe-fe_f2)) + return fpu_newnan(fe); + if (ISINF(fe-fe_f1) || ISZERO(fe-fe_f2)) + return fpu_newnan(fe); CPYFPN(X, fe-fe_f1); CPYFPN(Y, fe-fe_f2); x = X; y = Y; + q = 0; r = fe-fe_f2; /* @@ -111,12 +128,17 @@ __fpu_modrem(struct fpemu *fe, int is_mo signQ = (signX ^ signY); x-fp_sign = y-fp_sign = 0; + /* Special treatment that just return input value but Q is necessary */ + if (ISZERO(x) || ISINF(y)) { + r = fe-fe_f1; + goto Step7; + } + /* * Step 2 */ l = x-fp_exp - y-fp_exp; k = 0; - q = 0; CPYFPN(r, x); if (l = 0) { r-fp_exp -= l; @@ -125,21 +147,20 @@ __fpu_modrem(struct fpemu *fe, int is_mo /* * Step 3 */ - while (y-fp_exp != r-fp_exp || - y-fp_mant[0] != r-fp_mant[0] || - y-fp_mant[1] != r-fp_mant[1] || - y-fp_mant[2] != r-fp_mant[2]) { + for (;;) { + cmp = abscmp3(r, y); + + /* Step 3.1 */ + if (cmp == 0) +break; /* Step 3.2 */ - CPYFPN(r_bkup, r); - CPYFPN(fe-fe_f1, r); - CPYFPN(fe-fe_f2, y); - fe-fe_f2.fp_sign = 1; - r = fpu_add(fe); - if (r-fp_sign == 0) { + if (cmp 0) { +CPYFPN(fe-fe_f1, r); +CPYFPN(fe-fe_f2, y); +fe-fe_f2.fp_sign
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sun May 5 13:17:15 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_rem.c Log Message: Rename modrem - is_mod for a readability. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/m68k/fpe/fpu_rem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_rem.c diff -u src/sys/arch/m68k/fpe/fpu_rem.c:1.13 src/sys/arch/m68k/fpe/fpu_rem.c:1.14 --- src/sys/arch/m68k/fpe/fpu_rem.c:1.13 Tue Mar 26 11:30:21 2013 +++ src/sys/arch/m68k/fpe/fpu_rem.c Sun May 5 13:17:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_rem.c,v 1.13 2013/03/26 11:30:21 isaki Exp $ */ +/* $NetBSD: fpu_rem.c,v 1.14 2013/05/05 13:17:15 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.13 2013/03/26 11:30:21 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.14 2013/05/05 13:17:15 isaki Exp $); #include sys/types.h #include sys/signal.h @@ -85,10 +85,10 @@ __KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v *R := 0. Return signQ, last 7 bits of Q, and R. */ -static struct fpn * __fpu_modrem(struct fpemu *fe, int modrem); +static struct fpn * __fpu_modrem(struct fpemu *fe, int is_mod); static struct fpn * -__fpu_modrem(struct fpemu *fe, int modrem) +__fpu_modrem(struct fpemu *fe, int is_mod) { static struct fpn X, Y; struct fpn *x, *y, *r; @@ -157,7 +157,7 @@ __fpu_modrem(struct fpemu *fe, int modre } Step4: Last_Subtract = 0; - if (modrem == 0) + if (is_mod) goto Step6; /* @@ -226,11 +226,11 @@ __fpu_modrem(struct fpemu *fe, int modre struct fpn * fpu_rem(struct fpemu *fe) { - return __fpu_modrem(fe, 1); + return __fpu_modrem(fe, 0); } struct fpn * fpu_mod(struct fpemu *fe) { - return __fpu_modrem(fe, 0); + return __fpu_modrem(fe, 1); }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sun May 5 13:25:20 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_rem.c Log Message: R := X even if L 0 in Step2, according to algorithm of the comment. This solves many cases of |X| |Y|. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_rem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_rem.c diff -u src/sys/arch/m68k/fpe/fpu_rem.c:1.14 src/sys/arch/m68k/fpe/fpu_rem.c:1.15 --- src/sys/arch/m68k/fpe/fpu_rem.c:1.14 Sun May 5 13:17:15 2013 +++ src/sys/arch/m68k/fpe/fpu_rem.c Sun May 5 13:25:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_rem.c,v 1.14 2013/05/05 13:17:15 isaki Exp $ */ +/* $NetBSD: fpu_rem.c,v 1.15 2013/05/05 13:25:20 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.14 2013/05/05 13:17:15 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.15 2013/05/05 13:25:20 isaki Exp $); #include sys/types.h #include sys/signal.h @@ -117,8 +117,8 @@ __fpu_modrem(struct fpemu *fe, int is_mo l = x-fp_exp - y-fp_exp; k = 0; q = 0; + CPYFPN(r, x); if (l = 0) { - CPYFPN(r, x); r-fp_exp -= l; j = l;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 07:32:45 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_trig.c Log Message: Support sin(-0.0). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.14 src/sys/arch/m68k/fpe/fpu_trig.c:1.15 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.14 Sat Apr 20 05:27:05 2013 +++ src/sys/arch/m68k/fpe/fpu_trig.c Sat Apr 20 07:32:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.14 2013/04/20 05:27:05 isaki Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.15 2013/04/20 07:32:45 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.14 2013/04/20 05:27:05 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.15 2013/04/20 07:32:45 isaki Exp $); #include fpu_emulate.h @@ -330,6 +330,10 @@ fpu_sin(struct fpemu *fe) if (ISINF(fe-fe_f2)) return fpu_newnan(fe); + /* if x is +0/-0, return +0/-0 */ + if (ISZERO(fe-fe_f2)) + return fe-fe_f2; + CPYFPN(x, fe-fe_f2); /* x = abs(input) */
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 09:32:28 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_subr.c Log Message: Rewrite around BFFFO inline asm. o Prepare C version of BFFFO (from XM6i). It is helpful in running FPE on other platforms (for example, for a test). It is also helpful in porting to non-m68k 3rd party :) o A BFFFO is supported on 68020 or later (though I'm not sure whether sun2/68010 uses this FPE correctly or not). To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/fpe/fpu_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_subr.c diff -u src/sys/arch/m68k/fpe/fpu_subr.c:1.10 src/sys/arch/m68k/fpe/fpu_subr.c:1.11 --- src/sys/arch/m68k/fpe/fpu_subr.c:1.10 Tue Mar 26 11:30:21 2013 +++ src/sys/arch/m68k/fpe/fpu_subr.c Sat Apr 20 09:32:28 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_subr.c,v 1.10 2013/03/26 11:30:21 isaki Exp $ */ +/* $NetBSD: fpu_subr.c,v 1.11 2013/04/20 09:32:28 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_subr.c,v 1.10 2013/03/26 11:30:21 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_subr.c,v 1.11 2013/04/20 09:32:28 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -56,6 +56,25 @@ __KERNEL_RCSID(0, $NetBSD: fpu_subr.c,v #include fpu_arith.h /* + * m68020 or later has a BFFFO instruction, therefore use it. + * Otherwise, use C version. + */ +static inline int +bfffo(uint32_t src) +{ + int offset; +#if defined(__m68k__) !defined(M68010) + __asm volatile(bfffo %1{#0:#32},%0 : =d(offset) : g(src)); +#else + int width = 32; + for (offset = 0; width-- 0 (int)src = 0; src = 1) { + offset++; + } +#endif + return offset; +} + +/* * Shift the given number right rsh bits. Any bits that `fall off' will get * shoved into the sticky field; we return the resulting sticky. Note that * shifting NaNs is legal (this will never shift all bits out); a NaN's @@ -165,7 +184,7 @@ fpu_norm(struct fpn *fp) * We have a supernormal number. We need to shift it right. * We may assume m2==0. */ - __asm volatile(bfffo %1{#0:#32},%0 : =d(rsh) : g(m0)); + rsh = bfffo(m0); rsh = 31 - rsh - FP_LG; exp += rsh; lsh = 32 - rsh; @@ -177,7 +196,7 @@ fpu_norm(struct fpn *fp) * We have a regular denorm (a subnormal number), and need * to shift it left. */ - __asm volatile(bfffo %1{#0:#32},%0 : =d(lsh) : g(m0)); + lsh = bfffo(m0); lsh = FP_LG - 31 + lsh; exp -= lsh; rsh = 32 - lsh;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sun Apr 21 02:50:49 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_subr.c Log Message: M68010 - __mc68010__, pointed out by tsutsui@ To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/fpe/fpu_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_subr.c diff -u src/sys/arch/m68k/fpe/fpu_subr.c:1.11 src/sys/arch/m68k/fpe/fpu_subr.c:1.12 --- src/sys/arch/m68k/fpe/fpu_subr.c:1.11 Sat Apr 20 09:32:28 2013 +++ src/sys/arch/m68k/fpe/fpu_subr.c Sun Apr 21 02:50:48 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_subr.c,v 1.11 2013/04/20 09:32:28 isaki Exp $ */ +/* $NetBSD: fpu_subr.c,v 1.12 2013/04/21 02:50:48 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_subr.c,v 1.11 2013/04/20 09:32:28 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_subr.c,v 1.12 2013/04/21 02:50:48 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -63,7 +63,7 @@ static inline int bfffo(uint32_t src) { int offset; -#if defined(__m68k__) !defined(M68010) +#if defined(__m68k__) !defined(__mc68010__) __asm volatile(bfffo %1{#0:#32},%0 : =d(offset) : g(src)); #else int width = 32;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Fri Apr 19 13:57:53 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_trig.c Log Message: Implement inverse trigonometric functions (i.e., FACOS, FASIN, FATAN instructions). o arccos is calculated using arcsin. o arcsin is calculated using arctan. o arctan is calculated by the CORDIC. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.11 src/sys/arch/m68k/fpe/fpu_trig.c:1.12 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.11 Fri Apr 19 13:31:11 2013 +++ src/sys/arch/m68k/fpe/fpu_trig.c Fri Apr 19 13:57:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.11 2013/04/19 13:31:11 isaki Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.12 2013/04/19 13:57:52 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,28 +57,120 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.11 2013/04/19 13:31:11 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.12 2013/04/19 13:57:52 isaki Exp $); #include fpu_emulate.h +/* + * arccos(x) = pi/2 - arcsin(x) + */ struct fpn * fpu_acos(struct fpemu *fe) { - /* stub */ - return fe-fe_f2; + struct fpn *r; + + if (ISNAN(fe-fe_f2)) + return fe-fe_f2; + if (ISINF(fe-fe_f2)) + return fpu_newnan(fe); + + r = fpu_asin(fe); + CPYFPN(fe-fe_f2, r); + + /* pi/2 - asin(x) */ + fpu_const(fe-fe_f1, FPU_CONST_PI); + fe-fe_f1.fp_exp--; + fe-fe_f2.fp_sign = !fe-fe_f2.fp_sign; + r = fpu_add(fe); + + return r; } +/* + * x + * arcsin(x) = arctan(---) + * sqrt(1 - x^2) + */ struct fpn * fpu_asin(struct fpemu *fe) { - /* stub */ - return fe-fe_f2; + struct fpn x; + struct fpn *r; + + if (ISNAN(fe-fe_f2)) + return fe-fe_f2; + if (ISZERO(fe-fe_f2)) + return fe-fe_f2; + + if (ISINF(fe-fe_f2)) + return fpu_newnan(fe); + + CPYFPN(x, fe-fe_f2); + + /* x^2 */ + CPYFPN(fe-fe_f1, fe-fe_f2); + r = fpu_mul(fe); + + /* 1 - x^2 */ + CPYFPN(fe-fe_f2, r); + fe-fe_f2.fp_sign = 1; + fpu_const(fe-fe_f1, FPU_CONST_1); + r = fpu_add(fe); + + /* sqrt(1-x^2) */ + CPYFPN(fe-fe_f2, r); + r = fpu_sqrt(fe); + + /* x/sqrt */ + CPYFPN(fe-fe_f2, r); + CPYFPN(fe-fe_f1, x); + r = fpu_div(fe); + + /* arctan */ + CPYFPN(fe-fe_f2, r); + return fpu_atan(fe); } +/* + * arctan(x): + * + * if (x 0) { + * x = abs(x); + * sign = 1; + * } + * y = arctan(x); + * if (sign) { + * y = -y; + * } + */ struct fpn * fpu_atan(struct fpemu *fe) { - /* stub */ + struct fpn a; + struct fpn x; + struct fpn v; + + if (ISNAN(fe-fe_f2)) + return fe-fe_f2; + if (ISZERO(fe-fe_f2)) + return fe-fe_f2; + + CPYFPN(a, fe-fe_f2); + + if (ISINF(fe-fe_f2)) { + /* f2 - pi/2 */ + fpu_const(fe-fe_f2, FPU_CONST_PI); + fe-fe_f2.fp_exp--; + + fe-fe_f2.fp_sign = a.fp_sign; + return fe-fe_f2; + } + + fpu_const(x, FPU_CONST_1); + fpu_const(fe-fe_f2, FPU_CONST_0); + CPYFPN(v, fe-fe_f2); + fpu_cordit1(fe, x, a, fe-fe_f2, v); + return fe-fe_f2; }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 01:48:20 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_cordic.c Log Message: s/tayler/taylor/. pointed out by christos@ To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/m68k/fpe/fpu_cordic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_cordic.c diff -u src/sys/arch/m68k/fpe/fpu_cordic.c:1.1 src/sys/arch/m68k/fpe/fpu_cordic.c:1.2 --- src/sys/arch/m68k/fpe/fpu_cordic.c:1.1 Fri Apr 19 13:31:11 2013 +++ src/sys/arch/m68k/fpe/fpu_cordic.c Sat Apr 20 01:48:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_cordic.c,v 1.1 2013/04/19 13:31:11 isaki Exp $ */ +/* $NetBSD: fpu_cordic.c,v 1.2 2013/04/20 01:48:20 isaki Exp $ */ /* * Copyright (c) 2013 Tetsuya Isaki. All rights reserved. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_cordic.c,v 1.1 2013/04/19 13:31:11 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_cordic.c,v 1.2 2013/04/20 01:48:20 isaki Exp $); #include machine/ieee.h @@ -59,7 +59,7 @@ struct sfpn { static void prepare_cordic_const(struct fpemu *); static struct fpn *fpu_gain1_cordic(struct fpemu *); static struct fpn *fpu_gain2_cordic(struct fpemu *); -static struct fpn *fpu_atan_tayler(struct fpemu *); +static struct fpn *fpu_atan_taylor(struct fpemu *); static void printf_fpn(const struct fpn *); static void printf_sfpn(const struct sfpn *); static void fpn_to_sfpn(struct sfpn *, const struct fpn *); @@ -107,7 +107,7 @@ main(int argc, char *argv[]) /* * This routine uses fpu_const(), fpu_add(), fpu_div(), fpu_logn() - * and fpu_atan_tayler() as bootstrap. + * and fpu_atan_taylor() as bootstrap. */ static void prepare_cordic_const(struct fpemu *fe) @@ -122,7 +122,7 @@ prepare_cordic_const(struct fpemu *fe) for (i = 0; i EXT_FRACBITS; i++) { /* atan(t) */ CPYFPN(fe-fe_f2, t); - r = fpu_atan_tayler(fe); + r = fpu_atan_taylor(fe); fpn_to_sfpn(atan_table[i], r); /* t /= 2 */ @@ -216,7 +216,7 @@ fpu_gain2_cordic(struct fpemu *fe) * 3 5 7 */ static struct fpn * -fpu_atan_tayler(struct fpemu *fe) +fpu_atan_taylor(struct fpemu *fe) { struct fpn res; struct fpn x2;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 03:26:12 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: README Log Message: Update a list of implement/unimplement functions. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/fpe/README Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/README diff -u src/sys/arch/m68k/fpe/README:1.5 src/sys/arch/m68k/fpe/README:1.6 --- src/sys/arch/m68k/fpe/README:1.5 Sat Oct 15 15:24:28 2011 +++ src/sys/arch/m68k/fpe/README Sat Apr 20 03:26:11 2013 @@ -1,4 +1,4 @@ -* $NetBSD: README,v 1.5 2011/10/15 15:24:28 tsutsui Exp $ +* $NetBSD: README,v 1.6 2013/04/20 03:26:11 isaki Exp $ * NetBSD/m68k FPE (floating point emulation) README file * Created Oct/??/95 by k...@remus.rutgers.edu (Ken Nakata) * Last updated Oct/15/2011 by tsutsui @@ -68,7 +68,8 @@ Type=0: FMOVE (mem-FPr), FINT, FINTRZ, FGETMAN, FDIV, FADD, FMUL, FSGLDIV(*), FSCALE, FSGLMUL(*), FSUB, FCMP, FTST, FMOVE (FPr-mem), FMOVEM (FPr), FMOVEM (FPcr), FMOVECR, FLOGNP1, FLOGN, FLOG10, FLOG2, FMOD, FREM, - FCOSH, FSINH, FTANH, FCOS, FSIN, FTAN, FSINCOS + FCOSH, FSINH, FTANH, FCOS, FSIN, FTAN, FSINCOS, + FETOX, FETOXM1, FTENTOX, FTWOTOX, FATANH, FACOS, FASIN, FATAN Type=1: FDBcc, FScc, FTRAPcc, @@ -85,7 +86,7 @@ Type=5: none * Unimplemented Instructions -Type=0: FETOX, FETOXM1, FTENTOX, FTWOTOX, FATANH, FACOS, FASIN, FATAN +Type=0: none Type=1: none
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 04:38:51 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_exp.c fpu_hyperb.c Log Message: Break a loop off to avoid a long loop even if the precision is not enough. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/m68k/fpe/fpu_exp.c cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/fpe/fpu_hyperb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_exp.c diff -u src/sys/arch/m68k/fpe/fpu_exp.c:1.6 src/sys/arch/m68k/fpe/fpu_exp.c:1.7 --- src/sys/arch/m68k/fpe/fpu_exp.c:1.6 Sat Apr 20 03:06:19 2013 +++ src/sys/arch/m68k/fpe/fpu_exp.c Sat Apr 20 04:38:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_exp.c,v 1.6 2013/04/20 03:06:19 isaki Exp $ */ +/* $NetBSD: fpu_exp.c,v 1.7 2013/04/20 04:38:51 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,10 +32,13 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_exp.c,v 1.6 2013/04/20 03:06:19 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_exp.c,v 1.7 2013/04/20 04:38:51 isaki Exp $); #include fpu_emulate.h +/* The number of items to terminate the Taylor expansion */ +#define MAX_ITEMS (2000) + /* * fpu_exp.c: defines fpu_etox(), fpu_etoxm1(), fpu_tentox(), and fpu_twotox(); */ @@ -64,7 +67,7 @@ fpu_etox_taylor(struct fpemu *fe) CPYFPN(res, r); k = 2; - for (;; k++) { + for (; k MAX_ITEMS; k++) { /* s1 = s0 * x / k */ CPYFPN(fe-fe_f1, s0); CPYFPN(fe-fe_f2, x); Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.10 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.11 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.10 Fri Apr 19 14:05:12 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Sat Apr 20 04:38:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.10 2013/04/19 14:05:12 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.11 2013/04/20 04:38:51 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,10 +57,13 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.10 2013/04/19 14:05:12 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.11 2013/04/20 04:38:51 isaki Exp $); #include fpu_emulate.h +/* The number of items to terminate the Taylor expansion */ +#define MAX_ITEMS (2000) + /* * fpu_hyperb.c: defines the following functions * @@ -159,7 +162,7 @@ __fpu_sinhcosh_taylor(struct fpemu *fe, sign = 1; /* sign := (-1)^n */ - for (;;) { + for (; f (2 * MAX_ITEMS); ) { /* (f1 :=) s0 * x^2 */ CPYFPN(fe-fe_f1, s0); CPYFPN(fe-fe_f2, x2);
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 04:54:22 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_exp.c fpu_hyperb.c Log Message: Terminate a loop in EXT_FRACBITS(64bits) instead of FP_NMANT(83bits). I don't know why the mantissa of the accumulator is 83bits, but 64bits or more are not affected. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/fpe/fpu_exp.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/fpe/fpu_hyperb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_exp.c diff -u src/sys/arch/m68k/fpe/fpu_exp.c:1.7 src/sys/arch/m68k/fpe/fpu_exp.c:1.8 --- src/sys/arch/m68k/fpe/fpu_exp.c:1.7 Sat Apr 20 04:38:51 2013 +++ src/sys/arch/m68k/fpe/fpu_exp.c Sat Apr 20 04:54:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_exp.c,v 1.7 2013/04/20 04:38:51 isaki Exp $ */ +/* $NetBSD: fpu_exp.c,v 1.8 2013/04/20 04:54:22 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,9 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_exp.c,v 1.7 2013/04/20 04:38:51 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_exp.c,v 1.8 2013/04/20 04:54:22 isaki Exp $); + +#include machine/ieee.h #include fpu_emulate.h @@ -80,7 +82,7 @@ fpu_etox_taylor(struct fpemu *fe) /* break if s1 is enough small */ if (ISZERO(s1)) break; - if (res.fp_exp - s1-fp_exp = FP_NMANT) + if (res.fp_exp - s1-fp_exp = EXT_FRACBITS) break; /* s0 := s1 for next loop */ Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.11 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.12 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.11 Sat Apr 20 04:38:51 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Sat Apr 20 04:54:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.11 2013/04/20 04:38:51 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.12 2013/04/20 04:54:22 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,9 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.11 2013/04/20 04:38:51 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.12 2013/04/20 04:54:22 isaki Exp $); + +#include machine/ieee.h #include fpu_emulate.h @@ -180,7 +182,7 @@ __fpu_sinhcosh_taylor(struct fpemu *fe, /* break if s1 is enough small */ if (ISZERO(s1)) break; - if (res.fp_exp - s1-fp_exp = FP_NMANT) + if (res.fp_exp - s1-fp_exp = EXT_FRACBITS) break; /* s0 := s1 for next loop */
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 04:55:44 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_hyperb.c Log Message: Fix typo in comment. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/m68k/fpe/fpu_hyperb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.12 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.13 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.12 Sat Apr 20 04:54:22 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Sat Apr 20 04:55:44 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.12 2013/04/20 04:54:22 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.13 2013/04/20 04:55:44 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.12 2013/04/20 04:54:22 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.13 2013/04/20 04:55:44 isaki Exp $); #include machine/ieee.h @@ -172,8 +172,8 @@ __fpu_sinhcosh_taylor(struct fpemu *fe, CPYFPN(fe-fe_f1, r); /* - * for sin(), s1 := s0 * x^2 / (2n+1)2n - * for cos(), s1 := s0 * x^2 / 2n(2n-1) + * for sinh(), s1 := s0 * x^2 / (2n+1)2n + * for cosh(), s1 := s0 * x^2 / 2n(2n-1) */ k = f * (f + 1); fpu_explode(fe, fe-fe_f2, FTYPE_LNG, k);
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Apr 20 05:27:05 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_hyperb.c fpu_log.c fpu_trig.c Log Message: Clean up some useless codes. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/m68k/fpe/fpu_hyperb.c \ src/sys/arch/m68k/fpe/fpu_trig.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/m68k/fpe/fpu_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.13 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.14 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.13 Sat Apr 20 04:55:44 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Sat Apr 20 05:27:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.13 2013/04/20 04:55:44 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.14 2013/04/20 05:27:05 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.13 2013/04/20 04:55:44 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.14 2013/04/20 05:27:05 isaki Exp $); #include machine/ieee.h @@ -218,9 +218,8 @@ fpu_cosh(struct fpemu *fe) fpu_const(s0, FPU_CONST_1); r = __fpu_sinhcosh_taylor(fe, s0, 1); - CPYFPN(fe-fe_f2, r); - return fe-fe_f2; + return r; } struct fpn * @@ -236,9 +235,8 @@ fpu_sinh(struct fpemu *fe) CPYFPN(s0, fe-fe_f2); r = __fpu_sinhcosh_taylor(fe, s0, 2); - CPYFPN(fe-fe_f2, r); - return fe-fe_f2; + return r; } struct fpn * @@ -274,7 +272,5 @@ fpu_tanh(struct fpemu *fe) CPYFPN(fe-fe_f1, s); r = fpu_div(fe); - CPYFPN(fe-fe_f2, r); - - return fe-fe_f2; + return r; } Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.13 src/sys/arch/m68k/fpe/fpu_trig.c:1.14 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.13 Sat Apr 20 05:09:41 2013 +++ src/sys/arch/m68k/fpe/fpu_trig.c Sat Apr 20 05:27:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.13 2013/04/20 05:09:41 isaki Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.14 2013/04/20 05:27:05 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.13 2013/04/20 05:09:41 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.14 2013/04/20 05:27:05 isaki Exp $); #include fpu_emulate.h @@ -427,10 +427,7 @@ fpu_tan(struct fpemu *fe) CPYFPN(fe-fe_f1, s); r = fpu_div(fe); - - CPYFPN(fe-fe_f2, r); - - return fe-fe_f2; + return r; } struct fpn * Index: src/sys/arch/m68k/fpe/fpu_log.c diff -u src/sys/arch/m68k/fpe/fpu_log.c:1.16 src/sys/arch/m68k/fpe/fpu_log.c:1.17 --- src/sys/arch/m68k/fpe/fpu_log.c:1.16 Thu Apr 11 13:27:11 2013 +++ src/sys/arch/m68k/fpe/fpu_log.c Sat Apr 20 05:27:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_log.c,v 1.16 2013/04/11 13:27:11 isaki Exp $ */ +/* $NetBSD: fpu_log.c,v 1.17 2013/04/20 05:27:05 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_log.c,v 1.16 2013/04/11 13:27:11 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_log.c,v 1.17 2013/04/20 05:27:05 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -599,8 +599,7 @@ fpu_lognp1(struct fpemu *fe) fp = fpu_add(fe); /* copy the result to the src opr */ - if (fe-fe_f2 != fp) - CPYFPN(fe-fe_f2, fp); + CPYFPN(fe-fe_f2, fp); return fpu_logn(fe); }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Thu Apr 18 13:40:25 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_trig.c Log Message: Improve how to use cmp/sub. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.9 src/sys/arch/m68k/fpe/fpu_trig.c:1.10 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.9 Thu Apr 11 13:27:11 2013 +++ src/sys/arch/m68k/fpe/fpu_trig.c Thu Apr 18 13:40:25 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.9 2013/04/11 13:27:11 isaki Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.10 2013/04/18 13:40:25 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.9 2013/04/11 13:27:11 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.10 2013/04/18 13:40:25 isaki Exp $); #include fpu_emulate.h @@ -277,14 +277,10 @@ fpu_cos(struct fpemu *fe) */ CPYFPN(fe-fe_f1, x); CPYFPN(fe-fe_f2, p); - r = fpu_cmp(fe); + fe-fe_f2.fp_sign = 1; + r = fpu_add(fe); if (r-fp_sign == 0) { - CPYFPN(fe-fe_f1, x); - CPYFPN(fe-fe_f2, p); - fe-fe_f2.fp_sign = 1; - r = fpu_add(fe); CPYFPN(x, r); - sign ^= 1; } @@ -299,13 +295,9 @@ fpu_cos(struct fpemu *fe) */ CPYFPN(fe-fe_f1, x); CPYFPN(fe-fe_f2, p); - r = fpu_cmp(fe); + fe-fe_f2.fp_sign = 1; + r = fpu_add(fe); if (r-fp_sign == 0) { - CPYFPN(fe-fe_f1, x); - CPYFPN(fe-fe_f2, p); - fe-fe_f2.fp_sign = 1; - r = fpu_add(fe); - CPYFPN(fe-fe_f2, r); r = fpu_sin_halfpi(fe); sign ^= 1; @@ -389,14 +381,10 @@ fpu_sin(struct fpemu *fe) */ CPYFPN(fe-fe_f1, x); CPYFPN(fe-fe_f2, p); - r = fpu_cmp(fe); + fe-fe_f2.fp_sign = 1; + r = fpu_add(fe); if (r-fp_sign == 0) { - CPYFPN(fe-fe_f1, x); - CPYFPN(fe-fe_f2, p); - fe-fe_f2.fp_sign = 1; - r = fpu_add(fe); CPYFPN(x, r); - sign ^= 1; } @@ -411,13 +399,9 @@ fpu_sin(struct fpemu *fe) */ CPYFPN(fe-fe_f1, x); CPYFPN(fe-fe_f2, p); - r = fpu_cmp(fe); + fe-fe_f2.fp_sign = 1; + r = fpu_add(fe); if (r-fp_sign == 0) { - CPYFPN(fe-fe_f1, x); - CPYFPN(fe-fe_f2, p); - fe-fe_f2.fp_sign = 1; - r = fpu_add(fe); - CPYFPN(fe-fe_f2, r); r = fpu_cos_halfpi(fe); } else {
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Thu Apr 11 13:27:11 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.h fpu_hyperb.c fpu_log.c fpu_trig.c Log Message: Introduce FPU_CONST_* constants to avoid a magic number. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/m68k/fpe/fpu_emulate.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/fpe/fpu_hyperb.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_log.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.h diff -u src/sys/arch/m68k/fpe/fpu_emulate.h:1.22 src/sys/arch/m68k/fpe/fpu_emulate.h:1.23 --- src/sys/arch/m68k/fpe/fpu_emulate.h:1.22 Tue Mar 26 11:30:20 2013 +++ src/sys/arch/m68k/fpe/fpu_emulate.h Thu Apr 11 13:27:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.h,v 1.22 2013/03/26 11:30:20 isaki Exp $ */ +/* $NetBSD: fpu_emulate.h,v 1.23 2013/04/11 13:27:11 isaki Exp $ */ /* * Copyright (c) 1995 Gordon Ross @@ -253,6 +253,11 @@ struct fpn *fpu_sincos_taylor(struct fpe */ /* return values from constant rom */ struct fpn *fpu_const(struct fpn *, uint32_t); +#define FPU_CONST_PI (0x00) /* pi */ +#define FPU_CONST_LN_2 (0x30) /* ln(2) */ +#define FPU_CONST_LN_10 (0x31) /* ln(10) */ +#define FPU_CONST_1 (0x32) /* 1.0 */ + /* update exceptions and FPSR */ int fpu_upd_excp(struct fpemu *); uint32_t fpu_upd_fpsr(struct fpemu *, struct fpn *); Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.7 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.8 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.7 Sat Mar 23 12:06:24 2013 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Thu Apr 11 13:27:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.7 2013/03/23 12:06:24 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.8 2013/04/11 13:27:11 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.7 2013/03/23 12:06:24 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.8 2013/04/11 13:27:11 isaki Exp $); #include fpu_emulate.h @@ -89,7 +89,7 @@ fpu_cosh(struct fpemu *fe) return fe-fe_f2; } - fpu_const(s0, 0x32); /* 1.0 */ + fpu_const(s0, FPU_CONST_1); r = fpu_sincos_taylor(fe, s0, 1, hyperb); CPYFPN(fe-fe_f2, r); @@ -128,7 +128,7 @@ fpu_tanh(struct fpemu *fe) if (ISINF(fe-fe_f2)) { sign = fe-fe_f2.fp_sign; - fpu_const(fe-fe_f2, 0x32); + fpu_const(fe-fe_f2, FPU_CONST_1); fe-fe_f2.fp_sign = sign; return fe-fe_f2; } Index: src/sys/arch/m68k/fpe/fpu_log.c diff -u src/sys/arch/m68k/fpe/fpu_log.c:1.15 src/sys/arch/m68k/fpe/fpu_log.c:1.16 --- src/sys/arch/m68k/fpe/fpu_log.c:1.15 Tue Mar 26 11:30:21 2013 +++ src/sys/arch/m68k/fpe/fpu_log.c Thu Apr 11 13:27:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_log.c,v 1.15 2013/03/26 11:30:21 isaki Exp $ */ +/* $NetBSD: fpu_log.c,v 1.16 2013/04/11 13:27:11 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_log.c,v 1.15 2013/03/26 11:30:21 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_log.c,v 1.16 2013/04/11 13:27:11 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -210,13 +210,13 @@ __fpu_logn(struct fpemu *fe) printf(__fpu_logn: log near 1\n); #endif - fpu_const(fe-fe_f1, 0x32); + fpu_const(fe-fe_f1, FPU_CONST_1); /* X+1 */ d = fpu_add(fe); CPYFPN(V, d); CPYFPN(fe-fe_f1, X); - fpu_const(fe-fe_f2, 0x32); /* 1.0 */ + fpu_const(fe-fe_f2, FPU_CONST_1); fe-fe_f2.fp_sign = 1; /* -1.0 */ /* X-1 */ d = fpu_add(fe); @@ -352,7 +352,7 @@ __fpu_logn(struct fpemu *fe) /* KLOG2 = K * ln(2) */ /* fe_f1 == (fpn)k */ fpu_explode(fe, fe-fe_f1, FTYPE_LNG, k); - (void)fpu_const(fe-fe_f2, 0x30 /* ln(2) */); + (void)fpu_const(fe-fe_f2, FPU_CONST_LN_2); #if FPE_DEBUG printf(__fpu_logn: fp(k)=(%d,%08x,%08x...)\n, fe-fe_f1.fp_exp, @@ -491,7 +491,7 @@ fpu_log10(struct fpemu *fe) fp = __fpu_logn(fe); if (fp != fe-fe_f1) CPYFPN(fe-fe_f1, fp); - (void)fpu_const(fe-fe_f2, 0x31 /* ln(10) */); + (void)fpu_const(fe-fe_f2, FPU_CONST_LN_10); fp = fpu_div(fe); } /* else if fp == +Inf, return +Inf */ } else if (fp-fp_class == FPC_ZERO) { @@ -535,7 +535,7 @@ fpu_log2(struct fpemu *fe) fp = __fpu_logn(fe); if (fp != fe-fe_f1) CPYFPN(fe-fe_f1, fp); -(void)fpu_const(fe-fe_f2, 0x30 /* ln(2) */); +(void)fpu_const(fe-fe_f2, FPU_CONST_LN_2); fp = fpu_div(fe); } } /* else if fp == +Inf, return +Inf */ @@ -594,7 +594,7 @@ fpu_lognp1(struct fpemu *fe) struct fpn *fp; /* build a 1.0 */ - fp = fpu_const(fe-fe_f1, 0x32); /* get 1.0 */ + fp = fpu_const(fe-fe_f1, FPU_CONST_1); /* fp = 1.0 + f2 */ fp = fpu_add(fe); Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Mon Apr 1 13:59:21 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_arith.h Log Message: quad_t - uint64_t To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/fpe/fpu_arith.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_arith.h diff -u src/sys/arch/m68k/fpe/fpu_arith.h:1.7 src/sys/arch/m68k/fpe/fpu_arith.h:1.8 --- src/sys/arch/m68k/fpe/fpu_arith.h:1.7 Tue Mar 26 11:30:20 2013 +++ src/sys/arch/m68k/fpe/fpu_arith.h Mon Apr 1 13:59:21 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_arith.h,v 1.7 2013/03/26 11:30:20 isaki Exp $ */ +/* $NetBSD: fpu_arith.h,v 1.8 2013/04/01 13:59:21 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -57,7 +57,7 @@ #ifndef FPE_USE_ASM /* set up for extended-precision arithemtic */ -#define FPU_DECL_CARRY quad_t fpu_carry, fpu_tmp; +#define FPU_DECL_CARRY uint64_t fpu_carry, fpu_tmp; /* * We have three kinds of add: @@ -79,13 +79,13 @@ (r) = (x) + (y) + (!!fpu_carry) #define FPU_ADDS(r, x, y) \ { \ - fpu_tmp = (quad_t)(x) + (quad_t)(y); \ + fpu_tmp = (uint64_t)(x) + (uint64_t)(y); \ (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } #define FPU_ADDCS(r, x, y) \ { \ - fpu_tmp = (quad_t)(x) + (quad_t)(y) + (!!fpu_carry); \ + fpu_tmp = (uint64_t)(x) + (uint64_t)(y) + (!!fpu_carry); \ (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } @@ -93,13 +93,13 @@ (r) = (x) - (y) - (!!fpu_carry) #define FPU_SUBS(r, x, y) \ { \ - fpu_tmp = (quad_t)(x) - (quad_t)(y); \ + fpu_tmp = (uint64_t)(x) - (uint64_t)(y); \ (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } #define FPU_SUBCS(r, x, y) \ { \ - fpu_tmp = (quad_t)(x) - (quad_t)(y) - (!!fpu_carry); \ + fpu_tmp = (uint64_t)(x) - (uint64_t)(y) - (!!fpu_carry); \ (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Tue Mar 26 10:57:13 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_rem.c Log Message: Fix a wrong raw comparison in step3.2. It should solve a PR kern/47692. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/fpe/fpu_rem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_rem.c diff -u src/sys/arch/m68k/fpe/fpu_rem.c:1.11 src/sys/arch/m68k/fpe/fpu_rem.c:1.12 --- src/sys/arch/m68k/fpe/fpu_rem.c:1.11 Mon Jul 18 14:11:27 2011 +++ src/sys/arch/m68k/fpe/fpu_rem.c Tue Mar 26 10:57:13 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_rem.c,v 1.11 2011/07/18 14:11:27 isaki Exp $ */ +/* $NetBSD: fpu_rem.c,v 1.12 2013/03/26 10:57:13 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.11 2011/07/18 14:11:27 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_rem.c,v 1.12 2013/03/26 10:57:13 isaki Exp $); #include sys/types.h #include sys/signal.h @@ -92,6 +92,7 @@ __fpu_modrem(struct fpemu *fe, int modre { static struct fpn X, Y; struct fpn *x, *y, *r; + struct fpn r_bkup; u_int signX, signY, signQ; int j, k, l, q; int Last_Subtract; @@ -130,15 +131,15 @@ __fpu_modrem(struct fpemu *fe, int modre y-fp_mant[2] != r-fp_mant[2]) { /* Step 3.2 */ - if (y-fp_exp r-fp_exp || - y-fp_mant[0] r-fp_mant[0] || - y-fp_mant[1] r-fp_mant[1] || - y-fp_mant[2] r-fp_mant[2]) { -CPYFPN(fe-fe_f1, r); -CPYFPN(fe-fe_f2, y); -fe-fe_f2.fp_sign = 1; -r = fpu_add(fe); + CPYFPN(r_bkup, r); + CPYFPN(fe-fe_f1, r); + CPYFPN(fe-fe_f2, y); + fe-fe_f2.fp_sign = 1; + r = fpu_add(fe); + if (r-fp_sign == 0) { q++; + } else { +CPYFPN(r, r_bkup); } /* Step 3.3 */
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Tue Mar 26 11:30:21 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_add.c fpu_arith.h fpu_div.c fpu_emulate.c fpu_emulate.h fpu_explode.c fpu_fmovecr.c fpu_fscale.c fpu_fstore.c fpu_implode.c fpu_log.c fpu_mul.c fpu_rem.c fpu_sqrt.c fpu_subr.c fpu_trig.c Log Message: u_int - uint32_t To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/fpe/fpu_add.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/m68k/fpe/fpu_arith.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/fpe/fpu_div.c \ src/sys/arch/m68k/fpe/fpu_mul.c src/sys/arch/m68k/fpe/fpu_sqrt.c \ src/sys/arch/m68k/fpe/fpu_trig.c cvs rdiff -u -r1.36 -r1.37 src/sys/arch/m68k/fpe/fpu_emulate.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/m68k/fpe/fpu_emulate.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/m68k/fpe/fpu_explode.c \ src/sys/arch/m68k/fpe/fpu_fstore.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_fmovecr.c \ src/sys/arch/m68k/fpe/fpu_fscale.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_implode.c \ src/sys/arch/m68k/fpe/fpu_log.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/m68k/fpe/fpu_rem.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/fpe/fpu_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_add.c diff -u src/sys/arch/m68k/fpe/fpu_add.c:1.8 src/sys/arch/m68k/fpe/fpu_add.c:1.9 --- src/sys/arch/m68k/fpe/fpu_add.c:1.8 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_add.c Tue Mar 26 11:30:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_add.c,v 1.8 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_add.c,v 1.9 2013/03/26 11:30:20 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -47,7 +47,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_add.c,v 1.8 2013/03/19 09:17:17 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_add.c,v 1.9 2013/03/26 11:30:20 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -61,7 +61,7 @@ struct fpn * fpu_add(struct fpemu *fe) { struct fpn *x = fe-fe_f1, *y = fe-fe_f2, *r; - u_int r0, r1, r2; + uint32_t r0, r1, r2; int rd; /* Index: src/sys/arch/m68k/fpe/fpu_arith.h diff -u src/sys/arch/m68k/fpe/fpu_arith.h:1.6 src/sys/arch/m68k/fpe/fpu_arith.h:1.7 --- src/sys/arch/m68k/fpe/fpu_arith.h:1.6 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_arith.h Tue Mar 26 11:30:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_arith.h,v 1.6 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_arith.h,v 1.7 2013/03/26 11:30:20 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -80,13 +80,13 @@ #define FPU_ADDS(r, x, y) \ { \ fpu_tmp = (quad_t)(x) + (quad_t)(y); \ - (r) = (u_int)fpu_tmp; \ + (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } #define FPU_ADDCS(r, x, y) \ { \ fpu_tmp = (quad_t)(x) + (quad_t)(y) + (!!fpu_carry); \ - (r) = (u_int)fpu_tmp; \ + (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } #define FPU_SUBC(r, x, y) \ @@ -94,13 +94,13 @@ #define FPU_SUBS(r, x, y) \ { \ fpu_tmp = (quad_t)(x) - (quad_t)(y); \ - (r) = (u_int)fpu_tmp; \ + (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } #define FPU_SUBCS(r, x, y) \ { \ fpu_tmp = (quad_t)(x) - (quad_t)(y) - (!!fpu_carry); \ - (r) = (u_int)fpu_tmp; \ + (r) = (uint32_t)fpu_tmp; \ fpu_carry = ((fpu_tmp 0xLL) != 0); \ } Index: src/sys/arch/m68k/fpe/fpu_div.c diff -u src/sys/arch/m68k/fpe/fpu_div.c:1.7 src/sys/arch/m68k/fpe/fpu_div.c:1.8 --- src/sys/arch/m68k/fpe/fpu_div.c:1.7 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_div.c Tue Mar 26 11:30:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_div.c,v 1.7 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_div.c,v 1.8 2013/03/26 11:30:20 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.7 2013/03/19 09:17:17 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.8 2013/03/26 11:30:20 isaki Exp $); #include sys/types.h @@ -153,8 +153,8 @@ struct fpn * fpu_div(struct fpemu *fe) { struct fpn *x = fe-fe_f1, *y = fe-fe_f2; - u_int q, bit; - u_int r0, r1, r2, d0, d1, d2, y0, y1, y2; + uint32_t q, bit; + uint32_t r0, r1, r2, d0, d1, d2, y0, y1, y2; FPU_DECL_CARRY fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ Index: src/sys/arch/m68k/fpe/fpu_mul.c diff -u src/sys/arch/m68k/fpe/fpu_mul.c:1.7 src/sys/arch/m68k/fpe/fpu_mul.c:1.8 --- src/sys/arch/m68k/fpe/fpu_mul.c:1.7 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_mul.c Tue Mar 26 11:30:21 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_mul.c,v 1.7 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_mul.c,v 1.8 2013/03/26 11:30:21 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Mar 23 12:06:24 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_hyperb.c fpu_trig.c Log Message: Remove about updating fpsr. It was introduced by me but obviously duplicated with fpu_emul_arith(). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/m68k/fpe/fpu_hyperb.c \ src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.6 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.7 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.6 Sat Oct 15 15:14:30 2011 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Sat Mar 23 12:06:24 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.6 2011/10/15 15:14:30 tsutsui Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.7 2013/03/23 12:06:24 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.6 2011/10/15 15:14:30 tsutsui Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.7 2013/03/23 12:06:24 isaki Exp $); #include fpu_emulate.h @@ -81,8 +81,6 @@ fpu_cosh(struct fpemu *fe) struct fpn *r; int hyperb = 1; - fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ - if (ISNAN(fe-fe_f2)) return fe-fe_f2; @@ -95,7 +93,6 @@ fpu_cosh(struct fpemu *fe) r = fpu_sincos_taylor(fe, s0, 1, hyperb); CPYFPN(fe-fe_f2, r); - fpu_upd_fpsr(fe, fe-fe_f2); return fe-fe_f2; } @@ -106,8 +103,6 @@ fpu_sinh(struct fpemu *fe) struct fpn *r; int hyperb = 1; - fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ - if (ISNAN(fe-fe_f2)) return fe-fe_f2; if (ISINF(fe-fe_f2)) @@ -117,7 +112,6 @@ fpu_sinh(struct fpemu *fe) r = fpu_sincos_taylor(fe, s0, 2, hyperb); CPYFPN(fe-fe_f2, r); - fpu_upd_fpsr(fe, fe-fe_f2); return fe-fe_f2; } @@ -129,8 +123,6 @@ fpu_tanh(struct fpemu *fe) struct fpn *r; int sign; - fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ - if (ISNAN(fe-fe_f2)) return fe-fe_f2; @@ -158,6 +150,5 @@ fpu_tanh(struct fpemu *fe) CPYFPN(fe-fe_f2, r); - fpu_upd_fpsr(fe, fe-fe_f2); return fe-fe_f2; } Index: src/sys/arch/m68k/fpe/fpu_trig.c diff -u src/sys/arch/m68k/fpe/fpu_trig.c:1.6 src/sys/arch/m68k/fpe/fpu_trig.c:1.7 --- src/sys/arch/m68k/fpe/fpu_trig.c:1.6 Sat Oct 15 15:14:30 2011 +++ src/sys/arch/m68k/fpe/fpu_trig.c Sat Mar 23 12:06:24 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_trig.c,v 1.6 2011/10/15 15:14:30 tsutsui Exp $ */ +/* $NetBSD: fpu_trig.c,v 1.7 2013/03/23 12:06:24 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.6 2011/10/15 15:14:30 tsutsui Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_trig.c,v 1.7 2013/03/23 12:06:24 isaki Exp $); #include fpu_emulate.h @@ -239,8 +239,6 @@ fpu_cos(struct fpemu *fe) struct fpn *r; int sign; - fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ - if (ISNAN(fe-fe_f2)) return fe-fe_f2; if (ISINF(fe-fe_f2)) @@ -319,7 +317,6 @@ fpu_cos(struct fpemu *fe) CPYFPN(fe-fe_f2, r); fe-fe_f2.fp_sign = sign; - fpu_upd_fpsr(fe, fe-fe_f2); return fe-fe_f2; } @@ -354,8 +351,6 @@ fpu_sin(struct fpemu *fe) struct fpn *r; int sign; - fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ - if (ISNAN(fe-fe_f2)) return fe-fe_f2; if (ISINF(fe-fe_f2)) @@ -433,7 +428,6 @@ fpu_sin(struct fpemu *fe) CPYFPN(fe-fe_f2, r); fe-fe_f2.fp_sign = sign; - fpu_upd_fpsr(fe, fe-fe_f2); return fe-fe_f2; } @@ -447,8 +441,6 @@ fpu_tan(struct fpemu *fe) struct fpn s; struct fpn *r; - fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ - if (ISNAN(fe-fe_f2)) return fe-fe_f2; if (ISINF(fe-fe_f2)) @@ -471,7 +463,6 @@ fpu_tan(struct fpemu *fe) CPYFPN(fe-fe_f2, r); - fpu_upd_fpsr(fe, fe-fe_f2); return fe-fe_f2; } @@ -490,6 +481,5 @@ fpu_sincos(struct fpemu *fe, int regc) /* sin(x) */ CPYFPN(fe-fe_f2, x); r = fpu_sin(fe); - fpu_upd_fpsr(fe, r); return r; }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Sat Mar 23 12:08:47 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_fmovecr.c Log Message: Use the #error directive. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_fmovecr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_fmovecr.c diff -u src/sys/arch/m68k/fpe/fpu_fmovecr.c:1.14 src/sys/arch/m68k/fpe/fpu_fmovecr.c:1.15 --- src/sys/arch/m68k/fpe/fpu_fmovecr.c:1.14 Mon Jul 18 14:11:27 2011 +++ src/sys/arch/m68k/fpe/fpu_fmovecr.c Sat Mar 23 12:08:47 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_fmovecr.c,v 1.14 2011/07/18 14:11:27 isaki Exp $ */ +/* $NetBSD: fpu_fmovecr.c,v 1.15 2013/03/23 12:08:47 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_fmovecr.c,v 1.14 2011/07/18 14:11:27 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_fmovecr.c,v 1.15 2013/03/23 12:08:47 isaki Exp $); #include sys/param.h #include sys/systm.h @@ -42,7 +42,7 @@ __KERNEL_RCSID(0, $NetBSD: fpu_fmovecr. /* XXX: quick consistency check */ #if (FP_1 != 0x4) -Error you have to change this table when changing the mantissa size +#error you have to change this table when changing the mantissa size #endif static struct fpn constrom[] = {
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Fri Mar 22 13:46:38 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_implode.c Log Message: Fix fpu_ftox(). Update not only exponential but also mantissa when an integer part becomes 2 by rounding up. Without this fix, the extended precision value becomes 0.0 because mantissa (including explicit integer bit) is all-zero. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/m68k/fpe/fpu_implode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_implode.c diff -u src/sys/arch/m68k/fpe/fpu_implode.c:1.13 src/sys/arch/m68k/fpe/fpu_implode.c:1.14 --- src/sys/arch/m68k/fpe/fpu_implode.c:1.13 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_implode.c Fri Mar 22 13:46:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_implode.c,v 1.13 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_implode.c,v 1.14 2013/03/22 13:46:38 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -46,7 +46,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_implode.c,v 1.13 2013/03/19 09:17:17 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_implode.c,v 1.14 2013/03/22 13:46:38 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -433,8 +433,10 @@ fpu_ftox(struct fpemu *fe, struct fpn *f #if (FP_NMANT - FP_NG - EXT_FRACBITS) 0 (void) fpu_shr(fp, FP_NMANT - FP_NG - EXT_FRACBITS); #endif - if (fpu_round(fe, fp) fp-fp_mant[0] == EXT_EXPLICIT2) + if (fpu_round(fe, fp) fp-fp_mant[0] == EXT_EXPLICIT2) { exp++; + fpu_shr(fp, 1); + } if (exp = EXT_EXP_INFNAN) { fe-fe_fpsr |= FPSR_OPERR | FPSR_INEX2 | FPSR_OVFL; if (toinf(fe, sign)) {
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Tue Mar 19 09:17:17 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_add.c fpu_arith.h fpu_div.c fpu_emulate.h fpu_explode.c fpu_implode.c fpu_int.c fpu_mul.c fpu_sqrt.c fpu_subr.c Log Message: Remove 'register'. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/fpe/fpu_add.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/fpe/fpu_arith.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/m68k/fpe/fpu_div.c \ src/sys/arch/m68k/fpe/fpu_mul.c src/sys/arch/m68k/fpe/fpu_sqrt.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/m68k/fpe/fpu_emulate.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/m68k/fpe/fpu_explode.c \ src/sys/arch/m68k/fpe/fpu_int.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/m68k/fpe/fpu_implode.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/fpe/fpu_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_add.c diff -u src/sys/arch/m68k/fpe/fpu_add.c:1.7 src/sys/arch/m68k/fpe/fpu_add.c:1.8 --- src/sys/arch/m68k/fpe/fpu_add.c:1.7 Sat Mar 14 15:36:09 2009 +++ src/sys/arch/m68k/fpe/fpu_add.c Tue Mar 19 09:17:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_add.c,v 1.7 2009/03/14 15:36:09 dsl Exp $ */ +/* $NetBSD: fpu_add.c,v 1.8 2013/03/19 09:17:17 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -47,7 +47,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_add.c,v 1.7 2009/03/14 15:36:09 dsl Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_add.c,v 1.8 2013/03/19 09:17:17 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -58,11 +58,11 @@ __KERNEL_RCSID(0, $NetBSD: fpu_add.c,v #include fpu_emulate.h struct fpn * -fpu_add(register struct fpemu *fe) +fpu_add(struct fpemu *fe) { - register struct fpn *x = fe-fe_f1, *y = fe-fe_f2, *r; - register u_int r0, r1, r2; - register int rd; + struct fpn *x = fe-fe_f1, *y = fe-fe_f2, *r; + u_int r0, r1, r2; + int rd; /* * Put the `heavier' operand on the right (see fpu_emu.h). Index: src/sys/arch/m68k/fpe/fpu_arith.h diff -u src/sys/arch/m68k/fpe/fpu_arith.h:1.5 src/sys/arch/m68k/fpe/fpu_arith.h:1.6 --- src/sys/arch/m68k/fpe/fpu_arith.h:1.5 Sat Dec 24 22:45:35 2005 +++ src/sys/arch/m68k/fpe/fpu_arith.h Tue Mar 19 09:17:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_arith.h,v 1.5 2005/12/24 22:45:35 perry Exp $ */ +/* $NetBSD: fpu_arith.h,v 1.6 2013/03/19 09:17:17 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -110,7 +110,7 @@ #else /* set up for extended-precision arithemtic */ -#define FPU_DECL_CARRY register int fpu_tmp; +#define FPU_DECL_CARRY int fpu_tmp; /* * We have three kinds of add: Index: src/sys/arch/m68k/fpe/fpu_div.c diff -u src/sys/arch/m68k/fpe/fpu_div.c:1.6 src/sys/arch/m68k/fpe/fpu_div.c:1.7 --- src/sys/arch/m68k/fpe/fpu_div.c:1.6 Sat Mar 14 15:36:09 2009 +++ src/sys/arch/m68k/fpe/fpu_div.c Tue Mar 19 09:17:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_div.c,v 1.6 2009/03/14 15:36:09 dsl Exp $ */ +/* $NetBSD: fpu_div.c,v 1.7 2013/03/19 09:17:17 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.6 2009/03/14 15:36:09 dsl Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_div.c,v 1.7 2013/03/19 09:17:17 isaki Exp $); #include sys/types.h @@ -150,11 +150,11 @@ __KERNEL_RCSID(0, $NetBSD: fpu_div.c,v */ struct fpn * -fpu_div(register struct fpemu *fe) +fpu_div(struct fpemu *fe) { - register struct fpn *x = fe-fe_f1, *y = fe-fe_f2; - register u_int q, bit; - register u_int r0, r1, r2, d0, d1, d2, y0, y1, y2; + struct fpn *x = fe-fe_f1, *y = fe-fe_f2; + u_int q, bit; + u_int r0, r1, r2, d0, d1, d2, y0, y1, y2; FPU_DECL_CARRY fe-fe_fpsr = ~FPSR_EXCP; /* clear all exceptions */ Index: src/sys/arch/m68k/fpe/fpu_mul.c diff -u src/sys/arch/m68k/fpe/fpu_mul.c:1.6 src/sys/arch/m68k/fpe/fpu_mul.c:1.7 --- src/sys/arch/m68k/fpe/fpu_mul.c:1.6 Sat Mar 14 15:36:09 2009 +++ src/sys/arch/m68k/fpe/fpu_mul.c Tue Mar 19 09:17:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_mul.c,v 1.6 2009/03/14 15:36:09 dsl Exp $ */ +/* $NetBSD: fpu_mul.c,v 1.7 2013/03/19 09:17:17 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_mul.c,v 1.6 2009/03/14 15:36:09 dsl Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_mul.c,v 1.7 2013/03/19 09:17:17 isaki Exp $); #include sys/types.h @@ -77,8 +77,6 @@ __KERNEL_RCSID(0, $NetBSD: fpu_mul.c,v * * Since we do not have efficient multiword arithmetic, we code the * accumulator as four separate words, just like any other mantissa. - * We use local `register' variables in the hope that this is faster - * than memory. We keep x-fp_mant in locals for the same reason. * * In the algorithm above, the bits in y are inspected one at a time. * We will pick them up 32 at a time and then deal with those 32, one @@ -99,11 +97,11 @@
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Tue Mar 19 09:28:40 UTC 2013 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.h fpu_explode.c Log Message: const-ify. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/m68k/fpe/fpu_emulate.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/m68k/fpe/fpu_explode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.h diff -u src/sys/arch/m68k/fpe/fpu_emulate.h:1.20 src/sys/arch/m68k/fpe/fpu_emulate.h:1.21 --- src/sys/arch/m68k/fpe/fpu_emulate.h:1.20 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_emulate.h Tue Mar 19 09:28:39 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.h,v 1.20 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_emulate.h,v 1.21 2013/03/19 09:28:39 isaki Exp $ */ /* * Copyright (c) 1995 Gordon Ross @@ -227,7 +227,7 @@ int fpu_shr(struct fpn *, int); int fpu_round(struct fpemu *, struct fpn *); /* type conversion */ -void fpu_explode(struct fpemu *, struct fpn *, int t, u_int *); +void fpu_explode(struct fpemu *, struct fpn *, int t, const u_int *); void fpu_implode(struct fpemu *, struct fpn *, int t, u_int *); /* Index: src/sys/arch/m68k/fpe/fpu_explode.c diff -u src/sys/arch/m68k/fpe/fpu_explode.c:1.12 src/sys/arch/m68k/fpe/fpu_explode.c:1.13 --- src/sys/arch/m68k/fpe/fpu_explode.c:1.12 Tue Mar 19 09:17:17 2013 +++ src/sys/arch/m68k/fpe/fpu_explode.c Tue Mar 19 09:28:39 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_explode.c,v 1.12 2013/03/19 09:17:17 isaki Exp $ */ +/* $NetBSD: fpu_explode.c,v 1.13 2013/03/19 09:28:39 isaki Exp $ */ /* * Copyright (c) 1992, 1993 @@ -46,7 +46,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_explode.c,v 1.12 2013/03/19 09:17:17 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_explode.c,v 1.13 2013/03/19 09:28:39 isaki Exp $); #include sys/types.h #include sys/systm.h @@ -222,7 +222,7 @@ fpu_xtof(struct fpn *fp, u_int i, u_int * Explode the contents of a memory operand. */ void -fpu_explode(struct fpemu *fe, struct fpn *fp, int type, u_int *space) +fpu_explode(struct fpemu *fe, struct fpn *fp, int type, const u_int *space) { u_int s;
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Mon Jun 25 04:52:23 UTC 2012 Modified Files: src/sys/arch/m68k/fpe: fpu_int.c Log Message: Rewrite fpu_int(). Especially, remove the special treatment when |x| 1 because it forgets to consider FPCR round mode. See PR/46627 for the detail. Thanks Y.Sugahara for advice. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/fpe/fpu_int.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_int.c diff -u src/sys/arch/m68k/fpe/fpu_int.c:1.10 src/sys/arch/m68k/fpe/fpu_int.c:1.11 --- src/sys/arch/m68k/fpe/fpu_int.c:1.10 Mon Jul 18 14:11:27 2011 +++ src/sys/arch/m68k/fpe/fpu_int.c Mon Jun 25 04:52:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_int.c,v 1.10 2011/07/18 14:11:27 isaki Exp $ */ +/* $NetBSD: fpu_int.c,v 1.11 2012/06/25 04:52:23 isaki Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_int.c,v 1.10 2011/07/18 14:11:27 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_int.c,v 1.11 2012/06/25 04:52:23 isaki Exp $); #include sys/types.h @@ -78,50 +78,28 @@ struct fpn * fpu_int(struct fpemu *fe) { register struct fpn *x = fe-fe_f2; - register int rsh, lsh, wsh, i; + register int rsh; /* special cases first */ if (x-fp_class != FPC_NUM) { return x; } - /* - * even if we have exponent == -1, we still have possiblity - * that the result = 1.0 when mantissa ~= 1.0 and rounded up - */ - if (x-fp_exp -1) { - x-fp_class = FPC_ZERO; - x-fp_mant[0] = x-fp_mant[1] = x-fp_mant[2] = 0; - return x; - } - /* real work */ rsh = FP_NMANT - 1 - x-fp_exp; - if (rsh - FP_NG = 0) { + if (rsh = FP_NG) { return x; } - fpu_shr(x, rsh - FP_NG); /* shift to the right */ + /* shift to the right */ + x-fp_exp = 0; + fpu_shr(x, rsh - FP_NG); - if (fpu_round(fe, x) == 1 /* rounded up */ - x-fp_mant[2 - (FP_NMANT-rsh)/32] (1 ((FP_NMANT-rsh)%32)) - /* x = 2.0 */) { - rsh--; /* reduce shift count by 1 */ - x-fp_exp++; /* adjust exponent */ - } + /* round according to FPCR round mode */ + fpu_round(fe, x); /* shift it back to the left */ - wsh = rsh / 32; - lsh = rsh % 32; - rsh = 32 - lsh; - for (i = 0; i + wsh 2; i++) { - x-fp_mant[i] = (x-fp_mant[i+wsh] lsh) | - (x-fp_mant[i+wsh+1] rsh); - } - x-fp_mant[i] = (x-fp_mant[i+wsh] lsh); - i++; - for (; i 3; i++) { - x-fp_mant[i] = 0; - } + x-fp_exp = FP_NMANT - 1; + fpu_norm(x); return x; }
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Sat Oct 15 15:14:30 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.c fpu_emulate.h fpu_hyperb.c fpu_trig.c Log Message: Add hyperboric and trigonometric functions to m68k FPE, written by isaki@. With these emulations (~4KB text) xeyes on XM6i works better. Discussed with isaki@ at OSC 2011 Hiroshima. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/arch/m68k/fpe/fpu_emulate.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/m68k/fpe/fpu_emulate.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/fpe/fpu_hyperb.c \ src/sys/arch/m68k/fpe/fpu_trig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.c diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.35 src/sys/arch/m68k/fpe/fpu_emulate.c:1.36 --- src/sys/arch/m68k/fpe/fpu_emulate.c:1.35 Mon Jul 18 14:11:27 2011 +++ src/sys/arch/m68k/fpe/fpu_emulate.c Sat Oct 15 15:14:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.c,v 1.35 2011/07/18 14:11:27 isaki Exp $ */ +/* $NetBSD: fpu_emulate.c,v 1.36 2011/10/15 15:14:29 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.35 2011/07/18 14:11:27 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.36 2011/10/15 15:14:29 tsutsui Exp $); #include sys/param.h #include sys/types.h @@ -65,7 +65,6 @@ static int fpu_emul_arith(struct fpemu * static int fpu_emul_type1(struct fpemu *, struct instruction *); static int fpu_emul_brcc(struct fpemu *, struct instruction *); static int test_cc(struct fpemu *, int); -static struct fpn *fpu_cmp(struct fpemu *); #ifdef DEBUG_FPE #define DUMP_INSN(insn) \ @@ -494,7 +493,7 @@ fpu_emul_fmovm(struct fpemu *fe, struct return sig; } -static struct fpn * +struct fpn * fpu_cmp(struct fpemu *fe) { struct fpn *x = fe-fe_f1, *y = fe-fe_f2; Index: src/sys/arch/m68k/fpe/fpu_emulate.h diff -u src/sys/arch/m68k/fpe/fpu_emulate.h:1.17 src/sys/arch/m68k/fpe/fpu_emulate.h:1.18 --- src/sys/arch/m68k/fpe/fpu_emulate.h:1.17 Sun Oct 9 01:34:19 2011 +++ src/sys/arch/m68k/fpe/fpu_emulate.h Sat Oct 15 15:14:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.h,v 1.17 2011/10/09 01:34:19 tsutsui Exp $ */ +/* $NetBSD: fpu_emulate.h,v 1.18 2011/10/15 15:14:30 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon Ross @@ -244,6 +244,9 @@ int fpu_emul_fscale(struct fpemu *fe, st #include fpu_arith_proto.h int fpu_emulate(struct frame *frame, struct fpframe *fpf, ksiginfo_t *ksi); +struct fpn *fpu_cmp(struct fpemu *); + +struct fpn *fpu_sincos_taylor(struct fpemu *, struct fpn *, u_int, int); /* * helper functions Index: src/sys/arch/m68k/fpe/fpu_hyperb.c diff -u src/sys/arch/m68k/fpe/fpu_hyperb.c:1.5 src/sys/arch/m68k/fpe/fpu_hyperb.c:1.6 --- src/sys/arch/m68k/fpe/fpu_hyperb.c:1.5 Mon Jul 18 07:44:30 2011 +++ src/sys/arch/m68k/fpe/fpu_hyperb.c Sat Oct 15 15:14:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_hyperb.c,v 1.5 2011/07/18 07:44:30 isaki Exp $ */ +/* $NetBSD: fpu_hyperb.c,v 1.6 2011/10/15 15:14:30 tsutsui Exp $ */ /* * Copyright (c) 1995 Ken Nakata @@ -31,8 +31,33 @@ * @(#)fpu_hyperb.c 10/24/95 */ +/* + * Copyright (c) 2011 Tetsuya Isaki. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.5 2011/07/18 07:44:30 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_hyperb.c,v 1.6 2011/10/15 15:14:30 tsutsui Exp $); #include fpu_emulate.h @@ -52,20 +77,87 @@ fpu_atanh(struct fpemu *fe) struct fpn * fpu_cosh(struct fpemu *fe) { - /* stub */ + struct
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Sat Oct 15 15:24:28 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: README Log Message: Update implemented/unimplemented FP functions. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/m68k/fpe/README Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/README diff -u src/sys/arch/m68k/fpe/README:1.4 src/sys/arch/m68k/fpe/README:1.5 --- src/sys/arch/m68k/fpe/README:1.4 Sun Nov 5 04:23:00 1995 +++ src/sys/arch/m68k/fpe/README Sat Oct 15 15:24:28 2011 @@ -1,7 +1,7 @@ -* $NetBSD: README,v 1.4 1995/11/05 04:23:00 briggs Exp $ +* $NetBSD: README,v 1.5 2011/10/15 15:24:28 tsutsui Exp $ * NetBSD/m68k FPE (floating point emulation) README file * Created Oct/??/95 by k...@remus.rutgers.edu (Ken Nakata) -* Last updated Nov/04/95 by kenn +* Last updated Oct/15/2011 by tsutsui 1. INSTALLATION AND COMPILATION @@ -67,7 +67,8 @@ Type field = bit 8-6 of opcode word Type=0: FMOVE (mem-FPr), FINT, FINTRZ, FSQRT, FABS, FNEG, FGETEXP, FGETMAN, FDIV, FADD, FMUL, FSGLDIV(*), FSCALE, FSGLMUL(*), FSUB, FCMP, FTST, FMOVE (FPr-mem), FMOVEM (FPr), FMOVEM (FPcr), - FMOVECR, FLOGNP1, FLOGN, FLOG10, FLOG2, FMOD, FREM + FMOVECR, FLOGNP1, FLOGN, FLOG10, FLOG2, FMOD, FREM, + FCOSH, FSINH, FTANH, FCOS, FSIN, FTAN, FSINCOS Type=1: FDBcc, FScc, FTRAPcc, @@ -84,8 +85,7 @@ Type=5: none * Unimplemented Instructions -Type=0: FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN, - FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS +Type=0: FETOX, FETOXM1, FTENTOX, FTWOTOX, FATANH, FACOS, FASIN, FATAN Type=1: none
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Sat Oct 15 15:34:06 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.h Log Message: - remove variable names from function declarations - some KNF To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/m68k/fpe/fpu_emulate.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.h diff -u src/sys/arch/m68k/fpe/fpu_emulate.h:1.18 src/sys/arch/m68k/fpe/fpu_emulate.h:1.19 --- src/sys/arch/m68k/fpe/fpu_emulate.h:1.18 Sat Oct 15 15:14:30 2011 +++ src/sys/arch/m68k/fpe/fpu_emulate.h Sat Oct 15 15:34:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.h,v 1.18 2011/10/15 15:14:30 tsutsui Exp $ */ +/* $NetBSD: fpu_emulate.h,v 1.19 2011/10/15 15:34:06 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon Ross @@ -91,10 +91,10 @@ struct fpn { #define FP_1 (1 FP_LG) /* 1.0 in fp_mant[0] */ #define FP_2 (1 (FP_LG + 1)) /* 2.0 in fp_mant[0] */ -static inline void CPYFPN(struct fpn * dst, const struct fpn * src); +static inline void CPYFPN(struct fpn *, const struct fpn *); static inline void -CPYFPN(struct fpn * dst, const struct fpn * src) +CPYFPN(struct fpn *dst, const struct fpn *src) { if (dst != src) { @@ -213,37 +213,37 @@ struct instruction { */ /* Build a new Quiet NaN (sign=0, frac=all 1's). */ -struct fpn *fpu_newnan(struct fpemu *fe); +struct fpn *fpu_newnan(struct fpemu *); /* * Shift a number right some number of bits, taking care of round/sticky. * Note that the result is probably not a well-formed number (it will lack * the normal 1-bit mant[0]FP_1). */ -int fpu_shr(struct fpn * fp, int shr); +int fpu_shr(struct fpn *, int); /* * Round a number according to the round mode in FPCR */ -int fpu_round(register struct fpemu *fe, register struct fpn *fp); +int fpu_round(register struct fpemu *, register struct fpn *); /* type conversion */ -void fpu_explode(struct fpemu *fe, struct fpn *fp, int t, u_int *src); -void fpu_implode(struct fpemu *fe, struct fpn *fp, int t, u_int *dst); +void fpu_explode(struct fpemu *, struct fpn *, int t, u_int *); +void fpu_implode(struct fpemu *, struct fpn *, int t, u_int *); /* * non-static emulation functions */ /* type 0 */ -int fpu_emul_fmovecr(struct fpemu *fe, struct instruction *insn); -int fpu_emul_fstore(struct fpemu *fe, struct instruction *insn); -int fpu_emul_fscale(struct fpemu *fe, struct instruction *insn); +int fpu_emul_fmovecr(struct fpemu *, struct instruction *); +int fpu_emul_fstore(struct fpemu *, struct instruction *); +int fpu_emul_fscale(struct fpemu *, struct instruction *); /* * include function declarations of those which are called by fpu_emul_arith() */ #include fpu_arith_proto.h -int fpu_emulate(struct frame *frame, struct fpframe *fpf, ksiginfo_t *ksi); +int fpu_emulate(struct frame *, struct fpframe *, ksiginfo_t *); struct fpn *fpu_cmp(struct fpemu *); struct fpn *fpu_sincos_taylor(struct fpemu *, struct fpn *, u_int, int); @@ -252,21 +252,21 @@ struct fpn *fpu_sincos_taylor(struct fpe * helper functions */ /* return values from constant rom */ -struct fpn *fpu_const(struct fpn *fp, u_int offset); +struct fpn *fpu_const(struct fpn *, u_int); /* update exceptions and FPSR */ -int fpu_upd_excp(struct fpemu *fe); -u_int fpu_upd_fpsr(struct fpemu *fe, struct fpn *fp); +int fpu_upd_excp(struct fpemu *); +u_int fpu_upd_fpsr(struct fpemu *, struct fpn *); /* address mode decoder, and load/store */ -int fpu_decode_ea(struct frame *frame, struct instruction *insn, - struct insn_ea *ea, int modreg); -int fpu_load_ea(struct frame *frame, struct instruction *insn, - struct insn_ea *ea, char *dst); -int fpu_store_ea(struct frame *frame, struct instruction *insn, - struct insn_ea *ea, char *src); +int fpu_decode_ea(struct frame *, struct instruction *, + struct insn_ea *, int); +int fpu_load_ea(struct frame *, struct instruction *, + struct insn_ea *, char *); +int fpu_store_ea(struct frame *, struct instruction *, + struct insn_ea *, char *); /* fpu_subr.c */ -void fpu_norm(register struct fpn *fp); +void fpu_norm(register struct fpn *); #if !defined(FPE_DEBUG) # define FPE_DEBUG 0
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Sun Oct 9 01:34:20 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.h Log Message: Use static inline structure assignment for CPYFPN(). From isaki@. Tested on XM6i. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/m68k/fpe/fpu_emulate.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.h diff -u src/sys/arch/m68k/fpe/fpu_emulate.h:1.16 src/sys/arch/m68k/fpe/fpu_emulate.h:1.17 --- src/sys/arch/m68k/fpe/fpu_emulate.h:1.16 Mon Jul 18 07:44:30 2011 +++ src/sys/arch/m68k/fpe/fpu_emulate.h Sun Oct 9 01:34:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.h,v 1.16 2011/07/18 07:44:30 isaki Exp $ */ +/* $NetBSD: fpu_emulate.h,v 1.17 2011/10/09 01:34:19 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon Ross @@ -91,15 +91,15 @@ struct fpn { #define FP_1 (1 FP_LG) /* 1.0 in fp_mant[0] */ #define FP_2 (1 (FP_LG + 1)) /* 2.0 in fp_mant[0] */ -#define CPYFPN(dst, src) \ -if ((dst) != (src)) { \ - (dst)-fp_class = (src)-fp_class;\ - (dst)-fp_sign = (src)-fp_sign;\ - (dst)-fp_exp = (src)-fp_exp; \ - (dst)-fp_sticky = (src)-fp_sticky;\ - (dst)-fp_mant[0] = (src)-fp_mant[0];\ - (dst)-fp_mant[1] = (src)-fp_mant[1];\ - (dst)-fp_mant[2] = (src)-fp_mant[2];\ +static inline void CPYFPN(struct fpn * dst, const struct fpn * src); + +static inline void +CPYFPN(struct fpn * dst, const struct fpn * src) +{ + + if (dst != src) { + *dst = *src; + } } /*
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: isaki Date: Mon Jul 18 14:11:27 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_calcea.c fpu_emulate.c fpu_fmovecr.c fpu_fscale.c fpu_fstore.c fpu_int.c fpu_log.c fpu_rem.c Log Message: fix indent again. - Second level indents are four spaces. pointed out by tsutsui@ - fold long line. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/m68k/fpe/fpu_calcea.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/m68k/fpe/fpu_emulate.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/m68k/fpe/fpu_fmovecr.c \ src/sys/arch/m68k/fpe/fpu_log.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_fscale.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/m68k/fpe/fpu_fstore.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/fpe/fpu_int.c cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/fpe/fpu_rem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_calcea.c diff -u src/sys/arch/m68k/fpe/fpu_calcea.c:1.25 src/sys/arch/m68k/fpe/fpu_calcea.c:1.26 --- src/sys/arch/m68k/fpe/fpu_calcea.c:1.25 Mon Jul 18 07:44:30 2011 +++ src/sys/arch/m68k/fpe/fpu_calcea.c Mon Jul 18 14:11:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_calcea.c,v 1.25 2011/07/18 07:44:30 isaki Exp $ */ +/* $NetBSD: fpu_calcea.c,v 1.26 2011/07/18 14:11:27 isaki Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -34,7 +34,7 @@ #include opt_m68k_arch.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_calcea.c,v 1.25 2011/07/18 07:44:30 isaki Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_calcea.c,v 1.26 2011/07/18 14:11:27 isaki Exp $); #include sys/param.h #include sys/signal.h @@ -88,13 +88,13 @@ ea-ea_regnum = modreg 0xf; ea-ea_flags = EA_DIRECT; DPRINTF((%s: register direct reg=%d\n, - __func__, ea-ea_regnum)); + __func__, ea-ea_regnum)); } else if ((modreg 077) == 074) { /* immediate */ ea-ea_flags = EA_IMMED; sig = fetch_immed(frame, insn, ea-ea_immed[0]); DPRINTF((%s: immediate size=%d\n, - __func__, insn-is_datasize)); + __func__, insn-is_datasize)); } /* * rest of the address modes need to be separately @@ -106,7 +106,7 @@ ea-ea_flags = EA_FRAME_EA; ea-ea_fea = frame-f_fmt4.f_fa; DPRINTF((%s: 68LC040 - in-frame EA (%p) size %d\n, - __func__, (void *)ea-ea_fea, insn-is_datasize)); + __func__, (void *)ea-ea_fea, insn-is_datasize)); if ((modreg 070) == 030) { /* postincrement mode */ ea-ea_flags |= EA_POSTINCR; @@ -130,26 +130,26 @@ case 020: /* (An) */ ea-ea_flags = 0; DPRINTF((%s: register indirect reg=%d\n, -__func__, ea-ea_regnum)); + __func__, ea-ea_regnum)); break; case 030: /* (An)+ */ ea-ea_flags = EA_POSTINCR; DPRINTF((%s: reg indirect postincrement reg=%d\n, -__func__, ea-ea_regnum)); + __func__, ea-ea_regnum)); break; case 040: /* -(An) */ ea-ea_flags = EA_PREDECR; DPRINTF((%s: reg indirect predecrement reg=%d\n, -__func__, ea-ea_regnum)); + __func__, ea-ea_regnum)); break; case 050: /* (d16,An) */ ea-ea_flags = EA_OFFSET; sig = fetch_disp(frame, insn, 1, ea-ea_offset); DPRINTF((%s: reg indirect with displacement reg=%d\n, -__func__, ea-ea_regnum)); + __func__, ea-ea_regnum)); break; case 060: /* (d8,An,Xn) */ @@ -164,25 +164,25 @@ case 0: /* ().W */ ea-ea_flags = EA_ABS; sig = fetch_disp(frame, insn, 1, - ea-ea_absaddr); +ea-ea_absaddr); DPRINTF((%s: absolute address (word)\n, - __func__)); +__func__)); break; case 1: /* ().L */ ea-ea_flags = EA_ABS; sig = fetch_disp(frame, insn, 2, - ea-ea_absaddr); +ea-ea_absaddr); DPRINTF((%s: absolute address (long)\n, - __func__)); +__func__)); break; case 2: /* (d16,PC) */ ea-ea_flags = EA_PC_REL | EA_OFFSET; sig = fetch_disp(frame, insn, 1, - ea-ea_absaddr); +ea-ea_absaddr); DPRINTF((%s: pc relative word displacement\n, - __func__)); +__func__)); break; case 3: /* (d8,PC,Xn) */ @@ -194,7 +194,7 @@ /* it should have been taken care of earlier */ default: DPRINTF((%s: invalid addr mode (7,%d)\n, - __func__, modreg 7)); +__func__, modreg 7)); return SIGILL; } break; @@ -246,7 +246,7 @@ ea-ea_basedisp = idx + basedisp; ea-ea_outerdisp = 0; DPRINTF((%s: brief ext word idxreg=%d, basedisp=%08x\n, - __func__, ea-ea_idxreg, ea-ea_basedisp)); + __func__, ea-ea_idxreg, ea-ea_basedisp)); } else { /* full extension word */ if (extword 0x80) { @@ -278,16 +278,16 @@ break; default: DPRINTF((%s: invalid indirect mode: ext word %04x\n, -__func__, extword)); + __func__, extword)); return SIGILL; break; } DPRINTF((%s: full ext idxreg=%d, basedisp=%x, outerdisp=%x\n, - __func__,
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Wed May 25 15:17:21 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_calcea.c Log Message: KNF. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/m68k/fpe/fpu_calcea.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_calcea.c diff -u src/sys/arch/m68k/fpe/fpu_calcea.c:1.22 src/sys/arch/m68k/fpe/fpu_calcea.c:1.23 --- src/sys/arch/m68k/fpe/fpu_calcea.c:1.22 Sun Jun 6 04:50:07 2010 +++ src/sys/arch/m68k/fpe/fpu_calcea.c Wed May 25 15:17:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_calcea.c,v 1.22 2010/06/06 04:50:07 mrg Exp $ */ +/* $NetBSD: fpu_calcea.c,v 1.23 2011/05/25 15:17:21 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -34,7 +34,7 @@ #include opt_m68k_arch.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_calcea.c,v 1.22 2010/06/06 04:50:07 mrg Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_calcea.c,v 1.23 2011/05/25 15:17:21 tsutsui Exp $); #include sys/param.h #include sys/signal.h @@ -47,13 +47,11 @@ /* * Prototypes of static functions */ -static int decode_ea6(struct frame *frame, struct instruction *insn, - struct insn_ea *ea, int modreg); -static int fetch_immed(struct frame *frame, struct instruction *insn, - int *dst); -static int fetch_disp(struct frame *frame, struct instruction *insn, - int size, int *res); -static int calc_ea(struct insn_ea *ea, char *ptr, char **eaddr); +static int decode_ea6(struct frame *, struct instruction *, + struct insn_ea *, int); +static int fetch_immed(struct frame *, struct instruction *, int *); +static int fetch_disp(struct frame *, struct instruction *, int, int *); +static int calc_ea(struct insn_ea *, char *, char **); /* * Helper routines for dealing with effective address values. @@ -64,248 +62,253 @@ * Returns zero on success, else signal number. */ int -fpu_decode_ea(struct frame *frame, struct instruction *insn, struct insn_ea *ea, int modreg) +fpu_decode_ea(struct frame *frame, struct instruction *insn, +struct insn_ea *ea, int modreg) { -int sig; + int sig; #ifdef DEBUG -if (insn-is_datasize 0) { - panic(decode_ea: called with uninitialized datasize); -} + if (insn-is_datasize 0) + panic(decode_ea: called with uninitialized datasize); #endif -sig = 0; + sig = 0; -/* Set the most common value here. */ -ea-ea_regnum = 8 + (modreg 7); + /* Set the most common value here. */ + ea-ea_regnum = 8 + (modreg 7); -if ((modreg 060) == 0) { - /* register direct */ - ea-ea_regnum = modreg 0xf; - ea-ea_flags = EA_DIRECT; + if ((modreg 060) == 0) { + /* register direct */ + ea-ea_regnum = modreg 0xf; + ea-ea_flags = EA_DIRECT; #ifdef DEBUG_FPE - printf(decode_ea: register direct reg=%d\n, ea-ea_regnum); + printf(decode_ea: register direct reg=%d\n, ea-ea_regnum); #endif -} else if ((modreg 077) == 074) { - /* immediate */ - ea-ea_flags = EA_IMMED; - sig = fetch_immed(frame, insn, ea-ea_immed[0]); + } else if ((modreg 077) == 074) { + /* immediate */ + ea-ea_flags = EA_IMMED; + sig = fetch_immed(frame, insn, ea-ea_immed[0]); #ifdef DEBUG_FPE - printf(decode_ea: immediate size=%d\n, insn-is_datasize); + printf(decode_ea: immediate size=%d\n, insn-is_datasize); #endif -} -/* - * rest of the address modes need to be separately - * handled for the LC040 and the others. - */ + } + /* + * rest of the address modes need to be separately + * handled for the LC040 and the others. + */ #if 0 /* XXX */ -else if (frame-f_format == 4 frame-f_fmt4.f_fa) { - /* LC040 */ - ea-ea_flags = EA_FRAME_EA; - ea-ea_fea = frame-f_fmt4.f_fa; -#ifdef DEBUG_FPE - printf(decode_ea: 68LC040 - in-frame EA (%p) size %d\n, - (void *)ea-ea_fea, insn-is_datasize); -#endif - if ((modreg 070) == 030) { - /* postincrement mode */ - ea-ea_flags |= EA_POSTINCR; - } else if ((modreg 070) == 040) { - /* predecrement mode */ - ea-ea_flags |= EA_PREDECR; + else if (frame-f_format == 4 frame-f_fmt4.f_fa) { + /* LC040 */ + ea-ea_flags = EA_FRAME_EA; + ea-ea_fea = frame-f_fmt4.f_fa; +#ifdef DEBUG_FPE + printf(decode_ea: 68LC040 - in-frame EA (%p) size %d\n, + (void *)ea-ea_fea, insn-is_datasize); +#endif + if ((modreg 070) == 030) { + /* postincrement mode */ + ea-ea_flags |= EA_POSTINCR; + } else if ((modreg 070) == 040) { + /* predecrement mode */ + ea-ea_flags |= EA_PREDECR; #ifdef M68060 #if defined(M68020) || defined(M68030) || defined(M68040) - if (cputype == CPU_68060) + if (cputype == CPU_68060) #endif - if (insn-is_datasize == 12) - ea-ea_fea -= 8; +if (insn-is_datasize == 12) + ea-ea_fea -= 8; #endif + } } -} #endif /* XXX */ -else { - /* 020/030 */ - switch (modreg 070) { + else { + /* 020/030 */ + switch (modreg 070) { - case 020: /*
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Wed May 25 15:47:19 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_calcea.c Log Message: - consistently use #ifdef DEBUG_FPE and #ifdef DIAGNOSTIC - use DPRINTF() style debug printfs - use __func__ to print function names To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/m68k/fpe/fpu_calcea.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_calcea.c diff -u src/sys/arch/m68k/fpe/fpu_calcea.c:1.23 src/sys/arch/m68k/fpe/fpu_calcea.c:1.24 --- src/sys/arch/m68k/fpe/fpu_calcea.c:1.23 Wed May 25 15:17:21 2011 +++ src/sys/arch/m68k/fpe/fpu_calcea.c Wed May 25 15:47:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_calcea.c,v 1.23 2011/05/25 15:17:21 tsutsui Exp $ */ +/* $NetBSD: fpu_calcea.c,v 1.24 2011/05/25 15:47:19 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -34,7 +34,7 @@ #include opt_m68k_arch.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_calcea.c,v 1.23 2011/05/25 15:17:21 tsutsui Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_calcea.c,v 1.24 2011/05/25 15:47:19 tsutsui Exp $); #include sys/param.h #include sys/signal.h @@ -44,6 +44,12 @@ #include fpu_emulate.h +#ifdef DEBUG_FPE +#define DPRINTF(x) printf x +#else +#define DPRINTF(x) do {} while (/* CONSTCOND */ 0) +#endif + /* * Prototypes of static functions */ @@ -67,9 +73,9 @@ { int sig; -#ifdef DEBUG +#ifdef DIAGNOSTIC if (insn-is_datasize 0) - panic(decode_ea: called with uninitialized datasize); + panic(%s: called with uninitialized datasize, __func__); #endif sig = 0; @@ -81,16 +87,14 @@ /* register direct */ ea-ea_regnum = modreg 0xf; ea-ea_flags = EA_DIRECT; -#ifdef DEBUG_FPE - printf(decode_ea: register direct reg=%d\n, ea-ea_regnum); -#endif + DPRINTF((%s: register direct reg=%d\n, + __func__, ea-ea_regnum)); } else if ((modreg 077) == 074) { /* immediate */ ea-ea_flags = EA_IMMED; sig = fetch_immed(frame, insn, ea-ea_immed[0]); -#ifdef DEBUG_FPE - printf(decode_ea: immediate size=%d\n, insn-is_datasize); -#endif + DPRINTF((%s: immediate size=%d\n, + __func__, insn-is_datasize)); } /* * rest of the address modes need to be separately @@ -101,10 +105,8 @@ /* LC040 */ ea-ea_flags = EA_FRAME_EA; ea-ea_fea = frame-f_fmt4.f_fa; -#ifdef DEBUG_FPE - printf(decode_ea: 68LC040 - in-frame EA (%p) size %d\n, - (void *)ea-ea_fea, insn-is_datasize); -#endif + DPRINTF((%s: 68LC040 - in-frame EA (%p) size %d\n, + __func__, (void *)ea-ea_fea, insn-is_datasize)); if ((modreg 070) == 030) { /* postincrement mode */ ea-ea_flags |= EA_POSTINCR; @@ -127,35 +129,27 @@ case 020: /* (An) */ ea-ea_flags = 0; -#ifdef DEBUG_FPE - printf(decode_ea: register indirect reg=%d\n, - ea-ea_regnum); -#endif + DPRINTF((%s: register indirect reg=%d\n, + __func__, ea-ea_regnum)); break; case 030: /* (An)+ */ ea-ea_flags = EA_POSTINCR; -#ifdef DEBUG_FPE - printf(decode_ea: reg indirect postincrement reg=%d\n, - ea-ea_regnum); -#endif + DPRINTF((%s: reg indirect postincrement reg=%d\n, + __func__, ea-ea_regnum)); break; case 040: /* -(An) */ ea-ea_flags = EA_PREDECR; -#ifdef DEBUG_FPE - printf(decode_ea: reg indirect predecrement reg=%d\n, - ea-ea_regnum); -#endif + DPRINTF((%s: reg indirect predecrement reg=%d\n, + __func__, ea-ea_regnum)); break; case 050: /* (d16,An) */ ea-ea_flags = EA_OFFSET; sig = fetch_disp(frame, insn, 1, ea-ea_offset); -#ifdef DEBUG_FPE - printf(decode_ea: reg indirect with displacement - reg=%d\n, ea-ea_regnum); -#endif + DPRINTF((%s: reg indirect with displacement reg=%d\n, + __func__, ea-ea_regnum)); break; case 060: /* (d8,An,Xn) */ @@ -171,28 +165,24 @@ ea-ea_flags = EA_ABS; sig = fetch_disp(frame, insn, 1, ea-ea_absaddr); -#ifdef DEBUG_FPE -printf(decode_ea: absolute address (word)\n); -#endif +DPRINTF((%s: absolute address (word)\n, +__func__)); break; case 1: /* ().L */ ea-ea_flags = EA_ABS; sig = fetch_disp(frame, insn, 2, ea-ea_absaddr); -#ifdef DEBUG_FPE -printf(decode_ea: absolute address (long)\n); -#endif +DPRINTF((%s: absolute address (long)\n, +__func__)); break; case 2: /* (d16,PC) */ ea-ea_flags = EA_PC_REL | EA_OFFSET; sig = fetch_disp(frame, insn, 1, ea-ea_absaddr); -#ifdef DEBUG_FPE -printf(decode_ea: pc relative word -displacement\n); -#endif +DPRINTF((%s: pc relative word displacement\n, +__func__)); break; case 3: /* (d8,PC,Xn) */ @@ -203,10 +193,8 @@ case 4: /* #data */ /* it should have been taken care of earlier */ default: -#ifdef DEBUG_FPE -printf(decode_ea: invalid addr mode (7,%d)\n, -
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Mon May 23 14:52:31 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.c Log Message: KNF, mostly indent. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/m68k/fpe/fpu_emulate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.c diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.31 src/sys/arch/m68k/fpe/fpu_emulate.c:1.32 --- src/sys/arch/m68k/fpe/fpu_emulate.c:1.31 Sat May 14 16:17:55 2011 +++ src/sys/arch/m68k/fpe/fpu_emulate.c Mon May 23 14:52:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.c,v 1.31 2011/05/14 16:17:55 tsutsui Exp $ */ +/* $NetBSD: fpu_emulate.c,v 1.32 2011/05/23 14:52:31 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.31 2011/05/14 16:17:55 tsutsui Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.32 2011/05/23 14:52:31 tsutsui Exp $); #include sys/param.h #include sys/types.h @@ -51,29 +51,29 @@ #include fpu_emulate.h -#define fpe_abort(tfp, ksi, signo, code) \ -do { \ - (ksi)-ksi_signo = (signo); \ - (ksi)-ksi_code = (code); \ - (ksi)-ksi_addr = (void *)(frame)-f_pc; \ - return -1; \ -} while (/*CONSTCOND*/0) - -static int fpu_emul_fmovmcr(struct fpemu *fe, struct instruction *insn); -static int fpu_emul_fmovm(struct fpemu *fe, struct instruction *insn); -static int fpu_emul_arith(struct fpemu *fe, struct instruction *insn); -static int fpu_emul_type1(struct fpemu *fe, struct instruction *insn); -static int fpu_emul_brcc(struct fpemu *fe, struct instruction *insn); -static int test_cc(struct fpemu *fe, int pred); -static struct fpn *fpu_cmp(struct fpemu *fe); - -#if DEBUG_FPE -# define DUMP_INSN(insn) \ -printf(fpu_emulate: insn={adv=%d,siz=%d,op=%04x,w1=%04x}\n, \ - (insn)-is_advance, (insn)-is_datasize, \ - (insn)-is_opcode, (insn)-is_word1) +#define fpe_abort(tfp, ksi, signo, code) \ + do { \ + (ksi)-ksi_signo = (signo); \ + (ksi)-ksi_code = (code); \ + (ksi)-ksi_addr = (void *)(frame)-f_pc; \ + return -1; \ + } while (/* CONSTCOND */ 0) + +static int fpu_emul_fmovmcr(struct fpemu *, struct instruction *); +static int fpu_emul_fmovm(struct fpemu *, struct instruction *); +static int fpu_emul_arith(struct fpemu *, struct instruction *); +static int fpu_emul_type1(struct fpemu *, struct instruction *); +static int fpu_emul_brcc(struct fpemu *, struct instruction *); +static int test_cc(struct fpemu *, int); +static struct fpn *fpu_cmp(struct fpemu *); + +#if DEBUG_FPE +#define DUMP_INSN(insn) \ + printf(fpu_emulate: insn={adv=%d,siz=%d,op=%04x,w1=%04x}\n, \ + (insn)-is_advance, (insn)-is_datasize, \ + (insn)-is_opcode, (insn)-is_word1) #else -# define DUMP_INSN(insn) +#define DUMP_INSN(insn) #endif /* @@ -84,370 +84,378 @@ int fpu_emulate(struct frame *frame, struct fpframe *fpf, ksiginfo_t *ksi) { -static struct instruction insn; -static struct fpemu fe; -int word, optype, sig; - - -/* initialize insn.is_datasize to tell it is *not* initialized */ -insn.is_datasize = -1; - -fe.fe_frame = frame; -fe.fe_fpframe = fpf; -fe.fe_fpsr = fpf-fpf_fpsr; -fe.fe_fpcr = fpf-fpf_fpcr; - -#if DEBUG_FPE -printf(ENTERING fpu_emulate: FPSR=%08x, FPCR=%08x\n, - fe.fe_fpsr, fe.fe_fpcr); + static struct instruction insn; + static struct fpemu fe; + int word, optype, sig; + + + /* initialize insn.is_datasize to tell it is *not* initialized */ + insn.is_datasize = -1; + + fe.fe_frame = frame; + fe.fe_fpframe = fpf; + fe.fe_fpsr = fpf-fpf_fpsr; + fe.fe_fpcr = fpf-fpf_fpcr; + +#if DEBUG_FPE + printf(ENTERING fpu_emulate: FPSR=%08x, FPCR=%08x\n, + fe.fe_fpsr, fe.fe_fpcr); +#endif + + /* always set this (to avoid a warning) */ + insn.is_pc = frame-f_pc; + insn.is_nextpc = 0; + if (frame-f_format == 4) { + /* + * A format 4 is generated by the 68{EC,LC}040. The PC is + * already set to the instruction following the faulting + * instruction. We need to calculate that, anyway. The + * fslw is the PC of the faulted instruction, which is what + * we expect to be in f_pc. + * + * XXX - This is a hack; it assumes we at least know the + * sizes of all instructions we run across. + * XXX TODO: This may not be true, so we might want to save + * the PC in order to restore it later. + */ +#if 0 + insn.is_nextpc = frame-f_pc; #endif + insn.is_pc = frame-f_fmt4.f_fslw; + frame-f_pc = insn.is_pc; + } -/* always set this (to avoid a warning) */ -insn.is_pc = frame-f_pc; -insn.is_nextpc = 0; -if (frame-f_format == 4) { - /* - * A format 4 is generated by the 68{EC,LC}040. The PC is - * already set to the instruction following the faulting - * instruction. We need to
CVS commit: src/sys/arch/m68k/fpe
Module Name:src Committed By: tsutsui Date: Sat May 14 16:17:55 UTC 2011 Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.c Log Message: Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE. fpu_upd_fpsr() should be called even in discard_result case if an emulated instruction gets proper result without signal. Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and TME emulating sun3 without 68881. Should be pulled up to all netbsd-4 and netbsd-5 branches. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/arch/m68k/fpe/fpu_emulate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.c diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.30 src/sys/arch/m68k/fpe/fpu_emulate.c:1.31 --- src/sys/arch/m68k/fpe/fpu_emulate.c:1.30 Sat Mar 14 15:36:09 2009 +++ src/sys/arch/m68k/fpe/fpu_emulate.c Sat May 14 16:17:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.c,v 1.30 2009/03/14 15:36:09 dsl Exp $ */ +/* $NetBSD: fpu_emulate.c,v 1.31 2011/05/14 16:17:55 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.30 2009/03/14 15:36:09 dsl Exp $); +__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.31 2011/05/14 16:17:55 tsutsui Exp $); #include sys/param.h #include sys/types.h @@ -909,27 +909,34 @@ if (res == NULL) sig = SIGILL; -if (!discard_result sig == 0) { - fpu_implode(fe, res, FTYPE_EXT, fpregs[regnum * 3]); +if (sig == 0) { + if (!discard_result) + fpu_implode(fe, res, FTYPE_EXT, fpregs[regnum * 3]); /* update fpsr according to the result of operation */ fpu_upd_fpsr(fe, res); #if DEBUG_FPE - printf(fpu_emul_arith: %08x,%08x,%08x stored in FP%d\n, - fpregs[regnum*3], fpregs[regnum*3+1], - fpregs[regnum*3+2], regnum); -} else if (sig == 0) { - static const char *class_name[] = - { SNAN, QNAN, ZERO, NUM, INF }; - printf(fpu_emul_arith: result(%s,%c,%d,%08x,%08x,%08x) discarded\n, - class_name[res-fp_class + 2], - res-fp_sign ? '-' : '+', res-fp_exp, - res-fp_mant[0], res-fp_mant[1], - res-fp_mant[2]); -} else { - printf(fpu_emul_arith: received signal %d\n, sig); + if (!discard_result) { + printf(fpu_emul_arith: %08x,%08x,%08x stored in FP%d\n, + fpregs[regnum*3], fpregs[regnum*3+1], + fpregs[regnum*3+2], regnum); + } else { + static const char *class_name[] = + { SNAN, QNAN, ZERO, NUM, INF }; + printf(fpu_emul_arith: result(%s,%c,%d,%08x,%08x,%08x) + discarded\n, + class_name[res-fp_class + 2], + res-fp_sign ? '-' : '+', res-fp_exp, + res-fp_mant[0], res-fp_mant[1], + res-fp_mant[2]); + } #endif } +#if DEBUG_FPE +else { + printf(fpu_emul_arith: received signal %d\n, sig); +} +#endif #if DEBUG_FPE printf(fpu_emul_arith: FPSR = %08x, FPCR = %08x\n,