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).
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.
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.)
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.
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. */
34 #if _FP_W_TYPE_SIZE < 32
35 #error "Here's a nickel, kid. Go buy yourself a real computer."
38 #if _FP_W_TYPE_SIZE < 64
39 #define _FP_FRACTBITS_Q (4*_FP_W_TYPE_SIZE)
41 #define _FP_FRACTBITS_Q (2*_FP_W_TYPE_SIZE)
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
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))
63 typedef float TFtype
__attribute__((mode(TF
)));
65 #if _FP_W_TYPE_SIZE < 64
72 #if __BYTE_ORDER == __BIG_ENDIAN
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
;
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
;
86 #endif /* not bigendian */
87 } bits
__attribute__((packed
));
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) \
97 if (!FP_INHIBIT_RESULTS) \
98 _FP_PACK_RAW_4_P(Q,val,X); \
101 #define FP_UNPACK_Q(X,val) \
103 _FP_UNPACK_RAW_4(Q,X,val); \
104 _FP_UNPACK_CANONICAL(Q,4,X); \
107 #define FP_UNPACK_QP(X,val) \
109 _FP_UNPACK_RAW_4_P(Q,X,val); \
110 _FP_UNPACK_CANONICAL(Q,4,X); \
113 #define FP_UNPACK_SEMIRAW_Q(X,val) \
115 _FP_UNPACK_RAW_4(Q,X,val); \
116 _FP_UNPACK_SEMIRAW(Q,4,X); \
119 #define FP_UNPACK_SEMIRAW_QP(X,val) \
121 _FP_UNPACK_RAW_4_P(Q,X,val); \
122 _FP_UNPACK_SEMIRAW(Q,4,X); \
125 #define FP_PACK_Q(val,X) \
127 _FP_PACK_CANONICAL(Q,4,X); \
128 _FP_PACK_RAW_4(Q,val,X); \
131 #define FP_PACK_QP(val,X) \
133 _FP_PACK_CANONICAL(Q,4,X); \
134 if (!FP_INHIBIT_RESULTS) \
135 _FP_PACK_RAW_4_P(Q,val,X); \
138 #define FP_PACK_SEMIRAW_Q(val,X) \
140 _FP_PACK_SEMIRAW(Q,4,X); \
141 _FP_PACK_RAW_4(Q,val,X); \
144 #define FP_PACK_SEMIRAW_QP(val,X) \
146 _FP_PACK_SEMIRAW(Q,4,X); \
147 if (!FP_INHIBIT_RESULTS) \
148 _FP_PACK_RAW_4_P(Q,val,X); \
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)
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)
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)
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)
170 #else /* not _FP_W_TYPE_SIZE < 64 */
173 TFtype flt
/* __attribute__((mode(TF))) */ ;
178 #if __BYTE_ORDER == __BIG_ENDIAN
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
;
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
;
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) \
198 if (!FP_INHIBIT_RESULTS) \
199 _FP_PACK_RAW_2_P(Q,val,X); \
202 #define FP_UNPACK_Q(X,val) \
204 _FP_UNPACK_RAW_2(Q,X,val); \
205 _FP_UNPACK_CANONICAL(Q,2,X); \
208 #define FP_UNPACK_QP(X,val) \
210 _FP_UNPACK_RAW_2_P(Q,X,val); \
211 _FP_UNPACK_CANONICAL(Q,2,X); \
214 #define FP_UNPACK_SEMIRAW_Q(X,val) \
216 _FP_UNPACK_RAW_2(Q,X,val); \
217 _FP_UNPACK_SEMIRAW(Q,2,X); \
220 #define FP_UNPACK_SEMIRAW_QP(X,val) \
222 _FP_UNPACK_RAW_2_P(Q,X,val); \
223 _FP_UNPACK_SEMIRAW(Q,2,X); \
226 #define FP_PACK_Q(val,X) \
228 _FP_PACK_CANONICAL(Q,2,X); \
229 _FP_PACK_RAW_2(Q,val,X); \
232 #define FP_PACK_QP(val,X) \
234 _FP_PACK_CANONICAL(Q,2,X); \
235 if (!FP_INHIBIT_RESULTS) \
236 _FP_PACK_RAW_2_P(Q,val,X); \
239 #define FP_PACK_SEMIRAW_Q(val,X) \
241 _FP_PACK_SEMIRAW(Q,2,X); \
242 _FP_PACK_RAW_2(Q,val,X); \
245 #define FP_PACK_SEMIRAW_QP(val,X) \
247 _FP_PACK_SEMIRAW(Q,2,X); \
248 if (!FP_INHIBIT_RESULTS) \
249 _FP_PACK_RAW_2_P(Q,val,X); \
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)
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)
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)
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)
271 #endif /* not _FP_W_TYPE_SIZE < 64 */