diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-09-05 19:57:18 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-09-05 19:57:18 +0000 |
commit | 61b2290a5c248efd43dd45b1b256e7f792f21f02 (patch) | |
tree | d9340114f5023e3bd3cdef8624f2ae51f4132ca2 /gcc/machmode.h | |
parent | 7773dca7d22dad2a9e6d2385584411308913ab1b (diff) | |
download | gcc-61b2290a5c248efd43dd45b1b256e7f792f21f02.zip gcc-61b2290a5c248efd43dd45b1b256e7f792f21f02.tar.gz gcc-61b2290a5c248efd43dd45b1b256e7f792f21f02.tar.bz2 |
Make mode_for_size return an opt_mode
...to make it consistent with int_mode_for_size etc.
require () seems like the right choice in replace_reg_with_saved_mem
because we use the chosen mode for saving and restoring registers,
which cannot be done in BLKmode. Similarly require () seems like
the right choice in calls related to secondary memory reloads (the ones
in config/, and in get_secondary_mem) because the reload must always
have a defined mode, which e.g. determines the size of the slot.
We can use require () in simplify_subreg_concatn and assemble_integer
because it isn't meaningful to create a subreg with BLKmode (for one
thing, we couldn't tell then whether it was partial, paradoxical, etc.).
make_fract_type and make_accum_type must find a mode because that's
what distinguishes accumulator FIXED_POINT_TYPEs from fractional
FIXED_POINT_TYPEs.
2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* machmode.h (opt_machine_mode): New type.
(opt_mode<T>): Allow construction from anything that can be
converted to a T.
(is_a, as_a, dyn_cast): Add overloads for opt_mode.
(mode_for_size): Return an opt_machine_mode.
* stor-layout.c (mode_for_size): Likewise.
(mode_for_size_tree): Update call accordingly.
(bitwise_mode_for_mode): Likewise.
(make_fract_type): Likewise.
(make_accum_type): Likewise.
* caller-save.c (replace_reg_with_saved_mem): Update call
accordingly.
* config/alpha/alpha.h (SECONDARY_MEMORY_NEEDED_MODE): Likewise.
* config/i386/i386.h (SECONDARY_MEMORY_NEEDED_MODE): Likewise.
* config/s390/s390.h (SECONDARY_MEMORY_NEEDED_MODE): Likewise.
* config/sparc/sparc.h (SECONDARY_MEMORY_NEEDED_MODE): Likewise.
* expmed.c (extract_bit_field_1): Likewise.
* reload.c (get_secondary_mem): Likewise.
* varasm.c (assemble_integer): Likewise.
* lower-subreg.c (simplify_subreg_concatn): Likewise. Move
early-out.
From-SVN: r251728
Diffstat (limited to 'gcc/machmode.h')
-rw-r--r-- | gcc/machmode.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/gcc/machmode.h b/gcc/machmode.h index d8344a9..956e2c0 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -20,6 +20,8 @@ along with GCC; see the file COPYING3. If not see #ifndef HAVE_MACHINE_MODES #define HAVE_MACHINE_MODES +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 unsigned char mode_inner[NUM_MACHINE_MODES]; @@ -237,6 +239,8 @@ public: ALWAYS_INLINE opt_mode () : m_mode (E_VOIDmode) {} ALWAYS_INLINE opt_mode (const T &m) : m_mode (m) {} + template<typename U> + ALWAYS_INLINE opt_mode (const U &m) : m_mode (T (m)) {} ALWAYS_INLINE opt_mode (from_int m) : m_mode (machine_mode (m)) {} machine_mode else_void () const; @@ -325,6 +329,13 @@ is_a (machine_mode m) return T::includes_p (m); } +template<typename T, typename U> +inline bool +is_a (const opt_mode<U> &m) +{ + return T::includes_p (m.else_void ()); +} + /* Assert that mode M has type T, and return it in that form. */ template<typename T> @@ -335,6 +346,13 @@ as_a (machine_mode m) return typename mode_traits<T>::from_int (m); } +template<typename T, typename U> +inline T +as_a (const opt_mode<U> &m) +{ + return as_a <T> (m.else_void ()); +} + /* Convert M to an opt_mode<T>. */ template<typename T> @@ -346,6 +364,13 @@ dyn_cast (machine_mode m) return opt_mode<T> (); } +template<typename T, typename U> +inline opt_mode<T> +dyn_cast (const opt_mode<U> &m) +{ + return dyn_cast <T> (m.else_void ()); +} + /* Return true if mode M has type T, storing it as a T in *RESULT if so. */ @@ -627,11 +652,7 @@ GET_MODE_2XWIDER_MODE (const T &m) extern const unsigned char mode_complex[NUM_MACHINE_MODES]; #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE]) -/* Return the mode for data of a given size SIZE and mode class CLASS. - If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE. - The value is BLKmode if no other mode is found. */ - -extern machine_mode mode_for_size (unsigned int, enum mode_class, int); +extern opt_machine_mode mode_for_size (unsigned int, 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 |