Commit 382615c6 by Richard Sandiford Committed by Richard Sandiford

[76/77] Add a scalar_mode_pod class

This patch adds a scalar_mode_pod class and uses it to
replace the machine_mode in fixed_value.

2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* coretypes.h (scalar_mode_pod): New typedef.
	* gdbhooks.py (build_pretty_printer): Handle it.
	* machmode.h (gt_ggc_mx, gt_pch_nx): New functions.
	* fixed-value.h (fixed_value::mode): Change type to scalar_mode_pod.
	* fold-const.c (fold_convert_const_int_from_fixed): Use scalar_mode.
	* tree-streamer-in.c (unpack_ts_fixed_cst_value_fields): Use
	as_a <scalar_mode>.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r251526
parent 79d22165
...@@ -2,6 +2,18 @@ ...@@ -2,6 +2,18 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* coretypes.h (scalar_mode_pod): New typedef.
* gdbhooks.py (build_pretty_printer): Handle it.
* machmode.h (gt_ggc_mx, gt_pch_nx): New functions.
* fixed-value.h (fixed_value::mode): Change type to scalar_mode_pod.
* fold-const.c (fold_convert_const_int_from_fixed): Use scalar_mode.
* tree-streamer-in.c (unpack_ts_fixed_cst_value_fields): Use
as_a <scalar_mode>.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* machmode.h (mode_for_vector): Take a scalar_mode instead * machmode.h (mode_for_vector): Take a scalar_mode instead
of a machine_mode. of a machine_mode.
* stor-layout.c (mode_for_vector): Likewise. * stor-layout.c (mode_for_vector): Likewise.
......
...@@ -63,6 +63,7 @@ typedef opt_mode<scalar_mode> opt_scalar_mode; ...@@ -63,6 +63,7 @@ typedef opt_mode<scalar_mode> opt_scalar_mode;
typedef opt_mode<scalar_int_mode> opt_scalar_int_mode; typedef opt_mode<scalar_int_mode> opt_scalar_int_mode;
typedef opt_mode<scalar_float_mode> opt_scalar_float_mode; typedef opt_mode<scalar_float_mode> opt_scalar_float_mode;
template<typename> class pod_mode; template<typename> class pod_mode;
typedef pod_mode<scalar_mode> scalar_mode_pod;
typedef pod_mode<scalar_int_mode> scalar_int_mode_pod; typedef pod_mode<scalar_int_mode> scalar_int_mode_pod;
/* Subclasses of rtx_def, using indentation to show the class /* Subclasses of rtx_def, using indentation to show the class
......
...@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see
struct GTY(()) fixed_value struct GTY(()) fixed_value
{ {
double_int data; /* Store data up to 2 wide integers. */ double_int data; /* Store data up to 2 wide integers. */
machine_mode mode; /* Use machine mode to know IBIT and FBIT. */ scalar_mode_pod mode; /* Use machine mode to know IBIT and FBIT. */
}; };
#define FIXED_VALUE_TYPE struct fixed_value #define FIXED_VALUE_TYPE struct fixed_value
......
...@@ -1944,7 +1944,7 @@ fold_convert_const_int_from_fixed (tree type, const_tree arg1) ...@@ -1944,7 +1944,7 @@ fold_convert_const_int_from_fixed (tree type, const_tree arg1)
{ {
tree t; tree t;
double_int temp, temp_trunc; double_int temp, temp_trunc;
machine_mode mode; scalar_mode mode;
/* Right shift FIXED_CST to temp by fbit. */ /* Right shift FIXED_CST to temp by fbit. */
temp = TREE_FIXED_CST (arg1).data; temp = TREE_FIXED_CST (arg1).data;
......
...@@ -548,7 +548,8 @@ def build_pretty_printer(): ...@@ -548,7 +548,8 @@ def build_pretty_printer():
'opt_mode', OptMachineModePrinter) 'opt_mode', OptMachineModePrinter)
pp.add_printer_for_regex(r'pod_mode<(\S+)>', pp.add_printer_for_regex(r'pod_mode<(\S+)>',
'pod_mode', MachineModePrinter) 'pod_mode', MachineModePrinter)
pp.add_printer_for_types(['scalar_int_mode_pod'], pp.add_printer_for_types(['scalar_int_mode_pod',
'scalar_mode_pod'],
'pod_mode', MachineModePrinter) 'pod_mode', MachineModePrinter)
for mode in 'scalar_mode', '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) pp.add_printer_for_types([mode], mode, MachineModePrinter)
......
...@@ -893,4 +893,22 @@ namespace mode_iterator ...@@ -893,4 +893,22 @@ namespace mode_iterator
mode_iterator::iterate_p (&(ITERATOR)); \ mode_iterator::iterate_p (&(ITERATOR)); \
mode_iterator::get_2xwider (&(ITERATOR))) mode_iterator::get_2xwider (&(ITERATOR)))
template<typename T>
void
gt_ggc_mx (pod_mode<T> *)
{
}
template<typename T>
void
gt_pch_nx (pod_mode<T> *)
{
}
template<typename T>
void
gt_pch_nx (pod_mode<T> *, void (*) (void *, void *), void *)
{
}
#endif /* not HAVE_MACHINE_MODES */ #endif /* not HAVE_MACHINE_MODES */
...@@ -211,7 +211,7 @@ static void ...@@ -211,7 +211,7 @@ static void
unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr) unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
{ {
FIXED_VALUE_TYPE *fp = ggc_alloc<fixed_value> (); FIXED_VALUE_TYPE *fp = ggc_alloc<fixed_value> ();
fp->mode = bp_unpack_machine_mode (bp); fp->mode = as_a <scalar_mode> (bp_unpack_machine_mode (bp));
fp->data.low = bp_unpack_var_len_int (bp); fp->data.low = bp_unpack_var_len_int (bp);
fp->data.high = bp_unpack_var_len_int (bp); fp->data.high = bp_unpack_var_len_int (bp);
TREE_FIXED_CST_PTR (expr) = fp; TREE_FIXED_CST_PTR (expr) = fp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment