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