- fixed comment: bs cannot be NULL anymore (and was never NULL previously)
[libfirm] / ir / be / beifg.h
index 1e6caf3..dddb0b4 100644 (file)
-/**
- * @file   beifg.h
- * @date   18.11.2005
- * @author Sebastian Hack
+/*
+ * 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.
  *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * 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
+/**
+ * @file
+ * @brief       Interface for interference graphs.
+ * @author      Sebastian Hack
+ * @date        18.11.2005
+ * @version     $Id$
+ */
+#ifndef FIRM_BE_BEIFG_H
+#define FIRM_BE_BEIFG_H
+
+#include <stdio.h>
+
+#include "irnode.h"
+
+#include "becopyopt.h"
+#include "beirg.h"
+
+typedef struct _be_ifg_impl_t   be_ifg_impl_t;
+typedef struct _be_ifg_t        be_ifg_t;
+
+#define be_ifg_nodes_iter_alloca(self)          (alloca(be_ifg_nodes_iter_size(self)))
+#define be_ifg_neighbours_iter_alloca(self)     (alloca(be_ifg_neighbours_iter_size(self)))
+#define be_ifg_cliques_iter_alloca(self)        (alloca(be_ifg_cliques_iter_size(self)))
+
+size_t   (be_ifg_nodes_iter_size)(const be_ifg_t *self);
+size_t   (be_ifg_neighbours_iter_size)(const be_ifg_t *self);
+size_t   (be_ifg_cliques_iter_size)(const be_ifg_t *self);
+void     (be_ifg_free)(be_ifg_t *self);
+int      (be_ifg_connected)(const be_ifg_t *self, const ir_node *a, const ir_node *b);
+ir_node *(be_ifg_neighbours_begin)(const be_ifg_t *self, void *iter, const ir_node *irn);
+ir_node *(be_ifg_neighbours_next)(const be_ifg_t *self, void *iter);
+void     (be_ifg_neighbours_break)(const be_ifg_t *self, void *iter);
+ir_node *(be_ifg_nodes_begin)(const be_ifg_t *self, void *iter);
+ir_node *(be_ifg_nodes_next)(const be_ifg_t *self, void *iter);
+void     (be_ifg_nodes_break)(const be_ifg_t *self, void *iter);
+int      (be_ifg_cliques_begin)(const be_ifg_t *self, void *iter, ir_node **buf);
+int      (be_ifg_cliques_next)(const be_ifg_t *self, void *iter);
+void     (be_ifg_cliques_break)(const be_ifg_t *self, void *iter);
+int      (be_ifg_degree)(const be_ifg_t *self, const ir_node *irn);
+
+#define be_ifg_foreach_neighbour(self, iter, irn, pos) \
+       for(pos = be_ifg_neighbours_begin(self, iter, irn); (pos); pos = be_ifg_neighbours_next(self, iter))
+
+#define be_ifg_foreach_node(self, iter, pos) \
+       for(pos = be_ifg_nodes_begin(self, iter); (pos); pos = be_ifg_nodes_next(self, iter))
+
+#define be_ifg_foreach_clique(self, iter, buf, count) \
+       for(*(count) = be_ifg_cliques_begin(self, iter, buf); \
+        *(count) != -1 ; \
+        *(count) = be_ifg_cliques_next(self, iter))
 
-#include "obst.h"
-#include "bechordal_t.h"
+typedef struct {
+       int n_nodes;
+       int n_edges;
+       int n_comps;
+} be_ifg_stat_t;
 
-typedef struct _be_ifg_impl_t  be_ifg_impl_t;
-typedef struct _be_ifg_t                               be_ifg_t;
+void be_ifg_stat(be_irg_t *birg, be_ifg_t *ifg, be_ifg_stat_t *stat);
 
-struct _be_ifg_impl_t {
-       void (*free)(void *self);
+be_ifg_t *be_create_ifg(const be_chordal_env_t *env);
 
-       int (*connected)(void *self, const ir_node *a, const ir_node *b);
-       int (*neighbours_arr)(void *self, const ir_node *irn, ir_node **arr, size_t n);
-       int (*neighbours_obst)(void *self, const ir_node *irn, struct obstack *obst);
-       int (*degree)(void *self, const ir_node *irn);
-};
+/*
+     ____                        _
+    |  _ \ _   _ _ __ ___  _ __ (_)_ __   __ _
+    | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` |
+    | |_| | |_| | | | | | | |_) | | | | | (_| |
+    |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, |
+                          |_|            |___/
+*/
 
-struct _be_ifg_t {
-       const be_ifg_impl_t *impl;
-};
+typedef struct _be_ifg_dump_dot_cb_t {
+       int  (*is_dump_node)(void *self, ir_node *irn);
+       void (*graph_attr)(FILE *f, void *self);
+       void (*node_attr)(FILE *f, void *self, ir_node *irn);
+       void (*edge_attr)(FILE *f, void *self, ir_node *from, ir_node *to);
+       void (*at_begin)(FILE *file, void *self);
+       void (*at_end)(FILE *file, void *self);
+} be_ifg_dump_dot_cb_t;
 
-#define be_ifg_free(self)                                                                              ((self)->impl->free(self))
-#define be_ifg_connected(self,a,b)                                             ((self)->impl->connected(self, a, b))
-#define be_ifg_neighbours_arr(self,irn,arr,n)  ((self)->impl->neighbours_arr(self, irn, arr, n))
-#define be_ifg_neighbours_obst(self,irn,obst)  ((self)->impl->neighbours_arr(self, irn, obst))
-#define be_ifg_degree(self,irn)                                                                ((self)->impl->degree(self, irn))
+void be_ifg_dump_dot(be_ifg_t *ifg, ir_graph *irg, FILE *file, const be_ifg_dump_dot_cb_t *cb, void *self);
+void be_ifg_check_sorted(const be_ifg_t *ifg);
+void be_ifg_check_sorted_to_file(const be_ifg_t *ifg, FILE *f);
+void be_ifg_check_performance(be_chordal_env_t *chordal_env);
 
-be_ifg_t *be_ifg_std_new(const be_chordal_env_t *env);
 
-#endif /* _BEIFG_H */
+#endif /* FIRM_BE_BEIFG_H */