public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples] Gimplify va_arg and other fixes
@ 2007-08-01 22:07 Diego Novillo
  0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2007-08-01 22:07 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]


This patch fixes gimplification of va_arg on x86, removes
gimplify_to_stmt_list (which is superfluous since we now always emit
GIMPLE to a sequence) and fixes gimplification of switch() bodies to not
assume that the body will always be a STATEMENT_LIST.

With this patch we are down to 36 failures in compile.exp.

[-- Attachment #2: 20070801-compile.exp-fixes.diff --]
[-- Type: text/x-patch, Size: 12987 bytes --]

2007-08-01  Diego Novillo  <dnovillo@google.com>

	* gimplify.c (gimplify_switch_expr): Remove switch_body_seq_.
	Change switch_body_seq to struct gimple_sequence.
	Adjust all uses.
	Call gimplify_stmt instead of gimplify_statement_list
	(gimplify_to_stmt_list): Remove.
	Update all users.
	* tree-mudflap.c: Include gimple.h
	(mf_decl_cache_locals): Convert to emit GIMPLE.
	(mf_build_check_statement_for): Add FIXME and unreachable
	markers to convert to GIMPLE.
	* Makefile.in (tree-mudflap.o): Depend on $(GIMPLE_H).
	* config/i386/i386.c (ix86_gimplify_va_arg): Adapt to emit
	GIMPLE.

Index: tree-gimple.h
===================================================================
--- tree-gimple.h	(revision 127104)
+++ tree-gimple.h	(working copy)
@@ -132,7 +132,6 @@ extern enum gimplify_status gimplify_exp
 extern void gimplify_type_sizes (tree, gimple_seq);
 extern void gimplify_one_sizepos (tree *, gimple_seq);
 extern bool gimplify_stmt (tree *, gimple_seq);
-extern void gimplify_to_stmt_list (tree *);
 extern void gimplify_body (tree *, gimple_seq, tree, bool);
 extern void push_gimplify_context (void);
 extern void pop_gimplify_context (gimple);
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 127133)
+++ gimplify.c	(working copy)
@@ -784,7 +784,6 @@ annotate_all_with_locus (gimple_seq stmt
   for (i = gsi_start (stmt_p); !gsi_end_p (i); gsi_next (&i))
     {
       gimple gs = gsi_stmt (i);
-
       annotate_one_with_locus (gs, locus);
     }
 }
