OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [dfp-bit.h] - Blame information for rev 307

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

Line No. Rev Author Line
1 38 julius
/* Header file for dfp-bit.c.
2
   Copyright (C) 2005, 2006 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 2, or (at your option) any later
9
version.
10
 
11
In addition to the permissions in the GNU General Public License, the
12
Free Software Foundation gives you unlimited permission to link the
13
compiled version of this file into combinations with other programs,
14
and to distribute those combinations without any restriction coming
15
from the use of this file.  (The General Public License restrictions
16
do apply in other respects; for example, they cover modification of
17
the file, and distribution when not linked into a combine
18
executable.)
19
 
20
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
21
WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
for more details.
24
 
25
You should have received a copy of the GNU General Public License
26
along with GCC; see the file COPYING.  If not, write to the Free
27
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
28
02110-1301, USA.  */
29
 
30
#ifndef _DFPBIT_H
31
#define _DFPBIT_H
32
 
33
#include "tconfig.h"
34
#include "coretypes.h"
35
#include "tm.h"
36
 
37
#ifndef LIBGCC2_WORDS_BIG_ENDIAN
38
#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
39
#endif
40
 
41
#ifndef LIBGCC2_FLOAT_WORDS_BIG_ENDIAN
42
#define LIBGCC2_FLOAT_WORDS_BIG_ENDIAN LIBGCC2_WORDS_BIG_ENDIAN
43
#endif
44
 
45
#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
46
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
47
#endif
48
 
49
#ifndef LIBGCC2_HAS_XF_MODE
50
#define LIBGCC2_HAS_XF_MODE \
51
  (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
52
#endif
53
 
54
/* Depending on WIDTH, define a number of macros:
55
 
56
   DFP_C_TYPE: type of the arguments to the libgcc functions;
57
        (eg _Decimal32)
58
 
59
   IEEE_TYPE: the corresponding (encoded) IEEE754R type;
60
        (eg decimal32)
61
 
62
   TO_INTERNAL: the name of the decNumber function to convert an
63
   encoded value into the decNumber internal representation;
64
 
65
   TO_ENCODED: the name of the decNumber function to convert an
66
   internally represented decNumber into the encoded
67
   representation.
68
 
69
   FROM_STRING: the name of the decNumber function to read an
70
   encoded value from a string.
71
 
72
   TO_STRING: the name of the decNumber function to write an
73
   encoded value to a string.  */
74
 
75
#if WIDTH == 32
76
#define DFP_C_TYPE      _Decimal32
77
#define IEEE_TYPE       decimal32
78
#define HOST_TO_IEEE    __host_to_ieee_32
79
#define IEEE_TO_HOST    __ieee_to_host_32
80
#define TO_INTERNAL     __decimal32ToNumber
81
#define TO_ENCODED      __decimal32FromNumber
82
#define FROM_STRING     __decimal32FromString
83
#define TO_STRING       __decimal32ToString
84
#elif WIDTH == 64
85
#define DFP_C_TYPE      _Decimal64
86
#define IEEE_TYPE       decimal64
87
#define HOST_TO_IEEE    __host_to_ieee_64
88
#define IEEE_TO_HOST    __ieee_to_host_64
89
#define TO_INTERNAL     __decimal64ToNumber
90
#define TO_ENCODED      __decimal64FromNumber
91
#define FROM_STRING     __decimal64FromString
92
#define TO_STRING       __decimal64ToString
93
#elif WIDTH == 128
94
#define DFP_C_TYPE      _Decimal128
95
#define IEEE_TYPE       decimal128
96
#define HOST_TO_IEEE    __host_to_ieee_128
97
#define IEEE_TO_HOST    __ieee_to_host_128
98
#define TO_INTERNAL     __decimal128ToNumber
99
#define TO_ENCODED      __decimal128FromNumber
100
#define FROM_STRING     __decimal128FromString
101
#define TO_STRING       __decimal128ToString
102
#else
103
#error invalid decimal float word width
104
#endif
105
 
106
/* We define __DEC_EVAL_METHOD__ to 2, saying that we evaluate all
107
   operations and constants to the range and precision of the _Decimal128
108
   type.  Make it so.  */
109
#if WIDTH == 32
110
#define CONTEXT_INIT DEC_INIT_DECIMAL32
111
#elif WIDTH == 64
112
#define CONTEXT_INIT DEC_INIT_DECIMAL64
113
#elif WIDTH == 128
114
#define CONTEXT_INIT DEC_INIT_DECIMAL128
115
#endif
116
 
117
/* Define CONTEXT_ROUND to obtain the current decNumber rounding mode.  */
118
extern enum rounding    __decGetRound (void);
119
#define CONTEXT_ROUND   __decGetRound ()
120
 
121
extern int __dfp_traps;
122
#define CONTEXT_TRAPS   __dfp_traps
123
#define CONTEXT_ERRORS(context) context.status & DEC_Errors
124
extern void __dfp_raise (int);
125
#define DFP_RAISE(A)    __dfp_raise(A)
126
 
127
/* Conversions between different decimal float types use WIDTH_TO to
128
   determine additional macros to define.  */
129
 
130
#if defined (L_dd_to_sd) || defined (L_td_to_sd)
131
#define WIDTH_TO 32
132
#elif defined (L_sd_to_dd) || defined (L_td_to_dd)
133
#define WIDTH_TO 64
134
#elif defined (L_sd_to_td) || defined (L_dd_to_td)
135
#define WIDTH_TO 128
136
#endif
137
 
138
/* If WIDTH_TO is defined, define additional macros:
139
 
140
   DFP_C_TYPE_TO: type of the result of dfp to dfp conversion.
141
 
142
   IEEE_TYPE_TO: the corresponding (encoded) IEEE754R type.
143
 
144
   TO_ENCODED_TO: the name of the decNumber function to convert an
145
   internally represented decNumber into the encoded representation
146
   for the destination.  */
147
 
148
#if WIDTH_TO == 32
149
#define DFP_C_TYPE_TO   _Decimal32
150
#define IEEE_TYPE_TO    decimal32
151
#define TO_ENCODED_TO   __decimal32FromNumber
152
#define IEEE_TO_HOST_TO __ieee_to_host_32
153
#elif WIDTH_TO == 64
154
#define DFP_C_TYPE_TO   _Decimal64
155
#define IEEE_TYPE_TO    decimal64
156
#define TO_ENCODED_TO   __decimal64FromNumber
157
#define IEEE_TO_HOST_TO __ieee_to_host_64
158
#elif WIDTH_TO == 128
159
#define DFP_C_TYPE_TO   _Decimal128
160
#define IEEE_TYPE_TO    decimal128
161
#define TO_ENCODED_TO   __decimal128FromNumber
162
#define IEEE_TO_HOST_TO __ieee_to_host_128
163
#endif
164
 
165
/* Conversions between decimal float types and integral types use INT_KIND
166
   to determine the data type and C functions to use.  */
167
 
168
#if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si)  \
169
   || defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td)
