]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[16/77] Add scalar_int_mode_pod
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Aug 2017 11:10:18 +0000 (11:10 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Aug 2017 11:10:18 +0000 (11:10 +0000)
This patch adds a POD class for scalar integers, as an instance
of a new pod_mode template.  Later patches will use pod_mode in
situations that really do need to be POD; this patch is simply
using PODs to remove load-time initialisation.

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

gcc/
* coretypes.h (pod_mode): New type.
(scalar_int_mode_pod): New typedef.
* machmode.h (pod_mode): New class.
(int_n_data_t::m): Change type to scalar_int_mode_pod.
* genmodes.c (emit_mode_int_n): Update accordingly.
* lower-subreg.h (target_lower_subreg): Change type to
scalar_int_mode_pod.
* gdbhooks.py (build_pretty_printer): Handle pod_mode and
scalar_int_mode_pod.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251468 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/coretypes.h
gcc/gdbhooks.py
gcc/genmodes.c
gcc/lower-subreg.h
gcc/machmode.h

index 2f8f97045bf4a5d5a1a5cb8a271e3320f67fb77b..d7e70be58d6aa6ba7aa4dc594df646ca91e43c22 100644 (file)
@@ -1,3 +1,17 @@
+2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * coretypes.h (pod_mode): New type.
+       (scalar_int_mode_pod): New typedef.
+       * machmode.h (pod_mode): New class.
+       (int_n_data_t::m): Change type to scalar_int_mode_pod.
+       * genmodes.c (emit_mode_int_n): Update accordingly.
+       * lower-subreg.h (target_lower_subreg): Change type to
+       scalar_int_mode_pod.
+       * gdbhooks.py (build_pretty_printer): Handle pod_mode and
+       scalar_int_mode_pod.
+
 2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 6e01a5069bf172c1fde43ef0ad78f9cae180c36d..37c836d87fa245c359f54322aa7da5d2e07b1f67 100644 (file)
@@ -60,6 +60,8 @@ 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;
+template<typename> class pod_mode;
+typedef pod_mode<scalar_int_mode> scalar_int_mode_pod;
 
 /* Subclasses of rtx_def, using indentation to show the class
    hierarchy, along with the relevant invariant.
index 782e93f9fbc935fcc75986b013e3ac268f1f261b..678698df9c83e97b9b0cccdaa3f3ab00d185447b 100644 (file)
@@ -545,6 +545,10 @@ def build_pretty_printer():
     pp.add_printer_for_types(['opt_scalar_int_mode',
                               'opt_scalar_float_mode'],
                              'opt_mode', OptMachineModePrinter)
+    pp.add_printer_for_regex(r'pod_mode<(\S+)>',
+                             'pod_mode', MachineModePrinter)
+    pp.add_printer_for_types(['scalar_int_mode_pod'],
+                             'pod_mode', MachineModePrinter)
     for mode in 'scalar_int_mode', 'scalar_float_mode':
         pp.add_printer_for_types([mode], mode, MachineModePrinter)
 
index c7d8c75dbebd482191457a35b7959f7566317a94..3eb9b44c74b97f0ac218a6cb3bacb608ccdf12f0 100644 (file)
@@ -1799,7 +1799,7 @@ emit_mode_int_n (void)
       m = mode_sort[i];
       printf(" {\n");
       tagged_printf ("%u", m->int_n, m->name);
-      printf ("E_%smode,", m->name);
+      printf ("{ E_%smode },", m->name);
       printf(" },\n");
     }
 
index 4aed62f71e8db460355f2e3af6719ca7fae115f5..69e8c29173a486bfeeb21bea6265b4e03f81e274 100644 (file)
@@ -43,7 +43,7 @@ struct lower_subreg_choices {
 /* Target-specific information for the subreg lowering pass.  */
 struct target_lower_subreg {
   /* An integer mode that is twice as wide as word_mode.  */
-  machine_mode x_twice_word_mode;
+  scalar_int_mode_pod x_twice_word_mode;
 
   /* What we have decided to do when optimizing for size (index 0)
      and speed (index 1).  */
index dda7c0aed410ecacae24ac4607dea5c45908f132..25e72a83330a1e2a6b148c8f9f49d75d9fc37de0 100644 (file)
@@ -293,6 +293,19 @@ opt_mode<T>::exists (U *mode) const
   return false;
 }
 
+/* A POD version of mode class T.  */
+
+template<typename T>
+struct pod_mode
+{
+  typedef typename mode_traits<T>::from_int from_int;
+
+  machine_mode m_mode;
+  ALWAYS_INLINE operator machine_mode () const { return m_mode; }
+  ALWAYS_INLINE operator T () const { return from_int (m_mode); }
+  ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; }
+};
+
 /* Return true if mode M has type T.  */
 
 template<typename T>
@@ -647,7 +660,7 @@ extern void init_adjust_machine_modes (void);
 struct int_n_data_t {
   /* These parts are initailized by genmodes output */
   unsigned int bitsize;
-  machine_mode m;
+  scalar_int_mode_pod m;
   /* RID_* is RID_INTN_BASE + index into this array */
 };