View | Details | Raw Unified | Return to bug 3268 | Differences between
and this patch

Collapse All | Expand All

(-)libc25-cvstip-20070320/soft-fp/Makefile (-2 / +3 lines)
Lines 24-35 Link Here
24
24
25
gcc-single-routines := negsf2 addsf3 subsf3 mulsf3 divsf3 eqsf2 \
25
gcc-single-routines := negsf2 addsf3 subsf3 mulsf3 divsf3 eqsf2 \
26
	lesf2 gesf2 unordsf2 fixsfsi fixunssfsi floatsisf fixsfdi        \
26
	lesf2 gesf2 unordsf2 fixsfsi fixunssfsi floatsisf fixsfdi        \
27
	fixunssfdi floatdisf sqrtsf2 floatunsisf floatundisf
27
	fixunssfdi floatdisf sqrtsf2 floatunsisf floatundisf \
28
	fmasf4
28
29
29
gcc-double-routines := negdf2 adddf3 subdf3 muldf3 divdf3 eqdf2 \
30
gcc-double-routines := negdf2 adddf3 subdf3 muldf3 divdf3 eqdf2 \
30
	ledf2 gedf2 unorddf2 fixdfsi fixunsdfsi floatsidf fixdfdi        \
31
	ledf2 gedf2 unorddf2 fixdfsi fixunsdfsi floatsidf fixdfdi        \
31
	fixunsdfdi floatdidf extendsfdf2 truncdfsf2 sqrtdf2 floatunsidf \
32
	fixunsdfdi floatdidf extendsfdf2 truncdfsf2 sqrtdf2 floatunsidf \
32
	floatundidf
33
	floatundidf fmadf4
33
34
34
gcc-quad-routines := negtf2 addtf3 subtf3 multf3 divtf3 eqtf2 \
35
gcc-quad-routines := negtf2 addtf3 subtf3 multf3 divtf3 eqtf2 \
35
	letf2 getf2 unordtf2 fixtfsi fixunstfsi floatsitf fixtfdi      \
36
	letf2 getf2 unordtf2 fixtfsi fixunstfsi floatsitf fixtfdi      \
(-)libc25-cvstip-20070320/soft-fp/double.h (+91 lines)
Lines 142-147 Link Here
142
      _FP_PACK_RAW_2_P(D,val,X);	\
142
      _FP_PACK_RAW_2_P(D,val,X);	\
143
  } while (0)
143
  } while (0)
144
144
145
/* Copy the internal layout between RAW, SEMIRAW, and CANONICAL forms.
146
   These macros are used in the fma implementations.  */
147
148
#define FP_COPY_RAW_D(Y, X)		\
149
  do {					\
150
    Y##_f0 = X##_f0;			\
151
    Y##_f1 = X##_f1 &			\
152
    		((1 << (_FP_FRACBITS_D	\
153
    		- (_FP_IMPLBIT_D != 0)	\
154
		- _FP_W_TYPE_SIZE)) -1);\
155
    Y##_e  = X##_e  &			\
156
    		((1 << _FP_EXPBITS_D)	\
157
		-1);			\
158
    Y##_s  = X##_s;			\
159
  } while (0)
160
  
161
#define FP_COPY_RAW_TO_CANONICAL_D(Y,X)	\
162
  do {					\
163
    FP_COPY_RAW_D(Y,X);			\
164
    _FP_UNPACK_CANONICAL(D,2,Y);	\
165
  } while (0)
166
167
#define FP_COPY_RAW_TO_SEMIRAW_D(Y,X)	\
168
  do {					\
169
    FP_COPY_RAW_D(Y,X); 		\
170
    _FP_UNPACK_SEMIRAW(D,2,Y);		\
171
  } while (0)
172
173
#define FP_COPY_SEMIRAW_D(Y, X)		\
174
  do {					\
175
    Y##_f0 = X##_f0;			\
176
    Y##_f1 = X##_f1 &			\
177
    		((1 << (_FP_FRACBITS_D	\
178
    		- (_FP_IMPLBIT_D != 0)	\
179
		- _FP_W_TYPE_SIZE	\
180
		+ 3)) -1);		\
181
    Y##_e  = X##_e;			\
182
    Y##_s  = X##_s;			\
183
  } while (0)
