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