Annotation of gcc/real.h, revision 1.1.1.3

1.1       root        1: /* Front-end tree definitions for GNU compiler.
                      2:    Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: #ifndef REAL_H_INCLUDED
                     21: #define REAL_H_INCLUDED
                     22: 
                     23: /* Define codes for all the float formats that we know of.  */
                     24: #define UNKNOWN_FLOAT_FORMAT 0
                     25: #define IEEE_FLOAT_FORMAT 1
                     26: #define VAX_FLOAT_FORMAT 2
                     27: 
                     28: /* Default to IEEE float if not specified.  Nearly all machines use it.  */
                     29: 
                     30: #ifndef TARGET_FLOAT_FORMAT
                     31: #define        TARGET_FLOAT_FORMAT     IEEE_FLOAT_FORMAT
                     32: #endif
                     33: 
                     34: #ifndef HOST_FLOAT_FORMAT
                     35: #define        HOST_FLOAT_FORMAT       IEEE_FLOAT_FORMAT
                     36: #endif
                     37: 
                     38: #if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
                     39: #define REAL_INFINITY
                     40: #endif
                     41: 
                     42: #ifdef REAL_ARITHMETIC
                     43: /* Defining REAL_IS_NOT_DOUBLE breaks certain initializations
                     44:    when REAL_ARITHMETIC etc. are not defined.  */
                     45: 
                     46: /* Now see if the host and target machines use the same format. 
                     47:    If not, define REAL_IS_NOT_DOUBLE (even if we end up representing
                     48:    reals as doubles because we have no better way in this cross compiler.)
                     49:    This turns off various optimizations that can happen when we know the
                     50:    compiler's float format matches the target's float format.
                     51:    */
                     52: #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
                     53: #define        REAL_IS_NOT_DOUBLE
                     54: #ifndef REAL_VALUE_TYPE
                     55: #define REAL_VALUE_TYPE \
                     56:   struct real_value { long i[sizeof (double) / sizeof (long)]; }
                     57: #endif /* no REAL_VALUE_TYPE */
                     58: #endif /* formats differ */
                     59: #endif /* 0 */
                     60: 
                     61: /* If we are not cross-compiling, use a `double' to represent the
                     62:    floating-point value.  Otherwise, use some other type
                     63:    (probably a struct containing an array of longs).  */
                     64: #ifndef REAL_VALUE_TYPE
                     65: #define REAL_VALUE_TYPE double
                     66: #else
                     67: #define REAL_IS_NOT_DOUBLE
                     68: #endif
                     69: 
1.1.1.3 ! root       70: #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
        !            71: 
        !            72: /* Convert a type `double' value in host format first to a type `float'
        !            73:    value in host format and then to a single type `long' value which
        !            74:    is the bitwise equivalent of the `float' value.  */
        !            75: #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT)                           \
        !            76: do { float f = (float) (IN);                                           \
        !            77:      (OUT) = *(long *) &f;                                             \
        !            78:   } while (0)
        !            79: 
        !            80: /* Convert a type `double' value in host format to a pair of type `long'
        !            81:    values which is its bitwise equivalent, but put the two words into
        !            82:    proper word order for the target.  */
        !            83: #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
        !            84: #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT)                           \
        !            85: do { REAL_VALUE_TYPE in = (IN);  /* Make sure it's not in a register.  */\
        !            86:      (OUT)[0] = ((long *) &in)[0];                                     \
        !            87:      (OUT)[1] = ((long *) &in)[1];                                     \
        !            88:    } while (0)
        !            89: #else
        !            90: #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT)                           \
        !            91: do { REAL_VALUE_TYPE in = (IN);  /* Make sure it's not in a register.  */\
        !            92:      (OUT)[1] = ((long *) &in)[0];                                     \
        !            93:      (OUT)[0] = ((long *) &in)[1];                                     \
        !            94:    } while (0)
        !            95: #endif
        !            96: #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */
        !            97: 
