]> git.ipfire.org Git - thirdparty/gcc.git/blame - include/floatformat.h
Fix bug reported by Andrew Pinski.
[thirdparty/gcc.git] / include / floatformat.h
CommitLineData
6599da04 1/* IEEE floating point support declarations, for GDB, the GNU Debugger.
e89b6c1c
MK
2 Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
3 Free Software Foundation, Inc.
6599da04
JM
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
d6d47ea0 19Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
6599da04
JM
20
21#if !defined (FLOATFORMAT_H)
22#define FLOATFORMAT_H 1
23
24#include "ansidecl.h"
25
26/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
27 bytes are concatenated according to the byteorder flag, then each of those
28 fields is contiguous. We number the bits with 0 being the most significant
29 (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
30 contains with the *_start and *_len fields. */
31
0432a5de 32/* What is the order of the bytes? */
6599da04
JM
33
34enum floatformat_byteorders {
6599da04
JM
35 /* Standard little endian byte order.
36 EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
6599da04
JM
37 floatformat_little,
38
39 /* Standard big endian byte order.
40 EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
6599da04
JM
41 floatformat_big,
42
43 /* Little endian byte order but big endian word order.
44 EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
0432a5de 45 floatformat_littlebyte_bigword,
6599da04 46
0432a5de
MK
47 /* VAX byte order. Little endian byte order with 16-bit words. The
48 following example is an illustration of the byte order only; VAX
49 doesn't have a fully IEEE compliant floating-point format.
50 EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
51 floatformat_vax
6599da04
JM
52};
53
54enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
55
56struct floatformat
57{
58 enum floatformat_byteorders byteorder;
59 unsigned int totalsize; /* Total size of number in bits */
60
61 /* Sign bit is always one bit long. 1 means negative, 0 means positive. */
62 unsigned int sign_start;
63
64 unsigned int exp_start;
65 unsigned int exp_len;
a4cbdc57
AC
66 /* Bias added to a "true" exponent to form the biased exponent. It
67 is intentionally signed as, otherwize, -exp_bias can turn into a
68 very large number (e.g., given the exp_bias of 0x3fff and a 64
69 bit long, the equation (long)(1 - exp_bias) evaluates to
70 4294950914) instead of -16382). */
71 int exp_bias;
6599da04
JM
72 /* Exponent value which indicates NaN. This is the actual value stored in
73 the float, not adjusted by the exp_bias. This usually consists of all
74 one bits. */
75 unsigned int exp_nan;
76
77 unsigned int man_start;
78 unsigned int man_len;
79
80 /* Is the integer bit explicit or implicit? */
81 enum floatformat_intbit intbit;
0b72c3df
AC
82
83 /* Internal name for debugging. */
84 const char *name;
83c07342
AC
85
86 /* Validator method. */
e89b6c1c 87 int (*is_valid) (const struct floatformat *fmt, const void *from);
da59326f
JM
88
89 /* Is the format actually the sum of two smaller floating point
90 formats (IBM long double, as described in
91 gcc/config/rs6000/darwin-ldouble-format)? If so, this is the
92 smaller format in question, and the fields sign_start through
93 intbit describe the first half. If not, this is NULL. */
94 const struct floatformat *split_half;
6599da04
JM
95};
96
97/* floatformats for IEEE single and double, big and little endian. */
98
99extern const struct floatformat floatformat_ieee_single_big;
100extern const struct floatformat floatformat_ieee_single_little;
101extern const struct floatformat floatformat_ieee_double_big;
102extern const struct floatformat floatformat_ieee_double_little;
103
104/* floatformat for ARM IEEE double, little endian bytes and big endian words */
105
106extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
107
0432a5de
MK
108/* floatformats for VAX. */
109
110extern const struct floatformat floatformat_vax_f;
111extern const struct floatformat floatformat_vax_d;
112extern const struct floatformat floatformat_vax_g;
113
6599da04
JM
114/* floatformats for various extendeds. */
115
116extern const struct floatformat floatformat_i387_ext;
117extern const struct floatformat floatformat_m68881_ext;
118extern const struct floatformat floatformat_i960_ext;
119extern const struct floatformat floatformat_m88110_ext;
0310e5ac 120extern const struct floatformat floatformat_m88110_harris_ext;
0310e5ac
AC
121extern const struct floatformat floatformat_arm_ext_big;
122extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
123/* IA-64 Floating Point register spilt into memory. */
124extern const struct floatformat floatformat_ia64_spill_big;
125extern const struct floatformat floatformat_ia64_spill_little;
126extern const struct floatformat floatformat_ia64_quad_big;
127extern const struct floatformat floatformat_ia64_quad_little;
da59326f
JM
128/* IBM long double (double+double). */
129extern const struct floatformat floatformat_ibm_long_double;
6599da04
JM
130
131/* Convert from FMT to a double.
132 FROM is the address of the extended float.
133 Store the double in *TO. */
134
135extern void
e89b6c1c 136floatformat_to_double (const struct floatformat *, const void *, double *);
6599da04
JM
137
138/* The converse: convert the double *FROM to FMT
139 and store where TO points. */
140
141extern void
e89b6c1c 142floatformat_from_double (const struct floatformat *, const double *, void *);
6599da04 143
0d66a821
DJ
144/* Return non-zero iff the data at FROM is a valid number in format FMT. */
145
146extern int
e89b6c1c 147floatformat_is_valid (const struct floatformat *fmt, const void *from);
0d66a821 148
6599da04 149#endif /* defined (FLOATFORMAT_H) */