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]

[tree-ssa] Modified iterator code.


This patch basically removes the old gimple_stmt_iterator, and replaces
it with 2 new iterators:

    tree_stmt_iterator
    	&
    block_stmt_iterator

tree_stmt_iterator performs the same function that gimple_stmt_iterator 
performed before, except that it operates on any tree, GIMPLE or GENERIC. Thus
the name 'tsi_' appeared to be more appropriate that 'gimple_'. All the 
associated routines have been renamed to 'tsi_' from 'gsi_'

There is also a new iterator type for iterating over blocks. There was some
confusion on occasion which routines were suppose to be used, and it seems
much cleaner to go forward with a seperate type for block iterating.  Furthermore, there are
CFG changes afoot which will cause BIND_EXPR's to not force new basic blocks 
if it isn't necessary. This means the iterators will have to understand how 
to decend into the body of a BIND_EXPR node, and return when the end is 
reached. This will require an extra field in the iterator, which is in place
in this patch.  The decension code will follow with the CFG changes, although 
some minor changes have been affected here as well.

The tree_stmt_iterator code has been moved to a new file, tree-iterator.h

This has been bootstrapped on x86 and causes no new regressions. The new file
is at then end of the patch. Is this OK?

Andrew


2002-02-05  Andrew MacLeod  <amacleod@redhat.com>

	* Makefile.in : Include new file tree-iterator.h in tree-simple.h
	* gimplify.c (simplify_cleanup_point_expr): Use tsi_ rather than gsi_.
	* tree-cfg.c (make_blocks, remove_bb): Use tsi_ not gsi_ routines.
	(bsi_remove): Renamed from gsi_remove, use bsi_ routines.
	(successor_block, first_exec_stmt): Use tsi_ not gsi_ routines.
	(first_stmt, last_stmt, last_stmt_ptr): Use bsi_ not gsi_ routines.
	(bsi_init): Split out from bsi_start.
	(bsi_start): Renamed from gsi_start_bb, use bsi_ routines.
	(bsi_step_in_bb): Moved from tree-flow-inline.h and renamed from 
	gsi_step_in_bb. Also verify BB of new stmt.
	* tree-dfa.c (compute_immediate_uses, dump_immediate_uses, 
	collect_dfa_stats, compute_may_aliases): Use block_stmt_iterator.
	* tree-flow-inline.h (gsi_step_in_bb): Moved to tree-cfg.c
	(bsi_end_p): Renamed from gsi_end_bb_p.
	(bsi_step): renamed from gsi_step_bb
	(bsi_prev): New function.
	(bsi_stmt_ptr): Block version of gsi_stmt_ptr.
	(bsi_stmt): Block version of gsi_stmt.
	(bsi_container): Block version of gsi_container.
	* tree-flow.h (block_stmt_iterator): New iterator type.
	* tree-iterator.h: New include file for tree_iterator.
	* tree-simple.h : Include tree-iterator.h
	(gimple_stmt_iterator, gsi_start, gsi_end_p, gsi_step, gsi_stmt_ptr,
	gsi_stmt, gsi_container): Move to tree-iterator.h and rename to tsi_.
	* tree-ssa-ccp.c (simulate_block, substitute_and_fold): Use block
	iterators instead of gimple_stmt_iterator.
	* tree-ssa-dce.c (mark_control_parent_necessary, find_useful_stmts,
	remove_dead_stmts, remove_dead_stmt): Use block_stmt_iterator.
	* tree-ssa.c (mark_def_sites, rewrite_out_of_ssa, rewrite_stmts): Use
	block_stmt_iterator.




Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.70
diff -c -p -r1.903.2.70 Makefile.in
*** Makefile.in	3 Feb 2003 17:08:21 -0000	1.903.2.70
--- Makefile.in	5 Feb 2003 20:09:34 -0000
*************** SYSTEM_H = system.h hwint.h $(srcdir)/..
*** 627,634 ****
  PREDICT_H = predict.h predict.def
  CPPLIB_H = cpplib.h line-map.h
  TREE_DUMP_H = tree-dump.h $(SPLAY_TREE_H)
  TREE_FLOW_H = tree-flow.h tree-flow-inline.h bitmap.h $(BASIC_BLOCK_H) \
!               hard-reg-set.h tree-simple.h $(HASHTAB_H)
  
  # sed inserts variable overrides after the following line.
  ####target overrides
--- 627,635 ----
  PREDICT_H = predict.h predict.def
  CPPLIB_H = cpplib.h line-map.h
  TREE_DUMP_H = tree-dump.h $(SPLAY_TREE_H)
+ TREE_SIMPLE_H = tree-simple.h tree-iterator.h
  TREE_FLOW_H = tree-flow.h tree-flow-inline.h bitmap.h $(BASIC_BLOCK_H) \
!               hard-reg-set.h $(TREE_SIMPLE_H) $(HASHTAB_H)
  
  # sed inserts variable overrides after the following line.
  ####target overrides
*************** tree-optimize.o : tree-optimize.c $(TREE
*** 1468,1478 ****
     $(GGC_H) output.h diagnostic.h ssa.h errors.h flags.h tree-alias-common.h \
     tree-dchain.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H)
  c-simplify.o : c-simplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
!    $(C_TREE_H) $(C_COMMON_H) diagnostic.h tree-simple.h varray.h flags.h \
     langhooks.h toplev.h rtl.h $(TREE_FLOW_H) langhooks-def.h \
     $(TM_H) coretypes.h
  gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
!    diagnostic.h tree-simple.h tree-inline.h varray.h langhooks.h \
     langhooks-def.h $(TREE_FLOW_H) $(TIMEVAR_H) $(TM_H) coretypes.h except.h
  tree-browser.o : tree-browser.c tree-browser.def $(CONFIG_H) $(SYSTEM_H) \
     $(TREE_H) errors.h tree-inline.h diagnostic.h $(HASHTAB_H) \
--- 1469,1479 ----
     $(GGC_H) output.h diagnostic.h ssa.h errors.h flags.h tree-alias-common.h \
     tree-dchain.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H)
  c-simplify.o : c-simplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
!    $(C_TREE_H) $(C_COMMON_H) diagnostic.h $(TREE_SIMPLE_H) varray.h flags.h \
     langhooks.h toplev.h rtl.h $(TREE_FLOW_H) langhooks-def.h \
     $(TM_H) coretypes.h
  gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
!    diagnostic.h $(TREE_SIMPLE_H) tree-inline.h varray.h langhooks.h \
     langhooks-def.h $(TREE_FLOW_H) $(TIMEVAR_H) $(TM_H) coretypes.h except.h
  tree-browser.o : tree-browser.c tree-browser.def $(CONFIG_H) $(SYSTEM_H) \
     $(TREE_H) errors.h tree-inline.h diagnostic.h $(HASHTAB_H) \
