]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/dfp-bit.h
updat_bb_profile_for_threading TLC
[thirdparty/gcc.git] / libgcc / dfp-bit.h
CommitLineData
2d8d5935 1/* Header file for dfp-bit.c.
83ffe9cd 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
2d8d5935
RO
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16Under Section 7 of GPL version 3, you are granted additional
17permissions described in the GCC Runtime Library Exception, version
183.1, as published by the Free Software Foundation.
19
20You should have received a copy of the GNU General Public License and
21a copy of the GCC Runtime Library Exception along with this program;
22see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23<http://www.gnu.org/licenses/>. */
24
25#ifndef _DFPBIT_H
26#define _DFPBIT_H
27
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"
852b75ed 35#include "libgcc_tm.h"
2d8d5935 36
2d8d5935
RO
37/* We need to know the size of long double that the C library supports.
38 Don't use LIBGCC2_HAS_XF_MODE or LIBGCC2_HAS_TF_MODE here because
39 some targets set both of those. */
40
9a79452d
JM
41#ifndef __LIBGCC_XF_MANT_DIG__
42#define __LIBGCC_XF_MANT_DIG__ 0
43#endif
2d8d5935 44#define LONG_DOUBLE_HAS_XF_MODE \
9a79452d 45 (__LDBL_MANT_DIG__ == __LIBGCC_XF_MANT_DIG__)
2d8d5935 46
9a79452d
JM
47#ifndef __LIBGCC_TF_MANT_DIG__
48#define __LIBGCC_TF_MANT_DIG__ 0
49#endif
2d8d5935 50#define LONG_DOUBLE_HAS_TF_MODE \
9a79452d 51 (__LDBL_MANT_DIG__ == __LIBGCC_TF_MANT_DIG__)
2d8d5935
RO
52
53/* Depending on WIDTH, define a number of macros:
54
55 DFP_C_TYPE: type of the arguments to the libgcc functions;
56 (eg _Decimal32)
57
58 IEEE_TYPE: the corresponding (encoded) IEEE754 type;
59 (eg decimal32)
60
61 TO_INTERNAL: the name of the decNumber function to convert an
62 encoded value into the decNumber internal representation;
63
64 TO_ENCODED: the name of the decNumber function to convert an
65 internally represented decNumber into the encoded
66 representation.
67
68 FROM_STRING: the name of the decNumber function to read an
69 encoded value from a string.
70
71 TO_STRING: the name of the decNumber function to write an
72 encoded value to a string. */
73
74#if WIDTH == 32
75#define DFP_C_TYPE _Decimal32
76#define IEEE_TYPE decimal32
77#define HOST_TO_IEEE __host_to_ieee_32
78#define IEEE_TO_HOST __ieee_to_host_32
79#define TO_INTERNAL __decimal32ToNumber
80#define TO_ENCODED __decimal32FromNumber
81#define FROM_STRING __decimal32FromString
82#define TO_STRING __decimal32ToString
83#elif WIDTH == 64
84#define DFP_C_TYPE _Decimal64
85#define IEEE_TYPE decimal64
86#define HOST_TO_IEEE __host_to_ieee_64
87#define IEEE_TO_HOST __ieee_to_host_64
88#define TO_INTERNAL __decimal64ToNumber
89#define TO_ENCODED __decimal64FromNumber
90#define FROM_STRING __decimal64FromString
91#define TO_STRING __decimal64ToString
92#elif WIDTH == 128
93#define DFP_C_TYPE _Decimal128
94#define IEEE_TYPE decimal128
95#define HOST_TO_IEEE __host_to_ieee_128
96#define IEEE_TO_HOST __ieee_to_host_128
97#define TO_INTERNAL __decimal128ToNumber
98#define TO_ENCODED __decimal128FromNumber
99#define FROM_STRING __decimal128FromString
100#define TO_STRING __decimal128ToString
101#else
102#error invalid decimal float word width
103#endif
104
105/* We define __DEC_EVAL_METHOD__ to 2, saying that we evaluate all
106 operations and constants to the range and precision of the _Decimal128
107 type. Make it so. */
108#if WIDTH == 32
109#define CONTEXT_INIT DEC_INIT_DECIMAL32
110#elif WIDTH == 64
111#define CONTEXT_INIT DEC_INIT_DECIMAL64
112#elif WIDTH == 128
113#define CONTEXT_INIT DEC_INIT_DECIMAL128
114#endif
115
116#ifndef DFP_INIT_ROUNDMODE
117#define DFP_INIT_ROUNDMODE(A) A = DEC_ROUND_HALF_EVEN
118#endif
119
120#ifdef DFP_EXCEPTIONS_ENABLED
121/* Return IEEE exception flags based on decNumber status flags. */
122#define DFP_IEEE_FLAGS(DEC_FLAGS) __extension__ \
123({int _fe_flags = 0; \
124 if ((dec_flags & DEC_IEEE_854_Division_by_zero) != 0) \
125 _fe_flags |= FE_DIVBYZERO; \
126 if ((dec_flags & DEC_IEEE_854_Inexact) != 0) \
127 _fe_flags |= FE_INEXACT; \
128 if ((dec_flags & DEC_IEEE_854_Invalid_operation) != 0) \
129 _fe_flags |= FE_INVALID; \
130 if ((dec_flags & DEC_IEEE_854_Overflow) != 0) \
131 _fe_flags |= FE_OVERFLOW; \
132 if ((dec_flags & DEC_IEEE_854_Underflow) != 0) \
133 _fe_flags |= FE_UNDERFLOW; \
134 _fe_flags; })
135#else
136#define DFP_EXCEPTIONS_ENABLED 0
137#define DFP_IEEE_FLAGS(A) 0
138#define DFP_HANDLE_EXCEPTIONS(A) do {} while (0)
139#endif
140
141/* Conversions between different decimal float types use WIDTH_TO to
142 determine additional macros to define. */
143
144#if defined (L_dd_to_sd) || defined (L_td_to_sd)
145#define WIDTH_TO 32
146#elif defined (L_sd_to_dd) || defined (L_td_to_dd)
147#define WIDTH_TO 64
148#elif defined (L_sd_to_td) || defined (L_dd_to_td)
149#define WIDTH_TO 128
150#endif
151
152/* If WIDTH_TO is defined, define additional macros:
153
154 DFP_C_TYPE_TO: type of the result of dfp to dfp conversion.
155
156 IEEE_TYPE_TO: the corresponding (encoded) IEEE754 type.
157
158 TO_ENCODED_TO: the name of the decNumber function to convert an
159 internally represented decNumber into the encoded representation
160 for the destination. */
161
162#if WIDTH_TO == 32
163#define DFP_C_TYPE_TO _Decimal32
164#define IEEE_TYPE_TO decimal32
165#define TO_ENCODED_TO __decimal32FromNumber
166#define IEEE_TO_HOST_TO __ieee_to_host_32
167#elif WIDTH_TO == 64
168#define DFP_C_TYPE_TO _Decimal64
169#define IEEE_TYPE_TO decimal64
170#define TO_ENCODED_TO __decimal64FromNumber
171#define IEEE_TO_HOST_TO __ieee_to_host_64
172#elif WIDTH_TO == 128
173#define DFP_C_TYPE_TO _Decimal128
174#define IEEE_TYPE_TO decimal128
175#define TO_ENCODED_TO __decimal128FromNumber
176#define IEEE_TO_HOST_TO __ieee_to_host_128
177#endif
178
179/* Conversions between decimal float types and integral types use INT_KIND
180 to determine the data type and C functions to use. */
181
182#if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \
183 || defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td)
184#define INT_KIND 1
185#elif defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \
186 || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td)
187#define INT_KIND 2
188#elif defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \
189 || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td)
190#define INT_KIND 3
191#elif defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) \
192 || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td)
193#define INT_KIND 4
194#endif
195
196/* If INT_KIND is defined, define additional macros:
197
198 INT_TYPE: The integer data type.
199
200 INT_FMT: The format string for writing the integer to a string.
201
202 CAST_FOR_FMT: Cast variable of INT_KIND to C type for sprintf.
203 This works for ILP32 and LP64, won't for other type size systems.
204
205 STR_TO_INT: The function to read the integer from a string. */
206
207#if INT_KIND == 1
208#define INT_TYPE SItype
209#define INT_FMT "%d"
210#define CAST_FOR_FMT(A) (int)A
211#define STR_TO_INT strtol
212#elif INT_KIND == 2
213#define INT_TYPE DItype
214#define INT_FMT "%lld"
215#define CAST_FOR_FMT(A) (long long)A
216#define STR_TO_INT strtoll
217#elif INT_KIND == 3
218#define INT_TYPE USItype
219#define INT_FMT "%u"
220#define CAST_FOR_FMT(A) (unsigned int)A
221#define STR_TO_INT strtoul
222#elif INT_KIND == 4
223#define INT_TYPE UDItype
224#define INT_FMT "%llu"
225#define CAST_FOR_FMT(A) (unsigned long long)A
226#define STR_TO_INT strtoull
227#endif
228
229/* Conversions between decimal float types and binary float types use
230 BFP_KIND to determine the data type and C functions to use. */
231
232#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \
233 || defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td)
234#define BFP_KIND 1
235#elif defined (L_sd_to_df) || defined (L_dd_to_df ) || defined (L_td_to_df) \
236 || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td)
237#define BFP_KIND 2
238#elif defined (L_sd_to_xf) || defined (L_dd_to_xf ) || defined (L_td_to_xf) \
239 || defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)
240#define BFP_KIND 3
241#elif defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf) \
242 || defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)
243#define BFP_KIND 4
78118359
MM
244#elif defined (L_sd_to_kf) || defined (L_dd_to_kf) || defined (L_td_to_kf) \
245 || defined (L_kf_to_sd) || defined (L_kf_to_dd) || defined (L_kf_to_td)
246#define BFP_KIND 5
2d8d5935
RO
247#endif
248
249/* If BFP_KIND is defined, define additional macros:
250
251 BFP_TYPE: The binary floating point data type.
252
253 BFP_FMT: The format string for writing the value to a string.
254 The number of decimal digits printed is
255 ceil (nbits / log2 (10.) + 1)
256 as described in David Matula's CACM 19(3) 716-723 June 1968 paper.
257
258 BFP_VIA_TYPE: Type to which to cast a variable of BPF_TYPE for a
259 call to sprintf.
260
261 STR_TO_BFP: The function to read the value from a string. */
262
263#if BFP_KIND == 1
264#define BFP_TYPE SFtype
265#define BFP_FMT "%.9e"
266#define BFP_VIA_TYPE double
267#define STR_TO_BFP strtof
268
269#elif BFP_KIND == 2
270#define BFP_TYPE DFtype
271#define BFP_FMT "%.17e"
272#define BFP_VIA_TYPE double
273#define STR_TO_BFP strtod
274
275#elif BFP_KIND == 3
276#if LONG_DOUBLE_HAS_XF_MODE
277#define BFP_TYPE XFtype
278#define BFP_FMT "%.21Le"
279#define BFP_VIA_TYPE long double
280#define STR_TO_BFP strtold
281#endif /* LONG_DOUBLE_HAS_XF_MODE */
282
283#elif BFP_KIND == 4
284#if LONG_DOUBLE_HAS_TF_MODE
285#define BFP_TYPE TFtype
286#if LDBL_MANT_DIG == 106
287#define BFP_FMT "%.33Le"
288#elif LDBL_MANT_DIG == 113
289#define BFP_FMT "%.36Le"
290#else
291#error "unknown long double size, cannot define BFP_FMT"
292#endif /* LDBL_MANT_DIG */
293#define STR_TO_BFP strtold
294#define BFP_VIA_TYPE long double
295#endif /* LONG_DOUBLE_HAS_TF_MODE */
296
78118359
MM
297#elif BFP_KIND == 5
298#define BFP_TYPE _Float128
299#define BFP_FMT "%.36Le"
300#define BFP_VIA_TYPE _Float128
645bfc16
MM
301#define STR_TO_BFP __strtoieee128
302extern _Float128 __strtoieee128 (const char *, char **);
78118359 303
2d8d5935
RO
304#endif /* BFP_KIND */
305
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"
319
320/* Names of arithmetic functions. */
321
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
327
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
365
366/* Names of decNumber functions for DPD arithmetic. */
367
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
405
406/* Names of functions to convert between different decimal float types. */
407
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
427
428/* Names of functions to convert between decimal float and integers. */
429
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
487
488/* Names of functions to convert between decimal float and binary float. */
489
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)
78118359
MM
503#elif BFP_KIND == 5
504#define BFP_TO_DFP DPD_BID_NAME(__dpd_trunckfsd,__bid_trunckfsd)
505#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsdkf,__bid_extendsdkf)
2d8d5935
RO
506#endif /* BFP_KIND */
507
508#elif WIDTH == 64
509#if BFP_KIND == 1
510#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsfdd,__bid_extendsfdd)
511#define DFP_TO_BFP DPD_BID_NAME(__dpd_truncddsf,__bid_truncddsf)
512#elif BFP_KIND == 2
513#define BFP_TO_DFP DPD_BID_NAME(__dpd_extenddfdd,__bid_extenddfdd)
514#define DFP_TO_BFP DPD_BID_NAME(__dpd_truncdddf,__bid_truncdddf)
515#elif BFP_KIND == 3
516#define BFP_TO_DFP DPD_BID_NAME(__dpd_truncxfdd,__bid_truncxfdd)
517#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddxf,__bid_extendddxf)
518#elif BFP_KIND == 4
519#define BFP_TO_DFP DPD_BID_NAME(__dpd_trunctfdd,__bid_trunctfdd)
520#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddtf,__bid_extendddtf)
78118359
MM
521#elif BFP_KIND == 5
522#define BFP_TO_DFP DPD_BID_NAME(__dpd_trunckfdd,__bid_trunckfdd)
523#define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddkf,__bid_extendddkf)
2d8d5935
RO
524#endif /* BFP_KIND */
525
526#elif WIDTH == 128
527#if BFP_KIND == 1
528#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsftd,__bid_extendsftd)
529#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdsf,__bid_trunctdsf)
530#elif BFP_KIND == 2
531#define BFP_TO_DFP DPD_BID_NAME(__dpd_extenddftd,__bid_extenddftd)
532#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctddf,__bid_trunctddf)
533#elif BFP_KIND == 3
534#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendxftd,__bid_extendxftd)
535#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdxf,__bid_trunctdxf)
536#elif BFP_KIND == 4
537#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendtftd,__bid_extendtftd)
538#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdtf,__bid_trunctdtf)
78118359
MM
539#elif BFP_KIND == 5
540#define BFP_TO_DFP DPD_BID_NAME(__dpd_extendkftd,__bid_extendkftd)
541#define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdkf,__bid_trunctdkf)
2d8d5935
RO
542#endif /* BFP_KIND */
543
544#endif /* WIDTH */
545
546/* Some handy typedefs. */
547
548typedef float SFtype __attribute__ ((mode (SF)));
549typedef float DFtype __attribute__ ((mode (DF)));
550#if LONG_DOUBLE_HAS_XF_MODE
551typedef float XFtype __attribute__ ((mode (XF)));
552#endif /* LONG_DOUBLE_HAS_XF_MODE */
553#if LONG_DOUBLE_HAS_TF_MODE
554typedef float TFtype __attribute__ ((mode (TF)));
555#endif /* LONG_DOUBLE_HAS_TF_MODE */
556
557typedef int SItype __attribute__ ((mode (SI)));
558typedef int DItype __attribute__ ((mode (DI)));
559typedef unsigned int USItype __attribute__ ((mode (SI)));
560typedef unsigned int UDItype __attribute__ ((mode (DI)));
561
562/* The type of the result of a decimal float comparison. This must
563 match `__libgcc_cmp_return__' in GCC for the target. */
564
565typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
566
567/* Prototypes. */
568
569#if defined (L_mul_sd) || defined (L_mul_dd) || defined (L_mul_td)
570extern DFP_C_TYPE DFP_MULTIPLY (DFP_C_TYPE, DFP_C_TYPE);
571#endif
572
573#if defined (L_div_sd) || defined (L_div_dd) || defined (L_div_td)
574extern DFP_C_TYPE DFP_DIVIDE (DFP_C_TYPE, DFP_C_TYPE);
575#endif
576
577#if defined (L_addsub_sd) || defined (L_addsub_dd) || defined (L_addsub_td)
578extern DFP_C_TYPE DFP_ADD (DFP_C_TYPE, DFP_C_TYPE);
579extern DFP_C_TYPE DFP_SUB (DFP_C_TYPE, DFP_C_TYPE);
580#endif
581
582#if defined (L_eq_sd) || defined (L_eq_dd) || defined (L_eq_td)
583extern CMPtype DFP_EQ (DFP_C_TYPE, DFP_C_TYPE);
584#endif
585
586#if defined (L_ne_sd) || defined (L_ne_dd) || defined (L_ne_td)
587extern CMPtype DFP_NE (DFP_C_TYPE, DFP_C_TYPE);
588#endif
589
590#if defined (L_lt_sd) || defined (L_lt_dd) || defined (L_lt_td)
591extern CMPtype DFP_LT (DFP_C_TYPE, DFP_C_TYPE);
592#endif
593
594#if defined (L_gt_sd) || defined (L_gt_dd) || defined (L_gt_td)
595extern CMPtype DFP_GT (DFP_C_TYPE, DFP_C_TYPE);
596#endif
597
598#if defined (L_le_sd) || defined (L_le_dd) || defined (L_le_td)
599extern CMPtype DFP_LE (DFP_C_TYPE, DFP_C_TYPE);
600#endif
601
602#if defined (L_ge_sd) || defined (L_ge_dd) || defined (L_ge_td)
603extern CMPtype DFP_GE (DFP_C_TYPE, DFP_C_TYPE);
604#endif
605
606#if defined (L_unord_sd) || defined (L_unord_dd) || defined (L_unord_td)
607extern CMPtype DFP_UNORD (DFP_C_TYPE, DFP_C_TYPE);
608#endif
609
610#if defined (L_sd_to_dd) || defined (L_sd_to_td) || defined (L_dd_to_sd) \
611 || defined (L_dd_to_td) || defined (L_td_to_sd) || defined (L_td_to_dd)
612extern DFP_C_TYPE_TO DFP_TO_DFP (DFP_C_TYPE);
613#endif
614
615#if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \
616 || defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \
617 || defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \
618 || defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi)
619extern INT_TYPE DFP_TO_INT (DFP_C_TYPE);
620#endif
621
622#if defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) \
623 || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) \
624 || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) \
625 || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td)
626extern DFP_C_TYPE INT_TO_DFP (INT_TYPE);
627#endif
628
629#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \
630 || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \
78118359 631 || defined (L_sd_to_kf) || defined (L_dd_to_kf) || defined (L_td_to_kf) \
2d8d5935
RO
632 || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \
633 && LONG_DOUBLE_HAS_XF_MODE) \
634 || ((defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf)) \
635 && LONG_DOUBLE_HAS_TF_MODE)
636extern BFP_TYPE DFP_TO_BFP (DFP_C_TYPE);
637#endif
638
639#if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \
640 || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \
641 || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \
642 && LONG_DOUBLE_HAS_XF_MODE) \
643 || ((defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)) \
644 && LONG_DOUBLE_HAS_TF_MODE)
645extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE);
78118359
MM
646#define BFP_SPRINTF sprintf
647
648#elif defined (L_kf_to_sd) || defined (L_kf_to_dd) || defined (L_kf_to_td)
649extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE);
645bfc16
MM
650extern int __sprintfieee128 (char *restrict, const char *restrict, ...);
651#define BFP_SPRINTF __sprintfieee128
2d8d5935
RO
652#endif
653
654#endif /* _DFPBIT_H */