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]

[tuples] gs_bind changes


Hi guys!

I'm slowly but surely removing all the commented out code, and replacing
it with tuplified code.  Here are changes to gimplify_body() handling
GS_BIND with according changes throughout.

We no longer unshare_all_trees after gimplification, because duh, we're
not using trees anymore.  I thought of unsharing the leaves which are
still trees, but Diego said that wasn't necessary.

There's still more to come wrt GS_BIND, but I wanted to get this in
before Diego gets his big gimplify_expr() change in, and cause me all
sorts of grief :-).

Unfortunately, I've introduced a few warnings compiling gimplify.o, but
I'm tackling those right now.

Committed to branch.

Aldy

	* testsuite/gcc.dg/gimple/with_size_expr.c: Clean up dump.
	* testsuite/gcc.dg/gimple/gs_bind.c: Clean up dump.
	* gimplify.c (struct gimplify_ctx): Make current_bind_expr a tuple.
	(pop_gimplify_context): Accept gimple.
	Comment out call to declare_vars.
	(gimple_current_bind_expr): Return gimple.
	(unshare_all_trees): Remove.
	(gimplify_self_mod_expr): Remove comment.
	(gimplify_cleanup_point_expr): Correct typo in call to gs_seq_init.
	(gimplify_body): Remove body local.  
	Build GS_BIND tuples when needed.
	Do not call unshare_all_trees.
	Call pop_gimplify_context with appropriate argument.
	Comment out call to walk_tree.
	* tree-pretty-print.c (print_declaration): Remove static.
	* diagnostic.h (print_declaration): Prototype.
	* tree-gimple.h (pop_gimplify_context): Accept gimple tuple.
	(gimple_current_bind_expr): Return tuple.
	* gimple-pretty-print.c (dump_gs_seq): New.
	(dump_gs_bind): New.
	(dump_gimple_stmt): Add case for GS_BIND.  Print semi-colons after
	each statement.

Index: testsuite/gcc.dg/gimple/with_size_expr.c
===================================================================
--- testsuite/gcc.dg/gimple/with_size_expr.c	(revision 126065)
+++ testsuite/gcc.dg/gimple/with_size_expr.c	(working copy)
@@ -12,3 +12,4 @@ void f(int a) 
   d = c;
 }
 
+/* { dg-final { cleanup-tree-dump "gimple" } } */
Index: testsuite/gcc.dg/gimple/gs_bind.c
===================================================================
--- testsuite/gcc.dg/gimple/gs_bind.c	(revision 0)
+++ testsuite/gcc.dg/gimple/gs_bind.c	(revision 0)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+/* Test GS_BIND.  */
+
+int global;
+
+void foo(int p)
+{
+  int bar = p, joe;
+
+  joe = bar;
+  global = joe;
+}
+
+/* { dg-final { scan-tree-dump-times "gimpleir: GS_BIND tuple" 1 "gimple"} } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 126123)
+++ gimplify.c	(working copy)
@@ -84,7 +84,7 @@ struct gimplify_ctx
 {
   struct gimplify_ctx *prev_context;
 
-  tree current_bind_expr;
+  gimple current_bind_expr;
   tree temps;
   struct gs_sequence conditional_cleanups;
   tree exit_label;
@@ -172,7 +172,7 @@ push_gimplify_context (void)
    in the unexpanded_var_list.  */
 
 void
-pop_gimplify_context (tree body)
+pop_gimplify_context (gimple body)
 {
   struct gimplify_ctx *c = gimplify_ctxp;
   tree t;
@@ -184,7 +184,11 @@ pop_gimplify_context (tree body)
     DECL_GIMPLE_FORMAL_TEMP_P (t) = 0;
 
   if (body)
+  /* FIXME tuples */
+    ;
+#if 0
     declare_vars (c->temps, body, false);
+#endif
   else
     record_vars (c->temps);
 
@@ -207,7 +211,7 @@ gimple_pop_bind_expr (void)
     = TREE_CHAIN (gimplify_ctxp->current_bind_expr);
 }
 
-tree
+gimple
 gimple_current_bind_expr (void)
 {
   return gimplify_ctxp->current_bind_expr;
@@ -910,18 +914,6 @@ unvisit_body (tree *body_p, tree fndecl)
       unvisit_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl);
 }
 
