aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/math-emu/dp_add.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/math-emu/dp_add.c')
-rw-r--r--arch/mips/math-emu/dp_add.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/arch/mips/math-emu/dp_add.c b/arch/mips/math-emu/dp_add.c
index 48b9ef6f8a0d..9c98b96f7287 100644
--- a/arch/mips/math-emu/dp_add.c
+++ b/arch/mips/math-emu/dp_add.c
@@ -5,8 +5,6 @@
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * 7 *
8 * ########################################################################
9 *
10 * This program is free software; you can distribute it and/or modify it 8 * This program is free software; you can distribute it and/or modify it
11 * under the terms of the GNU General Public License (Version 2) as 9 * under the terms of the GNU General Public License (Version 2) as
12 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
@@ -18,17 +16,15 @@
18 * 16 *
19 * You should have received a copy of the GNU General Public License along 17 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc., 18 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * ########################################################################
24 *
25 */ 20 */
26 21
27
28#include "ieee754dp.h" 22#include "ieee754dp.h"
29 23
30union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y) 24union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
31{ 25{
26 int s;
27
32 COMPXDP; 28 COMPXDP;
33 COMPYDP; 29 COMPYDP;
34 30
@@ -69,9 +65,9 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
69 return x; 65 return x;
70 66
71 67
72 /* Infinity handling 68 /*
73 */ 69 * Infinity handling
74 70 */
75 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): 71 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
76 if (xs == ys) 72 if (xs == ys)
77 return x; 73 return x;
@@ -88,15 +84,14 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
88 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): 84 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM):
89 return x; 85 return x;
90 86
91 /* Zero handling 87 /*
92 */ 88 * Zero handling
93 89 */
94 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): 90 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
95 if (xs == ys) 91 if (xs == ys)
96 return x; 92 return x;
97 else 93 else
98 return ieee754dp_zero(ieee754_csr.rm == 94 return ieee754dp_zero(ieee754_csr.rm == IEEE754_RD);
99 IEEE754_RD);
100 95
101 case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO): 96 case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
102 case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): 97 case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
@@ -125,20 +120,24 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
125 assert(xm & DP_HIDDEN_BIT); 120 assert(xm & DP_HIDDEN_BIT);
126 assert(ym & DP_HIDDEN_BIT); 121 assert(ym & DP_HIDDEN_BIT);
127 122
128 /* provide guard,round and stick bit space */ 123 /*
124 * Provide guard,round and stick bit space.
125 */
129 xm <<= 3; 126 xm <<= 3;
130 ym <<= 3; 127 ym <<= 3;
131 128
132 if (xe > ye) { 129 if (xe > ye) {
133 /* have to shift y fraction right to align 130 /*
131 * Have to shift y fraction right to align.
134 */ 132 */
135 int s = xe - ye; 133 s = xe - ye;
136 ym = XDPSRS(ym, s); 134 ym = XDPSRS(ym, s);
137 ye += s; 135 ye += s;
138 } else if (ye > xe) { 136 } else if (ye > xe) {
139 /* have to shift x fraction right to align 137 /*
138 * Have to shift x fraction right to align.
140 */ 139 */
141 int s = ye - xe; 140 s = ye - xe;
142 xm = XDPSRS(xm, s); 141 xm = XDPSRS(xm, s);
143 xe += s; 142 xe += s;
144 } 143 }
@@ -146,8 +145,9 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
146 assert(xe <= DP_EMAX); 145 assert(xe <= DP_EMAX);
147 146
148 if (xs == ys) { 147 if (xs == ys) {
149 /* generate 28 bit result of adding two 27 bit numbers 148 /*
150 * leaving result in xm,xs,xe 149 * Generate 28 bit result of adding two 27 bit numbers
150 * leaving result in xm, xs and xe.
151 */ 151 */
152 xm = xm + ym; 152 xm = xm + ym;
153 xe = xe; 153 xe = xe;
@@ -168,15 +168,15 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
168 xs = ys; 168 xs = ys;
169 } 169 }
170 if (xm == 0) 170 if (xm == 0)
171 return ieee754dp_zero(ieee754_csr.rm == 171 return ieee754dp_zero(ieee754_csr.rm == IEEE754_RD);
172 IEEE754_RD);
173 172
174 /* normalize to rounding precision */ 173 /*
174 * Normalize to rounding precision.
175 */
175 while ((xm >> (DP_FBITS + 3)) == 0) { 176 while ((xm >> (DP_FBITS + 3)) == 0) {
176 xm <<= 1; 177 xm <<= 1;
177 xe--; 178 xe--;
178 } 179 }
179
180 } 180 }
181 181
182 return ieee754dp_format(xs, xe, xm); 182 return ieee754dp_format(xs, xe, xm);