170
#define INT_KIND 1
171
#elif defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \
172
   || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td)
173
#define INT_KIND 2
174
#elif defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \
175
   || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td)
176
#define INT_KIND 3
177
#elif defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) \
178
   || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td)
179
#define INT_KIND 4
180
#endif
181
 
182
/*  If INT_KIND is defined, define additional macros:
183
 
184
    INT_TYPE: The integer data type.
185
 
186
    INT_FMT: The format string for writing the integer to a string.
187
 
188
    CAST_FOR_FMT: Cast variable of INT_KIND to C type for sprintf.
189
    This works for ILP32 and LP64, won't for other type size systems.
190
 
191
    STR_TO_INT: The function to read the integer from a string.  */
192
 
193
#if INT_KIND == 1
194
#define INT_TYPE SItype
195
#define INT_FMT "%d"
196
#define CAST_FOR_FMT(A) (int)A
197
#define STR_TO_INT strtol
198
#elif INT_KIND == 2
199
#define INT_TYPE DItype
200
#define INT_FMT "%lld"
201
#define CAST_FOR_FMT(A) (long long)A
202
#define STR_TO_INT strtoll
203
#elif INT_KIND == 3
204
#define INT_TYPE USItype
205
#define INT_FMT "%u"
206
#define CAST_FOR_FMT(A) (unsigned int)A
207
#define STR_TO_INT strtoul
208
#elif INT_KIND == 4
209
#define INT_TYPE UDItype
210
#define INT_FMT "%llu"
211
#define CAST_FOR_FMT(A) (unsigned long long)A
212
#define STR_TO_INT strtoull
213
#endif
214
 
