bfd/
[deliverable/binutils-gdb.git] / include / floatformat.h
CommitLineData
252b5132 1/* IEEE floating point support declarations, for GDB, the GNU Debugger.
3b6940c0
DD
2 Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
3 Free Software Foundation, Inc.
252b5132
RH
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
e172dbf8 19Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
252b5132
RH
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
fb10537e 32/* What is the order of the bytes? */
252b5132
RH
33
34enum floatformat_byteorders {
252b5132
RH
35 /* Standard little endian byte order.
36 EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
252b5132
RH
37 floatformat_little,
38
39 /* Standard big endian byte order.
40 EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
252b5132
RH
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 */
fb10537e 45 floatformat_littlebyte_bigword,
252b5132 46
fb10537e
DD
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
252b5132
RH
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;
a58f1534
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;
252b5132
RH
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;
f03aa80d
AC
82
83 /* Internal name for debugging. */
84 const char *name;
5324d185
AC
85
86 /* Validator method. */
3b6940c0 87 int (*is_valid) (const struct floatformat *fmt, const void *from);
b14d30e1
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;
252b5132
RH
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
fb10537e
DD
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
252b5132
RH
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;
eb828599 120extern const struct floatformat floatformat_m88110_harris_ext;
eb828599
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;
b14d30e1
JM
128/* IBM long double (double+double). */
129extern const struct floatformat floatformat_ibm_long_double;
252b5132
RH
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
3b6940c0 136floatformat_to_double (const struct floatformat *, const void *, double *);
252b5132
RH
137
138/* The converse: convert the double *FROM to FMT
139 and store where TO points. */
140
141extern void
3b6940c0 142floatformat_from_double (const struct floatformat *, const double *, void *);
252b5132 143
fca63fe8
DJ
144/* Return non-zero iff the data at FROM is a valid number in format FMT. */
145
146extern int
3b6940c0 147floatformat_is_valid (const struct floatformat *fmt, const void *from);
fca63fe8 148
252b5132 149#endif /* defined (FLOATFORMAT_H) */
This page took 0.506705 seconds and 4 git commands to generate.