X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeifg.h;h=f0da29d023ffe3bc619c46f8138bb1b723bfb08c;hb=8a1c0ad68eaba7cecab7a3abd552681ad893de3e;hp=1e6caf35da19da2594c5946ce58674c680c3187d;hpb=c1bb7cfa8bbb9f489e195cf9770a7df8a772783f;p=libfirm diff --git a/ir/be/beifg.h b/ir/be/beifg.h index 1e6caf35d..f0da29d02 100644 --- a/ir/be/beifg.h +++ b/ir/be/beifg.h @@ -1,40 +1,125 @@ -/** - * @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 + +#include "irnode.h" +#include "irnodeset.h" + +#include "becopyopt.h" +#include "beirg.h" + +typedef struct be_ifg_t { + const be_chordal_env_t *env; +} be_ifg_t; + +typedef struct nodes_iter_t { + const be_chordal_env_t *env; + struct obstack obst; + int n; + int curr; + ir_node **nodes; +} nodes_iter_t; + +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; + +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_ifg_foreach_node(ifg, iter, pos) \ + for(pos = be_ifg_nodes_begin(ifg, iter); pos != NULL; pos = be_ifg_nodes_next(iter)) -#include "obst.h" -#include "bechordal_t.h" +#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)) -typedef struct _be_ifg_impl_t be_ifg_impl_t; -typedef struct _be_ifg_t be_ifg_t; +typedef struct { + int n_nodes; + int n_edges; + int n_comps; +} be_ifg_stat_t; -struct _be_ifg_impl_t { - void (*free)(void *self); +void be_ifg_stat(ir_graph *irg, be_ifg_t *ifg, be_ifg_stat_t *stat); - 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); -}; +be_ifg_t *be_create_ifg(const be_chordal_env_t *env); -struct _be_ifg_t { - const be_ifg_impl_t *impl; -}; +/* + ____ _ + | _ \ _ _ _ __ ___ _ __ (_)_ __ __ _ + | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` | + | |_| | |_| | | | | | | |_) | | | | | (_| | + |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, | + |_| |___/ +*/ -#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)) +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; -be_ifg_t *be_ifg_std_new(const be_chordal_env_t *env); +void be_ifg_dump_dot(be_ifg_t *ifg, ir_graph *irg, FILE *file, const be_ifg_dump_dot_cb_t *cb, void *self); -#endif /* _BEIFG_H */ +#endif