215
/* Conversions between decimal float types and binary float types use
216
   BFP_KIND to determine the data type and C functions to use.  */
217
 
218
#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \
219
 || defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td)
220
#define BFP_KIND 1
221
#elif defined (L_sd_to_df) || defined (L_dd_to_df ) || defined (L_td_to_df) \
222
 ||   defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td)
223
#define BFP_KIND 2
224
#elif defined (L_sd_to_xf) || defined (L_dd_to_xf ) || defined (L_td_to_xf) \
225
 ||   defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)
226
#define BFP_KIND 3
227
#endif
228
 
229
/*  If BFP_KIND is defined, define additional macros:
230
 
231
    BFP_TYPE: The binary floating point data type.
232
 
233
    BFP_FMT: The format string for writing the value to a string.
234
 
235
    STR_TO_BFP: The function to read the value from a string.  */
236
 
237
#if BFP_KIND == 1
238
/* strtof is declared in <stdlib.h> only for C99.  */
239
extern float strtof (const char *, char **);
240
#define BFP_TYPE SFtype
241
#define BFP_FMT "%e"
242
#define STR_TO_BFP strtof
243
 
244
#elif BFP_KIND == 2
245
#define BFP_TYPE DFtype
246
#define BFP_FMT "%e"
247
#define STR_TO_BFP strtod
248
 
249
#elif BFP_KIND == 3
250
#if LIBGCC2_HAS_XF_MODE
251
/* These aren't used if XF mode is not supported.  */
252
#define BFP_TYPE XFtype
253
#define BFP_FMT "%e"
254
#define BFP_VIA_TYPE double
255
#define STR_TO_BFP strtod
256
#endif
257
 
258
#endif /* BFP_KIND */
259
 
260
#if WIDTH == 128 || WIDTH_TO == 128
261
#include "decimal128.h"
262
#endif
263
#if WIDTH == 64 || WIDTH_TO == 64
264
#include "decimal64.h"
265
#endif
266
#if WIDTH == 32 || WIDTH_TO == 32
267
#include "decimal32.h"
268
#endif
269
#include "decNumber.h"
270
 
271
/* Names of arithmetic functions.  */
272
 
273
#if WIDTH == 32
274
#define DFP_ADD         __addsd3
275
#define DFP_SUB         __subsd3
276
#define DFP_MULTIPLY    __mulsd3
277
#define DFP_DIVIDE      __divsd3
278
#define DFP_EQ          __eqsd2
279
#define DFP_NE          __nesd2
280
#define DFP_LT          __ltsd2
281
#define DFP_GT          __gtsd2
282
#define DFP_LE          __lesd2
283
#define DFP_GE          __gesd2
284
#define DFP_UNORD       __unordsd2
285
#elif WIDTH == 64
286
#define DFP_ADD         __adddd3
287
#define DFP_SUB         __subdd3
288
#define DFP_MULTIPLY    __muldd3
289
#define DFP_DIVIDE      __divdd3
290
#define DFP_EQ          __eqdd2
291
#define DFP_NE          __nedd2
292
#define DFP_LT          __ltdd2
293
#define DFP_GT          __gtdd2
294
#define DFP_LE          __ledd2
295
#define DFP_GE          __gedd2
296
#define DFP_UNORD       __unorddd2
297
#elif WIDTH == 128
298
#define DFP_ADD         __addtd3
299
#define DFP_SUB         __subtd3
300
#define DFP_MULTIPLY    __multd3
301
#define DFP_DIVIDE      __divtd3
302
#define DFP_EQ          __eqtd2
303
#define DFP_NE          __netd2
304
#define DFP_LT          __lttd2
305
#define DFP_GT          __gttd2
306
#define DFP_LE          __letd2
307
#define DFP_GE          __getd2
308
#define DFP_UNORD       __unordtd2
309
#endif
310
 
311
/* Names of functions to convert between different decimal float types.  */
312
 
313
#if WIDTH == 32
314
#if WIDTH_TO == 64
315
#define DFP_TO_DFP      __extendsddd2
316
#elif WIDTH_TO == 128
317
#define DFP_TO_DFP      __extendsdtd2
318
#endif
319
#elif WIDTH == 64       
320
#if WIDTH_TO == 32
321
#define DFP_TO_DFP      __truncddsd2
322
#elif WIDTH_TO == 128
323
#define DFP_TO_DFP      __extendddtd2
324
#endif
325
#elif WIDTH == 128
326
#if WIDTH_TO == 32
327
#define DFP_TO_DFP      __trunctdsd2
328
#elif WIDTH_TO == 64
329
#define DFP_TO_DFP      __trunctddd2
330
#endif
331
#endif
332
 
