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