]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/real.h
postreload.c (reload_cse_simplify_set): Call cselib_lookup earlier.
[gcc.git] / gcc / real.h
index 7ac10ffdd9af19e58414df17d947d27a7919af07..71e3cc4b6b9f8222d6836dc72a278f871a9d5c06 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of floating-point access for GNU compiler.
-   Copyright (C) 1989, 1991, 1994, 1996, 1997, 1998,
-   1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1989, 1991, 1994, 1996, 1997, 1998, 1999,
+   2000, 2002, 2003 Free Software Foundation, Inc.
 
    This file is part of GCC.
 
 
 #include "machmode.h"
 
-/* REAL_VALUE_TYPE is an array of the minimum number of HOST_WIDE_INTs
-   required to hold a 128-bit floating point type.  This is true even
-   if the maximum precision floating point type on the target is smaller.
+/* An expanded form of the represented number.  */
 
-   The extra 32 bits are for storing the mode of the float.  Ideally
-   we'd keep this elsewhere, but that's too drastic a change all at once.  */
+/* Enumerate the special cases of numbers that we encounter.  */
+enum real_value_class {
+  rvc_zero,
+  rvc_normal,
+  rvc_inf,
+  rvc_nan
+};
+
+#define SIGNIFICAND_BITS       (128 + HOST_BITS_PER_LONG)
+#define EXP_BITS               (32 - 5)
+#define MAX_EXP                        ((1 << (EXP_BITS - 1)) - 1)
+#define SIGSZ                  (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
+#define SIG_MSB                        ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
+
+struct real_value GTY(())
+{
+  ENUM_BITFIELD (real_value_class) class : 2;
+  unsigned int sign : 1;
+  unsigned int signalling : 1;
+  unsigned int canonical : 1;
+  signed int exp : EXP_BITS;
+  unsigned long sig[SIGSZ];
+};
+
+/* Various headers condition prototypes on #ifdef REAL_VALUE_TYPE, so it
+   needs to be a macro.  We do need to continue to have a structure tag
+   so that other headers can forward declare it.  */
+#define REAL_VALUE_TYPE struct real_value
 
-#define REAL_VALUE_TYPE_SIZE (128 + 32)
+/* We store a REAL_VALUE_TYPE into an rtx, and we do this by putting it in
+   consecutive "w" slots.  Moreover, we've got to compute the number of "w"
+   slots at preprocessor time, which means we can't use sizeof.  Guess.  */
+
+#define REAL_VALUE_TYPE_SIZE (SIGNIFICAND_BITS + 32)
 #define REAL_WIDTH \
   (REAL_VALUE_TYPE_SIZE/HOST_BITS_PER_WIDE_INT \
    + (REAL_VALUE_TYPE_SIZE%HOST_BITS_PER_WIDE_INT ? 1 : 0)) /* round up */
 
-struct realvaluetype GTY(()) {
-  HOST_WIDE_INT r[REAL_WIDTH];
-};
-
-/* Various headers condition prototypes on #ifdef REAL_VALUE_TYPE, so it needs
-   to be a macro.  realvaluetype cannot be a typedef as this interferes with
-   other headers declaring opaque pointers to it.  */
-#define REAL_VALUE_TYPE struct realvaluetype
+/* Verify the guess.  */
+extern char test_real_width
+  [sizeof(REAL_VALUE_TYPE) <= REAL_WIDTH*sizeof(HOST_WIDE_INT) ? 1 : -1];
 
 /* Calculate the format for CONST_DOUBLE.  We need as many slots as
    are necessary to overlay a REAL_VALUE_TYPE on them.  This could be
@@ -67,17 +90,63 @@ struct realvaluetype GTY(()) {
 #    if REAL_WIDTH == 5
 #     define CONST_DOUBLE_FORMAT "wwwww"
 #    else
-      #error "REAL_WIDTH > 5 not supported"
+#     if REAL_WIDTH == 6
+#      define CONST_DOUBLE_FORMAT "wwwwww"
+#     else
+       #error "REAL_WIDTH > 6 not supported"
+#     endif
 #    endif
 #   endif
 #  endif
 # endif
 #endif
 
-/* Declare functions in real.c.  */
 
-/* Initialize the emulator.  */
-extern void init_real_once     PARAMS ((void));
+/* Describes the properties of the specific target format in use.  */
+struct real_format
+{
+  /* Move to and from the target bytes.  */
+  void (*encode) PARAMS ((const struct real_format *, long *,
+                         const REAL_VALUE_TYPE *));
+  void (*decode) PARAMS ((const struct real_format *, REAL_VALUE_TYPE *,
+                         const long *));
+
+  /* The radix of the exponent and digits of the significand.  */
+  int b;
+
+  /* log2(b).  */
+  int log2_b;
+
+  /* Size of the significand in digits of radix B.  */
+  int p;
+
+  /* Size of the significant of a NaN, in digits of radix B.  */
+  int pnan;
+
+  /* The minimum negative integer, x, such that b**(x-1) is normalized.  */
+  int emin;
+
+  /* The maximum integer, x, such that b**(x-1) is representable.  */
+  int emax;
+
+  /* The bit position of the sign bit, or -1 for a complex encoding.  */
+  int signbit;
+
+  /* Properties of the format.  */
+  bool has_nans;
+  bool has_inf;
+  bool has_denorm;
+  bool has_signed_zero;
+  bool qnan_msb_set;
+};
+
+
+/* The target format used for each floating floating point mode.
+   Indexed by MODE - QFmode.  */
+extern const struct real_format *real_format_for_mode[TFmode - QFmode + 1];
+
+
+/* Declare functions in real.c.  */
 
 /* Binary or unary arithmetic on tree_code.  */
 extern void real_arithmetic    PARAMS ((REAL_VALUE_TYPE *, int,
@@ -115,11 +184,11 @@ extern bool exact_real_truncate PARAMS ((enum machine_mode,
 
 /* Render R as a decimal floating point constant.  */
 extern void real_to_decimal    PARAMS ((char *, const REAL_VALUE_TYPE *,
-                                        int));
+                                        size_t, size_t, int));
 
 /* Render R as a hexadecimal floating point constant.  */
 extern void real_to_hexadecimal        PARAMS ((char *, const REAL_VALUE_TYPE *,
-                                        int));
+                                        size_t, size_t, int));
 
 /* Render R as an integer.  */
 extern HOST_WIDE_INT real_to_integer PARAMS ((const REAL_VALUE_TYPE *));
