Back to index

cell-binutils  2.17cvs20070401
floatformat.h
Go to the documentation of this file.
00001 /* IEEE floating point support declarations, for GDB, the GNU Debugger.
00002    Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
00003    Free Software Foundation, Inc.
00004 
00005 This file is part of GDB.
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 #if !defined (FLOATFORMAT_H)
00022 #define FLOATFORMAT_H 1
00023 
00024 #include "ansidecl.h"
00025 
00026 /* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
00027    bytes are concatenated according to the byteorder flag, then each of those
00028    fields is contiguous.  We number the bits with 0 being the most significant
00029    (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
00030    contains with the *_start and *_len fields.  */
00031 
00032 /* What is the order of the bytes?  */
00033 
00034 enum floatformat_byteorders {
00035   /* Standard little endian byte order.
00036      EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
00037   floatformat_little,
00038 
00039   /* Standard big endian byte order.
00040      EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
00041   floatformat_big,
00042 
00043   /* Little endian byte order but big endian word order.
00044      EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
00045   floatformat_littlebyte_bigword,
00046 
00047   /* VAX byte order.  Little endian byte order with 16-bit words.  The
00048      following example is an illustration of the byte order only; VAX
00049      doesn't have a fully IEEE compliant floating-point format.
00050      EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
00051   floatformat_vax
00052 };
00053 
00054 enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
00055 
00056 struct floatformat
00057 {
00058   enum floatformat_byteorders byteorder;
00059   unsigned int totalsize;   /* Total size of number in bits */
00060 
00061   /* Sign bit is always one bit long.  1 means negative, 0 means positive.  */
00062   unsigned int sign_start;
00063 
00064   unsigned int exp_start;
00065   unsigned int exp_len;
00066   /* Bias added to a "true" exponent to form the biased exponent.  It
00067      is intentionally signed as, otherwize, -exp_bias can turn into a
00068      very large number (e.g., given the exp_bias of 0x3fff and a 64
00069      bit long, the equation (long)(1 - exp_bias) evaluates to
00070      4294950914) instead of -16382).  */
00071   int exp_bias;
00072   /* Exponent value which indicates NaN.  This is the actual value stored in
00073      the float, not adjusted by the exp_bias.  This usually consists of all
00074      one bits.  */
00075   unsigned int exp_nan;
00076 
00077   unsigned int man_start;
00078   unsigned int man_len;
00079 
00080   /* Is the integer bit explicit or implicit?  */
00081   enum floatformat_intbit intbit;
00082 
00083   /* Internal name for debugging. */
00084   const char *name;
00085 
00086   /* Validator method.  */
00087   int (*is_valid) (const struct floatformat *fmt, const void *from);
00088 };
00089 
00090 /* floatformats for IEEE single and double, big and little endian.  */
00091 
00092 extern const struct floatformat floatformat_ieee_single_big;
00093 extern const struct floatformat floatformat_ieee_single_little;
00094 extern const struct floatformat floatformat_ieee_double_big;
00095 extern const struct floatformat floatformat_ieee_double_little;
00096 
00097 /* floatformat for ARM IEEE double, little endian bytes and big endian words */
00098 
00099 extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
00100 
00101 /* floatformats for VAX.  */
00102 
00103 extern const struct floatformat floatformat_vax_f;
00104 extern const struct floatformat floatformat_vax_d;
00105 extern const struct floatformat floatformat_vax_g;
00106 
00107 /* floatformats for various extendeds.  */
00108 
00109 extern const struct floatformat floatformat_i387_ext;
00110 extern const struct floatformat floatformat_m68881_ext;
00111 extern const struct floatformat floatformat_i960_ext;
00112 extern const struct floatformat floatformat_m88110_ext;
00113 extern const struct floatformat floatformat_m88110_harris_ext;
00114 extern const struct floatformat floatformat_arm_ext_big;
00115 extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
00116 /* IA-64 Floating Point register spilt into memory.  */
00117 extern const struct floatformat floatformat_ia64_spill_big;
00118 extern const struct floatformat floatformat_ia64_spill_little;
00119 extern const struct floatformat floatformat_ia64_quad_big;
00120 extern const struct floatformat floatformat_ia64_quad_little;
00121 
00122 /* Convert from FMT to a double.
00123    FROM is the address of the extended float.
00124    Store the double in *TO.  */
00125 
00126 extern void
00127 floatformat_to_double (const struct floatformat *, const void *, double *);
00128 
00129 /* The converse: convert the double *FROM to FMT
00130    and store where TO points.  */
00131 
00132 extern void
00133 floatformat_from_double (const struct floatformat *, const double *, void *);
00134 
00135 /* Return non-zero iff the data at FROM is a valid number in format FMT.  */
00136 
00137 extern int
00138 floatformat_is_valid (const struct floatformat *fmt, const void *from);
00139 
00140 #endif /* defined (FLOATFORMAT_H) */