2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / include / floatformat.h
bloba8244ada5c7267e8229e1cceb37e0795e0ac8c8d
1 /* IEEE floating point support declarations, for GDB, the GNU Debugger.
2 Copyright 1991, 1994, 1995, 1997, 2000, 2003 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #if !defined (FLOATFORMAT_H)
21 #define FLOATFORMAT_H 1
23 #include "ansidecl.h"
25 /* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
26 bytes are concatenated according to the byteorder flag, then each of those
27 fields is contiguous. We number the bits with 0 being the most significant
28 (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
29 contains with the *_start and *_len fields. */
31 /* What is the order of the bytes. */
33 enum floatformat_byteorders {
35 /* Standard little endian byte order.
36 EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
38 floatformat_little,
40 /* Standard big endian byte order.
41 EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
43 floatformat_big,
45 /* Little endian byte order but big endian word order.
46 EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
48 floatformat_littlebyte_bigword
52 enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
54 struct floatformat
56 enum floatformat_byteorders byteorder;
57 unsigned int totalsize; /* Total size of number in bits */
59 /* Sign bit is always one bit long. 1 means negative, 0 means positive. */
60 unsigned int sign_start;
62 unsigned int exp_start;
63 unsigned int exp_len;
64 /* Bias added to a "true" exponent to form the biased exponent. It
65 is intentionally signed as, otherwize, -exp_bias can turn into a
66 very large number (e.g., given the exp_bias of 0x3fff and a 64
67 bit long, the equation (long)(1 - exp_bias) evaluates to
68 4294950914) instead of -16382). */
69 int exp_bias;
70 /* Exponent value which indicates NaN. This is the actual value stored in
71 the float, not adjusted by the exp_bias. This usually consists of all
72 one bits. */
73 unsigned int exp_nan;
75 unsigned int man_start;
76 unsigned int man_len;
78 /* Is the integer bit explicit or implicit? */
79 enum floatformat_intbit intbit;
81 /* Internal name for debugging. */
82 const char *name;
84 /* Validator method. */
85 int (*is_valid) PARAMS ((const struct floatformat *fmt, const char *from));
88 /* floatformats for IEEE single and double, big and little endian. */
90 extern const struct floatformat floatformat_ieee_single_big;
91 extern const struct floatformat floatformat_ieee_single_little;
92 extern const struct floatformat floatformat_ieee_double_big;
93 extern const struct floatformat floatformat_ieee_double_little;
95 /* floatformat for ARM IEEE double, little endian bytes and big endian words */
97 extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
99 /* floatformats for various extendeds. */
101 extern const struct floatformat floatformat_i387_ext;
102 extern const struct floatformat floatformat_m68881_ext;
103 extern const struct floatformat floatformat_i960_ext;
104 extern const struct floatformat floatformat_m88110_ext;
105 extern const struct floatformat floatformat_m88110_harris_ext;
106 extern const struct floatformat floatformat_arm_ext_big;
107 extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
108 /* IA-64 Floating Point register spilt into memory. */
109 extern const struct floatformat floatformat_ia64_spill_big;
110 extern const struct floatformat floatformat_ia64_spill_little;
111 extern const struct floatformat floatformat_ia64_quad_big;
112 extern const struct floatformat floatformat_ia64_quad_little;
114 /* Convert from FMT to a double.
115 FROM is the address of the extended float.
116 Store the double in *TO. */
118 extern void
119 floatformat_to_double PARAMS ((const struct floatformat *, const char *, double *));
121 /* The converse: convert the double *FROM to FMT
122 and store where TO points. */
124 extern void
125 floatformat_from_double PARAMS ((const struct floatformat *,
126 const double *, char *));
128 /* Return non-zero iff the data at FROM is a valid number in format FMT. */
130 extern int
131 floatformat_is_valid PARAMS ((const struct floatformat *fmt, const char *from));
133 #endif /* defined (FLOATFORMAT_H) */