-/* Unshare T and all the trees reached from T via TREE_CHAIN.  */
-
-#if 0
-/* FIXME tuples */
-static void
-unshare_all_trees (tree t)
-{
-  walk_tree (&t, copy_if_shared_r, NULL, NULL);
-  walk_tree (&t, unmark_visited_r, NULL, NULL);
-}
-#endif
-
 /* Unconditionally make an unshared copy of EXPR.  This is used when using
    stored expressions which span multiple functions, such as BINFO_VTABLE,
    as the normal unsharing process can't tell that they're shared.  */
@@ -1986,12 +1978,6 @@ gimplify_self_mod_expr (tree *expr_p, gs
   if (postfix)
     {
       gimplify_and_add (t1, orig_post_p);
-
-      /* FIXME tuples: Why were we gimplifying here?  Shouldn't this be
-	 gimple already?  We should've append_to_statement_list_force() ??
-
-	 Hmmm... I hope ``post'' didn't contain ungimplified stuff.  */
-      /* gimplify_and_add (post, orig_post_p); */
       gs_seq_append (&post, orig_post_p);
 
       *expr_p = lhs;
@@ -4226,7 +4212,7 @@ gimplify_cleanup_point_expr (tree *expr_
   int old_conds = gimplify_ctxp->conditions;
   struct gs_sequence old_cleanups = gimplify_ctxp->conditional_cleanups;
   gimplify_ctxp->conditions = 0;
-  gs_seq_init (gimplify_ctxp->conditional_cleanups);
+  gs_seq_init (&gimplify_ctxp->conditional_cleanups);
 
   body = TREE_OPERAND (*expr_p, 0);
   gimplify_to_stmt_list (&body);
@@ -6482,8 +6468,8 @@ void
 gimplify_body (tree *body_p, gs_seq seq_p, tree fndecl, bool do_parms)
 {
   location_t saved_location = input_location;
-  //  tree body;
   struct gs_sequence parm_stmts;
+  gimple outer_bind;
 
   timevar_push (TV_TREE_GIMPLIFY);
 
@@ -6509,49 +6495,36 @@ gimplify_body (tree *body_p, gs_seq seq_
 
   /* Gimplify the function's body.  */
   gimplify_stmt (body_p, seq_p);
-#if 0
-/* FIXME tuples */
-  body = *body_p;
 
-  if (!body)
-    body = alloc_stmt_list ();
-  else if (TREE_CODE (body) == STATEMENT_LIST)
-    {
-      tree t = expr_only (*body_p);
-      if (t)
-	body = t;
-    }
+  outer_bind = gs_seq_first (seq_p);
 
-  /* If there isn't an outer BIND_EXPR, add one.  */
-  if (TREE_CODE (body) != BIND_EXPR)
+  /* If there isn't an outer GS_BIND, add one.  */
+  if (GS_SUBCODE_FLAGS (outer_bind) != GS_BIND)
     {
-      tree b = build3 (BIND_EXPR, void_type_node, NULL_TREE,
-		       NULL_TREE, NULL_TREE);
-      TREE_SIDE_EFFECTS (b) = 1;
-      append_to_statement_list_force (body, &BIND_EXPR_BODY (b));
-      body = b;
+      outer_bind = gs_build_bind (NULL_TREE, seq_p);
+      gs_seq_set_first (seq_p, outer_bind);
+      gs_seq_set_last (seq_p, outer_bind);
     }
 
+  *body_p = NULL_TREE;
+
   /* If we had callee-copies statements, insert them at the beginning
      of the function.  */
-  if (parm_stmts)
+  if (gs_seq_empty_p (&parm_stmts) != false)
     {
-      append_to_statement_list_force (BIND_EXPR_BODY (body), &parm_stmts);
-      BIND_EXPR_BODY (body) = parm_stmts;
+      gs_seq_append (gs_bind_body (outer_bind), &parm_stmts);
+      gs_bind_set_body (outer_bind, &parm_stmts);
     }
 
-  /* Unshare again, in case gimplification was sloppy.  */
-  unshare_all_trees (body);
-
-  *body_p = body;
-
-  pop_gimplify_context (body);
+  pop_gimplify_context (outer_bind);
   gcc_assert (gimplify_ctxp == NULL);
 
+  /* FIXME tuples */
+#if 0
 #ifdef ENABLE_CHECKING
   walk_tree (body_p, check_pointer_types_r, NULL, NULL);
 #endif
-#endif /* if 0 */
+#endif
 
   timevar_pop (TV_TREE_GIMPLIFY);
   input_location = saved_location;
Index: tree-pretty-print.c
===================================================================
--- tree-pretty-print.c	(revision 126065)
+++ tree-pretty-print.c	(working copy)
@@ -42,7 +42,6 @@ static void pretty_print_string (pretty_
 static void print_call_name (pretty_printer *, tree);
 static void newline_and_indent (pretty_printer *, int);
 static void maybe_init_pretty_print (FILE *);
-static void print_declaration (pretty_printer *, tree, int, int);
 static void print_struct_decl (pretty_printer *, tree, int, int);
 static void do_niy (pretty_printer *, tree);
 static void dump_vops (pretty_printer *, tree, int, int);
@@ -2085,7 +2084,7 @@ dump_generic_node (pretty_printer *buffe
 
 /* Print the declaration of a variable.  */
 
-static void
+void
 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
 {
   INDENT (spc);
Index: diagnostic.h
===================================================================
--- diagnostic.h	(revision 126065)
+++ diagnostic.h	(working copy)
@@ -208,6 +208,7 @@ extern char *diagnostic_build_prefix (di
 extern char *file_name_as_prefix (const char *);
 
 /* In tree-pretty-print.c  */
+extern void print_declaration (pretty_printer *, tree, int, int);
 extern int dump_generic_node (pretty_printer *, tree, int, int, bool);
 extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
 extern void print_generic_stmt (FILE *, tree, int);
Index: tree-gimple.h
===================================================================
--- tree-gimple.h	(revision 126091)
+++ tree-gimple.h	(working copy)
@@ -119,12 +119,12 @@ extern bool gimplify_stmt (tree *, gs_se
 extern void gimplify_to_stmt_list (tree *);
 extern void gimplify_body (tree *, gs_seq, tree, bool);
 extern void push_gimplify_context (void);
-extern void pop_gimplify_context (tree);
+extern void pop_gimplify_context (gimple);
 extern void gimplify_and_add (tree, gs_seq);
 
 /* Miscellaneous helpers.  */
 extern void gimple_add_tmp_var (tree);
-extern tree gimple_current_bind_expr (void);
+extern gimple gimple_current_bind_expr (void);
 extern tree voidify_wrapper_expr (tree, tree);
 extern tree gimple_build_eh_filter (tree, tree, tree);
 extern tree build_and_jump (tree *);
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 126091)
+++ gimple-pretty-print.c	(working copy)
@@ -92,6 +92,23 @@ debug_gimple_seq (gs_seq seq)
     }
 }
 
+/* Dump a sequence to a BUFFER.  */
+
+static void
+dump_gs_seq (pretty_printer *buffer, gs_seq seq, int spc, int flags)
+{
+  gimple_stmt_iterator i;
+
+  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+    {
+      gimple gs = gsi_stmt (i);
+      pp_string (buffer, "gimpleir: ");
+      dump_gimple_stmt (buffer, gs, spc, flags);
+    }
+}
+
+/* Dump a sequence to a FILE *.  */
+
 void
 dump_gimple_seq (FILE *file, gs_seq seq)
 {
@@ -248,6 +265,34 @@ dump_gs_cond (pretty_printer *buffer, gi
 }
 
 
+/* Dump a GS_BIND tuple.  */
+
+static void
+dump_gs_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
+{
+  pp_string (buffer, "GS_BIND tuple");
+  newline_and_indent (buffer, spc);
+
+  pp_character (buffer, '{');
+  newline_and_indent (buffer, spc + 2);
+  if (!(flags & TDF_SLIM))
+    {
+      tree var;
+
+      for (var = gs_bind_vars (gs); var; var = TREE_CHAIN (var))
+	{
+	  print_declaration (buffer, var, spc, flags);
+	  newline_and_indent (buffer, spc + 2);
+	}
+      newline_and_indent (buffer, spc + 2);
+    }
+
+  dump_gs_seq (buffer, gs_bind_body (gs), spc + 2, flags);
+  newline_and_indent (buffer, spc);
+  pp_character (buffer, '}');
+}
+
+
 /* Dump the gimple statement GS on the pretty_printer BUFFER, SPC
    spaces of indent.  FLAGS specifies details to show in the dump (see
    TDF_* in tree.h).  */
@@ -264,6 +309,10 @@ dump_gimple_stmt (pretty_printer *buffer
       dump_gs_assign (buffer, gs, spc, flags);
       break;
 
+    case GS_BIND:
+      dump_gs_bind (buffer, gs, spc, flags);
+      break;
+
     case GS_RETURN:
       dump_gs_return (buffer, gs, spc, flags);
       break;
@@ -290,5 +339,7 @@ dump_gimple_stmt (pretty_printer *buffer
       GS_NIY;
     }
 
+  pp_character (buffer, ';');
+  newline_and_indent (buffer, spc);
   pp_write_text_to_stream (buffer);
 }


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