Mercurial > hg > CbC > CbC_gcc
diff gcc/machmode.h @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | 84e7813d76e9 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/gcc/machmode.h Thu Oct 25 08:08:40 2018 +0900 +++ b/gcc/machmode.h Thu Oct 25 10:21:07 2018 +0900 @@ -1,5 +1,5 @@ /* Machine mode definitions for GCC; included by rtl.h and tree.h. - Copyright (C) 1991-2017 Free Software Foundation, Inc. + Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of GCC. @@ -22,10 +22,10 @@ typedef opt_mode<machine_mode> opt_machine_mode; -extern CONST_MODE_SIZE unsigned short mode_size[NUM_MACHINE_MODES]; -extern const unsigned short mode_precision[NUM_MACHINE_MODES]; +extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES]; +extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES]; extern const unsigned char mode_inner[NUM_MACHINE_MODES]; -extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; +extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES]; extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; extern const unsigned char mode_wider[NUM_MACHINE_MODES]; @@ -76,6 +76,14 @@ typedef machine_mode from_int; }; +/* Always treat machine modes as fixed-size while compiling code specific + to targets that have no variable-size modes. */ +#if defined (IN_TARGET_CODE) && NUM_POLY_INT_COEFFS == 1 +#define ONLY_FIXED_SIZE_MODES 1 +#else +#define ONLY_FIXED_SIZE_MODES 0 +#endif + /* Get the name of mode MODE as a string. */ extern const char * const mode_name[NUM_MACHINE_MODES]; @@ -100,6 +108,7 @@ (GET_MODE_CLASS (MODE) == MODE_INT \ || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \ || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ + || GET_MODE_CLASS (MODE) == MODE_VECTOR_BOOL \ || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT) /* Nonzero if MODE is a floating-point mode. */ @@ -115,8 +124,9 @@ || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) /* Nonzero if MODE is a vector mode. */ -#define VECTOR_MODE_P(MODE) \ - (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ +#define VECTOR_MODE_P(MODE) \ + (GET_MODE_CLASS (MODE) == MODE_VECTOR_BOOL \ + || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \ || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \ || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \ @@ -227,9 +237,6 @@ || CLASS == MODE_ACCUM \ || CLASS == MODE_UACCUM) -#define POINTER_BOUNDS_MODE_P(MODE) \ - (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS) - /* An optional T (i.e. a T or nothing), where T is some form of mode class. */ template<typename T> class opt_mode @@ -313,6 +320,7 @@ struct pod_mode { typedef typename mode_traits<T>::from_int from_int; + typedef typename T::measurement_type measurement_type; machine_mode m_mode; ALWAYS_INLINE operator machine_mode () const { return m_mode; } @@ -391,6 +399,7 @@ { public: typedef mode_traits<scalar_int_mode>::from_int from_int; + typedef unsigned short measurement_type; ALWAYS_INLINE scalar_int_mode () {} ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} @@ -415,6 +424,7 @@ { public: typedef mode_traits<scalar_float_mode>::from_int from_int; + typedef unsigned short measurement_type; ALWAYS_INLINE scalar_float_mode () {} ALWAYS_INLINE scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {} @@ -439,6 +449,7 @@ { public: typedef mode_traits<scalar_mode>::from_int from_int; + typedef unsigned short measurement_type; ALWAYS_INLINE scalar_mode () {} ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} @@ -468,7 +479,6 @@ case MODE_UACCUM: case MODE_FLOAT: case MODE_DECIMAL_FLOAT: - case MODE_POINTER_BOUNDS: return true; default: return false; @@ -480,6 +490,7 @@ { public: typedef mode_traits<complex_mode>::from_int from_int; + typedef unsigned short measurement_type; ALWAYS_INLINE complex_mode () {} ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_mode (m)) {} @@ -501,7 +512,7 @@ /* Return the base GET_MODE_SIZE value for MODE. */ -ALWAYS_INLINE unsigned short +ALWAYS_INLINE poly_uint16 mode_to_bytes (machine_mode mode) { #if GCC_VERSION >= 4001 @@ -514,7 +525,7 @@ /* Return the base GET_MODE_BITSIZE value for MODE. */ -ALWAYS_INLINE unsigned short +ALWAYS_INLINE poly_uint16 mode_to_bits (machine_mode mode) { return mode_to_bytes (mode) * BITS_PER_UNIT; @@ -522,7 +533,7 @@ /* Return the base GET_MODE_PRECISION value for MODE. */ -ALWAYS_INLINE unsigned short +ALWAYS_INLINE poly_uint16 mode_to_precision (machine_mode mode) { return mode_precision[mode]; @@ -570,7 +581,7 @@ /* Return the base GET_MODE_NUNITS value for MODE. */ -ALWAYS_INLINE unsigned short +ALWAYS_INLINE poly_uint16 mode_to_nunits (machine_mode mode) { #if GCC_VERSION >= 4001 @@ -583,15 +594,82 @@ /* Get the size in bytes of an object of mode MODE. */ -#define GET_MODE_SIZE(MODE) (mode_to_bytes (MODE)) +#if ONLY_FIXED_SIZE_MODES +#define GET_MODE_SIZE(MODE) ((unsigned short) mode_to_bytes (MODE).coeffs[0]) +#else +ALWAYS_INLINE poly_uint16 +GET_MODE_SIZE (machine_mode mode) +{ + return mode_to_bytes (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type +GET_MODE_SIZE (const T &mode) +{ + return mode_to_bytes (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type +GET_MODE_SIZE (const T &mode) +{ + return mode_to_bytes (mode).coeffs[0]; +} +#endif /* Get the size in bits of an object of mode MODE. */ -#define GET_MODE_BITSIZE(MODE) (mode_to_bits (MODE)) +#if ONLY_FIXED_SIZE_MODES +#define GET_MODE_BITSIZE(MODE) ((unsigned short) mode_to_bits (MODE).coeffs[0]) +#else +ALWAYS_INLINE poly_uint16 +GET_MODE_BITSIZE (machine_mode mode) +{ + return mode_to_bits (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type +GET_MODE_BITSIZE (const T &mode) +{ + return mode_to_bits (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type +GET_MODE_BITSIZE (const T &mode) +{ + return mode_to_bits (mode).coeffs[0]; +} +#endif /* Get the number of value bits of an object of mode MODE. */ -#define GET_MODE_PRECISION(MODE) (mode_to_precision (MODE)) +#if ONLY_FIXED_SIZE_MODES +#define GET_MODE_PRECISION(MODE) \ + ((unsigned short) mode_to_precision (MODE).coeffs[0]) +#else +ALWAYS_INLINE poly_uint16 +GET_MODE_PRECISION (machine_mode mode) +{ + return mode_to_precision (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type +GET_MODE_PRECISION (const T &mode) +{ + return mode_to_precision (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type +GET_MODE_PRECISION (const T &mode) +{ + return mode_to_precision (mode).coeffs[0]; +} +#endif /* Get the number of integral bits of an object of mode MODE. */ extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES]; @@ -627,7 +705,29 @@ /* Get the number of units in an object of mode MODE. This is 2 for complex modes and the number of elements for vector modes. */ -#define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE)) +#if ONLY_FIXED_SIZE_MODES +#define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE).coeffs[0]) +#else +ALWAYS_INLINE poly_uint16 +GET_MODE_NUNITS (machine_mode mode) +{ + return mode_to_nunits (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type +GET_MODE_NUNITS (const T &mode) +{ + return mode_to_nunits (mode); +} + +template<typename T> +ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type +GET_MODE_NUNITS (const T &mode) +{ + return mode_to_nunits (mode).coeffs[0]; +} +#endif /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ @@ -652,14 +752,59 @@ extern const unsigned char mode_complex[NUM_MACHINE_MODES]; #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE]) -extern opt_machine_mode mode_for_size (unsigned int, enum mode_class, int); +/* Represents a machine mode that must have a fixed size. The main + use of this class is to represent the modes of objects that always + have static storage duration, such as constant pool entries. + (No current target supports the concept of variable-size static data.) */ +class fixed_size_mode +{ +public: + typedef mode_traits<fixed_size_mode>::from_int from_int; + typedef unsigned short measurement_type; + + ALWAYS_INLINE fixed_size_mode () {} + ALWAYS_INLINE fixed_size_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE fixed_size_mode (const scalar_mode &m) : m_mode (m) {} + ALWAYS_INLINE fixed_size_mode (const scalar_int_mode &m) : m_mode (m) {} + ALWAYS_INLINE fixed_size_mode (const scalar_float_mode &m) : m_mode (m) {} + ALWAYS_INLINE fixed_size_mode (const scalar_mode_pod &m) : m_mode (m) {} + ALWAYS_INLINE fixed_size_mode (const scalar_int_mode_pod &m) : m_mode (m) {} + ALWAYS_INLINE fixed_size_mode (const complex_mode &m) : m_mode (m) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if MODE has a fixed size. */ + +inline bool +fixed_size_mode::includes_p (machine_mode mode) +{ + return mode_to_bytes (mode).is_constant (); +} + +/* Wrapper for mode arguments to target macros, so that if a target + doesn't need polynomial-sized modes, its header file can continue + to treat everything as fixed_size_mode. This should go away once + macros are moved to target hooks. It shouldn't be used in other + contexts. */ +#if NUM_POLY_INT_COEFFS == 1 +#define MACRO_MODE(MODE) (as_a <fixed_size_mode> (MODE)) +#else +#define MACRO_MODE(MODE) (MODE) +#endif + +extern opt_machine_mode mode_for_size (poly_uint64, enum mode_class, int); /* Return the machine mode to use for a MODE_INT of SIZE bits, if one exists. If LIMIT is nonzero, modes wider than MAX_FIXED_MODE_SIZE will not be used. */ inline opt_scalar_int_mode -int_mode_for_size (unsigned int size, int limit) +int_mode_for_size (poly_uint64 size, int limit) { return dyn_cast <scalar_int_mode> (mode_for_size (size, MODE_INT, limit)); } @@ -668,7 +813,7 @@ exists. */ inline opt_scalar_float_mode -float_mode_for_size (unsigned int size) +float_mode_for_size (poly_uint64 size) { return dyn_cast <scalar_float_mode> (mode_for_size (size, MODE_FLOAT, 0)); } @@ -682,21 +827,21 @@ (mode_for_size (size, MODE_DECIMAL_FLOAT, 0)); } -extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class); +extern machine_mode smallest_mode_for_size (poly_uint64, enum mode_class); /* Find the narrowest integer mode that contains at least SIZE bits. Such a mode must exist. */ inline scalar_int_mode -smallest_int_mode_for_size (unsigned int size) +smallest_int_mode_for_size (poly_uint64 size) { return as_a <scalar_int_mode> (smallest_mode_for_size (size, MODE_INT)); } extern opt_scalar_int_mode int_mode_for_mode (machine_mode); extern opt_machine_mode bitwise_mode_for_mode (machine_mode); -extern opt_machine_mode mode_for_vector (scalar_mode, unsigned); -extern opt_machine_mode mode_for_int_vector (unsigned int, unsigned int); +extern opt_machine_mode mode_for_vector (scalar_mode, poly_uint64); +extern opt_machine_mode mode_for_int_vector (unsigned int, poly_uint64); /* Return the integer vector equivalent of MODE, if one exists. In other words, return the mode for an integer vector that has the same number @@ -716,7 +861,7 @@ { public: bit_field_mode_iterator (HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, + poly_int64, poly_int64, unsigned int, bool); bool next_mode (scalar_int_mode *); bool prefer_smaller_modes (); @@ -727,8 +872,8 @@ for invalid input such as gcc.dg/pr48335-8.c. */ HOST_WIDE_INT m_bitsize; HOST_WIDE_INT m_bitpos; - HOST_WIDE_INT m_bitregion_start; - HOST_WIDE_INT m_bitregion_end; + poly_int64 m_bitregion_start; + poly_int64 m_bitregion_end; unsigned int m_align; bool m_volatilep; int m_count; @@ -736,8 +881,7 @@ /* Find the best mode to use to access a bit field. */ -extern bool get_best_mode (int, int, unsigned HOST_WIDE_INT, - unsigned HOST_WIDE_INT, unsigned int, +extern bool get_best_mode (int, int, poly_uint64, poly_uint64, unsigned int, unsigned HOST_WIDE_INT, bool, scalar_int_mode *); /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ @@ -784,9 +928,22 @@ (targetm.truly_noop_truncation (GET_MODE_PRECISION (MODE1), \ GET_MODE_PRECISION (MODE2))) -#define HWI_COMPUTABLE_MODE_P(MODE) \ - (SCALAR_INT_MODE_P (MODE) \ - && GET_MODE_PRECISION (MODE) <= HOST_BITS_PER_WIDE_INT) +/* Return true if MODE is a scalar integer mode that fits in a + HOST_WIDE_INT. */ + +inline bool +HWI_COMPUTABLE_MODE_P (machine_mode mode) +{ + machine_mode mme = mode; + return (SCALAR_INT_MODE_P (mme) + && mode_to_precision (mme).coeffs[0] <= HOST_BITS_PER_WIDE_INT); +} + +inline bool +HWI_COMPUTABLE_MODE_P (scalar_int_mode mode) +{ + return GET_MODE_PRECISION (mode) <= HOST_BITS_PER_WIDE_INT; +} struct int_n_data_t { /* These parts are initailized by genmodes output */ @@ -860,6 +1017,17 @@ return false; } +/* Return true if MODE is a scalar integer mode with a precision + smaller than LIMIT's precision. */ + +inline bool +is_narrower_int_mode (machine_mode mode, scalar_int_mode limit) +{ + scalar_int_mode int_mode; + return (is_a <scalar_int_mode> (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (limit)); +} + namespace mode_iterator { /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */