X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firloop.c;h=e257d1bb6ab0b9df6396fea53180ccdca84dc346;hb=ead8e569e6575d78c01c72bf76d918730967d49b;hp=7ac9132576877ed6169ff06b3089e5f37521b580;hpb=1a3b7d363474ab544c13093a2f0b578718d37c7a;p=libfirm diff --git a/ir/ana/irloop.c b/ir/ana/irloop.c index 7ac913257..e257d1bb6 100644 --- a/ir/ana/irloop.c +++ b/ir/ana/irloop.c @@ -22,7 +22,6 @@ * @brief Loop datastructure and access functions -- private stuff. * @author Goetz Lindenmaier * @date 7.2002 - * @version $Id: irloop_t.h 17143 2008-01-02 20:56:33Z beck $ */ #include "config.h" @@ -40,7 +39,6 @@ void add_loop_son(ir_loop *loop, ir_loop *son) assert(get_kind(son) == k_ir_loop); lson.son = son; ARR_APP1(loop_element, loop->children, lson); - ++loop->n_sons; loop->flags |= loop_outer_loop; } @@ -50,7 +48,6 @@ void add_loop_node(ir_loop *loop, ir_node *n) ln.node = n; assert(loop && loop->kind == k_ir_loop); ARR_APP1(loop_element, loop->children, ln); - loop->n_nodes++; } void add_loop_irg(ir_loop *loop, ir_graph *irg) @@ -59,102 +56,36 @@ void add_loop_irg(ir_loop *loop, ir_graph *irg) ln.irg = irg; assert(loop && loop->kind == k_ir_loop); ARR_APP1(loop_element, loop->children, ln); - loop->n_nodes++; } -/** - * Mature all loops by removing the flexible arrays of a loop. - * - * @param loop the loop to mature - * @param obst an obstack, where the new arrays are allocated on - */ void mature_loops(ir_loop *loop, struct obstack *obst) { + size_t i; + loop_element *new_children = DUP_ARR_D(loop_element, obst, loop->children); DEL_ARR_F(loop->children); loop->children = new_children; - if (loop->n_sons > 0) { - /* we have child loops, mature them */ - size_t i; + /* mature child loops */ + for (i = ARR_LEN(new_children); i > 0;) { + loop_element child = new_children[--i]; - for (i = ARR_LEN(new_children); i > 0;) { - loop_element child = new_children[--i]; - - if (*child.kind == k_ir_loop) { - mature_loops(child.son, obst); - } + if (*child.kind == k_ir_loop) { + mature_loops(child.son, obst); } } } -/* Returns outer loop, itself if outermost. */ ir_loop *(get_loop_outer_loop)(const ir_loop *loop) { return _get_loop_outer_loop(loop); } -/* Returns nesting depth of this loop */ unsigned (get_loop_depth)(const ir_loop *loop) { return _get_loop_depth(loop); } -/* Returns the number of inner loops */ -size_t (get_loop_n_sons)(const ir_loop *loop) -{ - return _get_loop_n_sons(loop); -} - -/* Returns the pos`th loop_node-child * - * TODO: This method isn`t very efficient ! * - * Returns NULL if there isn`t a pos`th loop_node */ -ir_loop *get_loop_son(ir_loop *loop, size_t pos) -{ - size_t child_nr = 0; - size_t loop_nr = 0; - - assert(loop && loop->kind == k_ir_loop); - for (child_nr = 0; child_nr < ARR_LEN(loop->children); ++child_nr) { - if (*(loop->children[child_nr].kind) != k_ir_loop) - continue; - if (loop_nr == pos) - return loop->children[child_nr].son; - loop_nr++; - } - return NULL; -} - -/* Returns the number of nodes in the loop */ -size_t get_loop_n_nodes(const ir_loop *loop) -{ - assert(loop); - assert(loop->kind == k_ir_loop); - return loop->n_nodes; -} - -/* Returns the pos'th ir_node-child * - * TODO: This method isn't very efficient ! * - * Returns NULL if there isn't a pos'th ir_node */ -ir_node *get_loop_node(const ir_loop *loop, size_t pos) -{ - size_t node_nr = 0; - size_t child_nr; - - assert(loop && loop->kind == k_ir_loop); - assert(pos < get_loop_n_nodes(loop)); - - for (child_nr = 0; child_nr < ARR_LEN(loop->children); ++child_nr) { - if (*(loop->children[child_nr].kind) != k_ir_node) - continue; - if (node_nr == pos) - return loop -> children[child_nr].node; - node_nr++; - } - panic("no child at pos found"); -} - -/* Returns the number of elements contained in loop. */ size_t get_loop_n_elements(const ir_loop *loop) { assert(loop && loop->kind == k_ir_loop); @@ -167,23 +98,6 @@ loop_element get_loop_element(const ir_loop *loop, size_t pos) return(loop -> children[pos]); } -size_t get_loop_element_pos(const ir_loop *loop, void *le) -{ - size_t n; - size_t i; - assert(loop && loop->kind == k_ir_loop); - - n = get_loop_n_elements(loop); - for (i = 0; i < n; i++) - if (get_loop_element(loop, i).node == le) - return i; - return INVALID_LOOP_POS; -} - - -/** - * Sets the loop for a node. - */ void set_irn_loop(ir_node *n, ir_loop *loop) { n->loop = loop; @@ -221,22 +135,16 @@ int (is_ir_loop)(const void *thing) return _is_ir_loop(thing); } -/* The outermost loop is remarked in the surrounding graph. */ void (set_irg_loop)(ir_graph *irg, ir_loop *loop) { _set_irg_loop(irg, loop); } -/* Returns the root loop info (if exists) for an irg. */ ir_loop *(get_irg_loop)(const ir_graph *irg) { return _get_irg_loop(irg); } -/* - * Allocates a new loop as son of father on the given obstack. - * If father is equal NULL, a new root loop is created. - */ ir_loop *alloc_loop(ir_loop *father, struct obstack *obst) { ir_loop *son; @@ -244,8 +152,6 @@ ir_loop *alloc_loop(ir_loop *father, struct obstack *obst) son = OALLOCZ(obst, ir_loop); son->kind = k_ir_loop; son->children = NEW_ARR_F(loop_element, 0); - son->n_nodes = 0; - son->n_sons = 0; son->link = NULL; if (father) { son->outer_loop = father;