[committed] Move add_implicit_parallel to gensupport
diff mbox

Message ID 877fr83po1.fsf@googlemail.com
State New
Headers show

Commit Message

Richard Sandiford June 13, 2015, 9:47 a.m. UTC
Several places in the generators want to convert a define_insn rtvec
into a single rtx.  This patch just puts the routine to do that in
gensupport.c.  The changes to process_one_cond_exec mean that we'll
allocate rtvecs more often, but that's not going to make a noticeable
difference and I think it's better to handle the single- and multi-rtx
forms consistently.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
with config-list.mk.  Applied.

Richard


gcc/
	* gensupport.h (add_implicit_parallel): Declare.
	* genrecog.c (add_implicit_parallel): Move to...
	* gensupport.c (add_implicit_parallel): ...here.
	(process_one_cond_exec): Use it.
	* genemit.c (gen_insn): Likewise.

Patch
diff mbox

Index: gcc/gensupport.h
===================================================================
--- gcc/gensupport.h	2015-06-13 10:37:47.844961062 +0100
+++ gcc/gensupport.h	2015-06-13 10:38:52.370125288 +0100
@@ -23,6 +23,7 @@  #define GCC_GENSUPPORT_H
 struct obstack;
 extern struct obstack *rtl_obstack;
 
+extern rtx add_implicit_parallel (rtvec);
 extern bool init_rtx_reader_args_cb (int, char **, bool (*)(const char *));
 extern bool init_rtx_reader_args (int, char **);
 extern rtx read_md_rtx (int *, int *);
Index: gcc/genrecog.c
===================================================================
--- gcc/genrecog.c	2015-06-13 10:37:47.844961062 +0100
+++ gcc/genrecog.c	2015-06-13 10:38:52.369125332 +0100
@@ -5187,22 +5187,6 @@  print_subroutine_group (output_state *os
   print_subroutine (os, root, 0);
 }
 
-/* Return the rtx pattern specified by the list of rtxes in a
-   define_insn or define_split.  */
-
-static rtx
-add_implicit_parallel (rtvec vec)
-{
-  if (GET_NUM_ELEM (vec) == 1)
-    return RTVEC_ELT (vec, 0);
-  else
-    {
-      rtx pattern = rtx_alloc (PARALLEL);
-      XVEC (pattern, 0) = vec;
-      return pattern;
-    }
-}
-
 /* Return the rtx pattern for the list of rtxes in a define_peephole2.  */
 
 static rtx
Index: gcc/gensupport.c
===================================================================
--- gcc/gensupport.c	2015-06-13 10:37:47.844961062 +0100
+++ gcc/gensupport.c	2015-06-13 10:38:52.370125288 +0100
@@ -143,6 +143,22 @@  gen_rtx_CONST_INT (machine_mode ARG_UNUS
   XWINT (rt, 0) = arg;
   return rt;
 }
+
+/* Return the rtx pattern specified by the list of rtxes in a
+   define_insn or define_split.  */
+
+rtx
+add_implicit_parallel (rtvec vec)
+{
+  if (GET_NUM_ELEM (vec) == 1)
+    return RTVEC_ELT (vec, 0);
+  else
+    {
+      rtx pattern = rtx_alloc (PARALLEL);
+      XVEC (pattern, 0) = vec;
+      return pattern;
+    }
+}
 
 /* Predicate handling.
 
@@ -1703,19 +1719,9 @@  process_one_cond_exec (struct queue_elem
       XSTR (insn, 0) = new_name;
       pattern = rtx_alloc (COND_EXEC);
       XEXP (pattern, 0) = pred;
-      if (XVECLEN (insn, 1) == 1)
-	{
-	  XEXP (pattern, 1) = XVECEXP (insn, 1, 0);
-	  XVECEXP (insn, 1, 0) = pattern;
-	  PUT_NUM_ELEM (XVEC (insn, 1), 1);
-	}
-      else
-	{
-	  XEXP (pattern, 1) = rtx_alloc (PARALLEL);
-	  XVEC (XEXP (pattern, 1), 0) = XVEC (insn, 1);
-	  XVEC (insn, 1) = rtvec_alloc (1);
-	  XVECEXP (insn, 1, 0) = pattern;
-	}
+      XEXP (pattern, 1) = add_implicit_parallel (XVEC (insn, 1));
+      XVEC (insn, 1) = rtvec_alloc (1);
+      XVECEXP (insn, 1, 0) = pattern;
 
        if (XVEC (ce_elem->data, 3) != NULL)
 	{
@@ -1760,19 +1766,10 @@  process_one_cond_exec (struct queue_elem
       /* Predicate the pattern matched by the split.  */
       pattern = rtx_alloc (COND_EXEC);
       XEXP (pattern, 0) = pred;
-      if (XVECLEN (split, 0) == 1)
-	{
-	  XEXP (pattern, 1) = XVECEXP (split, 0, 0);
-	  XVECEXP (split, 0, 0) = pattern;
-	  PUT_NUM_ELEM (XVEC (split, 0), 1);
-	}
-      else
-	{
-	  XEXP (pattern, 1) = rtx_alloc (PARALLEL);
-	  XVEC (XEXP (pattern, 1), 0) = XVEC (split, 0);
-	  XVEC (split, 0) = rtvec_alloc (1);
-	  XVECEXP (split, 0, 0) = pattern;
-	}
+      XEXP (pattern, 1) = add_implicit_parallel (XVEC (split, 0));
+      XVEC (split, 0) = rtvec_alloc (1);
+      XVECEXP (split, 0, 0) = pattern;
+
       /* Predicate all of the insns generated by the split.  */
       for (i = 0; i < XVECLEN (split, 2); i++)
 	{
Index: gcc/genemit.c
===================================================================
--- gcc/genemit.c	2015-06-13 10:37:47.844961062 +0100
+++ gcc/genemit.c	2015-06-13 10:38:52.369125332 +0100
@@ -378,27 +378,15 @@  gen_insn (rtx insn, int lineno)
 
   /* Output code to construct and return the rtl for the instruction body.  */
 
-  if (XVECLEN (insn, 1) == 1)
-    {
-      printf ("  return ");
-      gen_exp (XVECEXP (insn, 1, 0), DEFINE_INSN, NULL);
-      printf (";\n}\n\n");
-    }
-  else
-    {
-      char *used = XCNEWVEC (char, stats.num_generator_args);
-
-      printf ("  return gen_rtx_PARALLEL (VOIDmode, gen_rtvec (%d",
-	      XVECLEN (insn, 1));
-
-      for (i = 0; i < XVECLEN (insn, 1); i++)
-	{
-	  printf (",\n\t\t");
-	  gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN, used);
-	}
-      printf ("));\n}\n\n");
-      XDELETEVEC (used);
-    }
+  rtx pattern = add_implicit_parallel (XVEC (insn, 1));
+  /* ??? This is the traditional behavior, but seems suspect.  */
+  char *used = (XVECLEN (insn, 1) == 1
+		? NULL
+		: XCNEWVEC (char, stats.num_generator_args));
+  printf ("  return ");
+  gen_exp (pattern, DEFINE_INSN, used);
+  printf (";\n}\n\n");
+  XDELETEVEC (used);
 }
 
 /* Generate the `gen_...' function for a DEFINE_EXPAND.  */