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