Fixed warnings
[libfirm] / ir / ir / irgwalk.c
index 56a53c5..d8b3779 100644 (file)
@@ -1,24 +1,32 @@
 /*
- * Project:     libFIRM
- * File name:   ir/ir/irgwalk.c
- * Purpose:
- * Author:      Boris Boesler
- * Modified by: Goetz Lindenmaier, Michael Beck
- * Created:
- * CVS-ID:      $Id$
- * Copyright:   (c) 1999-20036Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
 /**
- * @file irgwalk.c
- *
- * traverse an ir graph
- * - execute the pre function before recursion
- * - execute the post function after recursion
+ * @file
+ * @brief   Functions for traversing ir graphs
+ * @author  Boris Boesler, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ * @summary
+ *  traverse an ir graph
+ *  - execute the pre function before recursion
+ *  - execute the post function after recursion
  */
-
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 #include "irgraph_t.h" /* visited flag */
 #include "irprog.h"
 #include "irgwalk.h"
-#include "typewalk.h"
 #include "irhooks.h"
 #include "ircgcons.h"
 
-#include "eset.h"
+#include "pset_new.h"
 #include "array.h"
 
 /**
  * Walk over an interprocedural graph (callgraph).
  * Visits only graphs in irg_set.
  */
-static void irg_walk_cg(ir_node * node, unsigned long visited, eset * irg_set,
-                        irg_walk_func *pre, irg_walk_func *post, void * env) {
+static void irg_walk_cg(ir_node * node, unsigned long visited,
+                        pset_new_t *irg_set, irg_walk_func *pre,
+                        irg_walk_func *post, void * env) {
   int i;
   ir_graph * rem = current_ir_graph;
   ir_node * pred;
@@ -73,7 +81,7 @@ static void irg_walk_cg(ir_node * node, unsigned long visited, eset * irg_set,
       if ((get_irn_op(pred) != op_CallBegin
            && get_irn_op(pred) != op_EndReg
            && get_irn_op(pred) != op_EndExcept)
-          || eset_contains(irg_set, get_irn_irg(pred))) {
+          || pset_new_contains(irg_set, get_irn_irg(pred))) {
         irg_walk_cg(exec, visited, irg_set, pre, post, env);
       }
     }
@@ -93,7 +101,7 @@ static void irg_walk_cg(ir_node * node, unsigned long visited, eset * irg_set,
         assert(get_irn_op(exec) == op_CallBegin
                || get_irn_op(exec) == op_EndReg
                || get_irn_op(exec) == op_EndExcept);
-        if (eset_contains(irg_set, get_irn_irg(exec))) {
+        if (pset_new_contains(irg_set, get_irn_irg(exec))) {
           current_ir_graph = get_irn_irg(exec);
           irg_walk_cg(pred, visited, irg_set, pre, post, env);
           current_ir_graph = rem;
@@ -115,14 +123,14 @@ static void irg_walk_cg(ir_node * node, unsigned long visited, eset * irg_set,
 /**
  * Insert all ir_graphs in irg_set, that are (transitive) reachable.
  */
-static void collect_irgs(ir_node * node, eset * irg_set) {
+static void collect_irgs(ir_node * node, pset_new_t *irg_set) {
   if (is_Call(node)) {
     int i;
     for (i = get_Call_n_callees(node) - 1; i >= 0; --i) {
       ir_entity * ent = get_Call_callee(node, i);
       ir_graph * irg = get_entity_irg(ent);
-      if (irg && !eset_contains(irg_set, irg)) {
-        eset_insert(irg_set, irg);
+      if (irg && !pset_new_contains(irg_set, irg)) {
+        pset_new_insert(irg_set, irg);
         irg_walk_graph(irg, (irg_walk_func *) collect_irgs, NULL, irg_set);
       }
     }
@@ -244,27 +252,29 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
   assert(is_ir_node(node));
 
   if (get_interprocedural_view()) {
-    eset * irg_set = eset_create();
-    unsigned long visited;
-    ir_graph * irg;
+       pset_new_t           irg_set;
+       pset_new_iterator_t  iter;
+    unsigned long        visited;
+    ir_graph            *irg;
     assert(get_irp_ip_view_state() == ip_view_valid);
 
+       pset_new_init(&irg_set);
     set_interprocedural_view(0);
-    eset_insert(irg_set, current_ir_graph);
-    irg_walk(node, (irg_walk_func *) collect_irgs, NULL, irg_set);
+    pset_new_insert(&irg_set, current_ir_graph);
+    irg_walk(node, (irg_walk_func *) collect_irgs, NULL, &irg_set);
     set_interprocedural_view(1);
     visited = get_max_irg_visited() + 1;
-    for (irg = eset_first(irg_set); irg; irg = eset_next(irg_set)) {
+
+       foreach_pset_new(&irg_set, irg, iter) {
       set_irg_visited(irg, visited);
     }
-    irg_walk_cg(node, visited, irg_set, pre, post, env);
-    eset_destroy(irg_set);
+    irg_walk_cg(node, visited, &irg_set, pre, post, env);
+       pset_new_destroy(&irg_set);
   } else {
-    assert(! inside_irg_walk(current_ir_graph)); /* we must not already be inside an irg walk */
-    set_inside_irg_walk(current_ir_graph);
+    set_using_visited(current_ir_graph);
     inc_irg_visited(current_ir_graph);
     nodes_touched = irg_walk_2(node, pre, post, env);
-    clear_inside_irg_walk(current_ir_graph);
+    clear_using_visited(current_ir_graph);
   }
   return;
 }
@@ -415,11 +425,10 @@ void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
   if (get_interprocedural_view()) {
        assert(0 && "This is not yet implemented.");
   } else {
-    assert(! inside_irg_walk(current_ir_graph)); /* we must not already be inside an irg walk */
-    set_inside_irg_walk(current_ir_graph);
+    set_using_visited(current_ir_graph);
     inc_irg_visited(current_ir_graph);
     nodes_touched = irg_walk_in_or_dep_2(node, pre, post, env);
-    clear_inside_irg_walk(current_ir_graph);
+    clear_using_visited(current_ir_graph);
   }
   return;
 }
@@ -604,9 +613,8 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void
   assert(node);
   assert(!get_interprocedural_view());   /* interprocedural_view not implemented, because it
                     * interleaves with irg_walk */
-  assert(! inside_irg_walk(current_ir_graph)); /* we must not already be in a block walk */
+  set_using_block_visited(current_ir_graph);
   inc_irg_block_visited(current_ir_graph);
-  set_inside_block_walk(current_ir_graph);
   block = is_Block(node) ? node : get_nodes_block(node);
   assert(get_irn_op(block) == op_Block);
   irg_block_walk_2(block, pre, post, env);
@@ -632,8 +640,7 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void
     }
   }
 
-  clear_inside_block_walk(current_ir_graph);
-  return;
+  clear_using_block_visited(current_ir_graph);
 }
 
 /*