This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][match-and-simplify] Remove outlining of C exprs


It no longer works in the face of (with { .... } which would
need to pass down all named temporaries.  Instead we can
simply inline all C exprs now that we pass 'output' to all
gen_transform calls.

Boostrap pending on x86_64-unknown-linux-gnu.

Richard.

2014-09-24  Richard Biener  <rguenther@suse.de>

	* genmatch.c (c_expr::output_code): Remove and inline into ...
	(c_expr::gen_transform): ... here.
	(outline_c_exprs): Remove.
	(main): Do not call outline_c_exprs.

Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 215551)
+++ gcc/genmatch.c	(working copy)
@@ -355,7 +355,6 @@ struct c_expr : public operand
   vec<id_tab> ids;
 
   virtual void gen_transform (FILE *f, const char *, bool, int, const char *, dt_operand **);
-  void output_code (FILE *f, bool);
 };
 
 struct capture : public operand
@@ -1051,9 +1050,17 @@ expr::gen_transform (FILE *f, const char
   fprintf (f, "}\n");
 }
 
+/* Generate code for a c_expr which is either the expression inside
+   an if statement or a sequence of statements which computes a
+   result to be stored to DEST.  */
+
 void
-c_expr::output_code (FILE *f, bool for_fn)
+c_expr::gen_transform (FILE *f, const char *dest,
+		       bool, int, const char *, dt_operand **)
 {
+  if (dest && nr_stmts == 1)
+    fprintf (f, "%s = ", dest);
+
   unsigned stmt_nr = 1;
   for (unsigned i = 0; i < code.length (); ++i)
     {
@@ -1100,35 +1107,14 @@ c_expr::output_code (FILE *f, bool for_f
       if (token->type == CPP_SEMICOLON)
 	{
 	  stmt_nr++;
-	  if (for_fn && stmt_nr == nr_stmts)
-	    fputs ("\n return ", f);
+	  if (dest && stmt_nr == nr_stmts)
+	    fprintf (f, "\n %s = ", dest);
 	  else
 	    fputc ('\n', f);
 	}
     }
 }
 
-
-void
-c_expr::gen_transform (FILE *f, const char *dest, bool, int, const char *, dt_operand **)
-{
-  /* If this expression has an outlined function variant, call it.  */
-  if (fname)
-    {
-      fprintf (f, "%s = %s (type, captures);\n", dest, fname);
-      return;
-    }
-
-  /* All multi-stmt expressions should have been outlined.  Expressions
-     with nr_stmts == 0 are used for if-expressions.  */
-  gcc_assert (nr_stmts <= 1);
-
-  if (nr_stmts == 1)
-    fprintf (f, "%s = ", dest);
-
-  output_code (f, false);
-}
-
 void
 capture::gen_transform (FILE *f, const char *dest, bool gimple, int depth, const char *in_type, dt_operand **indexes)
 {
@@ -2172,40 +2158,6 @@ write_predicate (FILE *f, predicate_id *
 
 
 static void
-outline_c_exprs (FILE *f, struct operand *op)
-{
-  if (op->type == operand::OP_C_EXPR)
-    {
-      c_expr *e = static_cast <c_expr *>(op);
-      static unsigned fnnr = 1;
-      if (e->nr_stmts > 1
-	  && !e->fname)
-	{
-	  e->fname = (char *)xmalloc (sizeof ("cexprfn") + 4);
-	  sprintf (e->fname, "cexprfn%d", fnnr);
-	  fprintf (f, "\nstatic tree\ncexprfn%d (tree type, tree *captures)\n",
-		   fnnr);
-	  fprintf (f, "{\n");
-	  e->output_code (f, true);
-	  fprintf (f, "}\n");
-	  fnnr++;
-	}
-    }
-  else if (op->type == operand::OP_CAPTURE)
-    {
-      capture *c = static_cast <capture *>(op);
-      if (c->what)
-	outline_c_exprs (f, c->what);
-    }
-  else if (op->type == operand::OP_EXPR)
-    {
-      expr *e = static_cast <expr *>(op);
-      for (unsigned i = 0; i < e->ops.length (); ++i)
-	outline_c_exprs (f, e->ops[i]);
-    }
-}
-
-static void
 write_header (FILE *f, const char *head)
 {
   fprintf (f, "/* Generated automatically by the program `genmatch' from\n");
@@ -3001,10 +2953,6 @@ add_operator (CONVERT2, "CONVERT2", "tcc
   if (verbose)
     dt.print (stderr);
 
-  /* Outline complex C expressions to helper functions.  */
-  for (unsigned i = 0; i < out_simplifiers.length (); ++i)
-    outline_c_exprs (stdout, out_simplifiers[i]->result);
-
   if (gimple)
     dt.gen_gimple (stdout);
   else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]