OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [config/] [dfp-bit.h] - Blame information for rev 282

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.