*************** c-call-graph.o : c-call-graph.c $(CONFIG
*** 1487,1501 ****
     $(C_COMMON_H) diagnostic.h hard-reg-set.h $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
     $(TM_H) coretypes.h
  tree-simple.o : tree-simple.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(EXPR_H) \
! 	$(RTL_H) tree-simple.h $(TM_H) coretypes.h
  tree-mudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \
!    $(C_TREE_H) $(C_COMMON_H) tree-simple.h diagnostic.h $(HASHTAB_H) \
     output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
  c-mudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \
!    $(C_TREE_H) $(C_COMMON_H) tree-simple.h diagnostic.h $(HASHTAB_H) \
     output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
  tree-nomudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \
!    $(C_TREE_H) $(C_COMMON_H) tree-simple.h diagnostic.h $(HASHTAB_H) \
     output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
  tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
     errors.h $(TREE_H) diagnostic.h real.h $(HASHTAB_H) $(TREE_FLOW_H) \
--- 1488,1502 ----
     $(C_COMMON_H) diagnostic.h hard-reg-set.h $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
     $(TM_H) coretypes.h
  tree-simple.o : tree-simple.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(EXPR_H) \
! 	$(RTL_H) $(TREE_SIMPLE_H) $(TM_H) coretypes.h
  tree-mudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \
!    $(C_TREE_H) $(C_COMMON_H) $(TREE_SIMPLE_H) diagnostic.h $(HASHTAB_H) \
     output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
  c-mudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \
!    $(C_TREE_H) $(C_COMMON_H) $(TREE_SIMPLE_H) diagnostic.h $(HASHTAB_H) \
     output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
  tree-nomudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \
!    $(C_TREE_H) $(C_COMMON_H) $(TREE_SIMPLE_H) diagnostic.h $(HASHTAB_H) \
     output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
  tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
     errors.h $(TREE_H) diagnostic.h real.h $(HASHTAB_H) $(TREE_FLOW_H) \
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.25
diff -c -p -r1.1.2.25 gimplify.c
*** gimplify.c	3 Feb 2003 17:08:37 -0000	1.1.2.25
--- gimplify.c	5 Feb 2003 20:11:14 -0000
*************** simplify_cleanup_point_expr (expr_p, pre
*** 2028,2034 ****
       tree *expr_p;
       tree *pre_p;
  {
!   gimple_stmt_iterator iter;
    tree body;
  
    tree temp = voidify_wrapper_expr (*expr_p);
--- 2028,2034 ----
       tree *expr_p;
       tree *pre_p;
  {
!   tsi_stmt_iterator iter;
    tree body;
  
    tree temp = voidify_wrapper_expr (*expr_p);
*************** simplify_cleanup_point_expr (expr_p, pre
*** 2043,2054 ****
  
    gimplify_ctxp->conditions = old_conds;  
    
!   for (iter = gsi_start (&body); !gsi_end_p (iter); )
      {
!       tree wce = gsi_stmt (iter);
        if (wce && TREE_CODE (wce) == WITH_CLEANUP_EXPR)
  	{
! 	  tree *container = gsi_container (iter);
  	  tree next, tfe;
  
  	  if (TREE_CODE (*container) == COMPOUND_EXPR)
--- 2043,2054 ----
  
    gimplify_ctxp->conditions = old_conds;  
    
!   for (iter = tsi_start (&body); !tsi_end_p (iter); )
      {
!       tree wce = tsi_stmt (iter);
        if (wce && TREE_CODE (wce) == WITH_CLEANUP_EXPR)
  	{
! 	  tree *container = tsi_container (iter);
  	  tree next, tfe;
  
  	  if (TREE_CODE (*container) == COMPOUND_EXPR)
*************** simplify_cleanup_point_expr (expr_p, pre
*** 2059,2068 ****
  	  tfe = build (TRY_FINALLY_EXPR, void_type_node,
  		       next, TREE_OPERAND (wce, 1));
  	  *container = tfe;
! 	  iter = gsi_start (&TREE_OPERAND (tfe, 0));
  	}
        else
! 	gsi_step (&iter);
      }
    
    if (temp)
--- 2059,2068 ----
  	  tfe = build (TRY_FINALLY_EXPR, void_type_node,
  		       next, TREE_OPERAND (wce, 1));
  	  *container = tfe;
! 	  iter = tsi_start (&TREE_OPERAND (tfe, 0));
  	}
        else
! 	tsi_step (&iter);
      }
    
    if (temp)
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.54
diff -c -p -r1.1.4.54 tree-cfg.c
*** tree-cfg.c	4 Feb 2003 06:38:57 -0000	1.1.4.54
--- tree-cfg.c	5 Feb 2003 20:12:36 -0000
*************** static edge find_taken_edge_cond_expr	PA
*** 110,115 ****
--- 110,119 ----
  static edge find_taken_edge_switch_expr	PARAMS ((basic_block, tree));
  static bool value_matches_some_label	PARAMS ((edge, tree, edge *));
  
+ /* Block iterator helpers.  */
+ 
+ static block_stmt_iterator bsi_init 	PARAMS ((tree *, basic_block));
+ 
  
  /* Remove any COMPOUND_EXPR container from NODE.  */
  #define STRIP_CONTAINERS(NODE)					\
*************** make_blocks (first_p, parent_block)
*** 211,217 ****
  {
    basic_block bb;
    bool start_new_block;
!   gimple_stmt_iterator i;
    tree stmt;
  
    if (first_p == NULL
--- 215,221 ----
  {
    basic_block bb;
    bool start_new_block;
!   tsi_stmt_iterator i;
    tree stmt;
  
    if (first_p == NULL
*************** make_blocks (first_p, parent_block)
*** 222,235 ****
    bb = NULL;
    start_new_block = true;
    stmt = NULL_TREE;
!   for (i = gsi_start (first_p); !gsi_end_p (i); gsi_step (&i))
      {
        tree prev_stmt;
        enum tree_code code;
!       tree *container = gsi_container (i);
  
        prev_stmt = stmt;
!       stmt = gsi_stmt (i);
  
        /* Set the block for the container of non-executable statements.  */
        if (stmt == NULL_TREE)
--- 226,239 ----
    bb = NULL;
    start_new_block = true;
    stmt = NULL_TREE;
!   for (i = tsi_start (first_p); !tsi_end_p (i); tsi_step (&i))
      {
        tree prev_stmt;
        enum tree_code code;
!       tree *container = tsi_container (i);
  
        prev_stmt = stmt;
!       stmt = tsi_stmt (i);
  
        /* Set the block for the container of non-executable statements.  */
        if (stmt == NULL_TREE)
*************** remove_bb (bb, remove_stmts)
*** 898,904 ****
       basic_block bb;
       int remove_stmts;
  {
!   gimple_stmt_iterator i;
  
    dump_file = dump_begin (TDI_cfg, &dump_flags);
    if (dump_file)
--- 902,908 ----
       basic_block bb;
       int remove_stmts;
  {
!   block_stmt_iterator i;
  
    dump_file = dump_begin (TDI_cfg, &dump_flags);
    if (dump_file)
*************** remove_bb (bb, remove_stmts)
*** 911,923 ****
      }
  
    /* Remove all the instructions in the block.  */
!   for (i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
      {
!       tree stmt = gsi_stmt (i);
  
        set_bb_for_stmt (stmt, NULL);
        if (remove_stmts)
! 	gsi_remove (i);
      }
  
    /* Remove the edges into and out of this block.  */
--- 915,927 ----
      }
  
    /* Remove all the instructions in the block.  */
!   for (i = bsi_start (bb); !bsi_end_p (i); bsi_step (&i))
      {
!       tree stmt = bsi_stmt (i);
  
        set_bb_for_stmt (stmt, NULL);
        if (remove_stmts)
! 	bsi_remove (i);
      }
  
    /* Remove the edges into and out of this block.  */
*************** is_parent (bb, child_bb)
*** 1042,1049 ****
      function.  */
  
  void
! gsi_remove (i)
!      gimple_stmt_iterator i;
  {
    tree t = *(i.tp);
  
--- 1046,1053 ----
      function.  */
  
  void
! bsi_remove (i)
!      block_stmt_iterator i;
  {
    tree t = *(i.tp);
  
*************** value_matches_some_label (dest_edge, val
*** 1375,1385 ****
       edge *default_edge_p;
  {
    basic_block dest_bb = dest_edge->dest;
!   gimple_stmt_iterator i;
  
!   for (i = gsi_start_bb (dest_bb); !gsi_end_p (i); gsi_step (&i))
      {
!       tree stmt = gsi_stmt (i);
  
        /* No more labels.  We haven't found a match.  */
        if (TREE_CODE (stmt) != CASE_LABEL_EXPR)
--- 1379,1389 ----
       edge *default_edge_p;
  {
    basic_block dest_bb = dest_edge->dest;
!   block_stmt_iterator i;
  
!   for (i = bsi_start (dest_bb); !bsi_end_p (i); bsi_step (&i))
      {
!       tree stmt = bsi_stmt (i);
  
        /* No more labels.  We haven't found a match.  */
        if (TREE_CODE (stmt) != CASE_LABEL_EXPR)
*************** successor_block (bb)
*** 1730,1736 ****
       basic_block bb;
  {
    basic_block succ_bb, parent_bb;
!   gimple_stmt_iterator i;
  
  #if defined ENABLE_CHECKING
    if (bb == NULL)
--- 1734,1740 ----
       basic_block bb;
  {
    basic_block succ_bb, parent_bb;
!   tsi_stmt_iterator i;
  
  #if defined ENABLE_CHECKING
    if (bb == NULL)
*************** successor_block (bb)
*** 1739,1747 ****
  
    /* By default, the successor block will be the block for the statement
       following BB's last statement.  */
!   i = gsi_start (bb->end_tree_p);
!   gsi_step (&i);
!   succ_bb = first_exec_block (gsi_container (i));
    if (succ_bb)
      return succ_bb;
  
--- 1743,1751 ----
  
    /* By default, the successor block will be the block for the statement
       following BB's last statement.  */
!   i = tsi_start (bb->end_tree_p);
!   tsi_step (&i);
!   succ_bb = first_exec_block (tsi_container (i));
    if (succ_bb)
      return succ_bb;
  
*************** successor_block (bb)
*** 1760,1768 ****
  
        /* Otherwise, If BB's control parent has a successor, return its
           block.  */
!       i = gsi_start (parent_bb->end_tree_p);
!       gsi_step (&i);
!       succ_bb = first_exec_block (gsi_container (i));
        if (succ_bb)
  	return succ_bb;
  
--- 1764,1772 ----
  
        /* Otherwise, If BB's control parent has a successor, return its
           block.  */
!       i = tsi_start (parent_bb->end_tree_p);
!       tsi_step (&i);
!       succ_bb = first_exec_block (tsi_container (i));
        if (succ_bb)
  	return succ_bb;
  
*************** static tree *
*** 1971,1982 ****
  first_exec_stmt (entry_p)
       tree *entry_p;
  {
!   gimple_stmt_iterator i;
    tree stmt;
  
!   for (i = gsi_start (entry_p); !gsi_end_p (i); gsi_step (&i))
      {
!       stmt = gsi_stmt (i);
        if (!stmt)
          continue;
  
--- 1975,1986 ----
  first_exec_stmt (entry_p)
       tree *entry_p;
  {
!   tsi_stmt_iterator i;
    tree stmt;
  
!   for (i = tsi_start (entry_p); !tsi_end_p (i); tsi_step (&i))
      {
!       stmt = tsi_stmt (i);
        if (!stmt)
          continue;
  
*************** first_exec_stmt (entry_p)
*** 1986,1992 ****
  	 statement, not the statement itself.  This is to allow the caller to
  	 start iterating from this point.  */
        if (is_exec_stmt (stmt))
! 	return gsi_container (i);
      }
  
    return NULL;
--- 1990,1996 ----
  	 statement, not the statement itself.  This is to allow the caller to
  	 start iterating from this point.  */
        if (is_exec_stmt (stmt))
! 	return tsi_container (i);
      }
  
    return NULL;
*************** tree
*** 2037,2053 ****
  first_stmt (bb)
       basic_block bb;
  {
!   gimple_stmt_iterator i;
    tree t;
  
    if (bb == NULL || bb->index < 0)
      return NULL_TREE;
  
!   i = gsi_start_bb (bb);
    /* Check for blocks with no remaining statements.  */
!   if (gsi_end_bb_p (i))
      return NULL_TREE;
!   t = gsi_stmt (i);
    STRIP_NOPS (t);
    return t;
  }
--- 2041,2057 ----
  first_stmt (bb)
       basic_block bb;
  {
!   block_stmt_iterator i;
    tree t;
  
    if (bb == NULL || bb->index < 0)
      return NULL_TREE;
  
!   i = bsi_start (bb);
    /* Check for blocks with no remaining statements.  */
!   if (bsi_end_p (i))
      return NULL_TREE;
!   t = bsi_stmt (i);
    STRIP_NOPS (t);
    return t;
  }
*************** tree
*** 2063,2083 ****
  last_stmt (bb)
       basic_block bb;
  {
!   gimple_stmt_iterator i;
    tree t;
    
    if (bb == NULL || bb->index == INVALID_BLOCK)
      return NULL_TREE;
  
!   i = gsi_start (bb->end_tree_p);
!   t = gsi_stmt (i);
  
    /* If the last statement is an empty_stmt_node, we have to traverse through
       the basic block until we find the last non-empty statement. ick.  */
    if (!t)
      {
!       for (i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
!         t = gsi_stmt(i);
      }
    if (t)
      {
--- 2067,2088 ----
  last_stmt (bb)
       basic_block bb;
  {
!   tsi_stmt_iterator i;
!   block_stmt_iterator b;
    tree t;
    
    if (bb == NULL || bb->index == INVALID_BLOCK)
      return NULL_TREE;
  
!   i = tsi_start (bb->end_tree_p);
!   t = tsi_stmt (i);
  
    /* If the last statement is an empty_stmt_node, we have to traverse through
       the basic block until we find the last non-empty statement. ick.  */
    if (!t)
      {
!       for (b = bsi_start (bb); !bsi_end_p (b); bsi_step (&b))
!         t = bsi_stmt(b);
      }
    if (t)
      {
*************** tree *
*** 2093,2099 ****
  last_stmt_ptr (bb)
       basic_block bb;
  {
!   gimple_stmt_iterator i, last;
  
    if (bb == NULL || bb->index == INVALID_BLOCK)
      return NULL;
--- 2098,2104 ----
  last_stmt_ptr (bb)
       basic_block bb;
  {
!   block_stmt_iterator i, last;
  
    if (bb == NULL || bb->index == INVALID_BLOCK)
      return NULL;
*************** last_stmt_ptr (bb)
*** 2101,2136 ****
    /* We can be more efficient here if we check if end_tree_p points to a
       non empty_stmt_node first.  */
       
!   for (last = i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
      last = i;
!   return gsi_stmt_ptr (last);
  }
  
  
! /* Similar to gsi_start() but initializes the iterator at the first
     statement in basic block BB which isn't an empty_stmt_node.
  
     NULL is returned if there are no such statements.  */
  
! gimple_stmt_iterator
! gsi_start_bb (bb)
       basic_block bb;
  {
!   gimple_stmt_iterator i;
  
    if (bb && bb->index != INVALID_BLOCK)
      {
        tree *tp = bb->head_tree_p;
!       i = gsi_start (tp);
!       /* If the first stmt is empty, get the next non-empty one.  */
!       if (i.tp != NULL && gsi_stmt (i) == NULL_TREE)
! 	gsi_step_in_bb (&i, bb);
!       /* If there were nothing but empty_stmt_nodes, just point to one.  */
!       if (i.tp == NULL)
!         i = gsi_start (tp);
!     }
!   else
!     i.tp = NULL;
  
    return i;
  }
--- 2106,2200 ----
    /* We can be more efficient here if we check if end_tree_p points to a
       non empty_stmt_node first.  */
       
!   for (last = i = bsi_start (bb); !bsi_end_p (i); bsi_step (&i))
      last = i;
!   return bsi_stmt_ptr (last);
  }
  
  
! /* Initialize a block stmt iterator with a container that contains stmt's
!    in a specified basic block. If the first real stmt is not in the
!    specified basic block, then return an empty iterator.  */
! static block_stmt_iterator
! bsi_init (tp, bb)
!      tree *tp;
!      basic_block bb;
! {
!   block_stmt_iterator i;
!   tree stmt;
! 
!   i.tp = tp;
!   i.context = NULL_TREE;
!   /* If the first stmt is empty, get the next non-empty one.  */
!   if (i.tp != NULL)
!     {
!       stmt = bsi_stmt (i);
!       if (stmt == NULL_TREE)
! 	bsi_step_in_bb (&i, bb);
!     }
! 
!   /* Now check that its the right basic block.  */
!   if (i.tp != NULL)
!     {
!       stmt = bsi_stmt (i);
!       if (bb_for_stmt (stmt) != bb)
!         i.tp = NULL;
!     }
! 
!   return i;
! }
! 
! /* Similar to tsi_step() but stops at basic block boundaries and ignores
!    empty_stmt_nodes inside a basic block.  */
! 
! void
! bsi_step_in_bb (i, bb)
!      block_stmt_iterator *i;
!      basic_block bb;
! {
!   tree t;
!   do
!     {
!       t = *(i->tp);
!       STRIP_NOPS (t);
!       if (TREE_CODE (t) == COMPOUND_EXPR)
! 	i->tp = &(TREE_OPERAND (t, 1));
!       else
! 	i->tp = NULL;
!     }
!   while (i->tp && bsi_stmt (*i) == NULL_TREE);
! 
!   if (i->tp && bb_for_stmt (*(i->tp)) != bb) 
!     i->tp = NULL;
! }
! 
! /* Similar to tsi_start() but initializes the iterator at the first
     statement in basic block BB which isn't an empty_stmt_node.
  
     NULL is returned if there are no such statements.  */
  
! block_stmt_iterator
! bsi_start (bb)
       basic_block bb;
  {
!   block_stmt_iterator i;
!   tree t;
  
    if (bb && bb->index != INVALID_BLOCK)
      {
        tree *tp = bb->head_tree_p;
!       i = bsi_init (tp, bb);
!       if (i.tp != NULL)
! 	{
! 	  /* If we get back a statement which is not within this basic 
! 	     block, that is wrong!  */
! 	  t = bsi_stmt (i);
! 	  if (t != NULL_TREE && bb_for_stmt (t) != bb)
! 	    abort ();
! 	}
!       }
!     else
!       i.tp = NULL;
  
    return i;
  }
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.71
diff -c -p -r1.1.4.71 tree-dfa.c
*** tree-dfa.c	4 Feb 2003 03:11:14 -0000	1.1.4.71
--- tree-dfa.c	5 Feb 2003 20:12:37 -0000
*************** compute_immediate_uses (flags)
*** 865,871 ****
       int flags;
  {
    basic_block bb;
!   gimple_stmt_iterator si;
  
    FOR_EACH_BB (bb)
      {
--- 865,871 ----
       int flags;
  {
    basic_block bb;
!   block_stmt_iterator si;
  
    FOR_EACH_BB (bb)
      {
*************** compute_immediate_uses (flags)
*** 874,881 ****
        for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	compute_immediate_uses_for (phi, flags);
  
!       for (si = gsi_start_bb (bb); !gsi_end_bb_p (si); gsi_step_bb (&si))
! 	compute_immediate_uses_for (gsi_stmt (si), flags);
      }
  }
  
--- 874,881 ----
        for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	compute_immediate_uses_for (phi, flags);
  
!       for (si = bsi_start (bb); !bsi_end_p (si); bsi_step (&si))
! 	compute_immediate_uses_for (bsi_stmt (si), flags);
      }
  }
  
*************** dump_immediate_uses (file)
*** 1127,1133 ****
       FILE *file;
  {
    basic_block bb;
!   gimple_stmt_iterator si;
  
    fprintf (file, "\nDef-use edges for function %s\n", current_function_name);
  
--- 1127,1133 ----
       FILE *file;
  {
    basic_block bb;
!   block_stmt_iterator si;
  
    fprintf (file, "\nDef-use edges for function %s\n", current_function_name);
  
*************** dump_immediate_uses (file)
*** 1138,1145 ****
        for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	dump_immediate_uses_for (file, phi);
  
!       for (si = gsi_start_bb (bb); !gsi_end_bb_p (si); gsi_step_bb (&si))
! 	dump_immediate_uses_for (file, gsi_stmt (si));
      }
  
    fprintf (file, "\n");
--- 1138,1145 ----
        for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	dump_immediate_uses_for (file, phi);
  
!       for (si = bsi_start (bb); !bsi_end_p (si); bsi_step (&si))
! 	dump_immediate_uses_for (file, bsi_stmt (si));
      }
  
    fprintf (file, "\n");
*************** collect_dfa_stats (dfa_stats_p)
*** 1298,1304 ****
  {
    htab_t htab;
    basic_block bb;
!   gimple_stmt_iterator i;
  
    if (dfa_stats_p == NULL)
      abort ();
--- 1298,1304 ----
  {
    htab_t htab;
    basic_block bb;
!   block_stmt_iterator i;
  
    if (dfa_stats_p == NULL)
      abort ();
*************** collect_dfa_stats (dfa_stats_p)
*** 1309,1316 ****
       basic block 0, but don't stop at block boundaries.  */
    htab = htab_create (30, htab_hash_pointer, htab_eq_pointer, NULL);
  
!   for (i = gsi_start_bb (BASIC_BLOCK (0)); !gsi_end_bb_p (i); gsi_step_bb (&i))
!     walk_tree (gsi_stmt_ptr (i), collect_dfa_stats_r, (void *) dfa_stats_p,
  	       (void *) htab);
  
    htab_delete (htab);
--- 1309,1316 ----
       basic block 0, but don't stop at block boundaries.  */
    htab = htab_create (30, htab_hash_pointer, htab_eq_pointer, NULL);
  
!   for (i = bsi_start (BASIC_BLOCK (0)); !bsi_end_p (i); bsi_step (&i))
!     walk_tree (bsi_stmt_ptr (i), collect_dfa_stats_r, (void *) dfa_stats_p,
  	       (void *) htab);
  
    htab_delete (htab);
*************** compute_may_aliases ()
*** 1422,1428 ****
    static htab_t indirect_refs_found;
    static htab_t addressable_vars_found;
    basic_block bb;
!   gimple_stmt_iterator si;
    htab_t walk_state[3];
  
    timevar_push (TV_TREE_MAY_ALIAS);
--- 1422,1428 ----
    static htab_t indirect_refs_found;
    static htab_t addressable_vars_found;
    basic_block bb;
!   block_stmt_iterator si;
    htab_t walk_state[3];
  
    timevar_push (TV_TREE_MAY_ALIAS);
*************** compute_may_aliases ()
*** 1453,1460 ****
    walk_state[2] = addressable_vars_found;
  
    FOR_EACH_BB (bb)
!     for (si = gsi_start_bb (bb); !gsi_end_bb_p (si); gsi_step_bb (&si))
!       walk_tree (gsi_stmt_ptr (si), find_vars_r, &walk_state, NULL);
  
    htab_delete (vars_found);
    htab_delete (indirect_refs_found);
--- 1453,1460 ----
    walk_state[2] = addressable_vars_found;
  
    FOR_EACH_BB (bb)
!     for (si = bsi_start (bb); !bsi_end_p (si); bsi_step (&si))
!       walk_tree (bsi_stmt_ptr (si), find_vars_r, &walk_state, NULL);
  
    htab_delete (vars_found);
    htab_delete (indirect_refs_found);
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.23
diff -c -p -r1.1.2.23 tree-flow-inline.h
*** tree-flow-inline.h	4 Feb 2003 03:11:15 -0000	1.1.2.23
--- tree-flow-inline.h	5 Feb 2003 20:12:38 -0000
*************** dom_children (bb)
*** 273,309 ****
    return bb_ann (bb)->dom_children;
  }
  
! /* Similar to gsi_step() but stops at basic block boundaries and ignores
!    empty_stmt_nodes inside a basic block.  */
! static inline void
! gsi_step_in_bb (i, bb)
!      gimple_stmt_iterator *i;
!      basic_block bb;
! {
!   do
!     gsi_step (i);
!   while (i->tp && gsi_stmt (*i) == NULL_TREE);
  
!   if (i->tp && bb_for_stmt (*(i->tp)) != bb)
!     i->tp = NULL;
  }
  
! 
! /* Similar to gsi_step() but stops at basic block boundaries. Assumes stmt
     has bb_for_stmt() set (can't be an empty_stmt_node).  */
  static inline void
! gsi_step_bb (i)
!      gimple_stmt_iterator *i;
  {
    basic_block bb = bb_for_stmt (*(i->tp));
!   gsi_step_in_bb (i, bb);
  }
  
! static inline bool
! gsi_end_bb_p (i)
! gimple_stmt_iterator i;
  {
!   return (i.tp == NULL || gsi_stmt (i) == NULL_TREE);
  }
  
  static inline bool
--- 273,343 ----
    return bb_ann (bb)->dom_children;
  }
  
! /*  -----------------------------------------------------------------------  */
  
! static inline bool
! bsi_end_p (i)
! block_stmt_iterator i;
! {
!   return (i.tp == NULL || bsi_stmt (i) == NULL_TREE);
  }
  
! /* Similar to tsi_step() but stops at basic block boundaries. Assumes stmt
     has bb_for_stmt() set (can't be an empty_stmt_node).  */
  static inline void
! bsi_step (i)
!      block_stmt_iterator *i;
  {
+   extern void bsi_step_in_bb (block_stmt_iterator *, basic_block);
+ 
    basic_block bb = bb_for_stmt (*(i->tp));
!   bsi_step_in_bb (i, bb);
  }
  
! static inline void
! bsi_prev (i)
!      block_stmt_iterator *i;
! {
!   printf (" bsi_prev (%p) is not implemented yet\n",(void *)i);
!   abort();
! }
! 
! static inline tree *
! bsi_stmt_ptr (i)
!      block_stmt_iterator i;
! {
!   tree t;
! 
! #if defined ENABLE_CHECKING
!   if (i.tp == NULL || *i.tp == NULL_TREE)
!     abort ();
! #endif
! 
!   t = *(i.tp);
!   STRIP_NOPS (t);
! 
!   if (TREE_CODE (t) == COMPOUND_EXPR)
!     return &TREE_OPERAND (t, 0);
!   else
!     return i.tp;
! }
! 
! static inline tree
! bsi_stmt (i)
!      block_stmt_iterator i;
! {
!   tree t = *(bsi_stmt_ptr (i));
!   STRIP_NOPS (t);
!   if (t == empty_stmt_node || t == error_mark_node)
!     t = NULL_TREE;
!   return t;
! }
! 
! static inline tree *
! bsi_container (i)
!      block_stmt_iterator i;
  {
!   return i.tp;
  }
  
  static inline bool
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.51
diff -c -p -r1.1.4.51 tree-flow.h
*** tree-flow.h	4 Feb 2003 06:38:57 -0000	1.1.4.51
--- tree-flow.h	5 Feb 2003 20:12:38 -0000
*************** bb_empty_p (b)
*** 227,246 ****
  /*---------------------------------------------------------------------------
  		 Iterators for statements inside a basic block
  ---------------------------------------------------------------------------*/
- static inline void gsi_step_in_bb	PARAMS ((gimple_stmt_iterator *,
-       						 basic_block));
- static inline void gsi_step_bb		PARAMS ((gimple_stmt_iterator *));
- static inline bool gsi_end_bb_p		PARAMS ((gimple_stmt_iterator));
- extern gimple_stmt_iterator gsi_start_bb PARAMS ((basic_block));
- extern void gsi_remove			PARAMS ((gimple_stmt_iterator));
  
! #if 0
! /* FIXME Not implemented yet.  */
! extern void gsi_insert_before (tree stmt, gimple_stmt_iterator, basic_block);
! extern void gsi_insert_after (tree stmt, gimple_stmt_iterator, basic_block);
! extern void gsi_replace (tree stmt, gimple_stmt_iterator, basic_block);
! #endif
  
  
  /*---------------------------------------------------------------------------
  			      Global declarations
--- 227,251 ----
  /*---------------------------------------------------------------------------
  		 Iterators for statements inside a basic block
  ---------------------------------------------------------------------------*/
  
! /* Iterator object for traversing over BASIC BLOCKs.  */
  
+ typedef struct {
+   tree *tp;
+   tree context;		/* Stack for decending into BIND_EXPR's.  */
+ } block_stmt_iterator;
+ 
+ extern block_stmt_iterator bsi_start 	PARAMS ((basic_block));
+ static inline bool bsi_end_p		PARAMS ((block_stmt_iterator));
+ static inline void bsi_step		PARAMS ((block_stmt_iterator *));
+ static inline void bsi_prev		PARAMS ((block_stmt_iterator *));
+ static inline tree bsi_stmt		PARAMS ((block_stmt_iterator));
+ static inline tree *bsi_stmt_ptr	PARAMS ((block_stmt_iterator));
+ static inline tree *bsi_container	PARAMS ((block_stmt_iterator));
+ 
+ extern void bsi_remove			PARAMS ((block_stmt_iterator));
+ 
+ void bsi_step_in_bb			PARAMS ((block_stmt_iterator *, basic_block));
  
  /*---------------------------------------------------------------------------
  			      Global declarations
Index: tree-simple.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.h,v
retrieving revision 1.1.4.21
diff -c -p -r1.1.4.21 tree-simple.h
*** tree-simple.h	28 Jan 2003 05:14:23 -0000	1.1.4.21
--- tree-simple.h	5 Feb 2003 20:12:40 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 22,27 ****
--- 22,30 ----
  #ifndef _TREE_SIMPLE_H
  #define _TREE_SIMPLE_H 1
  
+ 
+ #include "tree-iterator.h"
+ 
  /* Interface used in [break/goto]-elimination: to be declared in a .h file. */
  extern void insert_before_continue_end PARAMS ((tree, tree));
  extern void tree_build_scope           PARAMS ((tree *));
*************** tree voidify_wrapper_expr		PARAMS ((tree
*** 99,181 ****
  tree gimple_build_eh_filter		PARAMS ((tree, tree, tree));
  tree maybe_protect_cleanup		PARAMS ((tree));
  
- 
- /* Iterator object for GIMPLE statements.  */
- typedef struct {
-   tree *tp;
- } gimple_stmt_iterator;
- 
- static inline gimple_stmt_iterator gsi_start PARAMS ((tree *));
- static inline bool gsi_end_p		PARAMS ((gimple_stmt_iterator));
- static inline void gsi_step		PARAMS ((gimple_stmt_iterator *));
- static inline tree gsi_stmt		PARAMS ((gimple_stmt_iterator));
- static inline tree *gsi_stmt_ptr	PARAMS ((gimple_stmt_iterator));
- static inline tree *gsi_container	PARAMS ((gimple_stmt_iterator));
- 
- static inline gimple_stmt_iterator
- gsi_start (tp)
-      tree *tp;
- {
-   gimple_stmt_iterator i;
-   i.tp = tp;
-   return i;
- }
- 
- static inline bool
- gsi_end_p (i)
-      gimple_stmt_iterator i;
- {
-   return (i.tp == NULL || *(i.tp) == error_mark_node);
- }
- 
- static inline void
- gsi_step (i)
-      gimple_stmt_iterator *i;
- {
-   tree t = *(i->tp);
-   STRIP_NOPS (t);
-   if (TREE_CODE (t) == COMPOUND_EXPR)
-     i->tp = &(TREE_OPERAND (t, 1));
-   else
-     i->tp = NULL;
- }
- 
- static inline tree *
- gsi_stmt_ptr (i)
-      gimple_stmt_iterator i;
- {
-   tree t;
- 
- #if defined ENABLE_CHECKING
-   if (i.tp == NULL || *i.tp == NULL_TREE)
-     abort ();
- #endif
- 
-   t = *(i.tp);
-   STRIP_NOPS (t);
- 
-   if (TREE_CODE (t) == COMPOUND_EXPR)
-     return &TREE_OPERAND (t, 0);
-   else
-     return i.tp;
- }
- 
- static inline tree
- gsi_stmt (i)
-      gimple_stmt_iterator i;
- {
-   tree t = *(gsi_stmt_ptr (i));
-   STRIP_NOPS (t);
-   if (t == empty_stmt_node || t == error_mark_node)
-     t = NULL_TREE;
-   return t;
- }
- 
- static inline tree *
- gsi_container (i)
-      gimple_stmt_iterator i;
- {
-   return i.tp;
- }
  
  #endif /* _TREE_SIMPLE_H  */
--- 102,106 ----
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.44
diff -c -p -r1.1.2.44 tree-ssa-ccp.c
*** tree-ssa-ccp.c	4 Feb 2003 03:11:15 -0000	1.1.2.44
--- tree-ssa-ccp.c	5 Feb 2003 20:12:40 -0000
*************** simulate_block (block)
*** 217,229 ****
       must simulate each of its statements.  */
    if (!TEST_BIT (executable_blocks, block->index))
      {
!       gimple_stmt_iterator j;
  
        /* Note that we have simulated this block.  */
        SET_BIT (executable_blocks, block->index);
  
!       for (j = gsi_start_bb (block); !gsi_end_bb_p (j); gsi_step_bb (&j))
! 	visit_stmt (gsi_stmt (j));
  
        /* If the block has a single successor, it will always get executed.
  	 Add it to the worklist.  */
--- 217,229 ----
       must simulate each of its statements.  */
    if (!TEST_BIT (executable_blocks, block->index))
      {
!       block_stmt_iterator j;
  
        /* Note that we have simulated this block.  */
        SET_BIT (executable_blocks, block->index);
  
!       for (j = bsi_start (block); !bsi_end_p (j); bsi_step (&j))
! 	visit_stmt (bsi_stmt (j));
  
        /* If the block has a single successor, it will always get executed.
  	 Add it to the worklist.  */
*************** substitute_and_fold ()
*** 286,296 ****
    /* Substitute constants in every statement of every basic block.  */
    FOR_EACH_BB (bb)
      {
!       gimple_stmt_iterator i;
  
!       for (i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
  	{
! 	  tree stmt = gsi_stmt (i);
  
  	  /* Skip statements that have been folded already.  */
  	  if (stmt_modified_p (stmt) || !is_exec_stmt (stmt))
--- 286,296 ----
    /* Substitute constants in every statement of every basic block.  */
    FOR_EACH_BB (bb)
      {
!       block_stmt_iterator i;
  
!       for (i = bsi_start (bb); !bsi_end_p (i); bsi_step (&i))
  	{
! 	  tree stmt = bsi_stmt (i);
  
  	  /* Skip statements that have been folded already.  */
  	  if (stmt_modified_p (stmt) || !is_exec_stmt (stmt))
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.23
diff -c -p -r1.1.2.23 tree-ssa-dce.c
*** tree-ssa-dce.c	3 Feb 2003 01:26:53 -0000	1.1.2.23
--- tree-ssa-dce.c	5 Feb 2003 20:12:40 -0000
*************** static void find_useful_stmts			PARAMS (
*** 92,98 ****
  static bool stmt_useful_p			PARAMS ((tree));
  static void process_worklist			PARAMS ((void));
  static void remove_dead_stmts			PARAMS ((void));
! static void remove_dead_stmt			PARAMS ((gimple_stmt_iterator,
        							 basic_block));
  static void remove_dead_phis			PARAMS ((basic_block));
  
--- 92,98 ----
  static bool stmt_useful_p			PARAMS ((tree));
  static void process_worklist			PARAMS ((void));
  static void remove_dead_stmts			PARAMS ((void));
! static void remove_dead_stmt			PARAMS ((block_stmt_iterator,
        							 basic_block));
  static void remove_dead_phis			PARAMS ((basic_block));
  
*************** static void
*** 158,175 ****
  mark_control_parent_necessary (bb)
       basic_block bb;
  {
!   gimple_stmt_iterator i;
    tree t;
  
    /* Loops through the stmts in this block, marking them as necessary. */
    while (bb != NULL && bb->index != INVALID_BLOCK)
      {
!       for (i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
  	{
  	  /* Avoid needless calls back to this routine by directly calling 
  	     mark_tree since we know we are going to cycle through all parent 
  	     blocks and their statements.  */
! 	  t = gsi_stmt (i);
  	  mark_tree_necessary (t);
  	}
        bb = parent_block (bb);
--- 158,175 ----
  mark_control_parent_necessary (bb)
       basic_block bb;
  {
!   block_stmt_iterator i;
    tree t;
  
    /* Loops through the stmts in this block, marking them as necessary. */
    while (bb != NULL && bb->index != INVALID_BLOCK)
      {
!       for (i = bsi_start (bb); !bsi_end_p (i); bsi_step (&i))
  	{
  	  /* Avoid needless calls back to this routine by directly calling 
  	     mark_tree since we know we are going to cycle through all parent 
  	     blocks and their statements.  */
! 	  t = bsi_stmt (i);
  	  mark_tree_necessary (t);
  	}
        bb = parent_block (bb);
*************** static void
*** 251,257 ****
  find_useful_stmts ()
  {
    basic_block bb;
!   gimple_stmt_iterator i;
  
    FOR_EACH_BB (bb)
      {
--- 251,257 ----
  find_useful_stmts ()
  {
    basic_block bb;
!   block_stmt_iterator i;
  
    FOR_EACH_BB (bb)
      {
*************** find_useful_stmts ()
*** 263,271 ****
  	  mark_necessary (phi);
  
        /* Check all statements in the block.  */
!       for (i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
  	{
! 	  tree stmt = gsi_stmt (i);
  	  STRIP_NOPS (stmt);
  
  	  if (stmt_useful_p (stmt))
--- 263,271 ----
  	  mark_necessary (phi);
  
        /* Check all statements in the block.  */
!       for (i = bsi_start (bb); !bsi_end_p (i); bsi_step (&i))
  	{
! 	  tree stmt = bsi_stmt (i);
  	  STRIP_NOPS (stmt);
  
  	  if (stmt_useful_p (stmt))
*************** remove_dead_stmts ()
*** 418,424 ****
  {
    basic_block bb;
    tree t;
!   gimple_stmt_iterator i;
  
    dom_info = NULL;
  
--- 418,424 ----
  {
    basic_block bb;
    tree t;
!   block_stmt_iterator i;
  
    dom_info = NULL;
  
*************** remove_dead_stmts ()
*** 428,436 ****
        remove_dead_phis (bb);
  
        /* Remove dead statements.  */
!       for (i = gsi_start_bb (bb); !gsi_end_bb_p (i); gsi_step_bb (&i))
  	{
! 	  t = gsi_stmt (i);
  	  stats.total++;
  
  	  /* If `i' is not in `necessary' then remove from B.  */
--- 428,436 ----
        remove_dead_phis (bb);
  
        /* Remove dead statements.  */
!       for (i = bsi_start (bb); !bsi_end_p (i); bsi_step (&i))
  	{
! 	  t = bsi_stmt (i);
  	  stats.total++;
  
  	  /* If `i' is not in `necessary' then remove from B.  */
*************** remove_dead_phis (bb)
*** 479,490 ****
  
  static void
  remove_dead_stmt (i, bb)
!      gimple_stmt_iterator i;
       basic_block bb;
  {
    tree t;
  
!   t = gsi_stmt (i);
    STRIP_NOPS (t);
  
    if (dump_file && (dump_flags & TDF_DETAILS))
--- 479,490 ----
  
  static void
  remove_dead_stmt (i, bb)
!      block_stmt_iterator i;
       basic_block bb;
  {
    tree t;
  
!   t = bsi_stmt (i);
    STRIP_NOPS (t);
  
    if (dump_file && (dump_flags & TDF_DETAILS))
*************** remove_dead_stmt (i, bb)
*** 524,530 ****
        make_edge (bb, nb, EDGE_FALLTHRU);
      }
  
!   gsi_remove (i);
  }
  
  /* Main routine to eliminate dead code.  */
--- 524,530 ----
        make_edge (bb, nb, EDGE_FALLTHRU);
      }
  
!   bsi_remove (i);
  }
  
  /* Main routine to eliminate dead code.  */
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.47
diff -c -p -r1.1.4.47 tree-ssa.c
*** tree-ssa.c	4 Feb 2003 03:11:15 -0000	1.1.4.47
--- tree-ssa.c	5 Feb 2003 20:12:42 -0000
*************** mark_def_sites (idom)
*** 281,287 ****
       dominance_info idom;
  {
    basic_block bb;
!   gimple_stmt_iterator si;
    sbitmap nonlocal_vars;
    sbitmap killed_vars;
  
--- 281,287 ----
       dominance_info idom;
  {
    basic_block bb;
!   block_stmt_iterator si;
    sbitmap nonlocal_vars;
    sbitmap killed_vars;
  
*************** mark_def_sites (idom)
*** 304,317 ****
  	 zero out KILLED_VARS.  */
        sbitmap_zero (killed_vars);
  
!       for (si = gsi_start_bb (bb); !gsi_end_bb_p (si); gsi_step_bb (&si))
  	{
  	  varray_type ops;
  	  size_t i;
  	  tree stmt;
  	  tree *dest;
  
! 	  stmt = gsi_stmt (si);
  	  STRIP_NOPS (stmt);
  
  	  get_stmt_operands (stmt);
--- 304,317 ----
  	 zero out KILLED_VARS.  */
        sbitmap_zero (killed_vars);
  
!       for (si = bsi_start (bb); !bsi_end_p (si); bsi_step (&si))
  	{
  	  varray_type ops;
  	  size_t i;
  	  tree stmt;
  	  tree *dest;
  
! 	  stmt = bsi_stmt (si);
  	  STRIP_NOPS (stmt);
  
  	  get_stmt_operands (stmt);
*************** rewrite_out_of_ssa (fndecl)
*** 507,520 ****
       tree fndecl;
  {
    basic_block bb;
!   gimple_stmt_iterator si;
  
    FOR_EACH_BB (bb)
!     for (si = gsi_start_bb (bb); !gsi_end_bb_p (si); gsi_step_bb (&si))
        {
  	size_t i;
  	varray_type ops;
! 	tree stmt = gsi_stmt (si);
  	STRIP_NOPS (stmt);
  
  	get_stmt_operands (stmt);
--- 507,520 ----
       tree fndecl;
  {
    basic_block bb;
!   block_stmt_iterator si;
  
    FOR_EACH_BB (bb)
!     for (si = bsi_start (bb); !bsi_end_p (si); bsi_step (&si))
        {
  	size_t i;
  	varray_type ops;
! 	tree stmt = bsi_stmt (si);
  	STRIP_NOPS (stmt);
  
  	get_stmt_operands (stmt);
*************** rewrite_stmts (bb, block_defs_p)
*** 723,729 ****
       basic_block bb;
       varray_type *block_defs_p;
  {
!   gimple_stmt_iterator si;
    tree phi;
  
    /* Process PHI nodes in the block.  Conceptually, all the PHI nodes are
--- 723,729 ----
       basic_block bb;
       varray_type *block_defs_p;
  {
!   block_stmt_iterator si;
    tree phi;
  
    /* Process PHI nodes in the block.  Conceptually, all the PHI nodes are
*************** rewrite_stmts (bb, block_defs_p)
*** 735,742 ****
    /* Rewrite every variable used in each statement the block with its
       immediate reaching definitions.  Update the current definition of a
       variable when a new real or virtual definition is found.  */
!   for (si = gsi_start_bb (bb); !gsi_end_bb_p (si); gsi_step_bb (&si))
!     rewrite_stmt (gsi_stmt (si), block_defs_p);
  }
  
  
--- 735,742 ----
    /* Rewrite every variable used in each statement the block with its
       immediate reaching definitions.  Update the current definition of a
       variable when a new real or virtual definition is found.  */
!   for (si = bsi_start (bb); !bsi_end_p (si); bsi_step (&si))
!     rewrite_stmt (bsi_stmt (si), block_defs_p);
  }
  
  


-------- new file.   tree-iterator.h  --------------------------------


/* Iterator routines for manipulating GENERIC and GIMPLE tree statements.  
   Copyright (C) 2003 Free Software Foundation, Inc.
   Contributed by Andrew MacLeod  <amacleod@redhat.com>

This file is part of GNU CC.

GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


/* This file is dependant upon the implementation of tree's. It provides an
   abstract interface to the tree objects such that if all tree creation and 
   manipulations are done through this interface, we can easily change the 
   implementation of tree's, and not impact other code.

   In particular, we wish to replace the current linking scheme which uses 
   COMPOUND_EXPR nodes to link statements. We'd like to either use doubly
   linked lists, or another mechanism which takes the links completely out
   of the tree nodes all together. Before this can be done, the front end
   will have to be modified to use these routines to build up the initial
   GENERIC representation of the function tree.  */

/** @file tree-iterator.c
    @brief Routines for manipulating tree statements. */

#ifndef _TREE_ITERATOR_H
#define _TREE_ITERATOR_H 1

/* Iterator object for GENERIC or GIMPLE TREE statements.  */

typedef struct {
  tree *tp;
} tsi_stmt_iterator;

static inline tsi_stmt_iterator tsi_start 	PARAMS ((tree *));
static inline bool tsi_end_p			PARAMS ((tsi_stmt_iterator));
static inline void tsi_step			PARAMS ((tsi_stmt_iterator *));
static inline void tsi_prev			PARAMS ((tsi_stmt_iterator *));
static inline tree tsi_stmt			PARAMS ((tsi_stmt_iterator));
static inline tree *tsi_stmt_ptr		PARAMS ((tsi_stmt_iterator));
static inline tree *tsi_container		PARAMS ((tsi_stmt_iterator));


static inline tsi_stmt_iterator
tsi_start (tp)
     tree *tp;
{
  tsi_stmt_iterator i;
  i.tp = tp;
  return i;
}

static inline bool
tsi_end_p (i)
     tsi_stmt_iterator i;
{
  return (i.tp == NULL || *(i.tp) == error_mark_node);
}

static inline void
tsi_step (i)
     tsi_stmt_iterator *i;
{
  tree t = *(i->tp);
  STRIP_NOPS (t);
  if (TREE_CODE (t) == COMPOUND_EXPR)
    i->tp = &(TREE_OPERAND (t, 1));
  else
    i->tp = NULL;
}

static inline void
tsi_prev (i)
     tsi_stmt_iterator *i;
{
  printf (" tsi_prev (%p) is not implemented yet\n",(void *)i);
  abort();
}

static inline tree *
tsi_stmt_ptr (i)
     tsi_stmt_iterator i;
{
  tree t;

#if defined ENABLE_CHECKING
  if (i.tp == NULL || *i.tp == NULL_TREE)
    abort ();
#endif

  t = *(i.tp);
  STRIP_NOPS (t);

  if (TREE_CODE (t) == COMPOUND_EXPR)
    return &TREE_OPERAND (t, 0);
  else
    return i.tp;
}

static inline tree
tsi_stmt (i)
     tsi_stmt_iterator i;
{
  tree t = *(tsi_stmt_ptr (i));
  STRIP_NOPS (t);
  if (t == empty_stmt_node || t == error_mark_node)
    t = NULL_TREE;
  return t;
}

static inline tree *
tsi_container (i)
     tsi_stmt_iterator i;
{
  return i.tp;
}

#endif /* _TREE_ITERATOR_H  */



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