12159047fSniklas /* IEEE floating point support declarations, for GDB, the GNU Debugger. 2*007c2a45Smiod Copyright 1991, 1994, 1995, 1997, 2000, 2003 Free Software Foundation, Inc. 32159047fSniklas 42159047fSniklas This file is part of GDB. 52159047fSniklas 62159047fSniklas This program is free software; you can redistribute it and/or modify 72159047fSniklas it under the terms of the GNU General Public License as published by 82159047fSniklas the Free Software Foundation; either version 2 of the License, or 92159047fSniklas (at your option) any later version. 102159047fSniklas 112159047fSniklas This program is distributed in the hope that it will be useful, 122159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of 132159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 142159047fSniklas GNU General Public License for more details. 152159047fSniklas 162159047fSniklas You should have received a copy of the GNU General Public License 172159047fSniklas along with this program; if not, write to the Free Software 182159047fSniklas Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 192159047fSniklas 202159047fSniklas #if !defined (FLOATFORMAT_H) 212159047fSniklas #define FLOATFORMAT_H 1 222159047fSniklas 232159047fSniklas #include "ansidecl.h" 242159047fSniklas 252159047fSniklas /* A floatformat consists of a sign bit, an exponent and a mantissa. Once the 262159047fSniklas bytes are concatenated according to the byteorder flag, then each of those 272159047fSniklas fields is contiguous. We number the bits with 0 being the most significant 282159047fSniklas (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field 292159047fSniklas contains with the *_start and *_len fields. */ 302159047fSniklas 31f7cc78ecSespie /* What is the order of the bytes. */ 32f7cc78ecSespie 33f7cc78ecSespie enum floatformat_byteorders { 34f7cc78ecSespie 35f7cc78ecSespie /* Standard little endian byte order. 36f7cc78ecSespie EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */ 37f7cc78ecSespie 38f7cc78ecSespie floatformat_little, 39f7cc78ecSespie 40f7cc78ecSespie /* Standard big endian byte order. 41f7cc78ecSespie EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */ 42f7cc78ecSespie 43f7cc78ecSespie floatformat_big, 44f7cc78ecSespie 45f7cc78ecSespie /* Little endian byte order but big endian word order. 46f7cc78ecSespie EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */ 47f7cc78ecSespie 48f7cc78ecSespie floatformat_littlebyte_bigword 49f7cc78ecSespie 50f7cc78ecSespie }; 512159047fSniklas 522159047fSniklas enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no }; 532159047fSniklas 542159047fSniklas struct floatformat 552159047fSniklas { 562159047fSniklas enum floatformat_byteorders byteorder; 572159047fSniklas unsigned int totalsize; /* Total size of number in bits */ 582159047fSniklas 592159047fSniklas /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ 602159047fSniklas unsigned int sign_start; 612159047fSniklas 622159047fSniklas unsigned int exp_start; 632159047fSniklas unsigned int exp_len; 64*007c2a45Smiod /* Bias added to a "true" exponent to form the biased exponent. It 65*007c2a45Smiod is intentionally signed as, otherwize, -exp_bias can turn into a 66*007c2a45Smiod very large number (e.g., given the exp_bias of 0x3fff and a 64 67*007c2a45Smiod bit long, the equation (long)(1 - exp_bias) evaluates to 68*007c2a45Smiod 4294950914) instead of -16382). */ 69*007c2a45Smiod int exp_bias; 702159047fSniklas /* Exponent value which indicates NaN. This is the actual value stored in 712159047fSniklas the float, not adjusted by the exp_bias. This usually consists of all 722159047fSniklas one bits. */ 732159047fSniklas unsigned int exp_nan; 742159047fSniklas 752159047fSniklas unsigned int man_start; 762159047fSniklas unsigned int man_len; 772159047fSniklas 782159047fSniklas /* Is the integer bit explicit or implicit? */ 792159047fSniklas enum floatformat_intbit intbit; 80b55d4692Sfgsch 81b55d4692Sfgsch /* Internal name for debugging. */ 82b55d4692Sfgsch const char *name; 83*007c2a45Smiod 84*007c2a45Smiod /* Validator method. */ 85*007c2a45Smiod int (*is_valid) PARAMS ((const struct floatformat *fmt, const char *from)); 862159047fSniklas }; 872159047fSniklas 882159047fSniklas /* floatformats for IEEE single and double, big and little endian. */ 892159047fSniklas 902159047fSniklas extern const struct floatformat floatformat_ieee_single_big; 912159047fSniklas extern const struct floatformat floatformat_ieee_single_little; 922159047fSniklas extern const struct floatformat floatformat_ieee_double_big; 932159047fSniklas extern const struct floatformat floatformat_ieee_double_little; 942159047fSniklas 95f7cc78ecSespie /* floatformat for ARM IEEE double, little endian bytes and big endian words */ 96f7cc78ecSespie 97f7cc78ecSespie extern const struct floatformat floatformat_ieee_double_littlebyte_bigword; 98f7cc78ecSespie 992159047fSniklas /* floatformats for various extendeds. */ 1002159047fSniklas 1012159047fSniklas extern const struct floatformat floatformat_i387_ext; 1022159047fSniklas extern const struct floatformat floatformat_m68881_ext; 1032159047fSniklas extern const struct floatformat floatformat_i960_ext; 1042159047fSniklas extern const struct floatformat floatformat_m88110_ext; 105c074d1c9Sdrahn extern const struct floatformat floatformat_m88110_harris_ext; 106c074d1c9Sdrahn extern const struct floatformat floatformat_arm_ext_big; 107c074d1c9Sdrahn extern const struct floatformat floatformat_arm_ext_littlebyte_bigword; 108c074d1c9Sdrahn /* IA-64 Floating Point register spilt into memory. */ 109c074d1c9Sdrahn extern const struct floatformat floatformat_ia64_spill_big; 110c074d1c9Sdrahn extern const struct floatformat floatformat_ia64_spill_little; 111c074d1c9Sdrahn extern const struct floatformat floatformat_ia64_quad_big; 112c074d1c9Sdrahn extern const struct floatformat floatformat_ia64_quad_little; 1132159047fSniklas 1142159047fSniklas /* Convert from FMT to a double. 1152159047fSniklas FROM is the address of the extended float. 1162159047fSniklas Store the double in *TO. */ 1172159047fSniklas 1182159047fSniklas extern void 119*007c2a45Smiod floatformat_to_double PARAMS ((const struct floatformat *, const char *, double *)); 1202159047fSniklas 1212159047fSniklas /* The converse: convert the double *FROM to FMT 1222159047fSniklas and store where TO points. */ 1232159047fSniklas 1242159047fSniklas extern void 1252159047fSniklas floatformat_from_double PARAMS ((const struct floatformat *, 126*007c2a45Smiod const double *, char *)); 127*007c2a45Smiod 128*007c2a45Smiod /* Return non-zero iff the data at FROM is a valid number in format FMT. */ 129*007c2a45Smiod 130*007c2a45Smiod extern int 131*007c2a45Smiod floatformat_is_valid PARAMS ((const struct floatformat *fmt, const char *from)); 1322159047fSniklas 1332159047fSniklas #endif /* defined (FLOATFORMAT_H) */ 134