+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
+ * coretypes.h (scalar_mode): New class.
+ * machmode.h (scalar_mode): Likewise.
+ (scalar_mode::includes_p): New function.
+ (mode_to_inner): Return a scalar_mode rather than a machine_mode.
+ * gdbhooks.py (build_pretty_printers): Handle scalar_mode.
+ * genmodes.c (get_mode_class): Handle remaining scalar modes.
+ * cfgexpand.c (expand_debug_expr): Use scalar_mode.
+ * expmed.c (store_bit_field_1): Likewise.
+ (extract_bit_field_1): Likewise.
+ * expr.c (write_complex_part): Likewise.
+ (read_complex_part): Likewise.
+ (emit_move_complex_push): Likewise.
+ (expand_expr_real_2): Likewise.
+ * function.c (assign_parm_setup_reg): Likewise.
+ (assign_parms_unsplit_complex): Likewise.
+ * optabs.c (expand_binop): Likewise.
+ * rtlanal.c (subreg_get_info): Likewise.
+ * simplify-rtx.c (simplify_immed_subreg): Likewise.
+ * varasm.c (output_constant_pool_2): Likewise.
+
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
GET_MODE_INNER (mode)));
else
{
- machine_mode imode = GET_MODE_INNER (mode);
+ scalar_mode imode = GET_MODE_INNER (mode);
rtx re, im;
if (MEM_P (op0))
struct rtx_def;
typedef struct rtx_def *rtx;
typedef const struct rtx_def *const_rtx;
+class scalar_mode;
class scalar_int_mode;
class scalar_float_mode;
template<typename> class opt_mode;
#define tree union _dont_use_tree_here_ *
#define const_tree union _dont_use_tree_here_ *
+typedef struct scalar_mode scalar_mode;
typedef struct scalar_int_mode scalar_int_mode;
typedef struct scalar_float_mode scalar_float_mode;
/* Use vec_set patterns for inserting parts of vectors whenever
available. */
- if (VECTOR_MODE_P (GET_MODE (op0))
+ machine_mode outermode = GET_MODE (op0);
+ scalar_mode innermode = GET_MODE_INNER (outermode);
+ if (VECTOR_MODE_P (outermode)
&& !MEM_P (op0)
- && optab_handler (vec_set_optab, GET_MODE (op0)) != CODE_FOR_nothing
- && fieldmode == GET_MODE_INNER (GET_MODE (op0))
- && bitsize == GET_MODE_UNIT_BITSIZE (GET_MODE (op0))
- && !(bitnum % GET_MODE_UNIT_BITSIZE (GET_MODE (op0))))
+ && optab_handler (vec_set_optab, outermode) != CODE_FOR_nothing
+ && fieldmode == innermode
+ && bitsize == GET_MODE_BITSIZE (innermode)
+ && !(bitnum % GET_MODE_BITSIZE (innermode)))
{
struct expand_operand ops[3];
- machine_mode outermode = GET_MODE (op0);
- machine_mode innermode = GET_MODE_INNER (outermode);
enum insn_code icode = optab_handler (vec_set_optab, outermode);
int pos = bitnum / GET_MODE_BITSIZE (innermode);
/* Use vec_extract patterns for extracting parts of vectors whenever
available. */
- if (VECTOR_MODE_P (GET_MODE (op0))
+ machine_mode outermode = GET_MODE (op0);
+ scalar_mode innermode = GET_MODE_INNER (outermode);
+ if (VECTOR_MODE_P (outermode)
&& !MEM_P (op0)
- && (convert_optab_handler (vec_extract_optab, GET_MODE (op0),
- GET_MODE_INNER (GET_MODE (op0)))
+ && (convert_optab_handler (vec_extract_optab, outermode, innermode)
!= CODE_FOR_nothing)
- && ((bitnum + bitsize - 1) / GET_MODE_UNIT_BITSIZE (GET_MODE (op0))
- == bitnum / GET_MODE_UNIT_BITSIZE (GET_MODE (op0))))
+ && ((bitnum + bitsize - 1) / GET_MODE_BITSIZE (innermode)
+ == bitnum / GET_MODE_BITSIZE (innermode)))
{
struct expand_operand ops[3];
- machine_mode outermode = GET_MODE (op0);
- machine_mode innermode = GET_MODE_INNER (outermode);
enum insn_code icode
= convert_optab_handler (vec_extract_optab, outermode, innermode);
unsigned HOST_WIDE_INT pos = bitnum / GET_MODE_BITSIZE (innermode);
write_complex_part (rtx cplx, rtx val, bool imag_p)
{
machine_mode cmode;
- machine_mode imode;
+ scalar_mode imode;
unsigned ibitsize;
if (GET_CODE (cplx) == CONCAT)
rtx
read_complex_part (rtx cplx, bool imag_p)
{
- machine_mode cmode, imode;
+ machine_mode cmode;
+ scalar_mode imode;
unsigned ibitsize;
if (GET_CODE (cplx) == CONCAT)
rtx_insn *
emit_move_complex_push (machine_mode mode, rtx x, rtx y)
{
- machine_mode submode = GET_MODE_INNER (mode);
+ scalar_mode submode = GET_MODE_INNER (mode);
bool imag_first;
#ifdef PUSH_ROUNDING
GET_MODE_INNER (GET_MODE (target)), 0);
if (reg_overlap_mentioned_p (temp, op1))
{
- machine_mode imode = GET_MODE_INNER (GET_MODE (target));
+ scalar_mode imode = GET_MODE_INNER (GET_MODE (target));
temp = adjust_address_nv (target, imode,
GET_MODE_SIZE (imode));
if (reg_overlap_mentioned_p (temp, op0))
/* Mark complex types separately. */
if (GET_CODE (parmreg) == CONCAT)
{
- machine_mode submode
- = GET_MODE_INNER (GET_MODE (parmreg));
+ scalar_mode submode = GET_MODE_INNER (GET_MODE (parmreg));
int regnor = REGNO (XEXP (parmreg, 0));
int regnoi = REGNO (XEXP (parmreg, 1));
rtx stackr = adjust_address_nv (data->stack_parm, submode, 0);
&& targetm.calls.split_complex_arg (TREE_TYPE (parm)))
{
rtx tmp, real, imag;
- machine_mode inner = GET_MODE_INNER (DECL_MODE (parm));
+ scalar_mode inner = GET_MODE_INNER (DECL_MODE (parm));
real = DECL_RTL (fnargs[i]);
imag = DECL_RTL (fnargs[i + 1]);
'pod_mode', MachineModePrinter)
pp.add_printer_for_types(['scalar_int_mode_pod'],
'pod_mode', MachineModePrinter)
- for mode in 'scalar_int_mode', 'scalar_float_mode':
+ for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode':
pp.add_printer_for_types([mode], mode, MachineModePrinter)
return pp
case MODE_PARTIAL_INT:
return "scalar_int_mode";
+ case MODE_FRACT:
+ case MODE_UFRACT:
+ case MODE_ACCUM:
+ case MODE_UACCUM:
+ case MODE_POINTER_BOUNDS:
+ return "scalar_mode";
+
case MODE_FLOAT:
case MODE_DECIMAL_FLOAT:
return "scalar_float_mode";
return SCALAR_FLOAT_MODE_P (m);
}
+/* Represents a machine mode that is known to be scalar. */
+class scalar_mode
+{
+public:
+ typedef mode_traits<scalar_mode>::from_int from_int;
+
+ ALWAYS_INLINE scalar_mode () {}
+ ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {}
+ ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {}
+ ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {}
+ ALWAYS_INLINE scalar_mode (const scalar_int_mode_pod &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 M represents some kind of scalar value. */
+
+inline bool
+scalar_mode::includes_p (machine_mode m)
+{
+ switch (GET_MODE_CLASS (m))
+ {
+ case MODE_INT:
+ case MODE_PARTIAL_INT:
+ case MODE_FRACT:
+ case MODE_UFRACT:
+ case MODE_ACCUM:
+ case MODE_UACCUM:
+ case MODE_FLOAT:
+ case MODE_DECIMAL_FLOAT:
+ case MODE_POINTER_BOUNDS:
+ return true;
+ default:
+ return false;
+ }
+}
+
/* Return the base GET_MODE_SIZE value for MODE. */
ALWAYS_INLINE unsigned short
/* Return the base GET_MODE_INNER value for MODE. */
-ALWAYS_INLINE machine_mode
+ALWAYS_INLINE scalar_mode
mode_to_inner (machine_mode mode)
{
#if GCC_VERSION >= 4001
- return (machine_mode) (__builtin_constant_p (mode)
- ? mode_inner_inline (mode) : mode_inner[mode]);
+ return scalar_mode::from_int (__builtin_constant_p (mode)
+ ? mode_inner_inline (mode)
+ : mode_inner[mode]);
#else
- return (machine_mode) mode_inner[mode];
+ return scalar_mode::from_int (mode_inner[mode]);
#endif
}
{
/* The scalar may have been extended to be too wide. Truncate
it back to the proper size to fit in the broadcast vector. */
- machine_mode inner_mode = GET_MODE_INNER (mode);
+ scalar_mode inner_mode = GET_MODE_INNER (mode);
if (!CONST_INT_P (op1)
&& (GET_MODE_BITSIZE (as_a <scalar_int_mode> (GET_MODE (op1)))
> GET_MODE_BITSIZE (inner_mode)))
{
nregs_xmode = HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode);
unsigned int nunits = GET_MODE_NUNITS (xmode);
- machine_mode xmode_unit = GET_MODE_INNER (xmode);
+ scalar_mode xmode_unit = GET_MODE_INNER (xmode);
gcc_assert (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode_unit));
gcc_assert (nregs_xmode
== (nunits
rtx result_s = NULL;
rtvec result_v = NULL;
enum mode_class outer_class;
- machine_mode outer_submode;
+ scalar_mode outer_submode;
int max_bitsize;
/* Some ports misuse CCmode. */
case MODE_VECTOR_UACCUM:
{
int i, units;
- machine_mode submode = GET_MODE_INNER (mode);
+ scalar_mode submode = GET_MODE_INNER (mode);
unsigned int subalign = MIN (align, GET_MODE_BITSIZE (submode));
gcc_assert (GET_CODE (x) == CONST_VECTOR);