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