333
/* Names of functions to convert between decimal float and integers.  */
334
 
335
#if WIDTH == 32
336
#if INT_KIND == 1
337
#define INT_TO_DFP      __floatsisd
338
#define DFP_TO_INT      __fixsdsi
339
#elif INT_KIND == 2
340
#define INT_TO_DFP      __floatdisd
341
#define DFP_TO_INT      __fixsddi
342
#elif INT_KIND == 3
343
#define INT_TO_DFP      __floatunssisd
344
#define DFP_TO_INT      __fixunssdsi
345
#elif INT_KIND == 4
346
#define INT_TO_DFP      __floatunsdisd
347
#define DFP_TO_INT      __fixunssddi
348
#endif
349
#elif WIDTH == 64
350
#if INT_KIND == 1
351
#define INT_TO_DFP      __floatsidd
352
#define DFP_TO_INT      __fixddsi
353
#elif INT_KIND == 2
354
#define INT_TO_DFP      __floatdidd
355
#define DFP_TO_INT      __fixdddi
356
#elif INT_KIND == 3
357
#define INT_TO_DFP      __floatunssidd
358
#define DFP_TO_INT      __fixunsddsi
359
#elif INT_KIND == 4
360
#define INT_TO_DFP      __floatunsdidd
361
#define DFP_TO_INT      __fixunsdddi
362
#endif
363
#elif WIDTH == 128
364
#if INT_KIND == 1
365
#define INT_TO_DFP      __floatsitd
366
#define DFP_TO_INT      __fixtdsi
367
#elif INT_KIND == 2
368
#define INT_TO_DFP      __floatditd
369
#define DFP_TO_INT      __fixtddi
370
#elif INT_KIND == 3
371
#define INT_TO_DFP      __floatunssitd
372
#define DFP_TO_INT      __fixunstdsi
373
#elif INT_KIND == 4
374
#define INT_TO_DFP      __floatunsditd
375
#define DFP_TO_INT      __fixunstddi
376
#endif
377
#endif
378
 
379
/* Names of functions to convert between decimal float and binary float.  */
380
 
381
#if WIDTH == 32
382
#if BFP_KIND == 1
383
#define BFP_TO_DFP      __extendsfsd
384
#define DFP_TO_BFP      __truncsdsf
385
#elif BFP_KIND == 2
386
#define BFP_TO_DFP      __truncdfsd
387
#define DFP_TO_BFP      __extendsddf
388
#elif BFP_KIND == 3
389
#define BFP_TO_DFP      __truncxfsd
390
#define DFP_TO_BFP      __extendsdxf
391
#endif /* BFP_KIND */
392
 
393
#elif WIDTH == 64
394
#if BFP_KIND == 1
395
#define BFP_TO_DFP      __extendsfdd
396
#define DFP_TO_BFP      __truncddsf
397
#elif BFP_KIND == 2
398
#define BFP_TO_DFP      __extenddfdd
399
#define DFP_TO_BFP      __truncdddf
400
#elif BFP_KIND == 3
401
#define BFP_TO_DFP      __truncxfdd
402
#define DFP_TO_BFP      __extendddxf
403
#endif /* BFP_KIND */
404
 
405
#elif WIDTH == 128
406
#if BFP_KIND == 1
407
#define BFP_TO_DFP      __extendsftd
408
#define DFP_TO_BFP      __trunctdsf
409
#elif BFP_KIND == 2
410
#define BFP_TO_DFP      __extenddftd
411
#define DFP_TO_BFP      __trunctddf
412
#elif BFP_KIND == 3
413
#define BFP_TO_DFP      __extendxftd
414
#define DFP_TO_BFP      __trunctdxf
415
#endif /* BFP_KIND */
416
 
417
#endif /* WIDTH */
418
 
419
/* Some handy typedefs.  */
420
 
