[76/77] Add a scalar_mode_pod class

Message ID 871spkbtbo.fsf@linaro.org
State New
Headers show
Series
  • Add wrapper classes for machine_modes
Related show

Commit Message

Richard Sandiford July 13, 2017, 9:05 a.m.
This patch adds a scalar_mode_pod class and uses it to
replace the machine_mode in fixed_value.

2017-07-13  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>.

Comments

Jeff Law Aug. 25, 2017, 4:46 p.m. | #1
On 07/13/2017 03:05 AM, Richard Sandiford wrote:
> This patch adds a scalar_mode_pod class and uses it to

> replace the machine_mode in fixed_value.

> 

> 2017-07-13  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>.

OK.
jeff

Patch

Index: gcc/coretypes.h
===================================================================
--- gcc/coretypes.h	2017-07-13 09:18:56.810392248 +0100
+++ gcc/coretypes.h	2017-07-13 09:19:00.088160188 +0100
@@ -63,6 +63,7 @@  typedef opt_mode<scalar_mode> opt_scalar
 typedef opt_mode<scalar_int_mode> opt_scalar_int_mode;
 typedef opt_mode<scalar_float_mode> opt_scalar_float_mode;
 template<typename> class pod_mode;
+typedef pod_mode<scalar_mode> scalar_mode_pod;
 typedef pod_mode<scalar_int_mode> scalar_int_mode_pod;
 
 /* Subclasses of rtx_def, using indentation to show the class
Index: gcc/gdbhooks.py
===================================================================
--- gcc/gdbhooks.py	2017-07-13 09:18:56.812392104 +0100
+++ gcc/gdbhooks.py	2017-07-13 09:19:00.090160049 +0100
@@ -548,7 +548,8 @@  def build_pretty_printer():
                              'opt_mode', OptMachineModePrinter)
     pp.add_printer_for_regex(r'pod_mode<(\S+)>',
                              '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)
     for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode':
         pp.add_printer_for_types([mode], mode, MachineModePrinter)
Index: gcc/machmode.h
===================================================================
--- gcc/machmode.h	2017-07-13 09:18:59.187223319 +0100
+++ gcc/machmode.h	2017-07-13 09:19:00.090160049 +0100
@@ -894,4 +894,22 @@  #define FOR_EACH_2XWIDER_MODE(ITERATOR,
        mode_iterator::iterate_p (&(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 */
Index: gcc/fixed-value.h
===================================================================
--- gcc/fixed-value.h	2017-07-13 09:18:55.158511776 +0100
+++ gcc/fixed-value.h	2017-07-13 09:19:00.088160188 +0100
@@ -22,8 +22,8 @@  #define GCC_FIXED_VALUE_H
 
 struct GTY(()) fixed_value
 {
-  double_int data;		/* Store data up to 2 wide integers.  */
-  machine_mode mode;	/* Use machine mode to know IBIT and FBIT.  */
+  double_int data;       /* Store data up to 2 wide integers.  */
+  scalar_mode_pod mode;  /* Use machine mode to know IBIT and FBIT.  */
 };
 
 #define FIXED_VALUE_TYPE struct fixed_value
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	2017-07-13 09:18:53.998596742 +0100
+++ gcc/fold-const.c	2017-07-13 09:19:00.090160049 +0100
@@ -1952,7 +1952,7 @@  fold_convert_const_int_from_fixed (tree
 {
   tree t;
   double_int temp, temp_trunc;
-  machine_mode mode;
+  scalar_mode mode;
 
   /* Right shift FIXED_CST to temp by fbit.  */
   temp = TREE_FIXED_CST (arg1).data;
Index: gcc/tree-streamer-in.c
===================================================================
--- gcc/tree-streamer-in.c	2017-05-03 08:46:32.776861592 +0100
+++ gcc/tree-streamer-in.c	2017-07-13 09:19:00.090160049 +0100
@@ -208,7 +208,7 @@  unpack_ts_real_cst_value_fields (struct
 unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
 {
   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.high = bp_unpack_var_len_int (bp);
   TREE_FIXED_CST_PTR (expr) = fp;