public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples] more cleanups
@ 2007-08-29 19:05 Aldy Hernandez
  2007-08-29 20:23 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2007-08-29 19:05 UTC (permalink / raw)
  To: dnovillo, gcc-patches

More cleanups and conversions.

Unfortunately, I'm not sure whether I'm introducing more warnings than
I'm fixing.

Committed to branch.

	* tree-ssa-operands.h (pop_stmt_changes, push_stmt_changes):
	Argument is gimple.
	(struct ssa_operand_iterator_d): Member phi_stmt is gimple.
	* value-prof.c (gimple_add_histogram_value): Adjust for tuples.
	(gimple_duplicate_stmt_histograms): Same.
	* value-prof.h (gimple_add_histogram_value): Same.
	(gimple_duplicate_stmt_histograms): Same.
	* tree-flow-inline.h (clear_and_done_ssa_iter): Same.
	(op_iter_init): Same.
	(op_iter_init_phiuse): Same.
	* tree-flow.h (stmt_references_memory_p): Same.
	* tree-cfg.c (tree_can_merge_blocks_p): Same.
	(remove_bb): Same.
	(find_taken_edge): Same.
	(tree_cfg2vcg): Same.
	(first_stmt): Same.
	(last_stmt): Same.
	(bsi_move_after): Same.
	(bsi_move_before): Same.
	(tree_find_edge_insert_loc): Same.
	Remove code handling a GIMPLE_MODIFY_STMT inside a RETURN_EXPR.
	(delete_tree_cfg_annotations): Remove code to remove annotations.
	* tree-ssa-operands.c (struct scb_d): Stmt_p is a gimple *.
	(push_stmt_changes): Adjust for tuples.
	(mark_difference_for_renaming): Same.
	(pop_stmt_changes): Same.
	(stmt_references_memory_p): Same.

Index: tree-ssa-operands.h
===================================================================
--- tree-ssa-operands.h	(revision 127900)
+++ tree-ssa-operands.h	(working copy)
@@ -213,8 +213,8 @@ extern void debug_decl_set (bitmap);
 extern bool ssa_operands_active (void);
 
 extern void add_to_addressable_set (tree, bitmap *);