@@ -1384,13 +1383,11 @@ sort_case_labels (VEC(tree,heap)* label_
 static enum gimplify_status
 gimplify_switch_expr (tree *expr_p, gimple_seq pre_p)
 {
-  gimple_seq switch_body_seq;
   tree switch_expr;
   switch_expr = *expr_p;
-  struct gimple_sequence switch_body_seq_;
-  switch_body_seq = &switch_body_seq_;
+  struct gimple_sequence switch_body_seq;
   
-  gimple_seq_init (switch_body_seq);
+  gimple_seq_init (&switch_body_seq);
   gimplify_expr (&SWITCH_COND (switch_expr), pre_p, NULL, is_gimple_val,
                  fb_rvalue);
   
@@ -1411,7 +1408,7 @@ gimplify_switch_expr (tree *expr_p, gimp
       saved_labels = gimplify_ctxp->case_labels;
       gimplify_ctxp->case_labels = VEC_alloc (tree, heap, 8);
 
-      gimplify_statement_list (&SWITCH_BODY (switch_expr), switch_body_seq);
+      gimplify_stmt (&SWITCH_BODY (switch_expr), &switch_body_seq);
       labels = gimplify_ctxp->case_labels;
       gimplify_ctxp->case_labels = saved_labels;
  
@@ -1451,7 +1448,7 @@ gimplify_switch_expr (tree *expr_p, gimp
 	  tree def_lab = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE,
 	                         NULL_TREE, create_artificial_label ());
 	  gimple new_default = build_gimple_label (def_lab);
-	  gimple_add (switch_body_seq, new_default);
+	  gimple_add (&switch_body_seq, new_default);
 	  default_case = gimple_label_label (new_default);
 	}
 
@@ -1461,7 +1458,7 @@ gimplify_switch_expr (tree *expr_p, gimp
       gimple_switch = build_gimple_switch_vec (SWITCH_COND (switch_expr), 
                                                default_case, labels);
       gimple_add (pre_p, gimple_switch);
-      gimple_seq_append (pre_p, switch_body_seq);
+      gimple_seq_append (pre_p, &switch_body_seq);
       VEC_free(tree, heap, labels);
     }
   else
@@ -4312,7 +4309,7 @@ gimplify_cleanup_point_expr (tree *expr_
   gimple_seq_init (&gimplify_ctxp->conditional_cleanups);
 
   body = TREE_OPERAND (*expr_p, 0);
-  gimplify_to_stmt_list (&body);
+  gimplify_stmt (&body, pre_p);
 
   gimplify_ctxp->conditions = old_conds;
   gimplify_ctxp->conditional_cleanups = old_cleanups;
@@ -4489,7 +4486,11 @@ gimplify_target_expr (tree *expr_p, gimp
 
 /* Gimplification of expression trees.  */
 
-/* Gimplify an expression which appears at statement context into SEQ_P.
+/* Gimplify an expression which appears at statement context.  The
+   corresponding GIMPLE statements are added to SEQ_P.  Note that the
+   sequence is not initialized.  It is the caller's responsibility to
+   initialize it, if required. 
+
    Return true if we actually added a statement to the queue.  */
 
 bool
@@ -4502,27 +4503,6 @@ gimplify_stmt (tree *stmt_p, gimple_seq 
   return last != gimple_seq_last (seq_p);
 }
 
-/* Similarly, but force the result to be a STATEMENT_LIST.  */
-
-void
-gimplify_to_stmt_list (tree *stmt_p)
-{
-  /* FIXME tuples: This should be obsoleted in favor of putting everything
-     in a sequence.  */
-#if 0
-/* FIXME tuples */
-  gimplify_stmt (stmt_p);
-#endif
-  if (!*stmt_p)
-    *stmt_p = alloc_stmt_list ();
-  else if (TREE_CODE (*stmt_p) != STATEMENT_LIST)
-    {
-      tree t = *stmt_p;
-      *stmt_p = alloc_stmt_list ();
-      append_to_statement_list (t, stmt_p);
-    }
-}
-
 
 /* Add FIRSTPRIVATE entries for DECL in the OpenMP the surrounding parallels
    to CTX.  If entries already exist, force them to be some flavor of private.
@@ -5249,7 +5229,11 @@ gimplify_omp_for (tree *expr_p, gimple_s
       gcc_unreachable ();
     }
 
+#if 0
+  /* FIXME tuples.  Need to gimplify into a sequence using
+     gimplify_stmt and create the GIMPLE OMP_FOR with that sequence.  */
   gimplify_to_stmt_list (&OMP_FOR_BODY (for_stmt));
+#endif
   gimplify_adjust_omp_clauses (&OMP_FOR_CLAUSES (for_stmt));
 
   return ret == GS_ALL_DONE ? GS_ALL_DONE : GS_ERROR;
@@ -5264,7 +5248,11 @@ gimplify_omp_workshare (tree *expr_p, gi
   tree stmt = *expr_p;
 
   gimplify_scan_omp_clauses (&OMP_CLAUSES (stmt), pre_p, false, false);
+#if 0
+  /* FIXME tuples.  Need to gimplify into a sequence using
+     gimplify_stmt and create the GIMPLE OMP_FOR with that sequence.  */
   gimplify_to_stmt_list (&OMP_BODY (stmt));
+#endif
   gimplify_adjust_omp_clauses (&OMP_CLAUSES (stmt));
 
   return GS_ALL_DONE;
@@ -6057,12 +6045,12 @@ gimplify_expr (tree *expr_p, gimple_seq 
 	  break;
 
 	case CATCH_EXPR:
-	  gimplify_to_stmt_list (&CATCH_BODY (*expr_p));
+	  gimplify_stmt (&CATCH_BODY (*expr_p), pre_p);
 	  ret = GS_ALL_DONE;
 	  break;
 
 	case EH_FILTER_EXPR:
-	  gimplify_to_stmt_list (&EH_FILTER_FAILURE (*expr_p));
+	  gimplify_stmt (&EH_FILTER_FAILURE (*expr_p), pre_p);
 	  ret = GS_ALL_DONE;
 	  break;
 
@@ -6138,7 +6126,7 @@ gimplify_expr (tree *expr_p, gimple_seq 
 	case OMP_MASTER:
 	case OMP_ORDERED:
 	case OMP_CRITICAL:
-	  gimplify_to_stmt_list (&OMP_BODY (*expr_p));
+	  gimplify_stmt (&OMP_BODY (*expr_p), pre_p);
 	  break;
 
 	case OMP_ATOMIC:
Index: tree-mudflap.c
===================================================================
--- tree-mudflap.c	(revision 127104)
+++ tree-mudflap.c	(working copy)
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.  
 #include "ggc.h"
 #include "cgraph.h"
 #include "toplev.h"
+#include "gimple.h"
 
 /* Internal function decls */
 
@@ -450,8 +451,7 @@ execute_mudflap_function_ops (void)
 static void
 mf_decl_cache_locals (void)
 {
-  tree t, shift_init_stmts, mask_init_stmts;
-  tree_stmt_iterator tsi;
+  gimple g;
 
   /* Build the cache vars.  */
   mf_cache_shift_decl_l
@@ -464,27 +464,14 @@ mf_decl_cache_locals (void)
 
   /* Build initialization nodes for the cache vars.  We just load the
      globals into the cache variables.  */
-  t = build_gimple_modify_stmt (mf_cache_shift_decl_l, mf_cache_shift_decl);
-  SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (current_function_decl));
-  gimplify_to_stmt_list (&t);
-  shift_init_stmts = t;
-
-  t = build_gimple_modify_stmt (mf_cache_mask_decl_l, mf_cache_mask_decl);
-  SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (current_function_decl));
-  gimplify_to_stmt_list (&t);
-  mask_init_stmts = t;
+  g = build_gimple_assign (mf_cache_shift_decl_l, mf_cache_shift_decl);
+  set_gimple_locus (g, DECL_SOURCE_LOCATION (current_function_decl));
+  insert_edge_copies (g, ENTRY_BLOCK_PTR);
 
-  /* Anticipating multiple entry points, we insert the cache vars
-     initializers in each successor of the ENTRY_BLOCK_PTR.  */
-  for (tsi = tsi_start (shift_init_stmts);
-       ! tsi_end_p (tsi);
-       tsi_next (&tsi))
-    insert_edge_copies (tsi_stmt (tsi), ENTRY_BLOCK_PTR);
+  g = build_gimple_assign (mf_cache_mask_decl_l, mf_cache_mask_decl);
+  set_gimple_locus (g, DECL_SOURCE_LOCATION (current_function_decl));
+  insert_edge_copies (g, ENTRY_BLOCK_PTR);
 
-  for (tsi = tsi_start (mask_init_stmts);
-       ! tsi_end_p (tsi);
-       tsi_next (&tsi))
-    insert_edge_copies (tsi_stmt (tsi), ENTRY_BLOCK_PTR);
   bsi_commit_edge_inserts ();
 }
 
@@ -561,7 +548,12 @@ mf_build_check_statement_for (tree base,
 				fold_convert (mf_uintptr_type,
 					      unshare_expr (base)));
   SET_EXPR_LOCUS (t, locus);
+#if 0
+  /* FIXME tuples.  This whole function needs to be converted.  */
   gimplify_to_stmt_list (&t);
+#else
+  gcc_unreachable ();
+#endif
   head = tsi_start (t);
   tsi = tsi_last (t);
 
@@ -570,7 +562,12 @@ mf_build_check_statement_for (tree base,
 				fold_convert (mf_uintptr_type,
 					      unshare_expr (limit)));
   SET_EXPR_LOCUS (t, locus);
+#if 0
+  /* FIXME tuples.  This whole function needs to be converted.  */
   gimplify_to_stmt_list (&t);
+#else
+  gcc_unreachable ();
+#endif
   tsi_link_after (&tsi, t, TSI_CONTINUE_LINKING);
 
   /* Build: __mf_elem = &__mf_lookup_cache [(__mf_base >> __mf_shift)
@@ -587,7 +584,12 @@ mf_build_check_statement_for (tree base,
   t = build1 (ADDR_EXPR, mf_cache_structptr_type, t);
   t = build_gimple_modify_stmt (mf_elem, t);
   SET_EXPR_LOCUS (t, locus);
+#if 0
+  /* FIXME tuples.  This whole function needs to be converted.  */
   gimplify_to_stmt_list (&t);
+#else
+  gcc_unreachable ();
+#endif
   tsi_link_after (&tsi, t, TSI_CONTINUE_LINKING);
 
   /* Quick validity check.
@@ -632,7 +634,12 @@ mf_build_check_statement_for (tree base,
   t = build2 (TRUTH_OR_EXPR, boolean_type_node, t, u);
   cond = create_tmp_var (boolean_type_node, "__mf_unlikely_cond");
   t = build_gimple_modify_stmt (cond, t);
+#if 0
+  /* FIXME tuples.  This whole function needs to be converted.  */
   gimplify_to_stmt_list (&t);
+#else
+  gcc_unreachable ();
+#endif
   tsi_link_after (&tsi, t, TSI_CONTINUE_LINKING);
 
   /* Build the conditional jump.  'cond' is just a temporary so we can
@@ -669,7 +676,12 @@ mf_build_check_statement_for (tree base,
 		   fold_build2 (MINUS_EXPR, mf_uintptr_type, mf_limit, mf_base),
 		   integer_one_node);
   t = build_call_expr (mf_check_fndecl, 4, mf_base, v, dirflag, u);
+#if 0
+  /* FIXME tuples.  This whole function needs to be converted.  */
   gimplify_to_stmt_list (&t);
+#else
+  gcc_unreachable ();
+#endif
   head = tsi_start (t);
   tsi = tsi_last (t);
 
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 127104)
+++ Makefile.in	(working copy)
@@ -2267,7 +2267,7 @@ tree-mudflap.o : $(CONFIG_H) $(SYSTEM_H)
    $(TREE_GIMPLE_H) $(DIAGNOSTIC_H) $(HASHTAB_H) langhooks.h tree-mudflap.h \
    $(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(CGRAPH_H) $(GGC_H) \
    gt-tree-mudflap.h $(BASIC_BLOCK_H) $(FLAGS_H) $(FUNCTION_H) hard-reg-set.h \
-   $(RTL_H) $(TM_P_H) $(TREE_FLOW_H) toplev.h
+   $(RTL_H) $(TM_P_H) $(TREE_FLOW_H) toplev.h $(GIMPLE_H)
 tree-nomudflap.o : $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TREE_INLINE_H) \
    $(C_TREE_H) $(C_COMMON_H) $(TREE_GIMPLE_H) $(DIAGNOSTIC_H) $(HASHTAB_H) \
    output.h $(VARRAY_H) langhooks.h tree-mudflap.h $(TM_H) coretypes.h \
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 127104)
+++ config/i386/i386.c	(working copy)
@@ -4851,7 +4851,8 @@ ix86_va_start (tree valist, rtx nextarg)
 /* Implement va_arg.  */
 
 static tree
-ix86_gimplify_va_arg (tree valist, tree type, tree *pre_p, tree *post_p)
+ix86_gimplify_va_arg (tree valist, tree type, gimple_seq pre_p,
+		      gimple_seq post_p)
 {
   static const int intreg[6] = { 0, 1, 2, 3, 4, 5 };
   tree f_gpr, f_fpr, f_ovf, f_sav;
@@ -5043,6 +5044,7 @@ ix86_gimplify_va_arg (tree valist, tree 
 	  t = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (gpr), gpr, t);
 	  gimplify_and_add (t, pre_p);
 	}
+
       if (needed_sseregs)
 	{
 	  t = build2 (PLUS_EXPR, TREE_TYPE (fpr), fpr,
@@ -5051,11 +5053,9 @@ ix86_gimplify_va_arg (tree valist, tree 
 	  gimplify_and_add (t, pre_p);
 	}
 
-      t = build1 (GOTO_EXPR, void_type_node, lab_over);
-      gimplify_and_add (t, pre_p);
+      gimple_add (pre_p, build_gimple_goto (lab_over));
 
-      t = build1 (LABEL_EXPR, void_type_node, lab_false);
-      append_to_statement_list (t, pre_p);
+      gimple_add (pre_p, build_gimple_label (lab_false));
     }
 
   /* ... otherwise out of the overflow area.  */
@@ -5085,10 +5085,7 @@ ix86_gimplify_va_arg (tree valist, tree 
   gimplify_and_add (t, pre_p);
 
   if (container)
-    {
-      t = build1 (LABEL_EXPR, void_type_node, lab_over);
-      append_to_statement_list (t, pre_p);
-    }
+    gimple_add (pre_p, build_gimple_label (lab_over));
 
   ptrtype = build_pointer_type (type);
   addr = fold_convert (ptrtype, addr);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-08-01 22:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-01 22:07 [tuples] Gimplify va_arg and other fixes Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).