1.1       root       98: /* Compare two floating-point values for equality.  */
                     99: #ifndef REAL_VALUES_EQUAL
                    100: #define REAL_VALUES_EQUAL(x,y) ((x) == (y))
                    101: #endif
                    102: 
                    103: /* Compare two floating-point values for less than.  */
                    104: #ifndef REAL_VALUES_LESS
                    105: #define REAL_VALUES_LESS(x,y) ((x) < (y))
                    106: #endif
                    107: 
                    108: /* Convert a floating-point value to integer by truncating.  */
                    109: #ifndef REAL_VALUE_FIX_TRUNCATE
                    110: #define REAL_VALUE_FIX_TRUNCATE(x) ((int) (x))
                    111: #endif
                    112: 
                    113: /* Convert a floating-point value to unsigned integer by truncating.  */
                    114: #ifndef REAL_VALUE_UNSIGNED_FIX_TRUNCATE
                    115: #define REAL_VALUE_UNSIGNED_FIX_TRUNCATE(x) ((unsigned int) (x))
                    116: #endif
                    117: 
                    118: /* Convert a floating-point value to integer, using any rounding mode.  */
                    119: #ifndef REAL_VALUE_FIX
                    120: #define REAL_VALUE_FIX(x) ((int) (x))
                    121: #endif
                    122: 
                    123: /* Convert a floating-point value to unsigned integer, using any rounding
                    124:    mode.  */
                    125: #ifndef REAL_VALUE_UNSIGNED_FIX
                    126: #define REAL_VALUE_UNSIGNED_FIX(x) ((unsigned int) (x))
                    127: #endif
                    128: 
                    129: /* Scale X by Y powers of 2.  */
                    130: #ifndef REAL_VALUE_LDEXP
                    131: #define REAL_VALUE_LDEXP(x,y) ldexp (x, y)
                    132: extern double ldexp ();
                    133: #endif
                    134: 
                    135: /* Convert the string X to a floating-point value.  */
                    136: #ifndef REAL_VALUE_ATOF
                    137: #define REAL_VALUE_ATOF(x) atof (x)
                    138: #if defined (MIPSEL) || defined (MIPSEB)
                    139: /* MIPS compiler can't handle parens around the function name.
                    140:    This problem *does not* appear to be connected with any
                    141:    macro definition for atof.  It does not seem there is one.  */
                    142: extern double atof ();
                    143: #else
                    144: extern double (atof) ();
                    145: #endif
                    146: #endif
                    147: 
                    148: /* Negate the floating-point value X.  */
                    149: #ifndef REAL_VALUE_NEGATE
                    150: #define REAL_VALUE_NEGATE(x) (- (x))
                    151: #endif
                    152: 
                    153: /* Truncate the floating-point value X to mode MODE.  This is correct only
                    154:    for the most common case where the host and target have objects of the same
                    155:    size and where `float' is SFmode.  */
                    156: 
                    157: #ifndef REAL_VALUE_TRUNCATE
                    158: #define REAL_VALUE_TRUNCATE(mode, x) \
                    159:  (GET_MODE_BITSIZE (mode) == sizeof (float) * HOST_BITS_PER_CHAR       \
                    160:   ? (float) (x) : (x))
                    161: #endif
                    162: 
                    163: /* Determine whether a floating-point value X is infinite. */
                    164: #ifndef REAL_VALUE_ISINF
                    165: #define REAL_VALUE_ISINF(x) (target_isinf (x))
                    166: #endif
                    167: 
1.1.1.2   root      168: /* Determine whether a floating-point value X is a NaN. */
                    169: #ifndef REAL_VALUE_ISNAN
                    170: #define REAL_VALUE_ISNAN(x) (target_isnan (x))
                    171: #endif
                    172: 
1.1.1.3 ! root      173: /* Determine whether a floating-point value X is negative. */
        !           174: #ifndef REAL_VALUE_NEGATIVE
        !           175: #define REAL_VALUE_NEGATIVE(x) (target_negative (x))
        !           176: #endif
        !           177: 
1.1       root      178: /* Determine whether a floating-point value X is minus 0. */
                    179: #ifndef REAL_VALUE_MINUS_ZERO
1.1.1.3 ! root      180: #define REAL_VALUE_MINUS_ZERO(x) ((x) == 0 && REAL_VALUE_NEGATIVE (x))
1.1       root      181: #endif
                    182: 
                    183: /* Constant real values 0, 1, 2, and -1.  */
                    184: 
                    185: extern REAL_VALUE_TYPE dconst0;
                    186: extern REAL_VALUE_TYPE dconst1;
                    187: extern REAL_VALUE_TYPE dconst2;
                    188: extern REAL_VALUE_TYPE dconstm1;
                    189: 
                    190: /* Union type used for extracting real values from CONST_DOUBLEs
                    191:    or putting them in.  */
                    192: 
                    193: union real_extract 
                    194: {
                    195:   REAL_VALUE_TYPE d;
                    196:   int i[sizeof (REAL_VALUE_TYPE) / sizeof (int)];
                    197: };
                    198: 
                    199: /* For a CONST_DOUBLE:
                    200:    The usual two ints that hold the value.
                    201:    For a DImode, that is all there are;
                    202:     and CONST_DOUBLE_LOW is the low-order word and ..._HIGH the high-order.
                    203:    For a float, the number of ints varies,
                    204:     and CONST_DOUBLE_LOW is the one that should come first *in memory*.
                    205:     So use &CONST_DOUBLE_LOW(r) as the address of an array of ints.  */
                    206: #define CONST_DOUBLE_LOW(r) XINT (r, 2)
                    207: #define CONST_DOUBLE_HIGH(r) XINT (r, 3)
                    208: 
                    209: /* Link for chain of all CONST_DOUBLEs in use in current function.  */
                    210: #define CONST_DOUBLE_CHAIN(r) XEXP (r, 1)
                    211: /* The MEM which represents this CONST_DOUBLE's value in memory,
                    212:    or const0_rtx if no MEM has been made for it yet,
                    213:    or cc0_rtx if it is not on the chain.  */
                    214: #define CONST_DOUBLE_MEM(r) XEXP (r, 0)
                    215: 
                    216: /* Function to return a real value (not a tree node)
                    217:    from a given integer constant.  */
                    218: REAL_VALUE_TYPE real_value_from_int_cst ();
                    219: 
                    220: /* Given a CONST_DOUBLE in FROM, store into TO the value it represents.  */
                    221: 
                    222: #define REAL_VALUE_FROM_CONST_DOUBLE(to, from)         \
                    223: do { union real_extract u;                             \
                    224:      bcopy (&CONST_DOUBLE_LOW ((from)), &u, sizeof u); \
                    225:      to = u.d; } while (0)
                    226: 
                    227: /* Return a CONST_DOUBLE with value R and mode M.  */
                    228: 
                    229: #define CONST_DOUBLE_FROM_REAL_VALUE(r,m) immed_real_const_1 (r, m)
                    230: 
                    231: #endif /* Not REAL_H_INCLUDED */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.