184
185
#define FP_COPY_CANONICAL_TO_SEMIRAW_D(Y,X)	\
186
  do {					\
187
    _FP_PACK_CANONICAL(D,2,X);		\
188
    FP_COPY_RAW_D(Y,X);			\
189
    _FP_UNPACK_SEMIRAW(D,2,Y);		\
190
  } while (0)
191
145
#define FP_ISSIGNAN_D(X)		_FP_ISSIGNAN(D,2,X)
192
#define FP_ISSIGNAN_D(X)		_FP_ISSIGNAN(D,2,X)
146
#define FP_NEG_D(R,X)			_FP_NEG(D,2,R,X)
193
#define FP_NEG_D(R,X)			_FP_NEG(D,2,R,X)
147
#define FP_ADD_D(R,X,Y)			_FP_ADD(D,2,R,X,Y)
194
#define FP_ADD_D(R,X,Y)			_FP_ADD(D,2,R,X,Y)
Lines 239-244 Link Here
239
      _FP_PACK_RAW_1_P(D,val,X);	\
286
      _FP_PACK_RAW_1_P(D,val,X);	\
240
  } while (0)
287
  } while (0)
241
288
289
/* Copy the internal layout between RAW, SEMIRAW, and CANONICAL forms.
290
   These macros are used in the fma implementations.  */
291
292
#define FP_COPY_RAW_D(Y, X)		\
293
  do {					\
294
    Y##_f = X##_f & 			\
295
    		((1 << ( _FP_FRACBITS_D	\
296
    		- (_FP_IMPLBIT_D != 0)))\
297
		-1);			\
298
    Y##_e = X##_e &			\
299
    		((1 << _FP_EXPBITS_D)	\
300
		-1);			\
301
    Y##_s = X##_s;			\
302
  } while (0)
303
  
304
#define FP_COPY_RAW_TO_CANONICAL_D(Y,X)	\
305
  do {					\
306
    FP_COPY_RAW_D(Y,X);			\
307
    _FP_UNPACK_CANONICAL(D,1,Y);	\
308
  } while (0)
309
310
#define FP_COPY_RAW_TO_SEMIRAW_D(Y,X)	\
311
  do {					\
312
    FP_COPY_RAW_D(Y,X);			\
313
    _FP_UNPACK_SEMIRAW(D,1,Y);		\
314
  } while (0)
315
316
#define FP_COPY_SEMIRAW_D(Y, X)		\
317
  do {					\
318
    Y##_f = X##_f &			\
319
    		((1 << ( _FP_FRACBITS_D	\
320
    		- (_FP_IMPLBIT_D != 0)	\
321
		+ 3)) -1);		\
322
    Y##_e = X##_e;			\
323
    Y##_s = X##_s;			\
324
  } while (0)
325
  
326
#define FP_COPY_CANONICAL_TO_SEMIRAW_D(Y,X)	\
327
  do {					\
328
    _FP_PACK_CANONICAL(D,1,X);		\
329
    FP_COPY_RAW_D(Y,X);			\
330
    _FP_UNPACK_SEMIRAW(D,1,Y);		\
331
  } while (0)
332
242
#define FP_ISSIGNAN_D(X)		_FP_ISSIGNAN(D,1,X)
333
#define FP_ISSIGNAN_D(X)		_FP_ISSIGNAN(D,1,X)
243
#define FP_NEG_D(R,X)			_FP_NEG(D,1,R,X)
334
#define FP_NEG_D(R,X)			_FP_NEG(D,1,R,X)
244
#define FP_ADD_D(R,X,Y)			_FP_ADD(D,1,R,X,Y)
335
#define FP_ADD_D(R,X,Y)			_FP_ADD(D,1,R,X,Y)
(-)libc25-cvstip-20070320/soft-fp/fmadf4.c (+91 lines)
Line 0 Link Here
1
/* soft-fp x * y + z as ternary operation.
2
   Copyright (C) 2007 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
   Contributed by Steven Munroe <sjmunroe@us.ibm.com>, 2006.
5
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Lesser General Public
8
   License as published by the Free Software Foundation; either
9
   version 2.1 of the License, or (at your option) any later version.
10
11
   The GNU C Library is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Lesser General Public License for more details.
15
16
   In addition to the permissions in the GNU Lesser General Public
17
   License, the Free Software Foundation gives you unlimited
18
   permission to link the compiled version of this file into
19
   combinations with other programs, and to distribute those
20
   combinations without any restriction coming from the use of this
21
   file.  (The Lesser General Public License restrictions do apply in
22
   other respects; for example, they cover modification of the file,
23
   and distribution when not linked into a combine executable.)
24
25
   You should have received a copy of the GNU Lesser General Public
26
   License along with the GNU C Library; if not, write to the Free
27
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28
   02111-1307 USA.  */
