beifg: Let be_ifg_foreach_node() declare its iterator internally.
[libfirm] / ir / be / beifg.h
index 146f054..4b5032d 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2008 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.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -29,6 +15,7 @@
 #include "be_types.h"
 #include "bechordal.h"
 #include "irnodeset.h"
+#include "pset.h"
 
 struct be_ifg_t {
        const be_chordal_env_t *env;
@@ -69,7 +56,6 @@ ir_node *be_ifg_neighbours_next(neighbours_iter_t *iter);
 void     be_ifg_neighbours_break(neighbours_iter_t *iter);
 ir_node *be_ifg_nodes_begin(const be_ifg_t *ifg, nodes_iter_t *iter);
 ir_node *be_ifg_nodes_next(nodes_iter_t *iter);
-void     be_ifg_nodes_break(nodes_iter_t *iter);
 int      be_ifg_cliques_begin(const be_ifg_t *ifg, cliques_iter_t *iter,
                               ir_node **buf);
 int      be_ifg_cliques_next(cliques_iter_t *iter);
@@ -77,10 +63,12 @@ void     be_ifg_cliques_break(cliques_iter_t *iter);
 int      be_ifg_degree(const be_ifg_t *ifg, const ir_node *irn);
 
 #define be_ifg_foreach_neighbour(ifg, iter, irn, pos) \
-       for(pos = be_ifg_neighbours_begin(ifg, iter, irn); pos != NULL; pos = be_ifg_neighbours_next(iter))
+       for (ir_node *pos = be_ifg_neighbours_begin(ifg, iter, irn); pos; pos = be_ifg_neighbours_next(iter))
 
-#define be_ifg_foreach_node(ifg, iter, pos) \
-       for(pos = be_ifg_nodes_begin(ifg, iter); pos != NULL; pos = be_ifg_nodes_next(iter))
+#define be_ifg_foreach_node(ifg, pos) \
+       for (bool pos##__once = true; pos##__once;) \
+               for (nodes_iter_t pos##__iter; pos##__once; pos##__once = false) \
+                       for (ir_node *pos = be_ifg_nodes_begin(ifg, &pos##__iter); pos; pos = be_ifg_nodes_next(&pos##__iter))
 
 #define be_ifg_foreach_clique(ifg, iter, buf, count) \
        for(*(count) = be_ifg_cliques_begin(ifg, iter, buf); \