aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:10:11 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:10:11 +0000
commit501623d42404843e3b737db24bbd575db937ce1d (patch)
tree721c0b46dec4b883eb0047dd6aeb86ff1aaf7175
parent7c5bd57a753528f8a612d3e63d3cd0d53f99e71d (diff)
downloadgcc-501623d42404843e3b737db24bbd575db937ce1d.zip
gcc-501623d42404843e3b737db24bbd575db937ce1d.tar.gz
gcc-501623d42404843e3b737db24bbd575db937ce1d.tar.bz2
[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 <scalar_int_mode> goes away in a later patch. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> 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 <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251467
-rw-r--r--gcc/ChangeLog32
-rw-r--r--gcc/config/epiphany/epiphany.h3
-rw-r--r--gcc/config/powerpcspe/powerpcspe.c9
-rw-r--r--gcc/config/powerpcspe/powerpcspe.h4
-rw-r--r--gcc/config/rs6000/rs6000.c9
-rw-r--r--gcc/config/rs6000/rs6000.h4
-rw-r--r--gcc/config/s390/s390.c2
-rw-r--r--gcc/config/s390/s390.h2
-rw-r--r--gcc/coretypes.h3
-rw-r--r--gcc/emit-rtl.c28
-rw-r--r--gcc/gdbhooks.py7
-rw-r--r--gcc/genmodes.c4
-rw-r--r--gcc/machmode.h30
13 files changed, 101 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 221693a..2f8f970 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,38 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * 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.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* target.def (libgcc_floating_mode_supported_p): Take a
scalar_float_mode.
* doc/tm.texi: Regenerate.
diff --git a/gcc/config/epiphany/epiphany.h b/gcc/config/epiphany/epiphany.h
index d20d400..c06726c4 100644
--- a/gcc/config/epiphany/epiphany.h
+++ b/gcc/config/epiphany/epiphany.h
@@ -641,7 +641,8 @@ typedef struct GTY (()) machine_function
#define RTX_OK_FOR_OFFSET_P(MODE, X) \
RTX_OK_FOR_OFFSET_1 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
- && epiphany_vect_align == 4 ? SImode : (MODE), X)
+ && epiphany_vect_align == 4 \
+ ? (machine_mode) SImode : (machine_mode) (MODE), X)
#define RTX_OK_FOR_OFFSET_1(MODE, X) \
(GET_CODE (X) == CONST_INT \
&& !(INTVAL (X) & (GET_MODE_SIZE (MODE) - 1)) \
diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index 684467a..c4ddf40 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -186,9 +186,8 @@ int dot_symbols;
/* Specify the machine mode that pointers have. After generation of rtl, the
compiler makes no further distinction between pointers and any other objects
- of this machine mode. The type is unsigned since not all things that
- include powerpcspe.h also include machmode.h. */
-unsigned rs6000_pmode;
+ of this machine mode. */
+scalar_int_mode rs6000_pmode;
/* Width in bits of a pointer. */
unsigned rs6000_pointer_size;
@@ -4038,12 +4037,12 @@ rs6000_option_override_internal (bool global_init_p)
/* Set the pointer size. */
if (TARGET_64BIT)
{
- rs6000_pmode = (int)DImode;
+ rs6000_pmode = DImode;
rs6000_pointer_size = 64;
}
else
{
- rs6000_pmode = (int)SImode;
+ rs6000_pmode = SImode;
rs6000_pointer_size = 32;
}
diff --git a/gcc/config/powerpcspe/powerpcspe.h b/gcc/config/powerpcspe/powerpcspe.h
index e3e417a..f805f9b 100644
--- a/gcc/config/powerpcspe/powerpcspe.h
+++ b/gcc/config/powerpcspe/powerpcspe.h
@@ -2220,8 +2220,8 @@ do { \
/* Specify the machine mode that pointers have.
After generation of rtl, the compiler makes no further distinction
between pointers and any other objects of this machine mode. */
-extern unsigned rs6000_pmode;
-#define Pmode ((machine_mode)rs6000_pmode)
+extern scalar_int_mode rs6000_pmode;
+#define Pmode rs6000_pmode
/* Supply definition of STACK_SIZE_MODE for allocate_dynamic_stack_space. */
#define STACK_SIZE_MODE (TARGET_32BIT ? SImode : DImode)
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index e1371a1..5086a7a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -177,9 +177,8 @@ int dot_symbols;
/* Specify the machine mode that pointers have. After generation of rtl, the
compiler makes no further distinction between pointers and any other objects
- of this machine mode. The type is unsigned since not all things that
- include rs6000.h also include machmode.h. */
-unsigned rs6000_pmode;
+ of this machine mode. */
+scalar_int_mode rs6000_pmode;
/* Width in bits of a pointer. */
unsigned rs6000_pointer_size;
@@ -3952,12 +3951,12 @@ rs6000_option_override_internal (bool global_init_p)
/* Set the pointer size. */
if (TARGET_64BIT)
{
- rs6000_pmode = (int)DImode;
+ rs6000_pmode = DImode;
rs6000_pointer_size = 64;
}
else
{
- rs6000_pmode = (int)SImode;
+ rs6000_pmode = SImode;
rs6000_pointer_size = 32;
}
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index b31166b..d668c9b 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -2116,8 +2116,8 @@ do { \
/* Specify the machine mode that pointers have.
After generation of rtl, the compiler makes no further distinction
between pointers and any other objects of this machine mode. */
-extern unsigned rs6000_pmode;
-#define Pmode ((machine_mode)rs6000_pmode)
+extern scalar_int_mode rs6000_pmode;
+#define Pmode rs6000_pmode
/* Supply definition of STACK_SIZE_MODE for allocate_dynamic_stack_space. */
#define STACK_SIZE_MODE (TARGET_32BIT ? SImode : DImode)
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index cb0ffb8..a3b7418 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -999,7 +999,7 @@ s390_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
so we cannot use this. */
machine_mode target_mode =
(insn_op->predicate == address_operand
- ? Pmode : insn_op->mode);
+ ? (machine_mode) Pmode : insn_op->mode);
op[arity] = copy_to_mode_reg (target_mode, op[arity]);
}
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index 7847047..917aa29 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -1053,7 +1053,7 @@ do { \
/* Specify the machine mode that pointers have.
After generation of rtl, the compiler makes no further distinction
between pointers and any other objects of this machine mode. */
-#define Pmode ((machine_mode) (TARGET_64BIT ? DImode : SImode))
+#define Pmode (TARGET_64BIT ? DImode : SImode)
/* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
#define POINTERS_EXTEND_UNSIGNED -1
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 6313467..6e01a50 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -55,8 +55,10 @@ typedef const struct simple_bitmap_def *const_sbitmap;
struct rtx_def;
typedef struct rtx_def *rtx;
typedef const struct rtx_def *const_rtx;
+class scalar_int_mode;
class scalar_float_mode;
template<typename> class opt_mode;
+typedef opt_mode<scalar_int_mode> opt_scalar_int_mode;
typedef opt_mode<scalar_float_mode> opt_scalar_float_mode;
/* Subclasses of rtx_def, using indentation to show the class
@@ -313,6 +315,7 @@ union _dont_use_tree_here_;
#define tree union _dont_use_tree_here_ *
#define const_tree union _dont_use_tree_here_ *
+typedef struct scalar_int_mode scalar_int_mode;
typedef struct scalar_float_mode scalar_float_mode;
#endif
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index eaae009..399c5d6 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -70,9 +70,9 @@ struct target_rtl *this_target_rtl = &default_target_rtl;
/* Commonly used modes. */
-machine_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */
-machine_mode word_mode; /* Mode whose width is BITS_PER_WORD. */
-machine_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */
+scalar_int_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */
+scalar_int_mode word_mode; /* Mode whose width is BITS_PER_WORD. */
+scalar_int_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */
/* Datastructures maintained for currently processed function in RTL form. */
@@ -5863,22 +5863,24 @@ init_emit_regs (void)
void
init_derived_machine_modes (void)
{
- byte_mode = VOIDmode;
- word_mode = VOIDmode;
-
- machine_mode mode;
- FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
+ opt_scalar_int_mode mode_iter, opt_byte_mode, opt_word_mode;
+ FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
{
+ scalar_int_mode mode = mode_iter.require ();
+
if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT
- && byte_mode == VOIDmode)
- byte_mode = mode;
+ && !opt_byte_mode.exists ())
+ opt_byte_mode = mode;
if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD
- && word_mode == VOIDmode)
- word_mode = mode;
+ && !opt_word_mode.exists ())
+ opt_word_mode = mode;
}
- ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0);
+ byte_mode = opt_byte_mode.require ();
+ word_mode = opt_word_mode.require ();
+ ptr_mode = as_a <scalar_int_mode> (mode_for_size (POINTER_SIZE,
+ MODE_INT, 0));
}
/* Create some permanent unique rtl objects shared between all functions. */
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 8d0c065..782e93f 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -542,10 +542,11 @@ def build_pretty_printer():
pp.add_printer_for_regex(r'opt_mode<(\S+)>',
'opt_mode', OptMachineModePrinter)
- pp.add_printer_for_types(['opt_scalar_float_mode'],
+ pp.add_printer_for_types(['opt_scalar_int_mode',
+ 'opt_scalar_float_mode'],
'opt_mode', OptMachineModePrinter)
- pp.add_printer_for_types(['scalar_float_mode'],
- 'scalar_float_mode', MachineModePrinter)
+ for mode in 'scalar_int_mode', 'scalar_float_mode':
+ pp.add_printer_for_types([mode], mode, MachineModePrinter)
return pp
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index 8c27b42..c7d8c75 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -1137,6 +1137,10 @@ get_mode_class (struct mode_data *mode)
{
switch (mode->cl)
{
+ case MODE_INT:
+ case MODE_PARTIAL_INT:
+ return "scalar_int_mode";
+
case MODE_FLOAT:
case MODE_DECIMAL_FLOAT:
return "scalar_float_mode";
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<scalar_int_mode>::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);