OSDN Git Service

gcc:
[pf3gnuchains/gcc-fork.git] / libgcc / dfp-bit.h
1 /* Header file for dfp-bit.c.
2    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
3    Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 <http://www.gnu.org/licenses/>.  */
25
26 #ifndef _DFPBIT_H
27 #define _DFPBIT_H
28
29 #include <float.h>
30 #include <fenv.h>
31 #include <decRound.h>
32 #include <decExcept.h>
33 #include "tconfig.h"
34 #include "coretypes.h"
35 #include "tm.h"
36
37 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
38 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
39 #endif
40
41 /* We need to know the size of long double that the C library supports.
42    Don't use LIBGCC2_HAS_XF_MODE or LIBGCC2_HAS_TF_MODE here because
43    some targets set both of those.  */
44
45 #define LONG_DOUBLE_HAS_XF_MODE \
46   (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
47
48 #define LONG_DOUBLE_HAS_TF_MODE \
49   (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
50
51 /* Depending on WIDTH, define a number of macros:
52
53    DFP_C_TYPE: type of the arguments to the libgcc functions;
54         (eg _Decimal32)
55
56    IEEE_TYPE: the corresponding (encoded) IEEE754 type;
57         (eg decimal32)
58    
59    TO_INTERNAL: the name of the decNumber function to convert an
60    encoded value into the decNumber internal representation;
61
62    TO_ENCODED: the name of the decNumber function to convert an
63    internally represented decNumber into the encoded
64    representation.
65
66    FROM_STRING: the name of the decNumber function to read an
67    encoded value from a string.
68
69    TO_STRING: the name of the decNumber function to write an
70    encoded value to a string.  */
71
72 #if WIDTH == 32
73 #define DFP_C_TYPE      _Decimal32
74 #define IEEE_TYPE       decimal32
75 #define HOST_TO_IEEE    __host_to_ieee_32
76 #define IEEE_TO_HOST    __ieee_to_host_32
77 #define TO_INTERNAL     __decimal32ToNumber
78 #define TO_ENCODED      __decimal32FromNumber
79 #define FROM_STRING     __decimal32FromString
80 #define TO_STRING       __decimal32ToString
81 #elif WIDTH == 64
82 #define DFP_C_TYPE      _Decimal64
83 #define IEEE_TYPE       decimal64
84 #define HOST_TO_IEEE    __host_to_ieee_64
85 #define IEEE_TO_HOST    __ieee_to_host_64
86 #define TO_INTERNAL     __decimal64ToNumber
87 #define TO_ENCODED      __decimal64FromNumber
88 #define FROM_STRING     __decimal64FromString
89 #define TO_STRING       __decimal64ToString
90 #elif WIDTH == 128
91 #define DFP_C_TYPE      _Decimal128
92 #define IEEE_TYPE       decimal128
93 #define HOST_TO_IEEE    __host_to_ieee_128
94 #define IEEE_TO_HOST    __ieee_to_host_128
95 #define TO_INTERNAL     __decimal128ToNumber
96 #define TO_ENCODED      __decimal128FromNumber
97 #define FROM_STRING     __decimal128FromString
98 #define TO_STRING       __decimal128ToString
99 #else
100 #error invalid decimal float word width
101 #endif
102
103 /* We define __DEC_EVAL_METHOD__ to 2, saying that we evaluate all
104    operations and constants to the range and precision of the _Decimal128
105    type.  Make it so.  */
106 #if WIDTH == 32
107 #define CONTEXT_INIT DEC_INIT_DECIMAL32
108 #elif WIDTH == 64
109 #define CONTEXT_INIT DEC_INIT_DECIMAL64
110 #elif WIDTH == 128
111 #define CONTEXT_INIT DEC_INIT_DECIMAL128
112 #endif
113
114 #ifndef DFP_INIT_ROUNDMODE
115 #define DFP_INIT_ROUNDMODE(A) A = DEC_ROUND_HALF_EVEN
116 #endif
117
118 #ifdef DFP_EXCEPTIONS_ENABLED
119 /* Return IEEE exception flags based on decNumber status flags.  */
120 #define DFP_IEEE_FLAGS(DEC_FLAGS) __extension__                 \
121 ({int _fe_flags = 0;                                            \
122   if ((dec_flags & DEC_IEEE_854_Division_by_zero) != 0)         \
123     _fe_flags |= FE_DIVBYZERO;                                  \
124   if ((dec_flags & DEC_IEEE_854_Inexact) != 0)                  \
125     _fe_flags |= FE_INEXACT;                                    \
126   if ((dec_flags & DEC_IEEE_854_Invalid_operation) != 0)        \
127     _fe_flags |= FE_INVALID;                                    \
128   if ((dec_flags & DEC_IEEE_854_Overflow) != 0)                 \
129     _fe_flags |= FE_OVERFLOW;                                   \
130   if ((dec_flags & DEC_IEEE_854_Underflow) != 0)                \
131     _fe_flags |= FE_UNDERFLOW;                                  \
132   _fe_flags; })
133 #else
134 #define DFP_EXCEPTIONS_ENABLED 0
135 #define DFP_IEEE_FLAGS(A) 0
136 #define DFP_HANDLE_EXCEPTIONS(A) do {} while (0)
137 #endif
138
139 /* Conversions between different decimal float types use WIDTH_TO to
140    determine additional macros to define.  */
141
142 #if defined (L_dd_to_sd) || defined (L_td_to_sd)
143 #define WIDTH_TO 32
144 #elif defined (L_sd_to_dd) || defined (L_td_to_dd)
145 #define WIDTH_TO 64
146 #elif defined (L_sd_to_td) || defined (L_dd_to_td)
147 #define WIDTH_TO 128
148 #endif
149
150 /* If WIDTH_TO is defined, define additional macros:
151
152    DFP_C_TYPE_TO: type of the result of dfp to dfp conversion.
153
154    IEEE_TYPE_TO: the corresponding (encoded) IEEE754 type.
155
156    TO_ENCODED_TO: the name of the decNumber function to convert an
157    internally represented decNumber into the encoded representation
158    for the destination.  */
159
160 #if WIDTH_TO == 32
161 #define DFP_C_TYPE_TO   _Decimal32
162 #define IEEE_TYPE_TO    decimal32
163 #define TO_ENCODED_TO   __decimal32FromNumber
164 #define IEEE_TO_HOST_TO __ieee_to_host_32
165 #elif WIDTH_TO == 64
166 #define DFP_C_TYPE_TO   _Decimal64
167 #define IEEE_TYPE_TO    decimal64
168 #define TO_ENCODED_TO   __decimal64FromNumber
169 #define IEEE_TO_HOST_TO __ieee_to_host_64
170 #elif WIDTH_TO == 128
171 #define DFP_C_TYPE_TO   _Decimal128
172 #define IEEE_TYPE_TO    decimal128
173 #define TO_ENCODED_TO   __decimal128FromNumber
174 #define IEEE_TO_HOST_TO __ieee_to_host_128
175 #endif
176
177 /* Conversions between decimal float types and integral types use INT_KIND
178    to determine the data type and C functions to use.  */
179
180 #if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si)  \
181    || defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td)
182 #define INT_KIND 1
183 #elif defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \
184    || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td)
185 #define INT_KIND 2
186 #elif defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \
187    || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td)
188 #define INT_KIND 3
189 #elif defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) \
190    || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td)
191 #define INT_KIND 4
192 #endif
193
194 /*  If INT_KIND is defined, define additional macros:
195
196     INT_TYPE: The integer data type.
197
198     INT_FMT: The format string for writing the integer to a string.
199
200     CAST_FOR_FMT: Cast variable of INT_KIND to C type for sprintf.
201     This works for ILP32 and LP64, won't for other type size systems.
202
203     STR_TO_INT: The function to read the integer from a string.  */
204
205 #if INT_KIND == 1
206 #define INT_TYPE SItype
207 #define INT_FMT "%d"
208 #define CAST_FOR_FMT(A) (int)A
209 #define STR_TO_INT strtol
210 #elif INT_KIND == 2
211 #define INT_TYPE DItype
212 #define INT_FMT "%lld"
213 #define CAST_FOR_FMT(A) (long long)A
214 #define STR_TO_INT strtoll
215 #elif INT_KIND == 3
216 #define INT_TYPE USItype
217 #define INT_FMT "%u"
218 #define CAST_FOR_FMT(A) (unsigned int)A
219 #define STR_TO_INT strtoul
220 #elif INT_KIND == 4
221 #define INT_TYPE UDItype
222 #define INT_FMT "%llu"
223 #define CAST_FOR_FMT(A) (unsigned long long)A
224 #define STR_TO_INT strtoull
225 #endif
226
227 /* Conversions between decimal float types and binary float types use
228    BFP_KIND to determine the data type and C functions to use.  */
229
230 #if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \
231  || defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td)
232 #define BFP_KIND 1
233 #elif defined (L_sd_to_df) || defined (L_dd_to_df ) || defined (L_td_to_df) \
234  ||   defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td)
235 #define BFP_KIND 2
236 #elif defined (L_sd_to_xf) || defined (L_dd_to_xf ) || defined (L_td_to_xf) \
237  ||   defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)
238 #define BFP_KIND 3
239 #elif defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf) \
240  ||   defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)
241 #define BFP_KIND 4
242 #endif
243
244 /*  If BFP_KIND is defined, define additional macros:
245
246     BFP_TYPE: The binary floating point data type.
247
248     BFP_FMT: The format string for writing the value to a string.
249     The number of decimal digits printed is
250        ceil (nbits / log2 (10.) + 1)
251     as described in David Matula's CACM 19(3) 716-723 June 1968 paper.
252
253     BFP_VIA_TYPE: Type to which to cast a variable of BPF_TYPE for a
254     call to sprintf.
255     
256     STR_TO_BFP: The function to read the value from a string.  */
257
258 #if BFP_KIND == 1
259 #define BFP_TYPE SFtype
260 #define BFP_FMT "%.9e"
261 #define BFP_VIA_TYPE double
262 #define STR_TO_BFP strtof
263
264 #elif BFP_KIND == 2
265 #define BFP_TYPE DFtype
266 #define BFP_FMT "%.17e"
267 #define BFP_VIA_TYPE double
268 #define STR_TO_BFP strtod
269
270 #elif BFP_KIND == 3
271 #if LONG_DOUBLE_HAS_XF_MODE
272 #define BFP_TYPE XFtype
273 #define BFP_FMT "%.21Le"
274 #define BFP_VIA_TYPE long double
275 #define STR_TO_BFP strtold
276 #endif /* LONG_DOUBLE_HAS_XF_MODE */
277
278 #elif BFP_KIND == 4
279 #if LONG_DOUBLE_HAS_TF_MODE
280 #define BFP_TYPE TFtype
281 #if LDBL_MANT_DIG == 106
282 #define BFP_FMT "%.33Le"
283 #elif LDBL_MANT_DIG == 113
284 #define BFP_FMT "%.36Le"
285 #else
286 #error "unknown long double size, cannot define BFP_FMT"
287 #endif /* LDBL_MANT_DIG */
288 #define STR_TO_BFP strtold
289 #define BFP_VIA_TYPE long double
290 #endif /* LONG_DOUBLE_HAS_TF_MODE */
291
292 #endif /* BFP_KIND */
293
294 #if WIDTH == 128 || WIDTH_TO == 128
295 #include "decimal128.h"
296 #include "decQuad.h"
297 #endif
298 #if WIDTH == 64 || WIDTH_TO == 64
299 #include "decimal64.h"
300 #include "decDouble.h"
301 #endif
302 #if WIDTH == 32 || WIDTH_TO == 32
303 #include "decimal32.h"
304 #include "decSingle.h"
305 #endif
306 #include "decNumber.h"
307
308 /* Names of arithmetic functions.  */
309
310 #if ENABLE_DECIMAL_BID_FORMAT
311 #define DPD_BID_NAME(DPD,BID) BID
312 #else
313 #define DPD_BID_NAME(DPD,BID) DPD
314 #endif
315
316 #if WIDTH == 32
317 #define DFP_ADD         DPD_BID_NAME(__dpd_addsd3,__bid_addsd3)
318 #define DFP_SUB         DPD_BID_NAME(__dpd_subsd3,__bid_subsd3)
319 #define DFP_MULTIPLY    DPD_BID_NAME(__dpd_mulsd3,__bid_mulsd3)
320 #define DFP_DIVIDE      DPD_BID_NAME(__dpd_divsd3,__bid_divsd3)
321 #define DFP_EQ          DPD_BID_NAME(__dpd_eqsd2,__bid_eqsd2)
322 #define DFP_NE          DPD_BID_NAME(__dpd_nesd2,__bid_nesd2)
323 #define DFP_LT          DPD_BID_NAME(__dpd_ltsd2,__bid_ltsd2)
324 #define DFP_GT          DPD_BID_NAME(__dpd_gtsd2,__bid_gtsd2)
325 #define DFP_LE          DPD_BID_NAME(__dpd_lesd2,__bid_lesd2)
326 #define DFP_GE          DPD_BID_NAME(__dpd_gesd2,__bid_gesd2)
327 #define DFP_UNORD       DPD_BID_NAME(__dpd_unordsd2,__bid_unordsd2)
328 #elif WIDTH == 64
329 #define DFP_ADD         DPD_BID_NAME(__dpd_adddd3,__bid_adddd3)
330 #define DFP_SUB         DPD_BID_NAME(__dpd_subdd3,__bid_subdd3)
331 #define DFP_MULTIPLY    DPD_BID_NAME(__dpd_muldd3,__bid_muldd3)
332 #define DFP_DIVIDE      DPD_BID_NAME(__dpd_divdd3,__bid_divdd3)
333 #define DFP_EQ          DPD_BID_NAME(__dpd_eqdd2,__bid_eqdd2)
334 #define DFP_NE          DPD_BID_NAME(__dpd_nedd2,__bid_nedd2)
335 #define DFP_LT          DPD_BID_NAME(__dpd_ltdd2,__bid_ltdd2)
336 #define DFP_GT          DPD_BID_NAME(__dpd_gtdd2,__bid_gtdd2)
337 #define DFP_LE          DPD_BID_NAME(__dpd_ledd2,__bid_ledd2)
338 #define DFP_GE          DPD_BID_NAME(__dpd_gedd2,__bid_gedd2)
339 #define DFP_UNORD       DPD_BID_NAME(__dpd_unorddd2,__bid_unorddd2)
340 #elif WIDTH == 128
341 #define DFP_ADD         DPD_BID_NAME(__dpd_addtd3,__bid_addtd3)
342 #define DFP_SUB         DPD_BID_NAME(__dpd_subtd3,__bid_subtd3)
343 #define DFP_MULTIPLY    DPD_BID_NAME(__dpd_multd3,__bid_multd3)
344 #define DFP_DIVIDE      DPD_BID_NAME(__dpd_divtd3,__bid_divtd3)
345 #define DFP_EQ          DPD_BID_NAME(__dpd_eqtd2,__bid_eqtd2)
346 #define DFP_NE          DPD_BID_NAME(__dpd_netd2,__bid_netd2)
347 #define DFP_LT          DPD_BID_NAME(__dpd_lttd2,__bid_lttd2)
348 #define DFP_GT          DPD_BID_NAME(__dpd_gttd2,__bid_gttd2)
349 #define DFP_LE          DPD_BID_NAME(__dpd_letd2,__bid_letd2)
350 #define DFP_GE          DPD_BID_NAME(__dpd_getd2,__bid_getd2)
351 #define DFP_UNORD       DPD_BID_NAME(__dpd_unordtd2,__bid_unordtd2)
352 #endif
353
354 /* Names of decNumber functions for DPD arithmetic.  */
355
356 #if WIDTH == 32
357 #define decFloat                decDouble
358 #define DFP_BINARY_OP           d32_binary_op
359 #define DFP_COMPARE_OP          d32_compare_op
360 #define DEC_FLOAT_ADD           decDoubleAdd
361 #define DEC_FLOAT_SUBTRACT      decDoubleSubtract
362 #define DEC_FLOAT_MULTIPLY      decDoubleMultiply
363 #define DEC_FLOAT_DIVIDE        decDoubleDivide
364 #define DEC_FLOAT_COMPARE       decDoubleCompare
365 #define DEC_FLOAT_IS_ZERO       decDoubleIsZero
366 #define DEC_FLOAT_IS_NAN        decDoubleIsNaN
367 #define DEC_FLOAT_IS_SIGNED     decDoubleIsSigned
368 #elif WIDTH == 64
369 #define DFP_BINARY_OP           dnn_binary_op
370 #define DFP_COMPARE_OP          dnn_compare_op
371 #define decFloat                decDouble
372 #define DEC_FLOAT_ADD           decDoubleAdd
373 #define DEC_FLOAT_SUBTRACT      decDoubleSubtract
374 #define DEC_FLOAT_MULTIPLY      decDoubleMultiply
375 #define DEC_FLOAT_DIVIDE        decDoubleDivide
376 #define DEC_FLOAT_COMPARE       decDoubleCompare
377 #define DEC_FLOAT_IS_ZERO       decDoubleIsZero
378 #define DEC_FLOAT_IS_NAN        decDoubleIsNaN
379 #define DEC_FLOAT_IS_SIGNED     decDoubleIsSigned
380 #elif WIDTH == 128
381 #define DFP_BINARY_OP           dnn_binary_op
382 #define DFP_COMPARE_OP          dnn_compare_op
383 #define decFloat                decQuad
384 #define DEC_FLOAT_ADD           decQuadAdd
385 #define DEC_FLOAT_SUBTRACT      decQuadSubtract
386 #define DEC_FLOAT_MULTIPLY      decQuadMultiply
387 #define DEC_FLOAT_DIVIDE        decQuadDivide
388 #define DEC_FLOAT_COMPARE       decQuadCompare
389 #define DEC_FLOAT_IS_ZERO       decQuadIsZero
390 #define DEC_FLOAT_IS_NAN        decQuadIsNaN
391 #define DEC_FLOAT_IS_SIGNED     decQuadIsSigned
392 #endif
393
394 /* Names of functions to convert between different decimal float types.  */
395
396 #if WIDTH == 32
397 #if WIDTH_TO == 64
398 #define DFP_TO_DFP      DPD_BID_NAME(__dpd_extendsddd2,__bid_extendsddd2)
399 #elif WIDTH_TO == 128
400 #define DFP_TO_DFP      DPD_BID_NAME(__dpd_extendsdtd2,__bid_extendsdtd2)
401 #endif
402 #elif WIDTH == 64       
403 #if WIDTH_TO == 32
404 #define DFP_TO_DFP      DPD_BID_NAME(__dpd_truncddsd2,__bid_truncddsd2)
405 #elif WIDTH_TO == 128
406 #define DFP_TO_DFP      DPD_BID_NAME(__dpd_extendddtd2,__bid_extendddtd2)
407 #endif
408 #elif WIDTH == 128
409 #if WIDTH_TO == 32
410 #define DFP_TO_DFP      DPD_BID_NAME(__dpd_trunctdsd2,__bid_trunctdsd2)
411 #elif WIDTH_TO == 64
412 #define DFP_TO_DFP      DPD_BID_NAME(__dpd_trunctddd2,__bid_trunctddd2)
413 #endif
414 #endif
415
416 /* Names of functions to convert between decimal float and integers.  */
417
418 #if WIDTH == 32
419 #if INT_KIND == 1
420 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatsisd,__bid_floatsisd)
421 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixsdsi,__bid_fixsdsi)
422 #define DEC_FLOAT_FROM_INT decDoubleFromInt32
423 #define DEC_FLOAT_TO_INT   decDoubleToInt32
424 #elif INT_KIND == 2
425 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatdisd,__bid_floatdisd)
426 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixsddi,__bid_fixsddi)
427 #elif INT_KIND == 3
428 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatunssisd,__bid_floatunssisd)
429 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixunssdsi,__bid_fixunssdsi)
430 #define DEC_FLOAT_FROM_INT decDoubleFromUInt32
431 #define DEC_FLOAT_TO_INT   decDoubleToUInt32
432 #elif INT_KIND == 4
433 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatunsdisd,__bid_floatunsdisd)
434 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixunssddi,__bid_fixunssddi)
435 #endif
436 #elif WIDTH == 64
437 #define decFloat        decDouble
438 #if INT_KIND == 1
439 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatsidd,__bid_floatsidd)
440 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixddsi,__bid_fixddsi)
441 #define DEC_FLOAT_FROM_INT decDoubleFromInt32
442 #define DEC_FLOAT_TO_INT   decDoubleToInt32
443 #elif INT_KIND == 2
444 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatdidd,__bid_floatdidd)
445 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixdddi,__bid_fixdddi)
446 #elif INT_KIND == 3
447 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatunssidd,__bid_floatunssidd)
448 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixunsddsi,__bid_fixunsddsi)
449 #define DEC_FLOAT_FROM_INT decDoubleFromUInt32
450 #define DEC_FLOAT_TO_INT   decDoubleToUInt32
451 #elif INT_KIND == 4
452 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatunsdidd,__bid_floatunsdidd)
453 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixunsdddi,__bid_fixunsdddi)
454 #endif
455 #elif WIDTH == 128
456 #define decFloat        decQuad
457 #if INT_KIND == 1
458 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatsitd,__bid_floatsitd)
459 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixtdsi,__bid_fixtdsi)
460 #define DEC_FLOAT_FROM_INT decQuadFromInt32
461 #define DEC_FLOAT_TO_INT   decQuadToInt32
462 #elif INT_KIND == 2
463 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatditd,__bid_floatditd)
464 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixtddi,__bid_fixtddi)
465 #elif INT_KIND == 3
466 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatunssitd,__bid_floatunssitd)
467 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixunstdsi,__bid_fixunstdsi)
468 #define DEC_FLOAT_FROM_INT decQuadFromUInt32
469 #define DEC_FLOAT_TO_INT   decQuadToUInt32
470 #elif INT_KIND == 4
471 #define INT_TO_DFP      DPD_BID_NAME(__dpd_floatunsditd,__bid_floatunsditd)
472 #define DFP_TO_INT      DPD_BID_NAME(__dpd_fixunstddi,__bid_fixunstddi)
473 #endif
474 #endif
475
476 /* Names of functions to convert between decimal float and binary float.  */
477
478 #if WIDTH == 32
479 #if BFP_KIND == 1
480 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extendsfsd,__bid_extendsfsd)
481 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_truncsdsf,__bid_truncsdsf)
482 #elif BFP_KIND == 2
483 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_truncdfsd,__bid_truncdfsd)
484 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_extendsddf,__bid_extendsddf)
485 #elif BFP_KIND == 3
486 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_truncxfsd,__bid_truncxfsd)
487 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_extendsdxf,__bid_extendsdxf)
488 #elif BFP_KIND == 4
489 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_trunctfsd,__bid_trunctfsd)
490 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_extendsdtf,__bid_extendsdtf)
491 #endif /* BFP_KIND */
492
493 #elif WIDTH == 64
494 #if BFP_KIND == 1
495 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extendsfdd,__bid_extendsfdd)
496 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_truncddsf,__bid_truncddsf)
497 #elif BFP_KIND == 2
498 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extenddfdd,__bid_extenddfdd)
499 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_truncdddf,__bid_truncdddf)
500 #elif BFP_KIND == 3
501 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_truncxfdd,__bid_truncxfdd)
502 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_extendddxf,__bid_extendddxf)
503 #elif BFP_KIND == 4
504 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_trunctfdd,__bid_trunctfdd)
505 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_extendddtf,__bid_extendddtf)
506 #endif /* BFP_KIND */
507
508 #elif WIDTH == 128
509 #if BFP_KIND == 1
510 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extendsftd,__bid_extendsftd)
511 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_trunctdsf,__bid_trunctdsf)
512 #elif BFP_KIND == 2
513 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extenddftd,__bid_extenddftd)
514 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_trunctddf,__bid_trunctddf)
515 #elif BFP_KIND == 3
516 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extendxftd,__bid_extendxftd)
517 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_trunctdxf,__bid_trunctdxf)
518 #elif BFP_KIND == 4
519 #define BFP_TO_DFP      DPD_BID_NAME(__dpd_extendtftd,__bid_extendtftd)
520 #define DFP_TO_BFP      DPD_BID_NAME(__dpd_trunctdtf,__bid_trunctdtf)
521 #endif /* BFP_KIND */
522
523 #endif /* WIDTH */
524
525 /* Some handy typedefs.  */
526
527 typedef float SFtype __attribute__ ((mode (SF)));
528 typedef float DFtype __attribute__ ((mode (DF)));
529 #if LONG_DOUBLE_HAS_XF_MODE
530 typedef float XFtype __attribute__ ((mode (XF)));
531 #endif /* LONG_DOUBLE_HAS_XF_MODE */
532 #if LONG_DOUBLE_HAS_TF_MODE
533 typedef float TFtype __attribute__ ((mode (TF)));
534 #endif /* LONG_DOUBLE_HAS_TF_MODE */
535
536 typedef int SItype __attribute__ ((mode (SI)));
537 typedef int DItype __attribute__ ((mode (DI)));
538 typedef unsigned int USItype __attribute__ ((mode (SI)));
539 typedef unsigned int UDItype __attribute__ ((mode (DI)));
540
541 /* The type of the result of a decimal float comparison.  This must
542    match `__libgcc_cmp_return__' in GCC for the target.  */
543
544 typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
545
546 /* Prototypes.  */
547
548 #if defined (L_mul_sd) || defined (L_mul_dd) || defined (L_mul_td)
549 extern DFP_C_TYPE DFP_MULTIPLY (DFP_C_TYPE, DFP_C_TYPE);
550 #endif
551
552 #if defined (L_div_sd) || defined (L_div_dd) || defined (L_div_td)
553 extern DFP_C_TYPE DFP_DIVIDE (DFP_C_TYPE, DFP_C_TYPE);
554 #endif
555
556 #if defined (L_addsub_sd) || defined (L_addsub_dd) || defined (L_addsub_td)
557 extern DFP_C_TYPE DFP_ADD (DFP_C_TYPE, DFP_C_TYPE);
558 extern DFP_C_TYPE DFP_SUB (DFP_C_TYPE, DFP_C_TYPE);
559 #endif
560
561 #if defined (L_eq_sd) || defined (L_eq_dd) || defined (L_eq_td)
562 extern CMPtype DFP_EQ (DFP_C_TYPE, DFP_C_TYPE);
563 #endif
564
565 #if defined (L_ne_sd) || defined (L_ne_dd) || defined (L_ne_td)
566 extern CMPtype DFP_NE (DFP_C_TYPE, DFP_C_TYPE);
567 #endif
568
569 #if defined (L_lt_sd) || defined (L_lt_dd) || defined (L_lt_td)
570 extern CMPtype DFP_LT (DFP_C_TYPE, DFP_C_TYPE);
571 #endif
572
573 #if defined (L_gt_sd) || defined (L_gt_dd) || defined (L_gt_td)
574 extern CMPtype DFP_GT (DFP_C_TYPE, DFP_C_TYPE);
575 #endif
576
577 #if defined (L_le_sd) || defined (L_le_dd) || defined (L_le_td)
578 extern CMPtype DFP_LE (DFP_C_TYPE, DFP_C_TYPE);
579 #endif
580
581 #if defined (L_ge_sd) || defined (L_ge_dd) || defined (L_ge_td)
582 extern CMPtype DFP_GE (DFP_C_TYPE, DFP_C_TYPE);
583 #endif
584
585 #if defined (L_unord_sd) || defined (L_unord_dd) || defined (L_unord_td)
586 extern CMPtype DFP_UNORD (DFP_C_TYPE, DFP_C_TYPE);
587 #endif
588
589 #if defined (L_sd_to_dd) || defined (L_sd_to_td) || defined (L_dd_to_sd) \
590  || defined (L_dd_to_td) || defined (L_td_to_sd) || defined (L_td_to_dd)
591 extern DFP_C_TYPE_TO DFP_TO_DFP (DFP_C_TYPE);
592 #endif
593
594 #if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \
595  || defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \
596  || defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \
597  || defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi)
598 extern INT_TYPE DFP_TO_INT (DFP_C_TYPE);
599 #endif
600
601 #if defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) \
602  || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) \
603  || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) \
604  || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td)
605 extern DFP_C_TYPE INT_TO_DFP (INT_TYPE);
606 #endif
607
608 #if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \
609  || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \
610  || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \
611      && LONG_DOUBLE_HAS_XF_MODE) \
612  || ((defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf)) \
613      && LONG_DOUBLE_HAS_TF_MODE)
614 extern BFP_TYPE DFP_TO_BFP (DFP_C_TYPE);
615 #endif
616
617 #if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \
618  || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \
619  || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \
620      && LONG_DOUBLE_HAS_XF_MODE) \
621  || ((defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)) \
622      && LONG_DOUBLE_HAS_TF_MODE)
623 extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE);
624 #endif
625
626 #endif /* _DFPBIT_H */