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