@@ -135,9 +204,13 @@ extern void real_from_integer      PARAMS ((REAL_VALUE_TYPE *,
                                         unsigned HOST_WIDE_INT,
                                         HOST_WIDE_INT, int));
 
+extern long real_to_target_fmt PARAMS ((long *, const REAL_VALUE_TYPE *,
+                                        const struct real_format *));
 extern long real_to_target     PARAMS ((long *, const REAL_VALUE_TYPE *,
                                         enum machine_mode));
 
+extern void real_from_target_fmt PARAMS ((REAL_VALUE_TYPE *, const long *,
+                                         const struct real_format *));
 extern void real_from_target   PARAMS ((REAL_VALUE_TYPE *, const long *,
                                         enum machine_mode));
 
@@ -146,8 +219,37 @@ extern void real_inf               PARAMS ((REAL_VALUE_TYPE *));
 extern bool real_nan           PARAMS ((REAL_VALUE_TYPE *, const char *,
                                         int, enum machine_mode));
 
+extern void real_maxval                PARAMS ((REAL_VALUE_TYPE *, int,
+                                        enum machine_mode));
+
 extern void real_2expN         PARAMS ((REAL_VALUE_TYPE *, int));
 
+extern unsigned int real_hash  PARAMS ((const REAL_VALUE_TYPE *));
+
+
+/* Target formats defined in real.c.  */
+extern const struct real_format ieee_single_format;
+extern const struct real_format mips_single_format;
+extern const struct real_format ieee_double_format;
+extern const struct real_format mips_double_format;
+extern const struct real_format ieee_extended_motorola_format;
+extern const struct real_format ieee_extended_intel_96_format;
+extern const struct real_format ieee_extended_intel_96_round_53_format;
+extern const struct real_format ieee_extended_intel_128_format;
+extern const struct real_format ibm_extended_format;
+extern const struct real_format mips_extended_format;
+extern const struct real_format ieee_quad_format;
+extern const struct real_format mips_quad_format;
+extern const struct real_format vax_f_format;
+extern const struct real_format vax_d_format;
+extern const struct real_format vax_g_format;
+extern const struct real_format i370_single_format;
+extern const struct real_format i370_double_format;
+extern const struct real_format c4x_single_format;
+extern const struct real_format c4x_extended_format;
+extern const struct real_format real_internal_format;
+
+
 /* ====================================================================== */
 /* Crap.  */
 
@@ -182,9 +284,6 @@ extern void real_2expN              PARAMS ((REAL_VALUE_TYPE *, int));
 #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
   ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_FLOAT, 0)))
 
-#define REAL_VALUE_TO_DECIMAL(r, s, dig) \
-  real_to_decimal (s, &(r), dig)
-
 #define REAL_VALUE_FROM_INT(r, lo, hi, mode) \
   real_from_integer (&(r), mode, lo, hi, 0)
 
@@ -235,12 +334,14 @@ extern void real_ldexp            PARAMS ((REAL_VALUE_TYPE *,
 
 /* **** End of software floating point emulator interface macros **** */
 \f
-/* Constant real values 0, 1, 2, and -1.  */
+/* Constant real values 0, 1, 2, -1, -2 and 0.5.  */
 
 extern REAL_VALUE_TYPE dconst0;
 extern REAL_VALUE_TYPE dconst1;
 extern REAL_VALUE_TYPE dconst2;
 extern REAL_VALUE_TYPE dconstm1;
+extern REAL_VALUE_TYPE dconstm2;
+extern REAL_VALUE_TYPE dconsthalf;
 
 /* Function to return a real value (not a tree node)
    from a given integer constant.  */
@@ -263,5 +364,15 @@ extern bool exact_real_inverse     PARAMS ((enum machine_mode, REAL_VALUE_TYPE *));
 /* In tree.c: wrap up a REAL_VALUE_TYPE in a tree node.  */
 extern tree build_real                 PARAMS ((tree, REAL_VALUE_TYPE));
 
+/* Calculate R as the square root of X in the given machine mode.  */
+extern bool real_sqrt                  PARAMS ((REAL_VALUE_TYPE *,
+                                                enum machine_mode,
+                                                const REAL_VALUE_TYPE *));
+
+/* Calculate R as X raised to the integer exponent N in mode MODE.  */
+extern bool real_powi                  PARAMS ((REAL_VALUE_TYPE *,
+                                                enum machine_mode,
+                                                const REAL_VALUE_TYPE *,
+                                                HOST_WIDE_INT));
 
 #endif /* ! GCC_REAL_H */
This page took 0.03444 seconds and 5 git commands to generate.