]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/gcc/config/soft-fp/quad.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / gcc / config / soft-fp / quad.h
1 /* Software floating-point emulation.
2    Definitions for IEEE Quad Precision.
3    Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5    Contributed by Richard Henderson (rth@cygnus.com),
6                   Jakub Jelinek (jj@ultra.linux.cz),
7                   David S. Miller (davem@redhat.com) and
8                   Peter Maydell (pmaydell@chiark.greenend.org.uk).
9
10    The GNU C Library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 2.1 of the License, or (at your option) any later version.
14
15    In addition to the permissions in the GNU Lesser General Public
16    License, the Free Software Foundation gives you unlimited
17    permission to link the compiled version of this file into
18    combinations with other programs, and to distribute those
19    combinations without any restriction coming from the use of this
20    file.  (The Lesser General Public License restrictions do apply in
21    other respects; for example, they cover modification of the file,
22    and distribution when not linked into a combine executable.)
23
24    The GNU C Library is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27    Lesser General Public License for more details.
28
29    You should have received a copy of the GNU Lesser General Public
30    License along with the GNU C Library; if not, write to the Free
31    Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
32    MA 02110-1301, USA.  */
33
34 #if _FP_W_TYPE_SIZE < 32
35 #error "Here's a nickel, kid. Go buy yourself a real computer."
36 #endif
37
38 #if _FP_W_TYPE_SIZE < 64
39 #define _FP_FRACTBITS_Q         (4*_FP_W_TYPE_SIZE)
40 #else
41 #define _FP_FRACTBITS_Q         (2*_FP_W_TYPE_SIZE)
42 #endif
43
44 #define _FP_FRACBITS_Q          113
45 #define _FP_FRACXBITS_Q         (_FP_FRACTBITS_Q - _FP_FRACBITS_Q)
46 #define _FP_WFRACBITS_Q         (_FP_WORKBITS + _FP_FRACBITS_Q)
47 #define _FP_WFRACXBITS_Q        (_FP_FRACTBITS_Q - _FP_WFRACBITS_Q)
48 #define _FP_EXPBITS_Q           15
49 #define _FP_EXPBIAS_Q           16383
50 #define _FP_EXPMAX_Q            32767
51
52 #define _FP_QNANBIT_Q           \
53         ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2) % _FP_W_TYPE_SIZE)
54 #define _FP_QNANBIT_SH_Q                \
55         ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
56 #define _FP_IMPLBIT_Q           \
57         ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1) % _FP_W_TYPE_SIZE)
58 #define _FP_IMPLBIT_SH_Q                \
59         ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
60 #define _FP_OVERFLOW_Q          \
61         ((_FP_W_TYPE)1 << (_FP_WFRACBITS_Q % _FP_W_TYPE_SIZE))
62
63 typedef float TFtype __attribute__((mode(TF)));
64
65 #if _FP_W_TYPE_SIZE < 64
66
67 union _FP_UNION_Q
68 {
69    TFtype flt;
70    struct 
71    {
72 #if __BYTE_ORDER == __BIG_ENDIAN
73       unsigned sign : 1;
74       unsigned exp : _FP_EXPBITS_Q;
75       unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
76       unsigned long frac2 : _FP_W_TYPE_SIZE;
77       unsigned long frac1 : _FP_W_TYPE_SIZE;
78       unsigned long frac0 : _FP_W_TYPE_SIZE;
79 #else
80       unsigned long frac0 : _FP_W_TYPE_SIZE;
81       unsigned long frac1 : _FP_W_TYPE_SIZE;
82       unsigned long frac2 : _FP_W_TYPE_SIZE;
83       unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
84       unsigned exp : _FP_EXPBITS_Q;
85       unsigned sign : 1;
86 #endif /* not bigendian */
87    } bits __attribute__((packed));
88 };
89
90
91 #define FP_DECL_Q(X)            _FP_DECL(4,X)
92 #define FP_UNPACK_RAW_Q(X,val)  _FP_UNPACK_RAW_4(Q,X,val)
93 #define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_4_P(Q,X,val)
94 #define FP_PACK_RAW_Q(val,X)    _FP_PACK_RAW_4(Q,val,X)
95 #define FP_PACK_RAW_QP(val,X)           \
96   do {                                  \
97     if (!FP_INHIBIT_RESULTS)            \
98       _FP_PACK_RAW_4_P(Q,val,X);        \
99   } while (0)
100
101 #define FP_UNPACK_Q(X,val)              \
102   do {                                  \
103     _FP_UNPACK_RAW_4(Q,X,val);          \
104     _FP_UNPACK_CANONICAL(Q,4,X);        \
105   } while (0)
106
107 #define FP_UNPACK_QP(X,val)             \
108   do {                                  \
109     _FP_UNPACK_RAW_4_P(Q,X,val);        \
110     _FP_UNPACK_CANONICAL(Q,4,X);        \
111   } while (0)
112
113 #define FP_UNPACK_SEMIRAW_Q(X,val)      \
114   do {                                  \
115     _FP_UNPACK_RAW_4(Q,X,val);          \
116     _FP_UNPACK_SEMIRAW(Q,4,X);          \
117   } while (0)
118
119 #define FP_UNPACK_SEMIRAW_QP(X,val)     \
120   do {                                  \
121     _FP_UNPACK_RAW_4_P(Q,X,val);        \
122     _FP_UNPACK_SEMIRAW(Q,4,X);          \
123   } while (0)
124
125 #define FP_PACK_Q(val,X)                \
126   do {                                  \
127     _FP_PACK_CANONICAL(Q,4,X);          \
128     _FP_PACK_RAW_4(Q,val,X);            \
129   } while (0)
130
131 #define FP_PACK_QP(val,X)               \
132   do {                                  \
133     _FP_PACK_CANONICAL(Q,4,X);          \
134     if (!FP_INHIBIT_RESULTS)            \
135       _FP_PACK_RAW_4_P(Q,val,X);        \
136   } while (0)
137
138 #define FP_PACK_SEMIRAW_Q(val,X)        \
139   do {                                  \
140     _FP_PACK_SEMIRAW(Q,4,X);            \
141     _FP_PACK_RAW_4(Q,val,X);            \
142   } while (0)
143
144 #define FP_PACK_SEMIRAW_QP(val,X)       \
145   do {                                  \
146     _FP_PACK_SEMIRAW(Q,4,X);            \
147     if (!FP_INHIBIT_RESULTS)            \
148       _FP_PACK_RAW_4_P(Q,val,X);        \
149   } while (0)
150
151 #define FP_ISSIGNAN_Q(X)                _FP_ISSIGNAN(Q,4,X)
152 #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)
154 #define FP_SUB_Q(R,X,Y)                 _FP_SUB(Q,4,R,X,Y)
155 #define FP_MUL_Q(R,X,Y)                 _FP_MUL(Q,4,R,X,Y)
156 #define FP_DIV_Q(R,X,Y)                 _FP_DIV(Q,4,R,X,Y)
157 #define FP_SQRT_Q(R,X)                  _FP_SQRT(Q,4,R,X)
158 #define _FP_SQRT_MEAT_Q(R,S,T,X,Q)      _FP_SQRT_MEAT_4(R,S,T,X,Q)
159
160 #define FP_CMP_Q(r,X,Y,un)      _FP_CMP(Q,4,r,X,Y,un)
161 #define FP_CMP_EQ_Q(r,X,Y)      _FP_CMP_EQ(Q,4,r,X,Y)
162 #define FP_CMP_UNORD_Q(r,X,Y)   _FP_CMP_UNORD(Q,4,r,X,Y)
163
164 #define FP_TO_INT_Q(r,X,rsz,rsg)        _FP_TO_INT(Q,4,r,X,rsz,rsg)
165 #define FP_FROM_INT_Q(X,r,rs,rt)        _FP_FROM_INT(Q,4,X,r,rs,rt)
166
167 #define _FP_FRAC_HIGH_Q(X)      _FP_FRAC_HIGH_4(X)
168 #define _FP_FRAC_HIGH_RAW_Q(X)  _FP_FRAC_HIGH_4(X)
169
170 #else   /* not _FP_W_TYPE_SIZE < 64 */
171 union _FP_UNION_Q
172 {
173   TFtype flt /* __attribute__((mode(TF))) */ ;
174   struct {
175     _FP_W_TYPE a, b;
176   } longs;
177   struct {
178 #if __BYTE_ORDER == __BIG_ENDIAN
179     unsigned sign    : 1;
180     unsigned exp     : _FP_EXPBITS_Q;
181     _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
182     _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
183 #else
184     _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
185     _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
186     unsigned exp     : _FP_EXPBITS_Q;
187     unsigned sign    : 1;
188 #endif
189   } bits;
190 };
191
192 #define FP_DECL_Q(X)            _FP_DECL(2,X)
193 #define FP_UNPACK_RAW_Q(X,val)  _FP_UNPACK_RAW_2(Q,X,val)
194 #define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_2_P(Q,X,val)
195 #define FP_PACK_RAW_Q(val,X)    _FP_PACK_RAW_2(Q,val,X)
196 #define FP_PACK_RAW_QP(val,X)           \
197   do {                                  \
198     if (!FP_INHIBIT_RESULTS)            \
199       _FP_PACK_RAW_2_P(Q,val,X);        \
200   } while (0)
201
202 #define FP_UNPACK_Q(X,val)              \
203   do {                                  \
204     _FP_UNPACK_RAW_2(Q,X,val);          \
205     _FP_UNPACK_CANONICAL(Q,2,X);        \
206   } while (0)
207
208 #define FP_UNPACK_QP(X,val)             \
209   do {                                  \
210     _FP_UNPACK_RAW_2_P(Q,X,val);        \
211     _FP_UNPACK_CANONICAL(Q,2,X);        \
212   } while (0)
213
214 #define FP_UNPACK_SEMIRAW_Q(X,val)      \
215   do {                                  \
216     _FP_UNPACK_RAW_2(Q,X,val);          \
217     _FP_UNPACK_SEMIRAW(Q,2,X);          \
218   } while (0)
219
220 #define FP_UNPACK_SEMIRAW_QP(X,val)     \
221   do {                                  \
222     _FP_UNPACK_RAW_2_P(Q,X,val);        \
223     _FP_UNPACK_SEMIRAW(Q,2,X);          \
224   } while (0)
225
226 #define FP_PACK_Q(val,X)                \
227   do {                                  \
228     _FP_PACK_CANONICAL(Q,2,X);          \
229     _FP_PACK_RAW_2(Q,val,X);            \
230   } while (0)
231
232 #define FP_PACK_QP(val,X)               \
233   do {                                  \
234     _FP_PACK_CANONICAL(Q,2,X);          \
235     if (!FP_INHIBIT_RESULTS)            \
236       _FP_PACK_RAW_2_P(Q,val,X);        \
237   } while (0)
238
239 #define FP_PACK_SEMIRAW_Q(val,X)        \
240   do {                                  \
241     _FP_PACK_SEMIRAW(Q,2,X);            \
242     _FP_PACK_RAW_2(Q,val,X);            \
243   } while (0)
244
245 #define FP_PACK_SEMIRAW_QP(val,X)       \
246   do {                                  \
247     _FP_PACK_SEMIRAW(Q,2,X);            \
248     if (!FP_INHIBIT_RESULTS)            \
249       _FP_PACK_RAW_2_P(Q,val,X);        \
250   } while (0)
251
252 #define FP_ISSIGNAN_Q(X)                _FP_ISSIGNAN(Q,2,X)
253 #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)
255 #define FP_SUB_Q(R,X,Y)                 _FP_SUB(Q,2,R,X,Y)
256 #define FP_MUL_Q(R,X,Y)                 _FP_MUL(Q,2,R,X,Y)
257 #define FP_DIV_Q(R,X,Y)                 _FP_DIV(Q,2,R,X,Y)
258 #define FP_SQRT_Q(R,X)                  _FP_SQRT(Q,2,R,X)
259 #define _FP_SQRT_MEAT_Q(R,S,T,X,Q)      _FP_SQRT_MEAT_2(R,S,T,X,Q)
260
261 #define FP_CMP_Q(r,X,Y,un)      _FP_CMP(Q,2,r,X,Y,un)
262 #define FP_CMP_EQ_Q(r,X,Y)      _FP_CMP_EQ(Q,2,r,X,Y)
263 #define FP_CMP_UNORD_Q(r,X,Y)   _FP_CMP_UNORD(Q,2,r,X,Y)
264
265 #define FP_TO_INT_Q(r,X,rsz,rsg)        _FP_TO_INT(Q,2,r,X,rsz,rsg)
266 #define FP_FROM_INT_Q(X,r,rs,rt)        _FP_FROM_INT(Q,2,X,r,rs,rt)
267
268 #define _FP_FRAC_HIGH_Q(X)      _FP_FRAC_HIGH_2(X)
269 #define _FP_FRAC_HIGH_RAW_Q(X)  _FP_FRAC_HIGH_2(X)
270
271 #endif /* not _FP_W_TYPE_SIZE < 64 */