===================================================================
@@ -2220,8 +2220,8 @@ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE,
/* 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)
===================================================================
@@ -185,9 +185,8 @@ int fixuplabelno = 0;
/* 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;
@@ -4037,12 +4036,12 @@ rs6000_option_override_internal (bool gl
/* 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;
}
===================================================================
@@ -2130,8 +2130,8 @@ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE,
/* 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)
===================================================================
@@ -181,9 +181,8 @@ int fixuplabelno = 0;
/* 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;
@@ -3987,12 +3986,12 @@ rs6000_option_override_internal (bool gl
/* 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;
}
===================================================================
@@ -1053,7 +1053,7 @@ #define TRULY_NOOP_TRUNCATION(OUTPREC, I
/* 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
===================================================================
@@ -641,7 +641,8 @@ #define CONSTANT_ADDRESS_P(X) \
#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)) \
===================================================================
@@ -995,7 +995,7 @@ #define MAX_ARGS 6
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]);
}
===================================================================
@@ -55,8 +55,10 @@ typedef const struct simple_bitmap_def *
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 @@ #define rtx_insn struct _dont_use_rtx_in
#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
===================================================================
@@ -339,6 +339,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
{
@@ -606,9 +630,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);
===================================================================
@@ -69,9 +69,9 @@ #define initial_regno_reg_rtx (this_targ
/* 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. */
@@ -5869,22 +5869,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;
+
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;
+ word_mode = *opt_word_mode;
+ 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. */
===================================================================
@@ -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";
===================================================================
@@ -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