From 501623d42404843e3b737db24bbd575db937ce1d Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 30 Aug 2017 11:10:11 +0000 Subject: [15/77] Add scalar_int_mode Similar to the previous scalar_float_mode patch, but for modes that satisfy SCALAR_INT_MODE_P. There are very many uses of scalar integers, so this patch only makes a token change to the types of byte_mode, word_mode, ptr_mode and rs6000_pmode. The next patches in the series gradually replace more uses. The patch also removes and adds casts to some target-specific code due to the new types of SImode, DImode and Pmode. The as_a goes away in a later patch. 2017-08-30 Richard Sandiford Alan Hayward David Sherwood gcc/ * config/powerpcspe/powerpcspe.h (rs6000_pmode): Change type from machine_mode to scalar_int_mode. * config/powerpcspe/powerpcspe.c (rs6000_pmode): Likewise. (rs6000_option_override_internal): Remove cast to int. * config/rs6000/rs6000.h (rs6000_pmode): Change type from machine_mode to scalar_int_mode. * config/rs6000/rs6000.c (rs6000_pmode): Likewise. (rs6000_option_override_internal): Remove cast to int. * config/s390/s390.h (Pmode): Remove cast to machine_mode. * config/epiphany/epiphany.h (RTX_OK_FOR_OFFSET_P): Add cast to machine_mode. * config/s390/s390.c (s390_expand_builtin): Likewise. * coretypes.h (scalar_int_mode): New type. (opt_scalar_int_mode): New typedef. * machmode.h (scalar_int_mode): New class. (scalar_int_mode::includes_p): New function. (byte_mode): Change type to scalar_int_mode. (word_mode): Likewise. (ptr_mode): Likewise. * emit-rtl.c (byte_mode): Likewise. (word_mode): Likewise. (ptr_mode): Likewise. (init_derived_machine_modes): Update accordingly. * genmodes.c (get_mode_class): Return scalar_int_mode for MODE_INT and MODE_PARTIAL_INT. * gdbhooks.py (build_pretty_printer): Handle scalar_int_mode and opt_scalar_int_mode. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r251467 --- gcc/machmode.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'gcc/machmode.h') diff --git a/gcc/machmode.h b/gcc/machmode.h index 2603d83..dda7c0a 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -338,6 +338,30 @@ is_a (machine_mode m, U *result) return false; } +/* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */ +class scalar_int_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE scalar_int_mode () {} + ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_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 M is a scalar_int_mode. */ + +inline bool +scalar_int_mode::includes_p (machine_mode m) +{ + return SCALAR_INT_MODE_P (m); +} + /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ class scalar_float_mode { @@ -605,9 +629,9 @@ get_narrowest_mode (T mode) /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD and the mode whose class is Pmode and whose size is POINTER_SIZE. */ -extern machine_mode byte_mode; -extern machine_mode word_mode; -extern machine_mode ptr_mode; +extern scalar_int_mode byte_mode; +extern scalar_int_mode word_mode; +extern scalar_int_mode ptr_mode; /* Target-dependent machine mode initialization - in insn-modes.c. */ extern void init_adjust_machine_modes (void); -- cgit v1.1