133965Sjdp/* IEEE floating point support declarations, for GDB, the GNU Debugger.
2218822Sdim   Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
3218822Sdim   Free Software Foundation, Inc.
433965Sjdp
533965SjdpThis file is part of GDB.
633965Sjdp
733965SjdpThis program is free software; you can redistribute it and/or modify
833965Sjdpit under the terms of the GNU General Public License as published by
933965Sjdpthe Free Software Foundation; either version 2 of the License, or
1033965Sjdp(at your option) any later version.
1133965Sjdp
1233965SjdpThis program is distributed in the hope that it will be useful,
1333965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of
1433965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1533965SjdpGNU General Public License for more details.
1633965Sjdp
1733965SjdpYou should have received a copy of the GNU General Public License
1833965Sjdpalong with this program; if not, write to the Free Software
19218822SdimFoundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2033965Sjdp
2133965Sjdp#if !defined (FLOATFORMAT_H)
2233965Sjdp#define FLOATFORMAT_H 1
2333965Sjdp
2433965Sjdp#include "ansidecl.h"
2533965Sjdp
2633965Sjdp/* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
2733965Sjdp   bytes are concatenated according to the byteorder flag, then each of those
2833965Sjdp   fields is contiguous.  We number the bits with 0 being the most significant
2933965Sjdp   (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
3033965Sjdp   contains with the *_start and *_len fields.  */
3133965Sjdp
32218822Sdim/* What is the order of the bytes?  */
3333965Sjdp
3438889Sjdpenum floatformat_byteorders {
3538889Sjdp  /* Standard little endian byte order.
3638889Sjdp     EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
3738889Sjdp  floatformat_little,
3838889Sjdp
3938889Sjdp  /* Standard big endian byte order.
4038889Sjdp     EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
4138889Sjdp  floatformat_big,
4238889Sjdp
4338889Sjdp  /* Little endian byte order but big endian word order.
4438889Sjdp     EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
45218822Sdim  floatformat_littlebyte_bigword,
4638889Sjdp
47218822Sdim  /* VAX byte order.  Little endian byte order with 16-bit words.  The
48218822Sdim     following example is an illustration of the byte order only; VAX
49218822Sdim     doesn't have a fully IEEE compliant floating-point format.
50218822Sdim     EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
51218822Sdim  floatformat_vax
5238889Sjdp};
5338889Sjdp
5433965Sjdpenum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
5533965Sjdp
5633965Sjdpstruct floatformat
5733965Sjdp{
5833965Sjdp  enum floatformat_byteorders byteorder;
5933965Sjdp  unsigned int totalsize;	/* Total size of number in bits */
6033965Sjdp
6133965Sjdp  /* Sign bit is always one bit long.  1 means negative, 0 means positive.  */
6233965Sjdp  unsigned int sign_start;
6333965Sjdp
6433965Sjdp  unsigned int exp_start;
6533965Sjdp  unsigned int exp_len;
66130561Sobrien  /* Bias added to a "true" exponent to form the biased exponent.  It
67130561Sobrien     is intentionally signed as, otherwize, -exp_bias can turn into a
68130561Sobrien     very large number (e.g., given the exp_bias of 0x3fff and a 64
69130561Sobrien     bit long, the equation (long)(1 - exp_bias) evaluates to
70130561Sobrien     4294950914) instead of -16382).  */
71130561Sobrien  int exp_bias;
7233965Sjdp  /* Exponent value which indicates NaN.  This is the actual value stored in
7333965Sjdp     the float, not adjusted by the exp_bias.  This usually consists of all
7433965Sjdp     one bits.  */
7533965Sjdp  unsigned int exp_nan;
7633965Sjdp
7733965Sjdp  unsigned int man_start;
7833965Sjdp  unsigned int man_len;
7933965Sjdp
8033965Sjdp  /* Is the integer bit explicit or implicit?  */
8133965Sjdp  enum floatformat_intbit intbit;
8277298Sobrien
8377298Sobrien  /* Internal name for debugging. */
8477298Sobrien  const char *name;
85130561Sobrien
86130561Sobrien  /* Validator method.  */
87218822Sdim  int (*is_valid) (const struct floatformat *fmt, const void *from);
8833965Sjdp};
8933965Sjdp
9033965Sjdp/* floatformats for IEEE single and double, big and little endian.  */
9133965Sjdp
9233965Sjdpextern const struct floatformat floatformat_ieee_single_big;
9333965Sjdpextern const struct floatformat floatformat_ieee_single_little;
9433965Sjdpextern const struct floatformat floatformat_ieee_double_big;
9533965Sjdpextern const struct floatformat floatformat_ieee_double_little;
9633965Sjdp
9738889Sjdp/* floatformat for ARM IEEE double, little endian bytes and big endian words */
9838889Sjdp
9938889Sjdpextern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
10038889Sjdp
101218822Sdim/* floatformats for VAX.  */
102218822Sdim
103218822Sdimextern const struct floatformat floatformat_vax_f;
104218822Sdimextern const struct floatformat floatformat_vax_d;
105218822Sdimextern const struct floatformat floatformat_vax_g;
106218822Sdim
10733965Sjdp/* floatformats for various extendeds.  */
10833965Sjdp
10933965Sjdpextern const struct floatformat floatformat_i387_ext;
11033965Sjdpextern const struct floatformat floatformat_m68881_ext;
11133965Sjdpextern const struct floatformat floatformat_i960_ext;
11233965Sjdpextern const struct floatformat floatformat_m88110_ext;
11389857Sobrienextern const struct floatformat floatformat_m88110_harris_ext;
11489857Sobrienextern const struct floatformat floatformat_arm_ext_big;
11589857Sobrienextern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
11689857Sobrien/* IA-64 Floating Point register spilt into memory.  */
11789857Sobrienextern const struct floatformat floatformat_ia64_spill_big;
11889857Sobrienextern const struct floatformat floatformat_ia64_spill_little;
11989857Sobrienextern const struct floatformat floatformat_ia64_quad_big;
12089857Sobrienextern const struct floatformat floatformat_ia64_quad_little;
12133965Sjdp
12233965Sjdp/* Convert from FMT to a double.
12333965Sjdp   FROM is the address of the extended float.
12433965Sjdp   Store the double in *TO.  */
12533965Sjdp
12633965Sjdpextern void
127218822Sdimfloatformat_to_double (const struct floatformat *, const void *, double *);
12833965Sjdp
12933965Sjdp/* The converse: convert the double *FROM to FMT
13033965Sjdp   and store where TO points.  */
13133965Sjdp
13233965Sjdpextern void
133218822Sdimfloatformat_from_double (const struct floatformat *, const double *, void *);
13433965Sjdp
135130561Sobrien/* Return non-zero iff the data at FROM is a valid number in format FMT.  */
136130561Sobrien
137130561Sobrienextern int
138218822Sdimfloatformat_is_valid (const struct floatformat *fmt, const void *from);
139130561Sobrien
14033965Sjdp#endif	/* defined (FLOATFORMAT_H) */
141