-extern void push_stmt_changes (tree *);
-extern void pop_stmt_changes (tree *);
+extern void push_stmt_changes (gimple *);
+extern void pop_stmt_changes (gimple *);
 extern void discard_stmt_changes (tree *);
 
 enum ssa_op_iter_type {
@@ -240,7 +240,7 @@ typedef struct ssa_operand_iterator_d
   enum ssa_op_iter_type iter_type;
   int phi_i;
   int num_phi;
-  tree phi_stmt;
+  gimple phi_stmt;
   bool done;
   unsigned int vuse_index;
   unsigned int mayuse_index;
Index: value-prof.c
===================================================================
--- value-prof.c	(revision 127871)
+++ value-prof.c	(working copy)
@@ -154,7 +154,7 @@ gimple_histogram_value (struct function 
 /* Add histogram for STMT.  */
 
 void
-gimple_add_histogram_value (struct function *fun, tree stmt, histogram_value hist)
+gimple_add_histogram_value (struct function *fun, gimple stmt, histogram_value hist)
 {
   hist->hvalue.next = gimple_histogram_value (fun, stmt);
   set_histogram_value (fun, stmt, hist);
@@ -322,8 +322,8 @@ gimple_remove_stmt_histograms (struct fu
 /* Duplicate all histograms associates with OSTMT to STMT.  */
 
 void
-gimple_duplicate_stmt_histograms (struct function *fun, tree stmt,
-				  struct function *ofun, tree ostmt)
+gimple_duplicate_stmt_histograms (struct function *fun, gimple stmt,
+				  struct function *ofun, gimple ostmt)
 {
   histogram_value val;
   for (val = gimple_histogram_value (ofun, ostmt); val != NULL; val = val->hvalue.next)
Index: value-prof.h
===================================================================
--- value-prof.h	(revision 127871)
+++ value-prof.h	(working copy)
@@ -111,11 +111,11 @@ struct profile_hooks {
 
 histogram_value gimple_histogram_value (struct function *, gimple);
 histogram_value gimple_histogram_value_of_type (struct function *, tree, enum hist_type);
-void gimple_add_histogram_value (struct function *, tree, histogram_value);
+void gimple_add_histogram_value (struct function *, gimple, histogram_value);
 void dump_histograms_for_stmt (struct function *, FILE *, tree);
 void gimple_remove_histogram_value (struct function *, gimple, histogram_value);
 void gimple_remove_stmt_histograms (struct function *, gimple);
-void gimple_duplicate_stmt_histograms (struct function *, tree, struct function *, tree);
+void gimple_duplicate_stmt_histograms (struct function *, gimple, struct function *, gimple);
 void verify_histograms (void);
 void free_histograms (void);
 void stringop_block_profile (tree, unsigned int *, HOST_WIDE_INT *);
Index: tree-flow-inline.h
===================================================================
--- tree-flow-inline.h	(revision 127900)
+++ tree-flow-inline.h	(working copy)
@@ -1073,7 +1073,7 @@ clear_and_done_ssa_iter (ssa_op_iter *pt
   ptr->iter_type = ssa_op_iter_none;
   ptr->phi_i = 0;
   ptr->num_phi = 0;
-  ptr->phi_stmt = NULL_TREE;
+  ptr->phi_stmt = NULL;
   ptr->done = true;
   ptr->vuse_index = 0;
   ptr->mayuse_index = 0;
@@ -1092,7 +1092,7 @@ op_iter_init (ssa_op_iter *ptr, gimple s
 
   ptr->phi_i = 0;
   ptr->num_phi = 0;
-  ptr->phi_stmt = NULL_TREE;
+  ptr->phi_stmt = NULL;
   ptr->vuse_index = 0;
   ptr->mayuse_index = 0;
 }
@@ -1338,9 +1338,9 @@ single_phi_def (tree stmt, int flags)
 /* Initialize the iterator PTR for uses matching FLAGS in PHI.  FLAGS should
    be either SSA_OP_USES or SSA_OP_VIRTUAL_USES.  */
 static inline use_operand_p
-op_iter_init_phiuse (ssa_op_iter *ptr, tree phi, int flags)
+op_iter_init_phiuse (ssa_op_iter *ptr, gimple phi, int flags)
 {
-  tree phi_def = PHI_RESULT (phi);
+  tree phi_def = gimple_phi_result (phi);
   int comp;
 
   clear_and_done_ssa_iter (ptr);
@@ -1358,7 +1358,7 @@ op_iter_init_phiuse (ssa_op_iter *ptr, t
     }
 
   ptr->phi_stmt = phi;
-  ptr->num_phi = PHI_NUM_ARGS (phi);
+  ptr->num_phi = gimple_phi_nargs (phi);
   ptr->iter_type = ssa_op_iter_use;
   return op_iter_next_use (ptr);
 }
Index: tree-flow.h
===================================================================
--- tree-flow.h	(revision 127871)
+++ tree-flow.h	(working copy)
@@ -879,7 +879,7 @@ extern bool types_compatible_p (tree, tr
 extern void verify_ssa (bool);
 extern void delete_tree_ssa (void);
 extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
-extern bool stmt_references_memory_p (tree);
+extern bool stmt_references_memory_p (gimple);
 
 /* In tree-into-ssa.c  */
 void update_ssa (unsigned);
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 127871)
+++ tree-cfg.c	(working copy)
@@ -105,7 +105,7 @@ static inline void change_bb_for_stmt (g
 
 /* Flowgraph optimization and cleanup.  */
 static void tree_merge_blocks (basic_block, basic_block);
-static bool tree_can_merge_blocks_p (const_basic_block, const_basic_block);
+static bool tree_can_merge_blocks_p (basic_block, basic_block);
 static void remove_bb (basic_block);
 static edge find_taken_edge_computed_goto (basic_block, tree);
 static edge find_taken_edge_cond_expr (basic_block, tree);
@@ -1139,7 +1139,7 @@ group_case_labels (void)
 /* Checks whether we can merge block B into block A.  */
 
 static bool
-tree_can_merge_blocks_p (const_basic_block a, const_basic_block b)
+tree_can_merge_blocks_p (basic_block a, basic_block b)
 {
   gimple stmt;
   block_stmt_iterator bsi;
@@ -1365,7 +1365,7 @@ tree_merge_blocks (basic_block a, basic_
 
   /* Merge the chains.  */
   last = gsi_last (bb_seq (a));
-  gsi_link_after (&last, bb_seq (b), GSI_NEW_STMT);
+  gsi_link_after (last, bb_seq (b), GSI_NEW_STMT);
   set_bb_seq (b, NULL);
 
   if (cfgcleanup_altered_bbs)
@@ -2010,10 +2010,10 @@ remove_bb (basic_block bb)
     {
       for (i = bsi_start (bb); !bsi_end_p (i);)
 	{
-	  tree stmt = bsi_stmt (i);
-	  if (TREE_CODE (stmt) == LABEL_EXPR
-	      && (FORCED_LABEL (LABEL_EXPR_LABEL (stmt))
-		  || DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt))))
+	  gimple stmt = bsi_stmt (i);
+	  if (gimple_code (stmt) == GIMPLE_LABEL
+	      && (FORCED_LABEL (gimple_label_label (stmt))
+		  || DECL_NONLOCAL (gimple_label_label (stmt))))
 	    {
 	      basic_block new_bb;
 	      block_stmt_iterator new_bsi;
@@ -2021,10 +2021,10 @@ remove_bb (basic_block bb)
 	      /* A non-reachable non-local label may still be referenced.
 		 But it no longer needs to carry the extra semantics of
 		 non-locality.  */
-	      if (DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)))
+	      if (DECL_NONLOCAL (gimple_label_label (stmt)))
 		{
-		  DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)) = 0;
-		  FORCED_LABEL (LABEL_EXPR_LABEL (stmt)) = 1;
+		  DECL_NONLOCAL (gimple_label_label (stmt)) = 0;
+		  FORCED_LABEL (gimple_label_label (stmt)) = 1;
 		}
 
 	      new_bb = bb->prev_bb;
@@ -2087,7 +2087,7 @@ remove_bb (basic_block bb)
 edge
 find_taken_edge (basic_block bb, tree val)
 {
-  tree stmt;
+  gimple stmt;
 
   stmt = last_stmt (bb);
 
@@ -2390,17 +2390,17 @@ tree_cfg2vcg (FILE *file)
 
   FOR_EACH_BB (bb)
     {
-      enum tree_code head_code, end_code;
+      enum gimple_code head_code, end_code;
       const char *head_name, *end_name;
       int head_line = 0;
       int end_line = 0;
-      tree first = first_stmt (bb);
-      tree last = last_stmt (bb);
+      gimple first = first_stmt (bb);
+      gimple last = last_stmt (bb);
 
       if (first)
 	{
-	  head_code = TREE_CODE (first);
-	  head_name = tree_code_name[head_code];
+	  head_code = gimple_code (first);
+	  head_name = gimple_code_name[head_code];
 	  head_line = get_lineno (first);
 	}
       else
@@ -2408,8 +2408,8 @@ tree_cfg2vcg (FILE *file)
 
       if (last)
 	{
-	  end_code = TREE_CODE (last);
-	  end_name = tree_code_name[end_code];
+	  end_code = gimple_code (last);
+	  end_name = gimple_code_name[end_code];
 	  end_line = get_lineno (last);
 	}
       else
@@ -2572,22 +2572,11 @@ stmt_ends_bb_p (gimple t)
   return is_ctrl_stmt (t) || is_ctrl_altering_stmt (t);
 }
 
-/* Remove block annotations and other datastructures.  */
+/* Remove block annotations and other data structures.  */
 
 void
 delete_tree_cfg_annotations (void)
 {
-  basic_block bb;
-  block_stmt_iterator bsi;
-
-  /* Remove annotations from every tree in the function.  */
-  FOR_EACH_BB (bb)
-    for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-      {
-	tree stmt = bsi_stmt (bsi);
-	ggc_free (stmt->base.ann);
-	stmt->base.ann = NULL;
-      }
   label_to_block_map = NULL;
 }
 
@@ -2598,7 +2587,7 @@ gimple
 first_stmt (basic_block bb)
 {
   block_stmt_iterator i = bsi_start (bb);
-  return !bsi_end_p (i) ? bsi_stmt (i) : NULL_TREE;
+  return !bsi_end_p (i) ? bsi_stmt (i) : NULL;
 }
 
 /* Return the last statement in basic block BB.  */
@@ -2607,7 +2596,7 @@ gimple
 last_stmt (basic_block bb)
 {
   block_stmt_iterator b = bsi_last (bb);
-  return !bsi_end_p (b) ? bsi_stmt (b) : NULL_TREE;
+  return !bsi_end_p (b) ? bsi_stmt (b) : NULL;
 }
 
 /* Return the last statement of an otherwise empty block.  Return NULL
@@ -2805,7 +2794,7 @@ bsi_remove (block_stmt_iterator *i, bool
 void
 bsi_move_after (block_stmt_iterator *from, block_stmt_iterator *to)
 {
-  tree stmt = bsi_stmt (*from);
+  gimple stmt = bsi_stmt (*from);
   bsi_remove (from, false);
   /* We must have BSI_NEW_STMT here, as bsi_move_after is sometimes used to
      move statements to an empty block.  */
@@ -2818,7 +2807,7 @@ bsi_move_after (block_stmt_iterator *fro
 void
 bsi_move_before (block_stmt_iterator *from, block_stmt_iterator *to)
 {
-  tree stmt = bsi_stmt (*from);
+  gimple stmt = bsi_stmt (*from);
   bsi_remove (from, false);
   /* For consistency with bsi_move_after, it might be better to have
      BSI_NEW_STMT here; however, that breaks several places that expect
@@ -2854,7 +2843,7 @@ bsi_replace (const block_stmt_iterator *
 
   if (stmt == orig_stmt)
     return;
-  set_gimple_locus (stmt, *EXPR_LOCUS (orig_stmt));
+  set_gimple_locus (stmt, gimple_locus (orig_stmt));
   set_bb_for_stmt (stmt, bsi->bb);
 
   /* Preserve EH region information from the original statement, if
@@ -2893,7 +2882,7 @@ tree_find_edge_insert_loc (edge e, block
 			   basic_block *new_bb)
 {
   basic_block dest, src;
-  tree tmp;
+  gimple tmp;
 
   dest = e->dest;
  restart:
@@ -2915,7 +2904,7 @@ tree_find_edge_insert_loc (edge e, block
 
       /* Make sure we insert after any leading labels.  */
       tmp = bsi_stmt (*bsi);
-      while (TREE_CODE (tmp) == LABEL_EXPR)
+      while (gimple_code (tmp) == GIMPLE_LABEL)
 	{
 	  bsi_next (bsi);
 	  if (bsi_end_p (*bsi))
@@ -2948,17 +2937,8 @@ tree_find_edge_insert_loc (edge e, block
       if (!stmt_ends_bb_p (tmp))
 	return true;
 
-      /* Insert code just before returning the value.  We may need to decompose
-         the return in the case it contains non-trivial operand.  */
-      if (TREE_CODE (tmp) == RETURN_EXPR)
+      if (gimple_code (tmp) == GIMPLE_RETURN)
         {
-	  tree op = TREE_OPERAND (tmp, 0);
-	  if (op && !is_gimple_val (op))
-	    {
-	      gcc_assert (TREE_CODE (op) == GIMPLE_MODIFY_STMT);
-	      bsi_insert_before (bsi, op, BSI_NEW_STMT);
-	      TREE_OPERAND (tmp, 0) = GIMPLE_STMT_OPERAND (op, 0);
-	    }
 	  bsi_prev (bsi);
 	  return true;
         }
Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c	(revision 127900)
+++ tree-ssa-operands.c	(working copy)
@@ -178,7 +178,7 @@ static int n_initialized = 0;
 struct scb_d
 {
   /* Pointer to the statement being modified.  */
-  tree *stmt_p;
+  gimple *stmt_p;
 
   /* If the statement references memory these are the sets of symbols
      loaded and stored by the statement.  */
@@ -2763,15 +2763,15 @@ debug_immediate_uses_for (tree var)
    needed to keep the SSA form up to date.  */
 
 void
-push_stmt_changes (tree *stmt_p)
+push_stmt_changes (gimple *stmt_p)
 {
-  tree stmt;
+  gimple stmt;
   scb_t buf;
-  
+
   stmt = *stmt_p;
 
   /* It makes no sense to keep track of PHI nodes.  */
-  if (TREE_CODE (stmt) == PHI_NODE)
+  if (gimple_code (stmt) == GIMPLE_PHI)
     return;
 
   buf = XNEW (struct scb_d);
@@ -2839,9 +2839,10 @@ mark_difference_for_renaming (bitmap s1,
    the statement.  */
 
 void
-pop_stmt_changes (tree *stmt_p)
+pop_stmt_changes (gimple *stmt_p)
 {
-  tree op, stmt;
+  tree op;
+  gimple stmt;
   ssa_op_iter iter;
   bitmap loads, stores;
   scb_t buf;
@@ -2849,7 +2850,7 @@ pop_stmt_changes (tree *stmt_p)
   stmt = *stmt_p;
 
   /* It makes no sense to keep track of PHI nodes.  */
-  if (TREE_CODE (stmt) == PHI_NODE)
+  if (gimple_code (stmt) == GIMPLE_PHI)
     return;
 
   buf = VEC_pop (scb_t, scb_stack);
@@ -2954,10 +2955,11 @@ discard_stmt_changes (tree *stmt_p)
 /* Returns true if statement STMT may access memory.  */
 
 bool
-stmt_references_memory_p (tree stmt)
+stmt_references_memory_p (gimple stmt)
 {
-  if (!gimple_ssa_operands (cfun)->ops_active || TREE_CODE (stmt) == PHI_NODE)
+  if (!gimple_ssa_operands (cfun)->ops_active
+      || gimple_code (stmt) == GIMPLE_PHI)
     return false;
 
-  return stmt_ann (stmt)->references_memory;
+  return gimple_has_mem_ops (stmt);
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [tuples] more cleanups
  2007-08-29 19:05 [tuples] more cleanups Aldy Hernandez
@ 2007-08-29 20:23 ` Diego Novillo
  0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2007-08-29 20:23 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches

On 8/29/07, Aldy Hernandez <aldyh@redhat.com> wrote:

> Unfortunately, I'm not sure whether I'm introducing more warnings than
> I'm fixing.

How about this idea?

We disable enough code to go back to 0 warnings.  As we disable code,
we add gcc_unreachable() calls in the disabled code so it jumps at us
immediately.

As we continue converting things, we remove the if0s and the unreachable traps.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-29 20:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-29 19:05 [tuples] more cleanups Aldy Hernandez
2007-08-29 20:23 ` 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).