X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeifg_list.c;h=5c03a85e509f258c08026edd1b8407ab41a1cb5d;hb=662fc44c951bdb45a9b7d9563e9ffbb87101b9e4;hp=c7fd3fecbe30dc19829b54ec2e7ecf0a9207396b;hpb=4d5c3365a58cba59993045a9e08e686d8ae079a7;p=libfirm diff --git a/ir/be/beifg_list.c b/ir/be/beifg_list.c index c7fd3fecb..5c03a85e5 100644 --- a/ir/be/beifg_list.c +++ b/ir/be/beifg_list.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -18,27 +18,25 @@ */ /** - * @file beifg_list.c - * @date 18.11.2005 - * @author Sebastian Hack - * - * Copyright (C) 2005 Universitaet Karlsruhe - * Released under the GPL + * @file + * @brief List based implementation of chordal interference graphs. + * @author Sebastian Hack + * @date 18.11.2005 + * @version $Id$ */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif #include -#include "benodesets.h" #include "list.h" #include "irnode_t.h" #include "irgraph_t.h" #include "irgwalk.h" +#include "bearch_t.h" #include "be_t.h" #include "bera.h" #include "beifg_t.h" @@ -48,38 +46,39 @@ typedef struct _adj_head_t adj_head_t; typedef struct _ifg_list_t { - const be_ifg_impl_t *impl; + const be_ifg_impl_t *impl; const be_chordal_env_t *env; - struct obstack obst; - adj_head_t **adj_heads; + struct obstack obst; + adj_head_t **adj_heads; } ifg_list_t; typedef struct _adj_element_t adj_element_t; struct _adj_element_t { adj_element_t *next_adj_element; - ir_node *neighbour; + ir_node *neighbour; }; struct _adj_head_t { - ir_node *irn; /* the node you search neighbours for */ + ir_node *irn; /* the node you search neighbours for */ adj_element_t *first_adj_element; - int degree; + int degree; }; typedef struct _nodes_iter_t { const ifg_list_t *ifg; - unsigned int curr_node_idx; + unsigned int curr_node_idx; } nodes_iter_t; typedef struct _adj_iter_t { const ifg_list_t *ifg; - adj_element_t *curr_adj_element; + adj_element_t *curr_adj_element; } adj_iter_t; /* PRIVATE FUNCTIONS */ -static void create_node (ifg_list_t *ifg, ir_node *irn) /* add node to the array of all nodes in this ifg implementation, if the node isn't already in the ifg */ +/* add node to the array of all nodes in this ifg implementation, if the node isn't already in the ifg */ +static void create_node(ifg_list_t *ifg, ir_node *irn) { adj_head_t *adj_head = NULL; @@ -105,11 +104,12 @@ static adj_element_t *create_adj_element(ifg_list_t *ifg, ir_node *irn) return element; } -static void add_edge(ifg_list_t *ifg, ir_node *node_a, ir_node *node_b) /* write the information about the edge between a and b */ +/* write the information about the edge between a and b */ +static void add_edge(ifg_list_t *ifg, ir_node *node_a, ir_node *node_b) { - adj_head_t *adj_head = NULL; + adj_head_t *adj_head = NULL; adj_element_t *curr_element = NULL; - adj_element_t *new_element = NULL; + adj_element_t *new_element = NULL; adj_head = ifg->adj_heads[node_a->node_idx]; /* find the neighbours list of a */ @@ -165,26 +165,30 @@ static void add_edge(ifg_list_t *ifg, ir_node *node_a, ir_node *node_b) /* write } } -static void find_neighbour_walker(ir_node *bl, void *data) /* find all adjacent nodes in the irg */ +/* find all adjacent nodes in the irg */ +static void find_neighbour_walker(ir_node *bl, void *data) { - ifg_list_t *ifg = data; - struct list_head *head = get_block_border_head(ifg->env, bl); + ifg_list_t *ifg = data; + struct list_head *head = get_block_border_head(ifg->env, bl); + ir_nodeset_t live; + ir_node *live_irn = NULL; + border_t *b = NULL; - nodeset *live = new_nodeset(ifg->env->cls->n_regs); - ir_node *live_irn = NULL; - border_t *b = NULL; + ir_nodeset_init(&live); - assert (is_Block(bl) && "There is no block to work on"); + assert(is_Block(bl) && "There is no block to work on"); foreach_border_head(head, b) /* follow the borders of each block */ { if (b->is_def) { create_node(ifg, b->irn); /* add the node to the array of all nodes of this ifg implementation */ - nodeset_insert(live, b->irn); + ir_nodeset_insert(&live, b->irn); if (b->is_real) /* this is a new node */ { - foreach_nodeset(live, live_irn) + ir_nodeset_iterator_t iter; + + foreach_ir_nodeset(&live, live_irn, iter) { if (b->irn != live_irn) /* add a as a neighbour to b and vice versa */ add_edge(ifg, b->irn, live_irn); @@ -193,20 +197,18 @@ static void find_neighbour_walker(ir_node *bl, void *data) /* find all adjacent } else /* b->irn is now dead */ { - if (nodeset_find(live, b->irn)) - nodeset_remove(live, b->irn); + ir_nodeset_remove(&live, b->irn); } } - if (live) - del_nodeset(live); + ir_nodeset_destroy(&live); } static ir_node *get_first_node(const ifg_list_t *ifg, nodes_iter_t *it) { - ir_node *res = NULL; - adj_head_t *adj_head= NULL; - int curr_idx = -1; + ir_node *res = NULL; + adj_head_t *adj_head = NULL; + int curr_idx = -1; it->ifg = ifg; it->curr_node_idx = 0; @@ -230,10 +232,10 @@ static ir_node *get_first_node(const ifg_list_t *ifg, nodes_iter_t *it) static ir_node *get_next_node(nodes_iter_t *it) { - const ifg_list_t *ifg = it->ifg; - ir_node *res = NULL; - adj_head_t *adj_head= NULL; - unsigned int curr_idx = it->curr_node_idx; + const ifg_list_t *ifg = it->ifg; + ir_node *res = NULL; + adj_head_t *adj_head = NULL; + unsigned int curr_idx = it->curr_node_idx; while (adj_head == NULL && curr_idx < it->ifg->env->irg->last_node_idx - 1) { @@ -254,11 +256,11 @@ static ir_node *get_next_node(nodes_iter_t *it) static ir_node *get_first_neighbour(const ifg_list_t *ifg, adj_iter_t *it, const ir_node *curr_irn) { - ir_node *res = NULL; + ir_node *res = NULL; adj_head_t *adj_head = NULL; adj_head = ifg->adj_heads[curr_irn->node_idx]; - assert (adj_head && "There is no entry for this node"); + assert(adj_head && "There is no entry for this node"); it->curr_adj_element = NULL; it->ifg = ifg; @@ -276,7 +278,7 @@ static ir_node *get_first_neighbour(const ifg_list_t *ifg, adj_iter_t *it, const static ir_node *get_next_neighbour(adj_iter_t *it) { - ir_node *res = NULL; + ir_node *res = NULL; adj_element_t *element = it->curr_adj_element; if (element->next_adj_element) /* return next neighbour */ @@ -302,10 +304,10 @@ static void ifg_list_free(void *self) static int ifg_list_connected(const void *self, const ir_node *a, const ir_node *b) { - const ifg_list_t *ifg = self; - int res = -1; - adj_head_t *adj_head = NULL; - adj_element_t *curr_element = NULL; + const ifg_list_t *ifg = self; + int res = -1; + adj_head_t *adj_head = NULL; + adj_element_t *curr_element = NULL; /* first try: find b in the neigbours of a */ adj_head = ifg->adj_heads[a->node_idx]; @@ -313,7 +315,7 @@ static int ifg_list_connected(const void *self, const ir_node *a, const ir_node assert(adj_head && "There is no entry for the node a"); curr_element = adj_head->first_adj_element; - if(curr_element) + if (curr_element) { while (curr_element->neighbour != b && curr_element->next_adj_element) { @@ -333,7 +335,7 @@ static int ifg_list_connected(const void *self, const ir_node *a, const ir_node assert(adj_head && "There is no entry for the node b"); curr_element = adj_head->first_adj_element; - if(curr_element) + if (curr_element) { while (curr_element->neighbour != a && curr_element->next_adj_element) { @@ -361,12 +363,14 @@ static ir_node *ifg_list_nodes_begin(const void *self, void *iter) static ir_node *ifg_list_nodes_next(const void *self, void *iter) { + (void) self; return get_next_node(iter); } static void ifg_list_nodes_break(const void *self, void *iter) { nodes_iter_t *it = iter; + (void) self; it->curr_node_idx = 0; it->ifg = NULL; } @@ -379,12 +383,14 @@ static ir_node *ifg_list_neighbours_begin(const void *self, void *iter,const ir_ static ir_node *ifg_list_neighbours_next(const void *self, void *iter) { + (void) self; return get_next_neighbour(iter); } static void ifg_list_neighbours_break(const void *self, void *iter) { adj_iter_t *it= iter; + (void) self; it->curr_adj_element = NULL; it->ifg = NULL; }