bescripts: Copy all common node attributes into the constructor variants.
[libfirm] / ir / be / beifg.h
index ec0c9c6..0fc3ccf 100644 (file)
-/**
- * Common use interference graph.
- * Originally written by Sebastian Hack. Refactored into a seperate
- * source file and header by Kimon Hoffmann.
- * @author Sebastian Hack
- * @date 27.06.2005
+/*
+ * 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.
  */
-#ifndef _BEIFG_H_
-#define _BEIFG_H_
-
-typedef struct _be_if_graph_t be_if_graph_t;
-typedef struct _be_if_node_t be_if_node_t;
-typedef struct _be_if_edge_t be_if_edge_t;
 
 /**
- * Creates a new interference graph with the specified number of
- * initial slots.
- * @param slots the initial number of slots used for hashing.
- *             Must be greater than 0.
- * @return the created, empty interference graph.
+ * @file
+ * @brief       Interface for interference graphs.
+ * @author      Sebastian Hack
+ * @date        18.11.2005
  */
-be_if_graph_t* be_ifg_new(int slots);
+#ifndef FIRM_BE_BEIFG_H
+#define FIRM_BE_BEIFG_H
 
-/**
- * Frees the passed interference graph an all contained nodes.
- * @param graph the interference graph that shall be freed. Please note
- *             that after a call to this function all pointers to the graph,
- *             its edges or its nodes are invalid.
- */
-void be_ifg_free(be_if_graph_t* graph);
+#include "be_types.h"
+#include "bechordal.h"
+#include "irnodeset.h"
+#include "pset.h"
 
-/**
- * Adds a new undirected interference edge between the two nodes
- * specified by their node numbers. If the corresponding nodes do
- * not yet exist in the iunterference grpah they are created pririor
- * to creation of the edge.
- * @param graph the graph to add the interference edge to.
- * @param source the key of the source node.
- * @param target the key of the target node.
- */
-void be_ifg_add_interference(be_if_graph_t* graph, int source, int target);
+struct be_ifg_t {
+       const be_chordal_env_t *env;
+};
 
-/**
- * Returns the set of all edges within the specified
- * graph.
- * @param graph the graph the return the set of edges of.
- * @return A set of all edges within the specified graph as
- *             be_if_edge_t instances.
- */
-set* be_get_ifg_edges(const be_if_graph_t* graph);
+typedef struct nodes_iter_t {
+       const be_chordal_env_t *env;
+       struct obstack         obst;
+       int                    n;
+       int                    curr;
+       ir_node                **nodes;
+} nodes_iter_t;
 
-/**
- * Returns the set of all nodes within the specified
- * graph.
- * @param graph the graph the return the set of nodes of.
- * @return A set of all nodes within the specified graph as
- *             be_if_node_t instances.
- */
-set* be_get_ifg_nodes(const be_if_graph_t* graph);
+typedef struct neighbours_iter_t {
+       const be_chordal_env_t *env;
+       const ir_node        *irn;
+       int                   valid;
+       ir_nodeset_t          neighbours;
+       ir_nodeset_iterator_t iter;
+} neighbours_iter_t;
 
-/**
- * Returns whether the specified graph alreadz contains an undirected
- * edge between the two passed nodes.
- * @param graph the graph to which containment both nodes @p n1 and
- *             @p n2 belong.
- * @param n1 the one end of the edge to query the graph for.
- * @param n2 the other end of the edge.
- * @return TRUE if the graph contains an edge between @p n1 and @p n2,
- *             otherwise FALSE.
- */
-int be_ifg_has_edge(const be_if_graph_t* graph, const be_if_node_t* n1, const be_if_node_t* n2);
+typedef struct cliques_iter_t {
+       struct obstack ob;
+       const be_chordal_env_t *cenv;
+       ir_node **buf;
+       ir_node **blocks;
+       int n_blocks, blk;
+       struct list_head *bor;
+       pset *living;
+} cliques_iter_t;
+
+void     be_ifg_free(be_ifg_t *ifg);
+int      be_ifg_connected(const be_ifg_t *ifg, const ir_node *a,
+                          const ir_node *b);
+ir_node *be_ifg_neighbours_begin(const be_ifg_t *ifg, neighbours_iter_t *iter,
+                                 const ir_node *irn);
+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);
+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))
 
-#define be_ifn_get_degree(ifnode) \
-       pset_count(ifnode->neighb)
+#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_ifn_foreach_neighbour(ifnode, curr) \
-       for (curr = pset_first(ifnode->neighbourNodes); curr; curr = pset_next(ifnode->neighbourNodes))
+#define be_ifg_foreach_clique(ifg, iter, buf, count) \
+       for(*(count) = be_ifg_cliques_begin(ifg, iter, buf); \
+        *(count) != -1 ; \
+        *(count) = be_ifg_cliques_next(iter))
 
-#define be_ifg_foreach_node(ifgraph, curr) \
-       for (curr = set_first(ifgraph->nodes); curr; curr = set_next(ifgraph->nodes))
+typedef struct {
+       int n_nodes;
+       int n_edges;
+       int n_comps;
+} be_ifg_stat_t;
 
-#define be_ifg_foreach_edge(ifgraph, curr) \
-       for (curr = set_first(ifgraph->edges); curr; curr = set_next(ifgraph->edges))
+void be_ifg_stat(ir_graph *irg, be_ifg_t *ifg, be_ifg_stat_t *stat);
 
+be_ifg_t *be_create_ifg(const be_chordal_env_t *env);
 
-#endif /*_BEIFG_H_*/
+#endif