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