29
30
#include "soft-fp.h"
31
#include "double.h"
32
#include "quad.h"
33
34
/* Compute floating point multiply-add with higher (quad) precision.  */
35
DFtype
36
__fmadf4 (DFtype a, DFtype b, DFtype c)
37
{
38
    FP_DECL_EX;
39
    FP_DECL_D(A);
40
    FP_DECL_D(B);
41
    FP_DECL_D(C);
42
    FP_DECL_Q(X);
43
    FP_DECL_Q(Y);
44
    FP_DECL_Q(Z);
45
    FP_DECL_Q(U);
46
    FP_DECL_Q(V);
47
    FP_DECL_D(R);
48
    double r;
49
  
50
    FP_INIT_ROUNDMODE;
51
    FP_UNPACK_RAW_D (A, a);
52
    FP_UNPACK_RAW_D (B, b);
53
    FP_UNPACK_RAW_D (C, c);
54
55
    /* Extend double to quad.  */
56
#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
57
    FP_EXTEND(Q,D,4,2,X,A);
58
    FP_EXTEND(Q,D,4,2,Y,B);
59
    FP_EXTEND(Q,D,4,2,Z,C);
60
#else
61
    FP_EXTEND(Q,D,2,1,X,A);
62
    FP_EXTEND(Q,D,2,1,Y,B);
63
    FP_EXTEND(Q,D,2,1,Z,C);
64
#endif
65
    FP_HANDLE_EXCEPTIONS;
66
67
    /* Multiply.
68
       Rounding is not an issue as we keep the full 106 bit product.  */
69
    FP_COPY_RAW_TO_CANONICAL_Q(X,X);
70
    FP_COPY_RAW_TO_CANONICAL_Q(Y,Y);
71
    FP_MUL_Q(U,X,Y);
72
    FP_HANDLE_EXCEPTIONS;
73
74
    /* Add without rounding.  */
75
    FP_COPY_CANONICAL_TO_SEMIRAW_Q(U,U);
76
    FP_COPY_RAW_TO_SEMIRAW_Q(Z,Z);
77
    FP_ADD_Q(V,U,Z);
78
79
    /* Truncate quad to double and round.  */
80
    FP_COPY_SEMIRAW_Q(V,V);
81
#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
82
    FP_TRUNC(D,Q,2,4,R,V);
83
#else
84
    FP_TRUNC(D,Q,1,2,R,V);
85
#endif
86
    FP_PACK_SEMIRAW_D(r,R);
87
    FP_HANDLE_EXCEPTIONS;
88
89
    return r;
90
}
91
(-)libc25-cvstip-20070320/soft-fp/fmasf4.c (+90 lines)
Line 0 Link Here
1
/* soft-fp x * y + z as ternary operation.
2
   Copyright (C) 2007 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
   Contributed by Steven Munroe <sjmunroe@us.ibm.com>, 2006.
5
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Lesser General Public
8
   License as published by the Free Software Foundation; either
9
   version 2.1 of the License, or (at your option) any later version.
10
11
   In addition to the permissions in the GNU Lesser General Public
12
   License, the Free Software Foundation gives you unlimited
13
   permission to link the compiled version of this file into
14
   combinations with other programs, and to distribute those
15
   combinations without any restriction coming from the use of this
16
   file.  (The Lesser General Public License restrictions do apply in
17
   other respects; for example, they cover modification of the file,
18
   and distribution when not linked into a combine executable.)
19
20
   The GNU C Library is distributed in the hope that it will be useful,
21
   but WITHOUT ANY WARRANTY; without even the implied warranty of
22
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
   Lesser General Public License for more details.
24
25
   You should have received a copy of the GNU Lesser General Public
26
   License along with the GNU C Library; if not, write to the Free
27
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28
   02111-1307 USA.  */
