X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fana%2Firscc.c;h=931ad3f86a76bde91e9db6b57e945910e89f625b;hb=eb92b4074220dcecc72dd366983ce8548d1371cd;hp=e474878a9addc40dd92139dccf5cb7a68dc9f183;hpb=d9b6d0969fc324f197178583eee70bb58f0c845e;p=libfirm diff --git a/ir/ana/irscc.c b/ir/ana/irscc.c index e474878a9..931ad3f86 100644 --- a/ir/ana/irscc.c +++ b/ir/ana/irscc.c @@ -27,9 +27,7 @@ * @date 7.2002 * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #ifdef HAVE_STRING_H # include @@ -93,7 +91,7 @@ typedef struct scc_info { /** * Allocates a new SCC info on the given obstack. */ -static INLINE scc_info *new_scc_info(struct obstack *obst) { +static inline scc_info *new_scc_info(struct obstack *obst) { scc_info *info = obstack_alloc(obst, sizeof(*info)); memset(info, 0, sizeof(*info)); return info; @@ -102,7 +100,7 @@ static INLINE scc_info *new_scc_info(struct obstack *obst) { /** * Mark node n being on the SCC stack. */ -static INLINE void mark_irn_in_stack(ir_node *n) { +static inline void mark_irn_in_stack(ir_node *n) { scc_info *scc = get_irn_link(n); assert(scc); scc->in_stack = 1; @@ -111,7 +109,7 @@ static INLINE void mark_irn_in_stack(ir_node *n) { /** * Mark node n NOT being on the SCC stack. */ -static INLINE void mark_irn_not_in_stack(ir_node *n) { +static inline void mark_irn_not_in_stack(ir_node *n) { scc_info *scc = get_irn_link(n); assert(scc); scc->in_stack = 0; @@ -120,7 +118,7 @@ static INLINE void mark_irn_not_in_stack(ir_node *n) { /** * Checks if a node is on the SCC stack. */ -static INLINE int irn_is_in_stack(ir_node *n) { +static inline int irn_is_in_stack(ir_node *n) { scc_info *scc = get_irn_link(n); assert(scc); return scc->in_stack; @@ -129,7 +127,7 @@ static INLINE int irn_is_in_stack(ir_node *n) { /** * Sets the uplink number for a node. */ -static INLINE void set_irn_uplink(ir_node *n, int uplink) { +static inline void set_irn_uplink(ir_node *n, int uplink) { scc_info *scc = get_irn_link(n); assert(scc); scc->uplink = uplink; @@ -147,7 +145,7 @@ static int get_irn_uplink(ir_node *n) { /** * Sets the depth-first-search number for a node. */ -static INLINE void set_irn_dfn(ir_node *n, int dfn) { +static inline void set_irn_dfn(ir_node *n, int dfn) { scc_info *scc = get_irn_link(n); assert(scc); scc->dfn = dfn; @@ -200,7 +198,7 @@ static int tos = 0; /* top of stack */ /** * initializes the stack */ -static INLINE void init_stack(void) { +static inline void init_stack(void) { if (stack) { ARR_RESIZE(ir_node *, stack, 1000); } else { @@ -209,25 +207,20 @@ static INLINE void init_stack(void) { tos = 0; } -#if 0 /** * Frees the stack. */ -static INLINE void free_stack(void) { - if (stack != NULL) { - DEL_ARR_F(stack); - stack = NULL; - } - tos = 0; +static void finish_stack(void) { + DEL_ARR_F(stack); + stack = NULL; } -#endif /** * push a node onto the stack * * @param n The node to push */ -static INLINE void push(ir_node *n) { +static inline void push(ir_node *n) { if (tos == ARR_LEN(stack)) { int nlen = ARR_LEN(stack) * 2; ARR_RESIZE(ir_node *, stack, nlen); @@ -241,7 +234,7 @@ static INLINE void push(ir_node *n) { * * @return The topmost node */ -static INLINE ir_node *pop(void) { +static inline ir_node *pop(void) { ir_node *n = stack[--tos]; mark_irn_not_in_stack(n); return n; @@ -251,7 +244,7 @@ static INLINE ir_node *pop(void) { * The nodes up to n belong to the current loop. * Removes them from the stack and adds them to the current loop. */ -static INLINE void pop_scc_to_loop(ir_node *n) { +static inline void pop_scc_to_loop(ir_node *n) { ir_node *m; int i = 0; @@ -300,7 +293,7 @@ static void close_loop(ir_loop *l) { /* Removes and unmarks all nodes up to n from the stack. The nodes must be visited once more to assign them to a scc. */ -static INLINE void pop_scc_unmark_visit(ir_node *n) { +static inline void pop_scc_unmark_visit(ir_node *n) { ir_node *m = NULL; while (m != n) { @@ -330,19 +323,19 @@ static ir_loop *new_loop(void) { /* Initialization steps. **********************************************/ -static INLINE void init_node(ir_node *n, void *env) { +static inline void init_node(ir_node *n, void *env) { struct obstack *obst = env; set_irn_link(n, new_scc_info(obst)); clear_backedges(n); } -static INLINE void init_scc_common(void) { +static inline void init_scc_common(void) { current_dfn = 1; loop_node_cnt = 0; init_stack(); } -static INLINE void init_scc(ir_graph *irg, struct obstack *obst) { +static inline void init_scc(ir_graph *irg, struct obstack *obst) { init_scc_common(); irg_walk_graph(irg, init_node, NULL, obst); /* @@ -350,8 +343,13 @@ static INLINE void init_scc(ir_graph *irg, struct obstack *obst) { */ } +static inline void finish_scc(void) +{ + finish_stack(); +} + #ifdef INTERPROCEDURAL_VIEW -static INLINE void init_ip_scc(struct obstack *obst) { +static inline void init_ip_scc(struct obstack *obst) { init_scc_common(); cg_walk(init_node, NULL, obst); @@ -382,7 +380,7 @@ static int is_outermost_Start(ir_node *n) { } /* When to walk from nodes to blocks. Only for Control flow operations? */ -static INLINE int get_start_index(ir_node *n) { +static inline int get_start_index(ir_node *n) { #undef BLOCK_BEFORE_NODE #define BLOCK_BEFORE_NODE 1 @@ -393,11 +391,12 @@ static INLINE int get_start_index(ir_node *n) { not reachable. I.e., with this code, the order on the loop tree is correct. But a (single) test showed the loop tree is deeper. */ - if (get_irn_op(n) == op_Phi || - get_irn_op(n) == op_Block || - (get_irn_op(n) == op_Filter && get_interprocedural_view()) || - (get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats && - get_irn_pinned(n) == op_pin_state_floats)) + if (get_irn_op(n) == op_Phi || + is_Block(n) || + (is_Filter(n) && get_interprocedural_view()) || ( + get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats && + get_irn_pinned(n) == op_pin_state_floats + )) // Here we could test for backedge at -1 which is illegal return 0; else @@ -410,7 +409,7 @@ static INLINE int get_start_index(ir_node *n) { But it guarantees that Blocks are analysed before nodes contained in the block. If so, we can set the value to undef if the block is not \ executed. */ - if (is_cfop(n) || is_fragile_op(n) || get_irn_op(n) == op_Start) + if (is_cfop(n) || is_fragile_op(n) || is_Start(n)) return -1; else return 0; @@ -424,7 +423,7 @@ static INLINE int get_start_index(ir_node *n) { * * @param n the node to check */ -static INLINE int is_possible_loop_head(ir_node *n) { +static inline int is_possible_loop_head(ir_node *n) { ir_op *op = get_irn_op(n); return ((op == op_Block) || (op == op_Phi) || @@ -450,6 +449,8 @@ static int is_head(ir_node *n, ir_node *root) { if (!is_outermost_Start(n)) { #ifndef NDEBUG int uplink = get_irn_uplink(root); +#else + (void) root; #endif arity = get_irn_arity(n); for (i = get_start_index(n); i < arity; i++) { @@ -487,6 +488,8 @@ static int is_endless_head(ir_node *n, ir_node *root) { if (!is_outermost_Start(n)) { #ifndef NDEBUG int uplink = get_irn_uplink(root); +#else + (void) root; #endif arity = get_irn_arity(n); for (i = get_start_index(n); i < arity; i++) { @@ -695,7 +698,7 @@ ir_node *get_projx_link(ir_node *cb_projx) { #endif -static INLINE int is_outermost_loop(ir_loop *l) { +static inline int is_outermost_loop(ir_loop *l) { return l == get_loop_outer_loop(l); } @@ -710,9 +713,8 @@ static INLINE int is_outermost_loop(ir_loop *l) { * @param n node to start */ static void scc(ir_node *n) { - if (irn_visited(n)) + if (irn_visited_else_mark(n)) return; - mark_irn_visited(n); /* Initialize the node */ set_irn_dfn(n, current_dfn); /* Depth first number for this node */ @@ -811,9 +813,8 @@ static void scc(ir_node *n) { #ifdef INTERPROCEDURAL_VIEW static void my_scc(ir_node *n) { int i; - if (irn_visited(n)) + if (irn_visited_else_mark(n)) return; - mark_irn_visited(n); /* Initialize the node */ set_irn_dfn(n, current_dfn); /* Depth first number for this node */ @@ -833,7 +834,7 @@ static void my_scc(ir_node *n) { ir_node *m; if (is_backedge(n, i)) continue; m = get_irn_n(n, i); /* get_irn_ip_pred(n, i); */ - /* if ((!m) || (get_irn_op(m) == op_Unknown)) continue; */ + /* if (!m || is_Unknown(m)) continue; */ my_scc(m); if (irn_is_in_stack(m)) { /* Uplink of m is smaller if n->m is a backedge. @@ -931,6 +932,8 @@ int construct_backedges(ir_graph *irg) { inc_irg_visited(irg); scc(get_irg_end(irg)); + + finish_scc(); obstack_free(&temp, NULL); assert(head_rem == current_loop);