421
typedef float SFtype __attribute__ ((mode (SF)));
422
typedef float DFtype __attribute__ ((mode (DF)));
423
#if LIBGCC2_HAS_XF_MODE
424
typedef float XFtype __attribute__ ((mode (XF)));
425
#endif /* LIBGCC2_HAS_XF_MODE */
426
 
427
typedef int SItype __attribute__ ((mode (SI)));
428
typedef int DItype __attribute__ ((mode (DI)));
429
typedef unsigned int USItype __attribute__ ((mode (SI)));
430
typedef unsigned int UDItype __attribute__ ((mode (DI)));
431
 
432
/* The type of the result of a decimal float comparison.  This must
433
   match `word_mode' in GCC for the target.  */
434
 
435
typedef int CMPtype __attribute__ ((mode (word)));
436
 
437
/* Prototypes.  */
438
 
439
#if defined (L_mul_sd) || defined (L_mul_dd) || defined (L_mul_td)
440
extern DFP_C_TYPE DFP_MULTIPLY (DFP_C_TYPE, DFP_C_TYPE);
441
#endif
442
 
443
#if defined (L_div_sd) || defined (L_div_dd) || defined (L_div_td)
444
extern DFP_C_TYPE DFP_DIVIDE (DFP_C_TYPE, DFP_C_TYPE);
445
#endif
446
 
447
#if defined (L_addsub_sd) || defined (L_addsub_dd) || defined (L_addsub_td)
448
extern DFP_C_TYPE DFP_ADD (DFP_C_TYPE, DFP_C_TYPE);
449
extern DFP_C_TYPE DFP_SUB (DFP_C_TYPE, DFP_C_TYPE);
450
#endif
451
 
452
#if defined (L_eq_sd) || defined (L_eq_dd) || defined (L_eq_td)
453
extern CMPtype DFP_EQ (DFP_C_TYPE, DFP_C_TYPE);
454
#endif
455
 
456
#if defined (L_ne_sd) || defined (L_ne_dd) || defined (L_ne_td)
457
extern CMPtype DFP_NE (DFP_C_TYPE, DFP_C_TYPE);
458
#endif
459
 
460
#if defined (L_lt_sd) || defined (L_lt_dd) || defined (L_lt_td)
461
extern CMPtype DFP_LT (DFP_C_TYPE, DFP_C_TYPE);
462
#endif
463
 
464
#if defined (L_gt_sd) || defined (L_gt_dd) || defined (L_gt_td)
465
extern CMPtype DFP_GT (DFP_C_TYPE, DFP_C_TYPE);
466
#endif
467
 
468
#if defined (L_le_sd) || defined (L_le_dd) || defined (L_le_td)
469
extern CMPtype DFP_LE (DFP_C_TYPE, DFP_C_TYPE);
470
#endif
471
 
472
#if defined (L_ge_sd) || defined (L_ge_dd) || defined (L_ge_td)
473
extern CMPtype DFP_GE (DFP_C_TYPE, DFP_C_TYPE);
474
#endif
475
 
476
#if defined (L_unord_sd) || defined (L_unord_dd) || defined (L_unord_td)
477
extern CMPtype DFP_UNORD (DFP_C_TYPE, DFP_C_TYPE);
478
#endif
479
 
480
#if defined (L_sd_to_dd) || defined (L_sd_to_td) || defined (L_dd_to_sd) \
481
 || defined (L_dd_to_td) || defined (L_td_to_sd) || defined (L_td_to_dd)
482
extern DFP_C_TYPE_TO DFP_TO_DFP (DFP_C_TYPE);
483
#endif
484
 
485
#if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \
486
 || defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \
487
 || defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \
488
 || defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi)
489
extern INT_TYPE DFP_TO_INT (DFP_C_TYPE);
490
#endif
491
 
492
#if defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) \
493
 || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) \
494
 || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) \
495
 || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td)
496
extern DFP_C_TYPE INT_TO_DFP (INT_TYPE);
497
#endif
498
 
499
#if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \
500
 || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \
501
 || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \
502
     && LIBGCC2_HAS_XF_MODE)
503
extern BFP_TYPE DFP_TO_BFP (DFP_C_TYPE);
504
#endif
505
 
506
#if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \
507
 || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \
508
 || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \
509
     && LIBGCC2_HAS_XF_MODE)
510
extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE);
511
#endif
512
 
513
#endif /* _DFPBIT_H */

powered by: WebSVN 2.1.0

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