29
30
#include "soft-fp.h"
31
#include "single.h"
32
#include "double.h"
33
34
/* Compute floating point multiply-add with higher (double) precision.  */
35
SFtype
36
__fmasf4 (SFtype a, SFtype b, SFtype c)
37
{
38
    FP_DECL_EX;
39
    FP_DECL_S(A);
40
    FP_DECL_S(B);
41
    FP_DECL_S(C);
42
    FP_DECL_D(X);
43
    FP_DECL_D(Y);
44
    FP_DECL_D(Z);
45
    FP_DECL_D(U);
46
    FP_DECL_D(V);
47
    FP_DECL_S(R);
48
    float r;
49
    
50
    FP_INIT_ROUNDMODE;
51
    FP_UNPACK_RAW_S (A, a);
52
    FP_UNPACK_RAW_S (B, b);
53
    FP_UNPACK_RAW_S (C, c);
54
55
    /* Extend single to double.  */
56
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
57
    FP_EXTEND(D,S,2,1,X,A);
58
    FP_EXTEND(D,S,2,1,Y,B);
59
    FP_EXTEND(D,S,2,1,Z,C);
60
#else
61
    FP_EXTEND(D,S,1,1,X,A);
62
    FP_EXTEND(D,S,1,1,Y,B);
63
    FP_EXTEND(D,S,1,1,Z,C);
64
#endif
65
    FP_HANDLE_EXCEPTIONS;
66
67
    /* Multiply.
68
       Rounding is not an issue as we keep the full 48 bit product.  */
69
    FP_COPY_RAW_TO_CANONICAL_D(X,X);
70
    FP_COPY_RAW_TO_CANONICAL_D(Y,Y);
71
    FP_MUL_D(U,X,Y);
72
    FP_HANDLE_EXCEPTIONS;
73
74
    /* Add without rounding.  */
75
    FP_COPY_CANONICAL_TO_SEMIRAW_D(U,U);
76
    FP_COPY_RAW_TO_SEMIRAW_D(Z,Z);
77
    FP_ADD_D(V,U,Z);
78
79
    /* Truncate double to single and round.  */
80
    FP_COPY_SEMIRAW_D(V,V);
81
#if FP_W_TYPE_SIZE < _FP_FRACBITS_D
82
    FP_TRUNC(S,D,1,2,R,V);
83
#else
84
    FP_TRUNC(S,D,1,1,R,V);
85
#endif
86
    FP_PACK_SEMIRAW_S(r,R);
87
    FP_HANDLE_EXCEPTIONS;
88
89
    return r;
90
}
(-)libc25-cvstip-20070320/soft-fp/quad.h (+99 lines)
Lines 148-153 Link Here
148
      _FP_PACK_RAW_4_P(Q,val,X);	\
148
      _FP_PACK_RAW_4_P(Q,val,X);	\
149
  } while (0)
149
  } while (0)
150
150
151
/* Copy the internal layout between RAW, SEMIRAW, and CANONICAL forms.
152
   These macros are used in the fma implementations.  */
153
154
#define FP_COPY_RAW_Q(Y, X)		\
155
  do {					\
156
    Y##_f[0] = X##_f[0];		\
157
    Y##_f[1] = X##_f[1];		\
158
    Y##_f[2] = X##_f[2];		\
159
    Y##_f[3] = X##_f[3] &		\
160
    		((1 << (_FP_FRACBITS_Q	\
161
    		- (_FP_IMPLBIT_Q != 0)	\
162
		-(_FP_W_TYPE_SIZE * 3)))\
163
		-1);			\
164
    Y##_e    = X##_e  &			\
165
    		((1 << _FP_EXPBITS_Q)	\
166
		-1);			\
167
    Y##_s    = X##_s;			\
168
  } while (0)
169
  
170
#define FP_COPY_RAW_TO_CANONICAL_Q(Y,X)	\
171
  do {					\
172
    FP_COPY_RAW_Q(Y,X);			\
173
    _FP_UNPACK_CANONICAL(Q,4,Y);	\
174
  } while (0)
175
176
#define FP_COPY_RAW_TO_SEMIRAW_Q(Y,X)	\
177
  do {					\
178
    FP_COPY_RAW_Q(Y,X);			\
179
    _FP_UNPACK_SEMIRAW(Q,4,Y);		\
180
  } while (0)
181
182
#define FP_COPY_SEMIRAW_Q(Y, X)		\
183
  do {					\
184
    Y##_f[0] = X##_f[0];		\
185
    Y##_f[1] = X##_f[1];		\
186
    Y##_f[2] = X##_f[2];		\
187
    Y##_f[3] = X##_f[3] &		\
188
    		((1 << (_FP_FRACBITS_Q	\
189
    		- (_FP_IMPLBIT_Q != 0)	\
190
		-(_FP_W_TYPE_SIZE * 3)	\
191
		+ 3)) -1);		\
192
    Y##_e    = X##_e;			\
193
    Y##_s    = X##_s;			\
194
  } while (0)
