aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2008-08-12 13:25:22 +0000
committerUlrich Weigand <uweigand@gcc.gnu.org>2008-08-12 13:25:22 +0000
commit4099e2c2bb7e81926d3ee91a856834ee7672c694 (patch)
tree1a92af168da8700726521cc728ffef015dec9823 /gcc
parente0bddf109cc33590570b30eceea42bb6fcdea8ec (diff)
downloadgcc-4099e2c2bb7e81926d3ee91a856834ee7672c694.zip
gcc-4099e2c2bb7e81926d3ee91a856834ee7672c694.tar.gz
gcc-4099e2c2bb7e81926d3ee91a856834ee7672c694.tar.bz2
real.h (struct real_format): New member has_sign_dependent_rounding.
* real.h (struct real_format): New member has_sign_dependent_rounding. * real.c (ieee_single_format, mips_single_format, motorola_single_format, spu_single_format, ieee_double_format, mips_double_format, motorola_double_format, ieee_extended_motorola_format, ieee_extended_intel_96_format, ieee_extended_intel_128_format, ieee_extended_intel_96_round_53_format, ibm_extended_format, mips_extended_format, ieee_quad_format, mips_quad_format, vax_f_format, vax_d_format, vax_g_format): Initialize it. * config/pdp11/pdp11.c (pdp11_f_format, pdp11_d_format): Likewise. * defaults.h (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING): Remove. * config/spu/spu.h (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGN_DEPENDENT_ROUNDING): Remove. (ROUND_TOWARDS_ZERO): Likewise. * real.h (REAL_MODE_FORMAT): Protect MODE against macro expansion. (FLOAT_MODE_FORMAT): New macro. (REAL_MODE_FORMAT_COMPOSITE_P): Remove, replace by ... (MODE_COMPOSITE_P): ... this new macro. (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING): New macros. * machmode.h (GET_MODE_INNER): Cast result to enum machine_mode. * flags.h: Include "real.h". * fold-const.c (const_binop): Use MODE_COMPOSITE_P instead of REAL_MODE_FORMAT_COMPOSITE_P. * simplify-rtx.c (simplify_const_binary_operation): Likewise. * doc/tm.texi (Storage Layout): Remove documentation of MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING. Update documentation of ROUND_TOWARDS_ZERO and LARGEST_EXPONENT_IS_NORMAL to clarify they only apply to libgcc2.a. From-SVN: r139016
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog38
-rw-r--r--gcc/config/pdp11/pdp11.c2
-rw-r--r--gcc/config/spu/spu.h28
-rw-r--r--gcc/defaults.h26
-rw-r--r--gcc/doc/tm.texi76
-rw-r--r--gcc/flags.h1
-rw-r--r--gcc/fold-const.c3
-rw-r--r--gcc/machmode.h2
-rw-r--r--gcc/real.c22
-rw-r--r--gcc/real.h26
-rw-r--r--gcc/simplify-rtx.c3
11 files changed, 92 insertions, 135 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d4289a5..ceab6a4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,43 @@
2008-08-12 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
+ * real.h (struct real_format): New member has_sign_dependent_rounding.
+ * real.c (ieee_single_format, mips_single_format, motorola_single_format,
+ spu_single_format, ieee_double_format, mips_double_format,
+ motorola_double_format, ieee_extended_motorola_format,
+ ieee_extended_intel_96_format, ieee_extended_intel_128_format,
+ ieee_extended_intel_96_round_53_format, ibm_extended_format,
+ mips_extended_format, ieee_quad_format, mips_quad_format,
+ vax_f_format, vax_d_format, vax_g_format): Initialize it.
+ * config/pdp11/pdp11.c (pdp11_f_format, pdp11_d_format): Likewise.
+
+ * defaults.h (MODE_HAS_NANS, MODE_HAS_INFINITIES,
+ MODE_HAS_SIGNED_ZEROS, MODE_HAS_SIGN_DEPENDENT_ROUNDING): Remove.
+ * config/spu/spu.h (MODE_HAS_NANS, MODE_HAS_INFINITIES,
+ MODE_HAS_SIGN_DEPENDENT_ROUNDING): Remove.
+ (ROUND_TOWARDS_ZERO): Likewise.
+
+ * real.h (REAL_MODE_FORMAT): Protect MODE against macro expansion.
+ (FLOAT_MODE_FORMAT): New macro.
+ (REAL_MODE_FORMAT_COMPOSITE_P): Remove, replace by ...
+ (MODE_COMPOSITE_P): ... this new macro.
+ (MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS,
+ MODE_HAS_SIGN_DEPENDENT_ROUNDING): New macros.
+ * machmode.h (GET_MODE_INNER): Cast result to enum machine_mode.
+
+ * flags.h: Include "real.h".
+
+ * fold-const.c (const_binop): Use MODE_COMPOSITE_P instead of
+ REAL_MODE_FORMAT_COMPOSITE_P.
+ * simplify-rtx.c (simplify_const_binary_operation): Likewise.
+
+ * doc/tm.texi (Storage Layout): Remove documentation of
+ MODE_HAS_NANS, MODE_HAS_INFINITIES, MODE_HAS_SIGNED_ZEROS,
+ MODE_HAS_SIGN_DEPENDENT_ROUNDING. Update documentation of
+ ROUND_TOWARDS_ZERO and LARGEST_EXPONENT_IS_NORMAL to clarify
+ they only apply to libgcc2.a.
+
+2008-08-12 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
+
* config/spu/float_disf.c: New file.
* config/spu/float_unsdisf.c: New file.
* config/spu/t-elf (LIB2FUNCS_STATIC_EXTRA): Add them.
diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c
index 2de1938..661980f 100644
--- a/gcc/config/pdp11/pdp11.c
+++ b/gcc/config/pdp11/pdp11.c
@@ -79,6 +79,7 @@ const struct real_format pdp11_f_format =
false,
false,
false,
+ false,
false
};
@@ -99,6 +100,7 @@ const struct real_format pdp11_d_format =
false,
false,
false,
+ false,
false
};
diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
index 3405469..0bd69d3 100644
--- a/gcc/config/spu/spu.h
+++ b/gcc/config/spu/spu.h
@@ -124,34 +124,6 @@ extern GTY(()) int spu_tune;
#define STACK_SIZE_MODE SImode
-/* #define TARGET_FLOAT_FORMAT SPU_FLOAT_FORMAT */
-
-#ifndef MODE_HAS_NANS
-#define MODE_HAS_NANS(MODE) \
- (FLOAT_MODE_P (MODE) \
- && MODE != SFmode \
- && !LARGEST_EXPONENT_IS_NORMAL (GET_MODE_BITSIZE (MODE)))
-#endif
-
-#ifndef MODE_HAS_INFINITIES
-#define MODE_HAS_INFINITIES(MODE) \
- (FLOAT_MODE_P (MODE) \
- && MODE != SFmode \
- && !LARGEST_EXPONENT_IS_NORMAL (GET_MODE_BITSIZE (MODE)))
-#endif
-
-#ifndef MODE_HAS_SIGN_DEPENDENT_ROUNDING
-#define MODE_HAS_SIGN_DEPENDENT_ROUNDING(MODE) \
- (FLOAT_MODE_P (MODE) \
- && MODE != SFmode \
- && !ROUND_TOWARDS_ZERO)
-#endif
-
-#define ROUND_TOWARDS_ZERO 1
-
-/* This is certainly true. Should it be defined? (It wasn't before.) */
-/* #define LARGEST_EXPONENT_IS_NORMAL(size) (size != 32) */
-
/* Type Layout */
diff --git a/gcc/defaults.h b/gcc/defaults.h
index e68a065..d6145a4 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -681,32 +681,6 @@ along with GCC; see the file COPYING3. If not see
#define ROUND_TOWARDS_ZERO 0
#endif
-#ifndef MODE_HAS_NANS
-#define MODE_HAS_NANS(MODE) \
- (FLOAT_MODE_P (MODE) \
- && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT \
- && !LARGEST_EXPONENT_IS_NORMAL (GET_MODE_BITSIZE (MODE)))
-#endif
-
-#ifndef MODE_HAS_INFINITIES
-#define MODE_HAS_INFINITIES(MODE) \
- (FLOAT_MODE_P (MODE) \
- && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT \
- && !LARGEST_EXPONENT_IS_NORMAL (GET_MODE_BITSIZE (MODE)))
-#endif
-
-#ifndef MODE_HAS_SIGNED_ZEROS
-#define MODE_HAS_SIGNED_ZEROS(MODE) \
- (FLOAT_MODE_P (MODE) && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
-#endif
-
-#ifndef MODE_HAS_SIGN_DEPENDENT_ROUNDING
-#define MODE_HAS_SIGN_DEPENDENT_ROUNDING(MODE) \
- (FLOAT_MODE_P (MODE) \
- && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT \
- && !ROUND_TOWARDS_ZERO)
-#endif
-
#ifndef FLOAT_LIB_COMPARE_RETURNS_BOOL
#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) false
#endif
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 228af27..facf6f4 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1407,78 +1407,12 @@ The ordering of the component words of floating point values stored in
memory is controlled by @code{FLOAT_WORDS_BIG_ENDIAN}.
@end defmac
-@defmac MODE_HAS_NANS (@var{mode})
-When defined, this macro should be true if @var{mode} has a NaN
-representation. The compiler assumes that NaNs are not equal to
-anything (including themselves) and that addition, subtraction,
-multiplication and division all return NaNs when one operand is
-NaN@.
-
-By default, this macro is true if @var{mode} is a floating-point
-mode and the target floating-point format is IEEE@.
-@end defmac
-
-@defmac MODE_HAS_INFINITIES (@var{mode})
-This macro should be true if @var{mode} can represent infinity. At
-present, the compiler uses this macro to decide whether @samp{x - x}
-is always defined. By default, the macro is true when @var{mode}
-is a floating-point mode and the target format is IEEE@.
-@end defmac
-
-@defmac MODE_HAS_SIGNED_ZEROS (@var{mode})
-True if @var{mode} distinguishes between positive and negative zero.
-The rules are expected to follow the IEEE standard:
-
-@itemize @bullet
-@item
-@samp{x + x} has the same sign as @samp{x}.
-
-@item
-If the sum of two values with opposite sign is zero, the result is
-positive for all rounding modes expect towards @minus{}infinity, for
-which it is negative.
-
-@item
-The sign of a product or quotient is negative when exactly one
-of the operands is negative.
-@end itemize
-
-The default definition is true if @var{mode} is a floating-point
-mode and the target format is IEEE@.
-@end defmac
-
-@defmac MODE_HAS_SIGN_DEPENDENT_ROUNDING (@var{mode})
-If defined, this macro should be true for @var{mode} if it has at
-least one rounding mode in which @samp{x} and @samp{-x} can be
-rounded to numbers of different magnitude. Two such modes are
-towards @minus{}infinity and towards +infinity.
-
-The default definition of this macro is true if @var{mode} is
-a floating-point mode and the target format is IEEE@.
-@end defmac
-
@defmac ROUND_TOWARDS_ZERO
If defined, this macro should be true if the prevailing rounding
-mode is towards zero. A true value has the following effects:
-
-@itemize @bullet
-@item
-@code{MODE_HAS_SIGN_DEPENDENT_ROUNDING} will be false for all modes.
-
-@item
-@file{libgcc.a}'s floating-point emulator will round towards zero
-rather than towards nearest.
+mode is towards zero.
-@item
-The compiler's floating-point emulator will round towards zero after
-doing arithmetic, and when converting from the internal float format to
-the target format.
-@end itemize
-
-The macro does not affect the parsing of string literals. When the
-primary rounding mode is towards zero, library functions like
-@code{strtod} might still round towards nearest, and the compiler's
-parser should behave like the target's @code{strtod} where possible.
+Defining this macro only affects the way @file{libgcc.a} emulates
+floating-point arithmetic.
Not defining this macro is equivalent to returning zero.
@end defmac
@@ -1488,9 +1422,7 @@ This macro should return true if floats with @var{size}
bits do not have a NaN or infinity representation, but use the largest
exponent for normal numbers instead.
-Defining this macro to true for @var{size} causes @code{MODE_HAS_NANS}
-and @code{MODE_HAS_INFINITIES} to be false for @var{size}-bit modes.
-It also affects the way @file{libgcc.a} and @file{real.c} emulate
+Defining this macro only affects the way @file{libgcc.a} emulates
floating-point arithmetic.
The default definition of this macro returns false for all sizes.
diff --git a/gcc/flags.h b/gcc/flags.h
index ceff962..cfd278f 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "options.h"
+#include "real.h"
enum debug_info_type
{
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index cb693d6..cae45b5 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1885,8 +1885,7 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
flag_rounding_math is set, or if GCC's software emulation
is unable to accurately represent the result. */
if ((flag_rounding_math
- || (REAL_MODE_FORMAT_COMPOSITE_P (mode)
- && !flag_unsafe_math_optimizations))
+ || (MODE_COMPOSITE_P (mode) && !flag_unsafe_math_optimizations))
&& (inexact || !real_identical (&result, &value)))
return NULL_TREE;
diff --git a/gcc/machmode.h b/gcc/machmode.h
index 440e7bb..8db9f75 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -202,7 +202,7 @@ extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES];
/* Return the mode of the inner elements in a vector. */
extern const unsigned char mode_inner[NUM_MACHINE_MODES];
-#define GET_MODE_INNER(MODE) mode_inner[MODE]
+#define GET_MODE_INNER(MODE) ((enum machine_mode) mode_inner[MODE])
/* Get the size in bytes of the basic parts of an object of mode MODE. */
diff --git a/gcc/real.c b/gcc/real.c
index 806e2f8..da311c8 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -2873,6 +2873,7 @@ const struct real_format ieee_single_format =
true,
true,
true,
+ true,
false
};
@@ -2892,6 +2893,7 @@ const struct real_format mips_single_format =
true,
true,
true,
+ true,
false,
true
};
@@ -2913,6 +2915,7 @@ const struct real_format motorola_single_format =
true,
true,
true,
+ true,
true
};
@@ -2941,6 +2944,7 @@ const struct real_format spu_single_format =
true,
false,
false,
+ false,
true,
true,
false,
@@ -3152,6 +3156,7 @@ const struct real_format ieee_double_format =
true,
true,
true,
+ true,
false
};
@@ -3171,6 +3176,7 @@ const struct real_format mips_double_format =
true,
true,
true,
+ true,
false,
true
};
@@ -3192,6 +3198,7 @@ const struct real_format motorola_double_format =
true,
true,
true,
+ true,
true
};
@@ -3530,6 +3537,7 @@ const struct real_format ieee_extended_motorola_format =
true,
true,
true,
+ true,
true
};
@@ -3550,6 +3558,7 @@ const struct real_format ieee_extended_intel_96_format =
true,
true,
true,
+ true,
false
};
@@ -3570,6 +3579,7 @@ const struct real_format ieee_extended_intel_128_format =
true,
true,
true,
+ true,
false
};
@@ -3592,6 +3602,7 @@ const struct real_format ieee_extended_intel_96_round_53_format =
true,
true,
true,
+ true,
false
};
@@ -3679,6 +3690,7 @@ const struct real_format ibm_extended_format =
true,
true,
true,
+ true,
false
};
@@ -3698,6 +3710,7 @@ const struct real_format mips_extended_format =
true,
true,
true,
+ true,
false,
true
};
@@ -3961,6 +3974,7 @@ const struct real_format ieee_quad_format =
true,
true,
true,
+ true,
false
};
@@ -3980,6 +3994,7 @@ const struct real_format mips_quad_format =
true,
true,
true,
+ true,
false,
true
};
@@ -4280,6 +4295,7 @@ const struct real_format vax_f_format =
false,
false,
false,
+ false,
false
};
@@ -4300,6 +4316,7 @@ const struct real_format vax_d_format =
false,
false,
false,
+ false,
false
};
@@ -4320,6 +4337,7 @@ const struct real_format vax_g_format =
false,
false,
false,
+ false,
false
};
@@ -4393,6 +4411,7 @@ const struct real_format decimal_single_format =
true,
true,
true,
+ true,
true,
true,
false
@@ -4416,6 +4435,7 @@ const struct real_format decimal_double_format =
true,
true,
true,
+ true,
false
};
@@ -4434,6 +4454,7 @@ const struct real_format decimal_quad_format =
false,
true,
true,
+ true,
true,
true,
true,
@@ -4476,6 +4497,7 @@ const struct real_format real_internal_format =
-1,
-1,
false,
+ false,
true,
true,
false,
diff --git a/gcc/real.h b/gcc/real.h
index d849a2e..8cdf471 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -149,6 +149,7 @@ struct real_format
/* Default rounding mode for operations on this format. */
bool round_towards_zero;
+ bool has_sign_dependent_rounding;
/* Properties of the format. */
bool has_nans;
@@ -171,15 +172,32 @@ extern const struct real_format *
#define REAL_MODE_FORMAT(MODE) \
(real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \
- ? ((MODE - MIN_MODE_DECIMAL_FLOAT) \
+ ? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \
+ (MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1)) \
- : (MODE - MIN_MODE_FLOAT)])
+ : ((MODE) - MIN_MODE_FLOAT)])
+
+#define FLOAT_MODE_FORMAT(MODE) \
+ (REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \
+ : GET_MODE_INNER (MODE)))
/* The following macro determines whether the floating point format is
composite, i.e. may contain non-consecutive mantissa bits, in which
case compile-time FP overflow may not model run-time overflow. */
-#define REAL_MODE_FORMAT_COMPOSITE_P(MODE) \
- ((REAL_MODE_FORMAT(MODE))->pnan < (REAL_MODE_FORMAT (MODE))->p)
+#define MODE_COMPOSITE_P(MODE) \
+ (FLOAT_MODE_P (MODE) \
+ && FLOAT_MODE_FORMAT (MODE)->pnan < FLOAT_MODE_FORMAT (MODE)->p)
+
+/* Accessor macros for format properties. */
+#define MODE_HAS_NANS(MODE) \
+ (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_nans)
+#define MODE_HAS_INFINITIES(MODE) \
+ (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_inf)
+#define MODE_HAS_SIGNED_ZEROS(MODE) \
+ (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_signed_zero)
+#define MODE_HAS_SIGN_DEPENDENT_ROUNDING(MODE) \
+ (FLOAT_MODE_P (MODE) \
+ && FLOAT_MODE_FORMAT (MODE)->has_sign_dependent_rounding)
+
/* Declare functions in real.c. */
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 262c919..5c57c89 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -3080,8 +3080,7 @@ simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode,
is unable to accurately represent the result. */
if ((flag_rounding_math
- || (REAL_MODE_FORMAT_COMPOSITE_P (mode)
- && !flag_unsafe_math_optimizations))
+ || (MODE_COMPOSITE_P (mode) && !flag_unsafe_math_optimizations))
&& (inexact || !real_identical (&result, &value)))
return NULL_RTX;