195
196
#define FP_COPY_CANONICAL_TO_SEMIRAW_Q(Y,X)	\
197
  do {					\
198
    _FP_PACK_CANONICAL(Q,4,X);		\
199
    FP_COPY_RAW_Q(Y,X);			\
200
    _FP_UNPACK_SEMIRAW(Q,4,Y);		\
201
  } while (0)
202
151
#define FP_ISSIGNAN_Q(X)		_FP_ISSIGNAN(Q,4,X)
203
#define FP_ISSIGNAN_Q(X)		_FP_ISSIGNAN(Q,4,X)
152
#define FP_NEG_Q(R,X)			_FP_NEG(Q,4,R,X)
204
#define FP_NEG_Q(R,X)			_FP_NEG(Q,4,R,X)
153
#define FP_ADD_Q(R,X,Y)			_FP_ADD(Q,4,R,X,Y)
205
#define FP_ADD_Q(R,X,Y)			_FP_ADD(Q,4,R,X,Y)
Lines 249-254 Link Here
249
      _FP_PACK_RAW_2_P(Q,val,X);	\
301
      _FP_PACK_RAW_2_P(Q,val,X);	\
250
  } while (0)
302
  } while (0)
251
303
304
/* Copy the internal layout between RAW, SEMIRAW, and CANONICAL forms.
305
   These macros are used in the fma implementations.  */
306
307
#define FP_COPY_RAW_Q(Y, X)		\
308
  do {					\
309
    Y##_f0 = X##_f0;			\
310
    Y##_f1 = X##_f1 &			\
311
    		((1 << (_FP_FRACBITS_Q	\
312
    		- (_FP_IMPLBIT_Q != 0)	\
313
		- _FP_W_TYPE_SIZE)) -1);\
314
    Y##_e  = X##_e  &			\
315
    		((1 << _FP_EXPBITS_Q)	\
316
		-1);			\
317
    Y##_s  = X##_s;			\
318
  } while (0)
319
  
320
#define FP_COPY_RAW_TO_CANONICAL_Q(Y,X)	\
321
  do {					\
322
    FP_COPY_RAW_Q(Y,X);			\
323
    _FP_UNPACK_CANONICAL(Q,2,Y);	\
324
  } while (0)
325
326
#define FP_COPY_RAW_TO_SEMIRAW_Q(Y,X)	\
327
  do {					\
328
    FP_COPY_RAW_D(Y,X);			\
329
    _FP_UNPACK_SEMIRAW(Q,2,Y);		\
330
  } while (0)
331
332
#define FP_COPY_SEMIRAW_Q(Y, X)		\
333
  do {					\
334
    Y##_f0 = X##_f0;			\
335
    Y##_f1 = X##_f1 &			\
336
    		((1 << (_FP_FRACBITS_Q	\
337
    		- (_FP_IMPLBIT_Q != 0)	\
338
		- _FP_W_TYPE_SIZE	\
339
		+ 3)) -1);		\
340
    Y##_e  = X##_e;			\
341
    Y##_s  = X##_s;			\
342
  } while (0)
343
344
#define FP_COPY_CANONICAL_TO_SEMIRAW_Q(Y,X)	\
345
  do {					\
346
    _FP_PACK_CANONICAL(Q,2,X);		\
347
    FP_COPY_RAW_Q(Y,X);			\
348
    _FP_UNPACK_SEMIRAW(Q,2,Y);		\
349
  } while (0)
350
252
#define FP_ISSIGNAN_Q(X)		_FP_ISSIGNAN(Q,2,X)
351
#define FP_ISSIGNAN_Q(X)		_FP_ISSIGNAN(Q,2,X)
253
#define FP_NEG_Q(R,X)			_FP_NEG(Q,2,R,X)
352
#define FP_NEG_Q(R,X)			_FP_NEG(Q,2,R,X)
254
#define FP_ADD_Q(R,X,Y)			_FP_ADD(Q,2,R,X,Y)
353
#define FP_ADD_Q(R,X,Y)			_FP_ADD(Q,2,R,X,Y)

Return to bug 3268