From 7c36344d22a7c306a4e216f135c974bdb9f6b943 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 10 Mar 2010 17:25:21 +0000 Subject: [PATCH] - fix most of the -Wunreachable-code and -Wlogical-op warnings - rework ir_phase API (sorry for mixing these 2 things into 1 commit) [r27285] --- include/libfirm/firm_types.h | 1 - include/libfirm/iredges.h | 8 -- include/libfirm/irgraph.h | 2 - ir/adt/pqueue.c | 6 +- ir/ana/execution_frequency.c | 5 +- ir/ana/height.c | 4 +- ir/ana/irbackedge.c | 16 ++-- ir/ana/ircfscc.c | 2 + ir/ana/irlivechk.c | 14 +-- ir/ana/irloop.c | 71 ++++++++++----- ir/ana/irmemory.c | 3 +- ir/ana/irscc.c | 28 ++++-- ir/ana/vrp.c | 87 +++++++++--------- ir/be/TEMPLATE/bearch_TEMPLATE.c | 2 - ir/be/arm/arm_emitter.c | 6 +- ir/be/arm/arm_transform.c | 9 -- ir/be/beabi.c | 7 +- ir/be/beblocksched.c | 1 - ir/be/becopyheur2.c | 4 +- ir/be/becopyheur4.c | 5 +- ir/be/beifg.c | 5 +- ir/be/beifg_pointer.c | 4 +- ir/be/beilpsched.c | 5 +- ir/be/belive.c | 8 +- ir/be/bemain.c | 6 -- ir/be/beschedmris.c | 11 +-- ir/be/beschedrss.c | 7 +- ir/be/bespillbelady2.c | 4 +- ir/be/betranshlp.c | 7 +- ir/be/beuses.c | 6 +- ir/be/beutil.c | 9 +- ir/be/beutil.h | 8 +- ir/be/beverify.c | 61 ------------- ir/be/beverify.h | 13 +-- ir/be/ia32/bearch_ia32.c | 8 ++ ir/be/ia32/ia32_common_transform.c | 4 +- ir/be/ia32/ia32_finish.c | 3 +- ir/be/ia32/ia32_transform.c | 1 - ir/be/ia32/ia32_x87.c | 37 ++------ ir/be/mips/bearch_mips.c | 5 -- ir/be/ppc32/bearch_ppc32.c | 2 - ir/be/ppc32/ppc32_emitter.c | 2 - ir/be/ppc32/ppc32_transform.c | 6 +- ir/be/sparc/bearch_sparc.c | 6 +- ir/be/sparc/sparc_emitter.c | 1 - ir/debug/dbginfo.c | 4 +- ir/ir/irarch.c | 1 - ir/ir/ircons.c | 4 +- ir/ir/irdump.c | 23 +++-- ir/ir/irdumptxt.c | 16 +++- ir/ir/irgraph.c | 24 ++++- ir/ir/irgraph_t.h | 27 ++++++ ir/ir/irgwalk.c | 17 ++-- ir/ir/irmode.c | 3 +- ir/ir/irnode.c | 11 ++- ir/ir/irphase.c | 56 ++++-------- ir/ir/irphase.h | 85 ++++++++++++++++++ ir/ir/irphase_t.h | 138 +++++------------------------ ir/ir/irphaselist.h | 15 ---- ir/ir/irphases_t.h | 21 ----- ir/ir/irtypes.h | 13 ++- ir/ir/irvrfy.c | 47 +++++----- ir/opt/dead_code_elimination.c | 23 ++--- ir/opt/escape_ana.c | 7 +- ir/opt/ldstopt.c | 4 +- ir/opt/opt_osr.c | 2 - ir/stat/pattern.c | 5 +- ir/tr/entity.c | 4 +- ir/tv/fltcalc.c | 6 +- ir/tv/tv.c | 43 ++++----- 70 files changed, 496 insertions(+), 613 deletions(-) create mode 100644 ir/ir/irphase.h delete mode 100644 ir/ir/irphaselist.h delete mode 100644 ir/ir/irphases_t.h diff --git a/include/libfirm/firm_types.h b/include/libfirm/firm_types.h index 16da47806..f3ef93530 100644 --- a/include/libfirm/firm_types.h +++ b/include/libfirm/firm_types.h @@ -46,7 +46,6 @@ typedef struct ir_loop ir_loop, *ir_loop_ptr; typedef struct ir_region ir_region, *ir_region_ptr; typedef struct ir_reg_tree ir_reg_tree, *ir_reg_tree_ptr; typedef struct ir_entity ir_entity, *ir_entity_ptr; -typedef struct _ir_phase ir_phase, *ir_phase_ptr; typedef struct _ir_extblk ir_extblk, *ir_extblk_ptr; typedef struct ir_exec_freq ir_exec_freq, *ir_exec_freq_ptr; typedef struct ir_cdep ir_cdep, *ir_cdep_ptr; diff --git a/include/libfirm/iredges.h b/include/libfirm/iredges.h index 4e51f37f9..87622282b 100644 --- a/include/libfirm/iredges.h +++ b/include/libfirm/iredges.h @@ -182,10 +182,6 @@ void edges_init_dbg(int do_dbg); */ ir_graph_pass_t *irg_verify_edges_pass(const char *name, unsigned assert_on_problem); -/************************************************************************/ -/* Begin Old Interface */ -/************************************************************************/ - const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *src, int pos); #define edges_reroute(old, nw, irg) edges_reroute_kind(old, nw, EDGE_KIND_NORMAL, irg) @@ -272,8 +268,4 @@ void irg_block_edges_walk(ir_node *block, irg_walk_func *pre, irg_walk_func *pos */ void edges_reset_private_data(ir_graph *irg, int offset, unsigned size); -/************************************************************************/ -/* End Old Interface */ -/************************************************************************/ - #endif diff --git a/include/libfirm/irgraph.h b/include/libfirm/irgraph.h index 53a284b94..830750459 100644 --- a/include/libfirm/irgraph.h +++ b/include/libfirm/irgraph.h @@ -126,8 +126,6 @@ void set_current_ir_graph(ir_graph *graph); * (get_irn_*, set_irn_*) is influenced by this flag. */ int get_interprocedural_view(void); void set_interprocedural_view(int state); -#else -#define get_interprocedural_view() 0 #endif /** diff --git a/ir/adt/pqueue.c b/ir/adt/pqueue.c index 3fd6a6f15..0a7702ca3 100644 --- a/ir/adt/pqueue.c +++ b/ir/adt/pqueue.c @@ -27,6 +27,7 @@ #include "array.h" #include "pqueue.h" +#include "error.h" /* * Implements a heap. @@ -131,13 +132,10 @@ void *pqueue_pop_front(pqueue_t *q) { switch (ARR_LEN(q->elems)) { case 0: - assert(0 && "Attempt to retrieve element from empty priority queue."); - return NULL; - break; + panic("Attempt to retrieve element from empty priority queue."); case 1: ARR_SHRINKLEN(q->elems, 0); return q->elems[0].data; - break; default: { void *data = q->elems[0].data; int len = ARR_LEN(q->elems) - 1; diff --git a/ir/ana/execution_frequency.c b/ir/ana/execution_frequency.c index 844ab6a3f..8765c7164 100644 --- a/ir/ana/execution_frequency.c +++ b/ir/ana/execution_frequency.c @@ -31,6 +31,7 @@ #include "set.h" #include "pdeq.h" #include "hashptr.h" +#include "error.h" #include "irprog_t.h" #include "irgraph_t.h" @@ -265,10 +266,12 @@ static void precompute_cond_evaluation(void) /* both are exceptions */ if ((get_ProjX_probability(p0) == Cond_prob_exception_taken) && (get_ProjX_probability(p1) == Cond_prob_exception_taken) ) { - assert(0 && "I tried to avoid these!"); + panic("I tried to avoid these!"); +#if 0 /* It's a */ set_ProjX_probability(p0, Cond_prob_normal); set_ProjX_probability(p1, Cond_prob_normal); +#endif } /* p0 is exception */ diff --git a/ir/ana/height.c b/ir/ana/height.c index c45f1597a..2cebd570e 100644 --- a/ir/ana/height.c +++ b/ir/ana/height.c @@ -243,7 +243,7 @@ void heights_recompute(heights_t *h) heights_t *heights_new(ir_graph *irg) { heights_t *res = XMALLOC(heights_t); - phase_init(&res->ph, "heights", irg, PHASE_DEFAULT_GROWTH, irn_height_init, NULL); + phase_init(&res->ph, irg, irn_height_init); res->dump_handle = dump_add_node_info_callback(height_dump_cb, res); heights_recompute(res); @@ -252,7 +252,7 @@ heights_t *heights_new(ir_graph *irg) void heights_free(heights_t *h) { - phase_free(&h->ph); + phase_deinit(&h->ph); dump_remv_node_info_callback(h->dump_handle); xfree(h); } diff --git a/ir/ana/irbackedge.c b/ir/ana/irbackedge.c index b5f37b095..5cad71db6 100644 --- a/ir/ana/irbackedge.c +++ b/ir/ana/irbackedge.c @@ -49,25 +49,29 @@ static unsigned *mere_get_backarray(ir_node *n) switch (get_irn_opcode(n)) { case iro_Block: if (!get_Block_matured(n)) return NULL; +#ifdef INTERPROCEDURAL_VIEW if (get_interprocedural_view() && n->attr.block.in_cg) { assert(n->attr.block.cg_backedge && "backedge array not allocated!"); return n->attr.block.cg_backedge; - } else { - assert(n->attr.block.backedge && "backedge array not allocated!"); - return n->attr.block.backedge; } - break; +#endif + + assert(n->attr.block.backedge && "backedge array not allocated!"); + return n->attr.block.backedge; case iro_Phi: assert(n->attr.phi.u.backedge && "backedge array not allocated!"); return n->attr.phi.u.backedge; break; case iro_Filter: +#ifdef INTERPROCEDURAL_VIEW if (get_interprocedural_view()) { assert(n->attr.filter.backedge && "backedge array not allocated!"); return n->attr.filter.backedge; } +#endif + break; + default: break; - default: ; } return NULL; } @@ -122,9 +126,11 @@ void fix_backedges(struct obstack *obst, ir_node *n) if (opc == iro_Phi) n->attr.phi.u.backedge = arr; else if (opc == iro_Block) { +#ifdef INTERPROCEDURAL_VIEW if (!get_interprocedural_view()) n->attr.block.backedge = arr; else +#endif n->attr.block.cg_backedge = arr; } else if (opc == iro_Filter) diff --git a/ir/ana/ircfscc.c b/ir/ana/ircfscc.c index afb1cdad6..b112bd2d3 100644 --- a/ir/ana/ircfscc.c +++ b/ir/ana/ircfscc.c @@ -666,8 +666,10 @@ int construct_cf_backedges(ir_graph *irg) struct obstack temp; int i; +#ifdef INTERPROCEDURAL_VIEW assert(!get_interprocedural_view() && "use construct_ip_cf_backedges()"); +#endif max_loop_depth = 0; current_ir_graph = irg; diff --git a/ir/ana/irlivechk.c b/ir/ana/irlivechk.c index fc2a1b280..0fa2a275e 100644 --- a/ir/ana/irlivechk.c +++ b/ir/ana/irlivechk.c @@ -76,12 +76,12 @@ typedef struct _bl_info_t { #define get_block_info(lv, bl) ((bl_info_t *) phase_get_irn_data(&(lv)->ph, bl)) struct _lv_chk_t { - ir_phase ph; + ir_phase ph; const dfs_t *dfs; - int n_blocks; - bitset_t *back_edge_src; - bitset_t *back_edge_tgt; - bl_info_t **map; + int n_blocks; + bitset_t *back_edge_src; + bitset_t *back_edge_tgt; + bl_info_t **map; DEBUG_ONLY(firm_dbg_module_t *dbg;) }; @@ -251,7 +251,7 @@ lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs) compute_doms(irg); stat_ev_tim_push(); - phase_init(&res->ph, "liveness check", irg, PHASE_DEFAULT_GROWTH, init_block_data, NULL); + phase_init(&res->ph, irg, init_block_data); obst = phase_obst(&res->ph); FIRM_DBG_REGISTER(res->dbg, "ir.ana.lvchk"); @@ -310,7 +310,7 @@ lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs) void lv_chk_free(lv_chk_t *lv) { - phase_free(&lv->ph); + phase_deinit(&lv->ph); xfree(lv); } diff --git a/ir/ana/irloop.c b/ir/ana/irloop.c index 1722d4803..dd2fc3d45 100644 --- a/ir/ana/irloop.c +++ b/ir/ana/irloop.c @@ -31,8 +31,10 @@ #include "irloop_t.h" #include "irprog_t.h" +#include "error.h" -void add_loop_son(ir_loop *loop, ir_loop *son) { +void add_loop_son(ir_loop *loop, ir_loop *son) +{ loop_element lson; assert(loop && loop->kind == k_ir_loop); assert(get_kind(son) == k_ir_loop); @@ -42,7 +44,8 @@ void add_loop_son(ir_loop *loop, ir_loop *son) { loop->flags |= loop_outer_loop; } -void add_loop_node(ir_loop *loop, ir_node *n) { +void add_loop_node(ir_loop *loop, ir_node *n) +{ loop_element ln; ln.node = n; assert(loop && loop->kind == k_ir_loop); @@ -50,7 +53,8 @@ void add_loop_node(ir_loop *loop, ir_node *n) { loop->n_nodes++; } -void add_loop_irg(ir_loop *loop, ir_graph *irg) { +void add_loop_irg(ir_loop *loop, ir_graph *irg) +{ loop_element ln; ln.irg = irg; assert(loop && loop->kind == k_ir_loop); @@ -64,7 +68,8 @@ void add_loop_irg(ir_loop *loop, ir_graph *irg) { * @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) { +void mature_loops(ir_loop *loop, struct obstack *obst) +{ loop_element *new_children = DUP_ARR_D(loop_element, obst, loop->children); DEL_ARR_F(loop->children); loop->children = new_children; @@ -84,24 +89,28 @@ void mature_loops(ir_loop *loop, struct obstack *obst) { } /* Returns outer loop, itself if outermost. */ -ir_loop *(get_loop_outer_loop)(const ir_loop *loop) { +ir_loop *(get_loop_outer_loop)(const ir_loop *loop) +{ return _get_loop_outer_loop(loop); } /* Returns nesting depth of this loop */ -int (get_loop_depth)(const ir_loop *loop) { +int (get_loop_depth)(const ir_loop *loop) +{ return _get_loop_depth(loop); } /* Returns the number of inner loops */ -int (get_loop_n_sons)(const ir_loop *loop) { +int (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, int pos) { +ir_loop *get_loop_son(ir_loop *loop, int pos) +{ int child_nr = 0, loop_nr = -1; assert(loop && loop->kind == k_ir_loop); @@ -116,7 +125,8 @@ ir_loop *get_loop_son(ir_loop *loop, int pos) { } /* Returns the number of nodes in the loop */ -int get_loop_n_nodes(const ir_loop *loop) { +int get_loop_n_nodes(const ir_loop *loop) +{ assert(loop); assert(loop->kind == k_ir_loop); return loop->n_nodes; } @@ -124,7 +134,8 @@ int get_loop_n_nodes(const ir_loop *loop) { /* 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, int pos) { +ir_node *get_loop_node(const ir_loop *loop, int pos) +{ int child_nr, node_nr = -1; assert(loop && loop->kind == k_ir_loop); @@ -137,12 +148,12 @@ ir_node *get_loop_node(const ir_loop *loop, int pos) { return loop -> children[child_nr].node; } - assert(0 && "no child at pos found"); - return NULL; + panic("no child at pos found"); } /* Returns the number of elements contained in loop. */ -int get_loop_n_elements(const ir_loop *loop) { +int get_loop_n_elements(const ir_loop *loop) +{ assert(loop && loop->kind == k_ir_loop); return(ARR_LEN(loop->children)); } @@ -153,12 +164,14 @@ This may be a loop_node or a ir_node. The caller of this function has to check the *(loop_element.kind) field for "k_ir_node" or "k_ir_loop" and then select the appropriate "loop_element.node" or "loop_element.son". */ -loop_element get_loop_element(const ir_loop *loop, int pos) { +loop_element get_loop_element(const ir_loop *loop, int pos) +{ assert(loop && loop->kind == k_ir_loop && pos < ARR_LEN(loop->children)); return(loop -> children[pos]); } -int get_loop_element_pos(const ir_loop *loop, void *le) { +int get_loop_element_pos(const ir_loop *loop, void *le) +{ int i, n; assert(loop && loop->kind == k_ir_loop); @@ -173,15 +186,18 @@ int get_loop_element_pos(const ir_loop *loop, void *le) { /** * Sets the loop for a node. */ -void set_irn_loop(ir_node *n, ir_loop *loop) { +void set_irn_loop(ir_node *n, ir_loop *loop) +{ n->loop = loop; } -ir_loop *(get_irn_loop)(const ir_node *n) { +ir_loop *(get_irn_loop)(const ir_node *n) +{ return _get_irn_loop(n); } -int get_loop_loop_nr(const ir_loop *loop) { +int get_loop_loop_nr(const ir_loop *loop) +{ assert(loop && loop->kind == k_ir_loop); #ifdef DEBUG_libfirm return loop->loop_nr; @@ -190,26 +206,32 @@ int get_loop_loop_nr(const ir_loop *loop) { #endif } -void set_loop_link(ir_loop *loop, void *link) { +void set_loop_link(ir_loop *loop, void *link) +{ assert(loop && loop->kind == k_ir_loop); loop->link = link; } -void *get_loop_link(const ir_loop *loop) { + +void *get_loop_link(const ir_loop *loop) +{ assert(loop && loop->kind == k_ir_loop); return loop->link; } -int (is_ir_loop)(const void *thing) { +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) { +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) { +ir_loop *(get_irg_loop)(const ir_graph *irg) +{ return _get_irg_loop(irg); } @@ -217,7 +239,8 @@ ir_loop *(get_irg_loop)(const ir_graph *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 *alloc_loop(ir_loop *father, struct obstack *obst) +{ ir_loop *son; son = OALLOCZ(obst, ir_loop); diff --git a/ir/ana/irmemory.c b/ir/ana/irmemory.c index c4018483d..8f30cbd5d 100644 --- a/ir/ana/irmemory.c +++ b/ir/ana/irmemory.c @@ -64,7 +64,8 @@ const char *get_ir_alias_relation_name(ir_alias_relation rel) X(ir_no_alias); X(ir_may_alias); X(ir_sure_alias); - default: assert(0); return "UNKNOWN"; + default: + panic("UNKNOWN alias relation"); } #undef X } diff --git a/ir/ana/irscc.c b/ir/ana/irscc.c index 95a992db9..4a360ef6b 100644 --- a/ir/ana/irscc.c +++ b/ir/ana/irscc.c @@ -396,6 +396,16 @@ static int is_outermost_Start(ir_node *n) return 0; } +static inline int is_ip_Filter(ir_node *n) +{ +#ifdef INTERPROCEDURAL_VIEW + return is_Filter(n) && get_interprocedural_view(); +#else + (void) n; + return 0; +#endif +} + /* When to walk from nodes to blocks. Only for Control flow operations? */ static inline int get_start_index(ir_node *n) { @@ -405,13 +415,13 @@ static inline int get_start_index(ir_node *n) #if BLOCK_BEFORE_NODE /* This version assures, that all nodes are ordered absolutely. This allows - to undef all nodes in the heap analysis if the block is false, which means - 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 || - is_Block(n) || - (is_Filter(n) && get_interprocedural_view()) || ( + to undef all nodes in the heap analysis if the block is false, which + means 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 || + is_Block(n) || + (is_ip_Filter(n)) || ( get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats && get_irn_pinned(n) == op_pin_state_floats )) @@ -446,7 +456,7 @@ static inline int is_possible_loop_head(ir_node *n) ir_op *op = get_irn_op(n); return ((op == op_Block) || (op == op_Phi) || - ((op == op_Filter) && get_interprocedural_view())); + (is_ip_Filter(n))); } /** @@ -947,8 +957,10 @@ int construct_backedges(ir_graph *irg) ir_loop *head_rem; struct obstack temp; +#ifdef INTERPROCEDURAL_VIEW assert(!get_interprocedural_view() && "not implemented, use construct_ip_backedges()"); +#endif max_loop_depth = 0; current_ir_graph = irg; diff --git a/ir/ana/vrp.c b/ir/ana/vrp.c index e43af90b6..a54bb803c 100644 --- a/ir/ana/vrp.c +++ b/ir/ana/vrp.c @@ -46,6 +46,11 @@ struct vrp_env_t { waitq *workqueue; }; +static vrp_attr *get_vrp_attr(const ir_node *node) +{ + return (vrp_attr*) get_or_set_irn_phase_info(node, PHASE_VRP); +} + static int vrp_update_node(ir_node *node) { tarval *new_bits_set = get_tarval_bad(); @@ -55,21 +60,16 @@ static int vrp_update_node(ir_node *node) enum range_types new_range_type = VRP_UNDEFINED; int something_changed = 0; vrp_attr *vrp; - ir_phase *phase; if (!mode_is_int(get_irn_mode(node))) { return 0; /* we don't optimize for non-int-nodes*/ } - phase = get_irg_phase(get_irn_irg(node), PHASE_VRP); - ir_printf("update_vrp for %d called\n", get_irn_node_nr(node)); - vrp = phase_get_or_set_irn_data(phase, node); + vrp = get_vrp_attr(node); /* TODO: Check if all predecessors have valid VRP information*/ - - switch (get_irn_opcode(node)) { case iro_Const: { tarval *tv = get_Const_tarval(node); @@ -87,8 +87,8 @@ static int vrp_update_node(ir_node *node) left = get_And_left(node); right = get_And_right(node); - vrp_left = phase_get_or_set_irn_data(phase, left); - vrp_right = phase_get_or_set_irn_data(phase, right); + vrp_left = get_vrp_attr(left); + vrp_right = get_vrp_attr(right); new_bits_set = tarval_and(vrp_left->bits_set, vrp_right->bits_set); new_bits_not_set = tarval_or(vrp_left->bits_not_set, vrp_right->bits_not_set); @@ -99,8 +99,8 @@ static int vrp_update_node(ir_node *node) int overflow_top, overflow_bottom; tarval *new_top, *new_bottom; vrp_attr *vrp_left, *vrp_right; - vrp_left = phase_get_or_set_irn_data(phase, get_Add_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Add_right(node)); + vrp_left = get_vrp_attr(get_Add_left(node)); + vrp_right = get_vrp_attr(get_Add_right(node)); if (vrp_left->range_type == VRP_UNDEFINED || vrp_right->range_type == VRP_UNDEFINED || vrp_left->range_type == VRP_VARYING || @@ -131,8 +131,8 @@ static int vrp_update_node(ir_node *node) int overflow_top, overflow_bottom; tarval *new_top, *new_bottom; vrp_attr *vrp_left, *vrp_right; - vrp_left = phase_get_or_set_irn_data(phase, get_Sub_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Sub_right(node)); + vrp_left = get_vrp_attr(get_Sub_left(node)); + vrp_right = get_vrp_attr(get_Sub_right(node)); if (vrp_left->range_type == VRP_UNDEFINED || vrp_right->range_type == VRP_UNDEFINED) { @@ -164,8 +164,8 @@ static int vrp_update_node(ir_node *node) left = get_Or_left(node); right = get_Or_right(node); - vrp_left = phase_get_or_set_irn_data(phase, get_Or_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Or_right(node)); + vrp_left = get_vrp_attr(get_Or_left(node)); + vrp_right = get_vrp_attr(get_Or_right(node)); new_bits_set = tarval_or(vrp_left->bits_set, vrp_right->bits_set); new_bits_not_set = tarval_and(vrp_left->bits_not_set, vrp_right->bits_not_set); @@ -177,8 +177,8 @@ static int vrp_update_node(ir_node *node) vrp_attr *vrp_left, *vrp_right; ir_node *right = get_Rotl_right(node); - vrp_left = phase_get_or_set_irn_data(phase, get_Rotl_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Rotl_right(node)); + vrp_left = get_vrp_attr(get_Rotl_left(node)); + vrp_right = get_vrp_attr(get_Rotl_right(node)); /* We can only compute this if the right value is a constant*/ if (is_Const(right)) { @@ -195,8 +195,8 @@ static int vrp_update_node(ir_node *node) case iro_Shl: { vrp_attr *vrp_left, *vrp_right; ir_node *right = get_Shl_right(node); - vrp_left = phase_get_or_set_irn_data(phase, get_Shl_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Shl_right(node)); + vrp_left = get_vrp_attr(get_Shl_left(node)); + vrp_right = get_vrp_attr(get_Shl_right(node)); /* We can only compute this if the right value is a constant*/ if (is_Const(right)) { @@ -221,8 +221,8 @@ static int vrp_update_node(ir_node *node) vrp_attr *vrp_left, *vrp_right; ir_node *right = get_Shr_right(node); - vrp_left = phase_get_or_set_irn_data(phase, get_Shr_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Shr_right(node)); + vrp_left = get_vrp_attr(get_Shr_left(node)); + vrp_right = get_vrp_attr(get_Shr_right(node)); /* We can only compute this if the right value is a constant*/ if (is_Const(right)) { @@ -246,8 +246,8 @@ static int vrp_update_node(ir_node *node) vrp_attr *vrp_left, *vrp_right; ir_node *right = get_Shrs_right(node); - vrp_left = phase_get_or_set_irn_data(phase, get_Shrs_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Shrs_right(node)); + vrp_left = get_vrp_attr(get_Shrs_left(node)); + vrp_right = get_vrp_attr(get_Shrs_right(node)); /* We can only compute this if the right value is a constant*/ if (is_Const(right)) { @@ -271,8 +271,8 @@ static int vrp_update_node(ir_node *node) tarval *bits_set, *bits_not_set; vrp_attr *vrp_left, *vrp_right; - vrp_left = phase_get_or_set_irn_data(phase, get_Eor_left(node)); - vrp_right = phase_get_or_set_irn_data(phase, get_Eor_right(node)); + vrp_left = get_vrp_attr(get_Eor_left(node)); + vrp_right = get_vrp_attr(get_Eor_right(node)); bits_not_set = tarval_or( tarval_and(vrp_left->bits_set, vrp_right->bits_set), @@ -289,7 +289,7 @@ static int vrp_update_node(ir_node *node) } case iro_Id: { - vrp_attr *vrp_pred = phase_get_or_set_irn_data(phase, get_Id_pred(node)); + vrp_attr *vrp_pred = get_vrp_attr(get_Id_pred(node)); new_bits_set = vrp_pred->bits_set; new_bits_not_set = vrp_pred->bits_not_set; new_range_top = vrp_pred->range_top; @@ -299,7 +299,7 @@ static int vrp_update_node(ir_node *node) } case iro_Not: { - vrp_attr *vrp_pred = phase_get_or_set_irn_data(phase, get_Not_op(node)); + vrp_attr *vrp_pred = get_vrp_attr(get_Not_op(node)); new_bits_set = tarval_or(vrp_pred->bits_not_set, vrp->bits_set); new_bits_not_set = tarval_or(vrp_pred->bits_set, vrp->bits_not_set); break; @@ -308,7 +308,7 @@ static int vrp_update_node(ir_node *node) case iro_Conv: { ir_node *pred = get_Conv_op(node); ir_mode *old_mode = get_irn_mode(pred); - vrp_attr *vrp_pred = phase_get_or_set_irn_data(phase, pred); + vrp_attr *vrp_pred = get_vrp_attr(pred); ir_mode *new_mode; tarval *bits_not_set; @@ -382,7 +382,7 @@ static int vrp_update_node(ir_node *node) int i; ir_node *pred = get_Phi_pred(node,0); - vrp_attr *vrp_pred = phase_get_or_set_irn_data(phase, pred); + vrp_attr *vrp_pred = get_vrp_attr(pred); new_range_top = vrp_pred->range_top; new_range_bottom = vrp_pred->range_bottom; new_range_type = vrp_pred->range_type; @@ -394,7 +394,7 @@ static int vrp_update_node(ir_node *node) for (i = 1; i < num; i++) { pred = get_Phi_pred(node, i); - vrp_pred = phase_get_or_set_irn_data(phase, pred); + vrp_pred = get_vrp_attr(pred); if (new_range_type == VRP_RANGE && vrp_pred->range_type == VRP_RANGE) { cmp = tarval_cmp(new_range_top, vrp_pred->range_top); @@ -586,22 +586,18 @@ static void *vrp_init_node(ir_phase *phase, const ir_node *n, void *old) void set_vrp_data(ir_graph *irg) { - ir_node *succ, *node; int i; struct vrp_env_t *env; ir_phase *phase; - if (!irg) { - /* no graph, skip */ - return; - } - assure_irg_outs(irg); /* ensure that out edges are consistent*/ - if (!(phase = get_irg_phase(irg, PHASE_VRP))) { - /* this is our first run */ - phase = init_irg_phase(irg, PHASE_VRP, 0, vrp_init_node); - env = phase_alloc(phase, sizeof(struct vrp_env_t)); + phase = irg_get_phase(irg, PHASE_VRP); + if (phase == NULL) { + /* this is our first run */ + phase = new_phase(irg, vrp_init_node); + irg_register_phase(irg, PHASE_VRP, phase); + env = phase_alloc(phase, sizeof(*env)); phase->priv = env; } else { env = phase->priv; @@ -609,7 +605,6 @@ void set_vrp_data(ir_graph *irg) env->workqueue = new_waitq(); - irg_walk_graph(irg, NULL, vrp_first_pass, env); /* while there are entries in the worklist, continue*/ @@ -662,15 +657,15 @@ pn_Cmp vrp_cmp(const ir_node *left, const ir_node *right) return pn_Cmp_False; } -vrp_attr *vrp_get_info(const ir_node *n) { - ir_graph *irg = get_irn_irg(n); - ir_phase *phase = get_irg_phase(irg, PHASE_VRP); - +vrp_attr *vrp_get_info(const ir_node *node) +{ + const ir_graph *irg = get_irn_irg(node); + const ir_phase *phase = irg_get_phase(irg, PHASE_VRP); - if (!phase) { + if (phase == NULL) { /* phase has not yet been initialized */ return NULL; } - return phase_get_irn_data(phase, n); + return phase_get_irn_data(phase, node); } diff --git a/ir/be/TEMPLATE/bearch_TEMPLATE.c b/ir/be/TEMPLATE/bearch_TEMPLATE.c index 667a08264..e4ba0d2c6 100644 --- a/ir/be/TEMPLATE/bearch_TEMPLATE.c +++ b/ir/be/TEMPLATE/bearch_TEMPLATE.c @@ -481,7 +481,6 @@ static const be_execution_unit_t ***TEMPLATE_get_allowed_execution_units( { (void) irn; /* TODO */ - assert(0); return NULL; } @@ -489,7 +488,6 @@ static const be_machine_t *TEMPLATE_get_machine(const void *self) { (void) self; /* TODO */ - assert(0); return NULL; } diff --git a/ir/be/arm/arm_emitter.c b/ir/be/arm/arm_emitter.c index 847bd514d..4bf44916e 100644 --- a/ir/be/arm/arm_emitter.c +++ b/ir/be/arm/arm_emitter.c @@ -545,7 +545,7 @@ static void emit_arm_CopyB(const ir_node *irn) assert(size > 0 && "CopyB needs size > 0" ); if (size & 3) { - assert(!"strange hack enabled: copy more bytes than needed!"); + fprintf(stderr, "strange hack enabled: copy more bytes than needed!"); size += 4; } @@ -788,7 +788,6 @@ static void emit_be_Copy(const ir_node *irn) arm_emit_source_register(irn, 0); be_emit_finish_line_gas(irn); } else { - assert(0 && "move not supported for this mode"); panic("emit_be_Copy: move not supported for this mode"); } } else if (mode_is_data(mode)) { @@ -796,9 +795,8 @@ static void emit_be_Copy(const ir_node *irn) arm_emit_dest_register(irn, 0); be_emit_cstring(", "); arm_emit_source_register(irn, 0); - be_emit_finish_line_gas(irn); + be_emit_finish_line_gas(irn); } else { - assert(0 && "move not supported for this mode"); panic("emit_be_Copy: move not supported for this mode"); } } diff --git a/ir/be/arm/arm_transform.c b/ir/be/arm/arm_transform.c index 339589185..62e1233ba 100644 --- a/ir/be/arm/arm_transform.c +++ b/ir/be/arm/arm_transform.c @@ -218,10 +218,8 @@ static ir_node *gen_Conv(ir_node *node) } } else if (USE_VFP(env_cg->isa)) { panic("VFP not supported yet"); - return NULL; } else { panic("Softfloat not supported yet"); - return NULL; } } else { /* complete in gp registers */ int src_bits = get_mode_size_bits(src_mode); @@ -403,11 +401,9 @@ static ir_node *gen_Add(ir_node *node) } else if (USE_VFP(env_cg->isa)) { assert(mode != mode_E && "IEEE Extended FP not supported"); panic("VFP not supported yet"); - return NULL; } else { panic("Softfloat not supported yet"); - return NULL; } } else { #if 0 @@ -462,11 +458,9 @@ static ir_node *gen_Mul(ir_node *node) else if (USE_VFP(env_cg->isa)) { assert(mode != mode_E && "IEEE Extended FP not supported"); panic("VFP not supported yet"); - return NULL; } else { panic("Softfloat not supported yet"); - return NULL; } } assert(mode_is_data(mode)); @@ -506,7 +500,6 @@ static ir_node *gen_Quot(ir_node *node) } else { panic("Softfloat not supported yet"); - return NULL; } } @@ -572,10 +565,8 @@ static ir_node *gen_Sub(ir_node *node) } else if (USE_VFP(env_cg->isa)) { assert(mode != mode_E && "IEEE Extended FP not supported"); panic("VFP not supported yet"); - return NULL; } else { panic("Softfloat not supported yet"); - return NULL; } } else { return gen_int_binop(node, MATCH_SIZE_NEUTRAL, diff --git a/ir/be/beabi.c b/ir/be/beabi.c index 2daec1f19..f5d83b047 100644 --- a/ir/be/beabi.c +++ b/ir/be/beabi.c @@ -1597,16 +1597,11 @@ static void fix_address_of_parameter_access(be_abi_irg_t *env, ent_pos_pair *val if (new_list != NULL) { /* ok, change the graph */ ir_node *start_bl = get_irg_start_block(irg); - ir_node *first_bl = NULL; + ir_node *first_bl = get_first_block_succ(start_bl); ir_node *frame, *imem, *nmem, *store, *mem, *args, *args_bl; - const ir_edge_t *edge; optimization_state_t state; unsigned offset; - foreach_block_succ(start_bl, edge) { - first_bl = get_edge_src_irn(edge); - break; - } assert(first_bl && first_bl != start_bl); /* we had already removed critical edges, so the following assertion should be always true. */ diff --git a/ir/be/beblocksched.c b/ir/be/beblocksched.c index 801db202b..ecf3884e5 100644 --- a/ir/be/beblocksched.c +++ b/ir/be/beblocksched.c @@ -758,5 +758,4 @@ ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs) } panic("unknown blocksched algo"); - return NULL; } diff --git a/ir/be/becopyheur2.c b/ir/be/becopyheur2.c index 322d03da5..b5b62d586 100644 --- a/ir/be/becopyheur2.c +++ b/ir/be/becopyheur2.c @@ -1230,7 +1230,7 @@ int co_solve_heuristic_new(copy_opt_t *co) co2_t env; FILE *f; - phase_init(&env.ph, "co2", co->cenv->birg->irg, PHASE_DEFAULT_GROWTH, co2_irn_init, NULL); + phase_init(&env.ph, co->cenv->birg->irg, co2_irn_init); env.touched = NULL; env.visited = 0; env.co = co; @@ -1261,7 +1261,7 @@ int co_solve_heuristic_new(copy_opt_t *co) } writeback_colors(&env); - phase_free(&env.ph); + phase_deinit(&env.ph); return 0; } diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c index ece1314fd..b26615971 100644 --- a/ir/be/becopyheur4.c +++ b/ir/be/becopyheur4.c @@ -1425,7 +1425,8 @@ static int co_solve_heuristic_mst(copy_opt_t *co) stat_ev_tim_push(); /* init phase */ - phase_init(&mst_env.ph, "co_mst", co->irg, PHASE_DEFAULT_GROWTH, co_mst_irn_init, &mst_env); + phase_init(&mst_env.ph, co->irg, co_mst_irn_init); + phase_set_private(&mst_env.ph, &mst_env); k = be_put_ignore_regs(co->cenv->birg, co->cls, ignore_regs); k = n_regs - k; @@ -1491,7 +1492,7 @@ static int co_solve_heuristic_mst(copy_opt_t *co) /* free allocated memory */ del_pqueue(mst_env.chunks); - phase_free(&mst_env.ph); + phase_deinit(&mst_env.ph); del_pset(mst_env.chunkset); stat_ev_tim_pop("heur4_total"); diff --git a/ir/be/beifg.c b/ir/be/beifg.c index 2a3a5e5f6..30572872d 100644 --- a/ir/be/beifg.c +++ b/ir/be/beifg.c @@ -85,7 +85,7 @@ static void *regs_irn_data_init(ir_phase *ph, const ir_node *irn, void *data) static coloring_t *coloring_init(coloring_t *c, ir_graph *irg) { - phase_init(&c->ph, "regs_map", irg, PHASE_DEFAULT_GROWTH, regs_irn_data_init, NULL); + phase_init(&c->ph, irg, regs_irn_data_init); c->irg = irg; return c; } @@ -764,8 +764,7 @@ be_ifg_t *be_create_ifg(const be_chordal_env_t *chordal_env) switch (ifg_flavor) { default: - assert(0); - fprintf(stderr, "no valid ifg flavour selected. falling back to std\n"); + panic("invalid ifg flavour selected"); case BE_IFG_STD: case BE_IFG_FAST: ifg = be_ifg_std_new(chordal_env); diff --git a/ir/be/beifg_pointer.c b/ir/be/beifg_pointer.c index 48e8aa2f9..55c76b795 100644 --- a/ir/be/beifg_pointer.c +++ b/ir/be/beifg_pointer.c @@ -568,7 +568,7 @@ static void ifg_pointer_free(void *self) { ifg_pointer_t *ifg = self; obstack_free(&ifg->obst, NULL); - phase_free(&ifg->ph); + phase_deinit(&ifg->ph); free(self); } @@ -672,7 +672,7 @@ be_ifg_t *be_ifg_pointer_new(const be_chordal_env_t *env) ifg->impl = &ifg_pointer_impl; ifg->env = env; - phase_init(&ifg->ph, "ptr_map", env->irg, PHASE_DEFAULT_GROWTH, ptr_irn_data_init, NULL); + phase_init(&ifg->ph, env->irg, ptr_irn_data_init); obstack_init(&ifg->obst); dom_tree_walk_irg(env->irg, find_neighbour_walker, NULL, ifg); diff --git a/ir/be/beilpsched.c b/ir/be/beilpsched.c index 2324ef8d7..d083788c5 100644 --- a/ir/be/beilpsched.c +++ b/ir/be/beilpsched.c @@ -2003,7 +2003,6 @@ static void create_ilp(ir_node *block, void *walk_env) void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts) { be_ilpsched_env_t env; - const char *name = "be ilp scheduling"; ir_graph *irg = be_get_birg_irg(birg); const arch_env_t *arch_env = be_get_birg_arch_env(birg); const ilp_sched_selector_t *sel = arch_env->impl->get_ilp_sched_selector(arch_env); @@ -2024,7 +2023,7 @@ void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts) env.opts = &ilp_opts; env.birg = birg; env.be_opts = be_opts; - phase_init(&env.ph, name, env.irg, PHASE_DEFAULT_GROWTH, init_ilpsched_irn, NULL); + phase_init(&env.ph, env.irg, init_ilpsched_irn); /* assign a unique per block number to all interesting nodes */ irg_walk_in_or_dep_graph(env.irg, NULL, build_block_idx, &env); @@ -2061,7 +2060,7 @@ void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts) irg_block_walk_graph(env.irg, NULL, clear_unwanted_data, &env); /* free all allocated object */ - phase_free(&env.ph); + phase_deinit(&env.ph); heights_free(env.height); /* notify backend */ diff --git a/ir/be/belive.c b/ir/be/belive.c index 1cf291fd3..997746039 100644 --- a/ir/be/belive.c +++ b/ir/be/belive.c @@ -541,7 +541,7 @@ void be_liveness_assure_sets(be_lv_t *lv) be_timer_push(T_LIVE); lv->nodes = bitset_malloc(2 * get_irg_last_idx(lv->irg)); - phase_init(&lv->ph, "liveness", lv->irg, PHASE_DEFAULT_GROWTH, lv_phase_data_init, NULL); + phase_init(&lv->ph, lv->irg, lv_phase_data_init); compute_liveness(lv); /* be_live_chk_compare(lv, lv->lvc); */ @@ -564,7 +564,7 @@ void be_liveness_invalidate(be_lv_t *lv) { if (lv && lv->nodes) { unregister_hook(hook_node_info, &lv->hook_info); - phase_free(&lv->ph); + phase_deinit(&lv->ph); bitset_free(lv->nodes); lv->nodes = NULL; } @@ -598,8 +598,8 @@ void be_liveness_recompute(be_lv_t *lv) } else bitset_clear_all(lv->nodes); - phase_free(&lv->ph); - phase_init(&lv->ph, "liveness", lv->irg, PHASE_DEFAULT_GROWTH, lv_phase_data_init, NULL); + phase_deinit(&lv->ph); + phase_init(&lv->ph, lv->irg, lv_phase_data_init); compute_liveness(lv); be_timer_pop(T_LIVE); diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 1e2fd19b8..4af25edef 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -658,9 +658,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) if (be_options.vrfy_option == BE_VRFY_WARN) { be_check_dominance(irg); - be_verify_out_edges(irg); } else if (be_options.vrfy_option == BE_VRFY_ASSERT) { - assert(be_verify_out_edges(irg)); assert(be_check_dominance(irg) && "Dominance verification failed"); } @@ -673,9 +671,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) if (be_options.vrfy_option == BE_VRFY_WARN) { be_check_dominance(irg); - be_verify_out_edges(irg); } else if (be_options.vrfy_option == BE_VRFY_ASSERT) { - assert(be_verify_out_edges(irg)); assert(be_check_dominance(irg) && "Dominance verification failed"); } @@ -798,12 +794,10 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) if (be_options.vrfy_option == BE_VRFY_WARN) { irg_verify(irg, VRFY_ENFORCE_SSA); be_check_dominance(irg); - be_verify_out_edges(irg); be_verify_schedule(birg); be_verify_register_allocation(birg); } else if (be_options.vrfy_option == BE_VRFY_ASSERT) { assert(irg_verify(irg, VRFY_ENFORCE_SSA) && "irg verification failed"); - assert(be_verify_out_edges(irg) && "out edge verification failed"); assert(be_check_dominance(irg) && "Dominance verification failed"); assert(be_verify_schedule(birg) && "Schedule verification failed"); assert(be_verify_register_allocation(birg) diff --git a/ir/be/beschedmris.c b/ir/be/beschedmris.c index 82f151326..3891b534c 100644 --- a/ir/be/beschedmris.c +++ b/ir/be/beschedmris.c @@ -316,11 +316,8 @@ static int fuse_two_lineages(mris_env_t *env, mris_irn_t *u, mris_irn_t *v) return 0; if (get_irn_mode(last) == mode_T) { - const ir_edge_t *edge; - foreach_out_edge(last, edge) { - last = get_edge_src_irn(edge); - break; - } + const ir_edge_t *edge = get_irn_out_edge_first(last); + last = get_edge_src_irn(edge); } /* irn now points to the last node in lineage u; mi has the info for the node _before_ the terminator of the lineage. */ @@ -406,7 +403,7 @@ mris_env_t *be_sched_mris_preprocess(const be_irg_t *birg) mris_env_t *env = XMALLOC(mris_env_t); ir_graph *irg = be_get_birg_irg(birg); - phase_init(&env->ph, "mris", irg, 2 * PHASE_DEFAULT_GROWTH, mris_irn_data_init, NULL); + phase_init(&env->ph, irg, mris_irn_data_init); env->irg = irg; env->visited = 0; env->heights = heights_new(irg); @@ -422,7 +419,7 @@ mris_env_t *be_sched_mris_preprocess(const be_irg_t *birg) void be_sched_mris_free(mris_env_t *env) { - phase_free(&env->ph); + phase_deinit(&env->ph); heights_free(env->heights); free(env); } diff --git a/ir/be/beschedrss.c b/ir/be/beschedrss.c index ca23f2d48..b04586f46 100644 --- a/ir/be/beschedrss.c +++ b/ir/be/beschedrss.c @@ -799,9 +799,6 @@ static int is_potential_killer(rss_t *rss, rss_irn_t *v, rss_irn_t *u) plist_element_t *el; (void) rss; - assert(is_Sink(v->irn) || ((plist_count(v->descendant_list) > 0 && v->descendants) || 1)); - assert(is_Sink(u->irn) || ((plist_count(u->consumer_list) > 0 && u->consumer) || 1)); - /* as we loop over the list: loop over the shorter one */ if (plist_count(v->descendant_list) > plist_count(u->consumer_list)) { list = u->consumer_list; @@ -2087,7 +2084,7 @@ static void process_block(ir_node *block, void *env) int i, n; const ir_edge_t *edge; - phase_init(&rss->ph, "rss block preprocessor", rss->irg, PHASE_DEFAULT_GROWTH, init_rss_irn, NULL); + phase_init(&rss->ph, rss->irg, init_rss_irn); DBG((rss->dbg, LEVEL_1, "preprocessing block %+F\n", block)); rss->block = block; @@ -2173,7 +2170,7 @@ static void process_block(ir_node *block, void *env) ir_nodeset_destroy(&rss->live_block); } - phase_free(&rss->ph); + phase_deinit(&rss->ph); } BE_REGISTER_MODULE_CONSTRUCTOR(be_init_schedrss); diff --git a/ir/be/bespillbelady2.c b/ir/be/bespillbelady2.c index 921665093..4b2386fa9 100644 --- a/ir/be/bespillbelady2.c +++ b/ir/be/bespillbelady2.c @@ -348,7 +348,7 @@ static void build_next_uses(block_info_t *bi) sched_renumber(bi->bl); - phase_init(&bi->next_uses, "next uses", bi->bel->irg, PHASE_DEFAULT_GROWTH, next_use_init, NULL); + phase_init(&bi->next_uses, bi->bel->irg, next_use_init); sched_foreach_reverse(bi->bl, irn) { int i; @@ -744,7 +744,7 @@ static void belady(belady_env_t *env, int id) env->instr_nr++; } - phase_free(&block_info->next_uses); + phase_deinit(&block_info->next_uses); /* Remember end-workset for this block */ block_info->ws_end = workset_clone(env, &env->ob, env->ws); diff --git a/ir/be/betranshlp.c b/ir/be/betranshlp.c index 04a8c5fa9..9da59a9f9 100644 --- a/ir/be/betranshlp.c +++ b/ir/be/betranshlp.c @@ -130,9 +130,6 @@ ir_node *be_duplicate_node(ir_node *node) return new_node; } -/** - * Calls transformation function for given node and marks it visited. - */ ir_node *be_transform_node(ir_node *node) { ir_op *op; @@ -158,9 +155,6 @@ ir_node *be_transform_node(ir_node *node) return new_node; } -/** - * enqueue all inputs into the transform queue. - */ void be_enqueue_preds(ir_node *node) { int i, arity; @@ -442,6 +436,7 @@ void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func) free_trouts(); free_loop_information(irg); set_irg_doms_inconsistent(irg); + irg_invalidate_phases(irg); be_liveness_invalidate(be_get_birg_liveness(birg)); /* Hack for now, something is buggy with invalidate liveness... */ diff --git a/ir/be/beuses.c b/ir/be/beuses.c index 2ad2399c0..5b9375f09 100644 --- a/ir/be/beuses.c +++ b/ir/be/beuses.c @@ -121,7 +121,6 @@ static int be_is_phi_argument(const ir_node *block, const ir_node *def) { ir_node *node; ir_node *succ_block = NULL; - const ir_edge_t *edge; int arity, i; #if 1 @@ -131,10 +130,7 @@ static int be_is_phi_argument(const ir_node *block, const ir_node *def) #endif return 0; - foreach_block_succ(block, edge) { - succ_block = get_edge_src_irn(edge); - break; - } + succ_block = get_first_block_succ(block); arity = get_Block_n_cfgpreds(succ_block); if (arity <= 1) diff --git a/ir/be/beutil.c b/ir/be/beutil.c index 621da7d6e..6e6abf2bb 100644 --- a/ir/be/beutil.c +++ b/ir/be/beutil.c @@ -38,7 +38,7 @@ #include "irgopt.h" #include "irtools.h" #include "irprintf.h" -#include "iredges.h" +#include "iredges_t.h" #include "beutil.h" #include "besched.h" @@ -191,3 +191,10 @@ ir_node **be_get_cfgpostorder(ir_graph *irg) return list; } + +ir_node *get_first_block_succ(const ir_node *block) +{ + const ir_edge_t *edge = get_irn_out_edge_first_kind(block, EDGE_KIND_BLOCK); + assert(edge != NULL); + return get_edge_src_irn(edge); +} diff --git a/ir/be/beutil.h b/ir/be/beutil.h index 72a81fa05..0dcd29bfe 100644 --- a/ir/be/beutil.h +++ b/ir/be/beutil.h @@ -154,4 +154,10 @@ ir_node **be_get_cfgpostorder(ir_graph *irg); */ FILE *be_ffopen(const char *base, const char *ext, const char *mode); -#endif /* FIRM_BE_BEUTIL_H */ +/** + * convenience function to return the first successor block + * (it is often known that there is exactly 1 successor anyway) + */ +ir_node *get_first_block_succ(const ir_node *block); + +#endif diff --git a/ir/be/beverify.c b/ir/be/beverify.c index 11635285c..436af8319 100644 --- a/ir/be/beverify.c +++ b/ir/be/beverify.c @@ -908,64 +908,3 @@ int be_verify_register_allocation(const be_irg_t *birg) return !problem_found; } - - - -/*--------------------------------------------------------------------------- */ - - - -typedef struct _verify_out_dead_nodes_env { - ir_graph *irg; - bitset_t *reachable; - int problem_found; -} verify_out_dead_nodes_env; - -static void check_out_edges(ir_node *node, verify_out_dead_nodes_env *env) -{ - ir_graph *irg = env->irg; - const ir_edge_t* edge; - - if (irn_visited_else_mark(node)) - return; - - /* we find too many (uncritical) dead nodes in block out edges */ - if (is_Block(node)) - return; - - foreach_out_edge(node, edge) { - ir_node* src = get_edge_src_irn(edge); - - if (!bitset_is_set(env->reachable, get_irn_idx(src)) && !is_Block(src)) { - ir_fprintf(stderr, "Verify warning: Node %+F in block %+F(%s) only reachable through out edges from %+F\n", - src, get_nodes_block(src), get_irg_dump_name(irg), node); - env->problem_found = 1; - continue; - } - - check_out_edges(src, env); - } -} - -static void set_reachable(ir_node *node, void* data) -{ - bitset_t* reachable = data; - bitset_set(reachable, get_irn_idx(node)); -} - -int be_verify_out_edges(ir_graph *irg) -{ - verify_out_dead_nodes_env env; - -return 1; - env.irg = irg; - env.reachable = bitset_alloca(get_irg_last_idx(irg)); - env.problem_found = edges_verify(irg); - - irg_walk_in_or_dep_graph(irg, set_reachable, NULL, env.reachable); - irg_walk_anchors(irg, set_reachable, NULL, env.reachable); - inc_irg_visited(irg); - check_out_edges(get_irg_start(irg), &env); - - return ! env.problem_found; -} diff --git a/ir/be/beverify.h b/ir/be/beverify.h index 180ad5a63..8117f5f0d 100644 --- a/ir/be/beverify.h +++ b/ir/be/beverify.h @@ -69,15 +69,4 @@ int be_verify_spillslots(ir_graph *irg); */ int be_verify_register_allocation(const be_irg_t *birg); -/** - * Verify that out edges are valid. - * - * @param irg The irg to check - * @param 1 if verify succeeded, 0 otherwise - * - * @note: This function requires O(|nodes|^2) memory. Too much for - * the Java Grande benchmark for instance! - */ -int be_verify_out_edges(ir_graph *irg); - -#endif /* FIRM_BE_BEVERIFY_H */ +#endif diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index 4ff347a74..72a94a57a 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -558,6 +558,13 @@ static int ia32_get_op_estimated_cost(const ir_node *irn) */ static arch_inverse_t *ia32_get_inverse(const ir_node *irn, int i, arch_inverse_t *inverse, struct obstack *obst) { + (void) irn; + (void) i; + (void) inverse; + (void) obst; + return NULL; + +#if 0 ir_mode *mode; ir_mode *irn_mode; ir_node *block, *noreg, *nomem; @@ -670,6 +677,7 @@ static arch_inverse_t *ia32_get_inverse(const ir_node *irn, int i, arch_inverse_ } return inverse; +#endif } static ir_mode *get_spill_mode_mode(const ir_mode *mode) diff --git a/ir/be/ia32/ia32_common_transform.c b/ir/be/ia32/ia32_common_transform.c index 9f3267033..24ee7a71c 100644 --- a/ir/be/ia32/ia32_common_transform.c +++ b/ir/be/ia32/ia32_common_transform.c @@ -869,7 +869,8 @@ ir_node *gen_Proj_tls(ir_node *node) break; #endif - default: panic("invalid transformer"); + default: + panic("invalid transformer"); } res = new_bd_ia32_LdTls(dbgi, block, mode_Iu); @@ -899,7 +900,6 @@ ir_node *gen_Unknown(ir_node *node) } else { panic("unsupported Unknown-Mode"); } - return NULL; } const arch_register_req_t *make_register_req(const constraint_t *constraint, diff --git a/ir/be/ia32/ia32_finish.c b/ir/be/ia32/ia32_finish.c index 011b79663..a0656ee8f 100644 --- a/ir/be/ia32/ia32_finish.c +++ b/ir/be/ia32/ia32_finish.c @@ -240,8 +240,7 @@ static int get_first_same(const arch_register_req_t* req) for (i = 0; i < 32; ++i) { if (other & (1U << i)) return i; } - assert(! "same position not found"); - return 32; + panic("same position not found"); } static inline bool is_unknown_reg(const arch_register_t *reg) diff --git a/ir/be/ia32/ia32_transform.c b/ir/be/ia32/ia32_transform.c index 973e788b1..bdfc06ae7 100644 --- a/ir/be/ia32/ia32_transform.c +++ b/ir/be/ia32/ia32_transform.c @@ -4398,7 +4398,6 @@ static ir_node *gen_ia32_l_FloattoLL(ir_node *node) static ir_node *bad_transform(ir_node *node) { panic("No transform function for %+F available.", node); - return NULL; } static ir_node *gen_Proj_l_FloattoLL(ir_node *node) diff --git a/ir/be/ia32/ia32_x87.c b/ir/be/ia32/ia32_x87.c index 0559658ec..09db9d0bc 100644 --- a/ir/be/ia32/ia32_x87.c +++ b/ir/be/ia32/ia32_x87.c @@ -1834,7 +1834,6 @@ static int sim_Copy(x87_state *state, ir_node *n) const arch_register_t *op1; const arch_register_class_t *cls; ir_node *node, *next; - ia32_x87_attr_t *attr; int op1_idx, out_idx; unsigned live; @@ -1898,10 +1897,12 @@ static int sim_Copy(x87_state *state, ir_node *n) if (out_idx >= 0 && out_idx != op1_idx) { /* Matze: out already on stack? how can this happen? */ - assert(0); + panic("invalid stack state in x87 simulator"); +#if 0 /* op1 must be killed and placed where out is */ if (out_idx == 0) { + ia32_x87_attr_t *attr; /* best case, simple remove and rename */ x87_patch_insn(n, op_ia32_Pop); attr = get_ia32_x87_attr(n); @@ -1910,6 +1911,7 @@ static int sim_Copy(x87_state *state, ir_node *n) x87_pop(state); x87_set_st(state, arch_register_get_index(out), n, op1_idx - 1); } else { + ia32_x87_attr_t *attr; /* move op1 to tos, store and pop it */ if (op1_idx != 0) { x87_create_fxch(state, n, op1_idx); @@ -1923,6 +1925,7 @@ static int sim_Copy(x87_state *state, ir_node *n) x87_set_st(state, arch_register_get_index(out), n, out_idx - 1); } DB((dbg, LEVEL_1, "<<< %+F %s\n", n, op1->name)); +#endif } else { /* just a virtual copy */ x87_set_st(state, arch_register_get_index(out), get_unop_op(n), op1_idx); @@ -2007,34 +2010,6 @@ end_call: return NO_NODE_ADDED; } /* sim_Call */ -/** - * Simulate a be_Spill. - * - * @param state the x87 state - * @param n the node that should be simulated (and patched) - * - * Should not happen, spills are lowered before x87 simulator see them. - */ -static int sim_Spill(x87_state *state, ir_node *n) -{ - panic("Spill not lowered before x87 simulator run"); - return sim_fst(state, n); -} /* sim_Spill */ - -/** - * Simulate a be_Reload. - * - * @param state the x87 state - * @param n the node that should be simulated (and patched) - * - * Should not happen, reloads are lowered before x87 simulator see them. - */ -static int sim_Reload(x87_state *state, ir_node *n) -{ - panic("Reload not lowered before x87 simulator run"); - return sim_fld(state, n); -} /* sim_Reload */ - /** * Simulate a be_Return. * @@ -2432,8 +2407,6 @@ static void x87_init_simulator(x87_simulator *sim, ir_graph *irg) register_sim(op_ia32_vFucomFnstsw, sim_Fucom); register_sim(op_ia32_vFucomi, sim_Fucom); register_sim(op_be_Copy, sim_Copy); - register_sim(op_be_Spill, sim_Spill); - register_sim(op_be_Reload, sim_Reload); register_sim(op_be_Return, sim_Return); register_sim(op_be_Perm, sim_Perm); register_sim(op_be_Keep, sim_Keep); diff --git a/ir/be/mips/bearch_mips.c b/ir/be/mips/bearch_mips.c index c53821e9a..37904da7b 100644 --- a/ir/be/mips/bearch_mips.c +++ b/ir/be/mips/bearch_mips.c @@ -424,7 +424,6 @@ static const arch_register_t *mips_abi_prologue(void *self, ir_node** mem, pmap sp = new_bd_mips_addu(NULL, block, sp, mips_create_Immediate(initialstackframesize)); arch_set_irn_register(sp, &mips_gp_regs[REG_SP]); - panic("FIXME Use IncSP or set register requirement with ignore"); /* TODO: where to get an edge with a0-a3 int i; @@ -462,7 +461,6 @@ static const arch_register_t *mips_abi_prologue(void *self, ir_node** mem, pmap sp = new_bd_mips_addu(NULL, block, sp, mips_create_Immediate(-initialstackframesize)); arch_set_irn_register(sp, &mips_gp_regs[REG_SP]); - panic("FIXME Use IncSP or set register requirement with ignore"); reg = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_FP]); store = new_bd_mips_sw(NULL, block, sp, reg, *mem, NULL, 0); @@ -474,7 +472,6 @@ static const arch_register_t *mips_abi_prologue(void *self, ir_node** mem, pmap fp = new_bd_mips_addu(NULL, block, sp, mips_create_Immediate(-initialstackframesize)); arch_set_irn_register(fp, &mips_gp_regs[REG_FP]); - panic("FIXME Use IncSP or set register requirement with ignore"); be_abi_reg_map_set(reg_map, &mips_gp_regs[REG_FP], fp); be_abi_reg_map_set(reg_map, &mips_gp_regs[REG_SP], sp); @@ -495,12 +492,10 @@ static void mips_abi_epilogue(void *self, ir_node *block, ir_node **mem, pmap *r // copy fp to sp sp = new_bd_mips_or(NULL, block, fp, mips_create_zero()); arch_set_irn_register(sp, &mips_gp_regs[REG_SP]); - panic("FIXME Use be_Copy or set register requirement with ignore"); // 1. restore fp load = new_bd_mips_lw(NULL, block, sp, *mem, NULL, fp_save_offset - initial_frame_size); - panic("FIXME register requirement with ignore"); fp = new_r_Proj(load, mode_Iu, pn_mips_lw_res); *mem = new_r_Proj(load, mode_Iu, pn_mips_lw_M); diff --git a/ir/be/ppc32/bearch_ppc32.c b/ir/be/ppc32/bearch_ppc32.c index 0972131f2..5d3c70d45 100644 --- a/ir/be/ppc32/bearch_ppc32.c +++ b/ir/be/ppc32/bearch_ppc32.c @@ -738,7 +738,6 @@ static const be_execution_unit_t ***ppc32_get_allowed_execution_units(const ir_n (void) irn; /* TODO */ panic("Unimplemented ppc32_get_allowed_execution_units()"); - return NULL; } static const be_machine_t *ppc32_get_machine(const void *self) @@ -746,7 +745,6 @@ static const be_machine_t *ppc32_get_machine(const void *self) (void) self; /* TODO */ panic("Unimplemented ppc32_get_machine()"); - return NULL; } /** diff --git a/ir/be/ppc32/ppc32_emitter.c b/ir/be/ppc32/ppc32_emitter.c index faa0e343c..92be552bb 100644 --- a/ir/be/ppc32/ppc32_emitter.c +++ b/ir/be/ppc32/ppc32_emitter.c @@ -403,7 +403,6 @@ static void emit_be_Copy(const ir_node *irn) } else if (regclass == &ppc32_reg_classes[CLASS_ppc32_condition]) { be_emit_cstring("\tmcrf "); } else { - assert(0 && "Illegal register class for Copy"); panic("ppc32 Emitter: Illegal register class for Copy"); } ppc32_emit_dest_register(irn, 0); @@ -483,7 +482,6 @@ static void emit_be_Perm(const ir_node *irn) ppc32_emit_source_register(irn, 1); be_emit_cstring(", cr7"); } else { - assert(0 && "Illegal register class for Perm"); panic("ppc32 Emitter: Illegal register class for Perm"); } be_emit_finish_line_gas(irn); diff --git a/ir/be/ppc32/ppc32_transform.c b/ir/be/ppc32/ppc32_transform.c index 773c53311..982a88353 100644 --- a/ir/be/ppc32/ppc32_transform.c +++ b/ir/be/ppc32/ppc32_transform.c @@ -563,10 +563,7 @@ static ir_node *gen_Mod(ppc32_transform_env_t *env) break; default: - fprintf(stderr, "Mode for Mod not supported: %s\n", get_mode_name(res_mode)); - assert(0); - return NULL; - + panic("Mode for Mod not supported: %s\n", get_mode_name(res_mode)); } proj_div = new_rd_Proj(env->dbg, div_result, res_mode, pn_DivMod_res_div); @@ -914,7 +911,6 @@ static ir_node *gen_Abs(ppc32_transform_env_t *env) break; } panic("Mode for Abs not supported: %F", env->mode); - return NULL; } /** diff --git a/ir/be/sparc/bearch_sparc.c b/ir/be/sparc/bearch_sparc.c index e2ce5af7d..210cbc3a4 100644 --- a/ir/be/sparc/bearch_sparc.c +++ b/ir/be/sparc/bearch_sparc.c @@ -623,16 +623,14 @@ static const be_execution_unit_t ***sparc_get_allowed_execution_units( { (void) irn; /* TODO */ - assert(0); - return NULL; + panic("sparc_get_allowed_execution_units not implemented yet"); } static const be_machine_t *sparc_get_machine(const void *self) { (void) self; /* TODO */ - assert(0); - return NULL; + panic("sparc_get_machine not implemented yet"); } static ir_graph **sparc_get_backend_irg_list(const void *self, diff --git a/ir/be/sparc/sparc_emitter.c b/ir/be/sparc/sparc_emitter.c index ccc384a19..53585b176 100644 --- a/ir/be/sparc/sparc_emitter.c +++ b/ir/be/sparc/sparc_emitter.c @@ -472,7 +472,6 @@ static void emit_be_Copy(const ir_node *irn) sparc_emit_dest_register(irn, 0); be_emit_finish_line_gas(irn); } else { - assert(0 && "move not supported for this mode"); panic("emit_be_Copy: move not supported for this mode"); } } diff --git a/ir/debug/dbginfo.c b/ir/debug/dbginfo.c index 08591d14f..a4fd57cac 100644 --- a/ir/debug/dbginfo.c +++ b/ir/debug/dbginfo.c @@ -30,6 +30,7 @@ #include "irnode_t.h" #include "type_t.h" #include "entity_t.h" +#include "error.h" merge_pair_func *__dbg_info_merge_pair = default_dbg_info_merge_pair; merge_sets_func *__dbg_info_merge_sets = default_dbg_info_merge_sets; @@ -72,8 +73,7 @@ const char *dbg_action_2_str(dbg_action a) if (a <= dbg_max) return "string conversion not implemented"; else - assert(!"Missing debug action in dbg_action_2_str()"); - return NULL; + panic("Missing debug action in dbg_action_2_str()"); } #undef CASE } diff --git a/ir/ir/irarch.c b/ir/ir/irarch.c index 47b1b2b76..c08f3ab1b 100644 --- a/ir/ir/irarch.c +++ b/ir/ir/irarch.c @@ -480,7 +480,6 @@ static ir_node *build_graph(mul_env *env, instruction *inst) return inst->irn = new_Const(get_mode_null(env->mode)); default: panic("Unsupported instruction kind"); - return NULL; } } diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 0e2c5a863..413abf441 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -42,6 +42,7 @@ #include "irflag_t.h" #include "iredges_t.h" #include "irflag_t.h" +#include "error.h" /* when we need verifying */ #ifdef NDEBUG @@ -916,8 +917,7 @@ static int is_exception_flow(ir_node *cf_pred, ir_node *prev_cf_op) return 1; } /* Hmm, exception but not a Proj? */ - assert(!"unexpected condition: fragile op without a proj"); - return 1; + panic("unexpected condition: fragile op without a proj"); } return 0; } /* is_exception_flow */ diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 48bf349d5..24f136e7f 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -804,12 +804,14 @@ int dump_node_opcode(FILE *F, ir_node *n) } break; +#ifdef INTERPROCEDURAL_VIEW case iro_Filter: if (!get_interprocedural_view()) fprintf(F, "Proj'"); else goto default_case; break; +#endif case iro_Proj: { ir_node *pred = get_Proj_pred(n); @@ -821,6 +823,8 @@ int dump_node_opcode(FILE *F, ir_node *n) else goto default_case; } break; + +#ifdef INTERPROCEDURAL_VIEW case iro_Start: case iro_End: case iro_EndExcept: @@ -830,6 +834,7 @@ int dump_node_opcode(FILE *F, ir_node *n) break; } else goto default_case; +#endif case iro_CallBegin: { ir_node *addr = get_CallBegin_ptr(n); @@ -1134,12 +1139,6 @@ static int dump_node_nodeattr(FILE *F, ir_node *n) return ops->dump_node(n, F, dump_node_nodeattr_txt); switch (get_irn_opcode(n)) { - case iro_Start: - if (0 && get_interprocedural_view()) { - fprintf(F, "%s ", get_ent_dump_name(get_irg_entity(current_ir_graph))); - } - break; - case iro_Const: ir_fprintf(F, "%T ", get_Const_tarval(n)); break; @@ -1147,7 +1146,9 @@ static int dump_node_nodeattr(FILE *F, ir_node *n) case iro_Proj: pred = get_Proj_pred(n); proj_nr = get_Proj_proj(n); +#ifdef INTERPROCEDURAL_VIEW handle_lut: +#endif code = get_irn_opcode(pred); if (code == iro_Cmp) @@ -1183,11 +1184,13 @@ handle_lut: break; case iro_Filter: proj_nr = get_Filter_proj(n); +#ifdef INTERPROCEDURAL_VIEW if (! get_interprocedural_view()) { /* it's a Proj' */ pred = get_Filter_pred(n); goto handle_lut; } else +#endif fprintf(F, "%ld ", proj_nr); break; case iro_Sel: @@ -1643,7 +1646,6 @@ static void print_edge_vcgattr(FILE *F, ir_node *from, int to) static void dump_ir_data_edges(FILE *F, ir_node *n) { int i, num; - ir_visited_t visited = get_irn_visited(n); if (!dump_keepalive && is_End(n)) { /* the End node has only keep-alive edges */ @@ -1677,8 +1679,10 @@ static void dump_ir_data_edges(FILE *F, ir_node *n) ir_node *pred = get_irn_n(n, i); assert(pred); - if ((get_interprocedural_view() && get_irn_visited(pred) < visited)) +#ifdef INTERPROCEDURAL_VIEW + if ((get_interprocedural_view() && get_irn_visited(pred) < get_irn_visited(n))) continue; /* pred not dumped */ +#endif if (dump_backedge_information_flag && is_backedge(n, i)) fprintf(F, "backedge: {sourcename: \""); @@ -2558,9 +2562,12 @@ static void do_dump(ir_graph *irg, const char *suffix, const char *suffix_ip, rem = current_ir_graph; current_ir_graph = irg; + (void) suffix_ip; +#ifdef INTERPROCEDURAL_VIEW if (get_interprocedural_view()) suffix1 = suffix_ip; else +#endif suffix1 = suffix_nonip; current_ir_graph = rem; diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index e61d3b344..685739703 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -95,6 +95,16 @@ static FILE *text_open(const char *basename, const char * suffix1, const char *s return F; } +static inline int is_ip_Filter(ir_node *n) +{ +#ifdef INTERPROCEDURAL_VIEW + return is_Filter(n) && get_interprocedural_view(); +#else + (void) n; + return 0; +#endif +} + /* Write the irnode and all its attributes to the file passed. */ int dump_irnode_to_file(FILE *F, ir_node *n) { @@ -177,7 +187,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) /* This is not nice, output it as a marker in the predecessor list. */ if (is_Block(n) || get_irn_op(n) == op_Phi || - (is_Filter(n) && get_interprocedural_view())) { + (is_ip_Filter(n))) { fprintf(F, " backedges:"); comma = ' '; for (i = 0; i < get_irn_arity(n); i++) @@ -304,14 +314,18 @@ int dump_irnode_to_file(FILE *F, ir_node *n) ir_fprintf(F, " cast to type: %+F\n", get_Cast_type(n)); } break; case iro_Return: { +#ifdef INTERPROCEDURAL_VIEW if (!get_interprocedural_view()) { +#endif ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n))); ir_fprintf(F, " return in method of type %+F\n", tp); for (i = 0; i < get_method_n_ress(tp); ++i) { ir_fprintf(F, " result %d type: %+F\n", i, get_method_res_type(tp, i)); } +#ifdef INTERPROCEDURAL_VIEW } +#endif } break; case iro_Const: { assert(get_Const_type(n) != firm_none_type); diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index 2f9b1c2a5..a4b8ae50e 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -48,6 +48,7 @@ #include "iredges_t.h" #include "type_t.h" #include "irmemory.h" +#include "irphase.h" #define INITIAL_IDX_IRN_MAP_SIZE 1024 @@ -119,8 +120,7 @@ static ir_graph *alloc_graph(void) { ir_graph *res; size_t size = sizeof(ir_graph) + additional_graph_data_size; - char *ptr = xmalloc(size); - memset(ptr, 0, size); + char *ptr = XMALLOCNZ(char, size); res = (ir_graph *)(ptr + additional_graph_data_size); res->kind = k_ir_graph; @@ -1004,6 +1004,26 @@ void *get_irg_loc_description(ir_graph *irg, int n) return irg->loc_descriptions ? irg->loc_descriptions[n] : NULL; } +void irg_register_phase(ir_graph *irg, ir_phase_id id, ir_phase *phase) +{ + assert(id <= PHASE_LAST); + assert(irg->phases[id] == NULL); + irg->phases[id] = phase; +} + +void irg_invalidate_phases(ir_graph *irg) +{ + int p; + for (p = 0; p <= PHASE_LAST; ++p) { + ir_phase *phase = irg->phases[p]; + if (phase == NULL) + continue; + + phase_free(phase); + irg->phases[p] = NULL; + } +} + #ifndef NDEBUG void ir_reserve_resources(ir_graph *irg, ir_resources_t resources) { diff --git a/ir/ir/irgraph_t.h b/ir/ir/irgraph_t.h index e0ade39da..6640ef2ea 100644 --- a/ir/ir/irgraph_t.h +++ b/ir/ir/irgraph_t.h @@ -527,6 +527,33 @@ static inline void set_irg_anchor(ir_graph *irg, int idx, ir_node *irn) set_irn_n(irg->anchor, idx, irn); } + + +/** + * Register a phase on an irg. + * The phase will then be managed by the irg. This means you can easily + * access the phase when you only have a graph handle, the memory will be + * freed when the graph is freed and some care is taken that the phase data + * will be invalidated/preserved on events like dead code elemination and + * code selection. + */ +void irg_register_phase(ir_graph *irg, ir_phase_id id, ir_phase *phase); + +/** + * Frees all phase infos attached to an irg + */ +void irg_invalidate_phases(ir_graph *irg); + +/** + * return phase with given id + */ +static inline ir_phase *irg_get_phase(const ir_graph *irg, ir_phase_id id) +{ + assert(id <= PHASE_LAST); + return irg->phases[id]; +} + + #ifdef INTERPROCEDURAL_VIEW extern int firm_interprocedural_view; diff --git a/ir/ir/irgwalk.c b/ir/ir/irgwalk.c index 51bf3ec73..6007f9289 100644 --- a/ir/ir/irgwalk.c +++ b/ir/ir/irgwalk.c @@ -430,14 +430,15 @@ void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post, { assert(is_ir_node(node)); +#ifdef INTERPROCEDURAL_VIEW if (get_interprocedural_view()) { - assert(0 && "This is not yet implemented."); - } else { - ir_reserve_resources(current_ir_graph, IR_RESOURCE_IRN_VISITED); - inc_irg_visited(current_ir_graph); - nodes_touched = irg_walk_in_or_dep_2(node, pre, post, env); - ir_free_resources(current_ir_graph, IR_RESOURCE_IRN_VISITED); + panic("This is not yet implemented."); } +#endif + ir_reserve_resources(current_ir_graph, IR_RESOURCE_IRN_VISITED); + inc_irg_visited(current_ir_graph); + nodes_touched = irg_walk_in_or_dep_2(node, pre, post, env); + ir_free_resources(current_ir_graph, IR_RESOURCE_IRN_VISITED); } /* @@ -456,6 +457,7 @@ void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func * /***************************************************************************/ +#ifdef INTERPROCEDURAL_VIEW /** * Returns current_ir_graph and sets it to the irg of predecessor index * of node n. @@ -479,7 +481,6 @@ static inline ir_graph * switch_irg(ir_node *n, int index) return old_current; } -#ifdef INTERPROCEDURAL_VIEW static void cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) { int i; @@ -619,8 +620,10 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void hook_irg_block_walk(irg, node, (generic_func *)pre, (generic_func *)post); assert(node); +#ifdef INTERPROCEDURAL_VIEW assert(!get_interprocedural_view()); /* interprocedural_view not implemented, because it * interleaves with irg_walk */ +#endif ir_reserve_resources(irg, IR_RESOURCE_BLOCK_VISITED); inc_irg_block_visited(irg); block = is_Block(node) ? node : get_nodes_block(node); diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index 41f1de201..bce2fb359 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -347,8 +347,7 @@ ir_mode *new_ir_vector_mode(const char *name, ir_mode_sort sort, int bit_size, u } if (num_of_elem <= 1) { - assert(0 && "vector modes should have at least 2 elements"); - return NULL; + panic("vector modes should have at least 2 elements"); } /* sanity checks */ diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 4d1ef81ee..35eb89858 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -39,6 +39,7 @@ #include "iredgekinds.h" #include "iredges_t.h" #include "ircons.h" +#include "error.h" #include "irhooks.h" #include "irtools.h" @@ -2873,9 +2874,8 @@ ir_node *get_fragile_op_mem(ir_node *node) case iro_Bad : case iro_Unknown: return node; - default: ; - assert(0 && "should not be reached"); - return NULL; + default: + panic("should not be reached"); } } @@ -2887,9 +2887,8 @@ ir_mode *get_divop_resmod(const ir_node *node) case iro_DivMod: return get_DivMod_resmode(node); case iro_Div : return get_Div_resmode(node); case iro_Mod : return get_Mod_resmode(node); - default: ; - assert(0 && "should not be reached"); - return NULL; + default: + panic("should not be reached"); } } diff --git a/ir/ir/irphase.c b/ir/ir/irphase.c index 44e461596..7edb541bc 100644 --- a/ir/ir/irphase.c +++ b/ir/ir/irphase.c @@ -42,57 +42,35 @@ void *phase_irn_init_default(ir_phase *ph, const ir_node *irn, void *old) return NULL; } -ir_phase *init_irg_phase(ir_graph *irg, ir_phase_id id, size_t size, phase_irn_init *data_init) +void phase_init(ir_phase *phase, ir_graph *irg, phase_irn_init *data_init) { - ir_phase *ph; + memset(phase, 0, sizeof(*phase)); - size = MAX(sizeof(*ph), size); - assert(id != PHASE_NOT_IRG_MANAGED && id < PHASE_LAST); - assert(irg->phases[id] == NULL && "you cannot overwrite another irg managed phase"); - - ph = xmalloc(size); - memset(ph, 0, size); - obstack_init(&ph->obst); - ph->id = id; - ph->growth_factor = PHASE_DEFAULT_GROWTH; - ph->data_init = data_init; - ph->irg = irg; - ph->n_data_ptr = 0; - ph->data_ptr = NULL; - - irg->phases[id] = ph; - - return ph; + obstack_init(&phase->obst); + phase->data_init = data_init; + phase->irg = irg; + phase->n_data_ptr = 0; + phase->data_ptr = NULL; } -void free_irg_phase(ir_graph *irg, ir_phase_id id) +ir_phase *new_phase(ir_graph *irg, phase_irn_init *data_init) { - ir_phase *ph = get_irg_phase(irg, id); - phase_free(ph); - xfree(ph); - irg->phases[id] = NULL; + ir_phase *phase = xmalloc(sizeof(*phase)); + phase_init(phase, irg, data_init); + return phase; } -ir_phase *phase_init(ir_phase *ph, const char *name, ir_graph *irg, unsigned growth_factor, phase_irn_init *data_init, void *priv) +void phase_deinit(ir_phase *phase) { - obstack_init(&ph->obst); - - (void) name; - ph->id = PHASE_NOT_IRG_MANAGED; - ph->growth_factor = growth_factor; - ph->data_init = data_init; - ph->irg = irg; - ph->n_data_ptr = 0; - ph->data_ptr = NULL; - ph->priv = priv; - return ph; + obstack_free(&phase->obst, NULL); + if (phase->data_ptr) + xfree(phase->data_ptr); } void phase_free(ir_phase *phase) { - obstack_free(&phase->obst, NULL); - if (phase->data_ptr) - xfree(phase->data_ptr); + phase_deinit(phase); + xfree(phase); } phase_stat_t *phase_stat(const ir_phase *phase, phase_stat_t *stat) diff --git a/ir/ir/irphase.h b/ir/ir/irphase.h new file mode 100644 index 000000000..3b5ba5020 --- /dev/null +++ b/ir/ir/irphase.h @@ -0,0 +1,85 @@ +/* + * 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. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/** + * @file + * @brief Phase information handling using node indexes. + * @author Sebastian Hack + * @version $Id: irphase_t.h 27270 2010-03-07 22:20:43Z matze $ + */ +#ifndef FIRM_IR_PHASE_H +#define FIRM_IR_PHASE_H + +#include "firm_types.h" + +typedef struct ir_phase ir_phase; +typedef void *(phase_irn_init)(ir_phase *phase, const ir_node *irn, void *old); + +/** + * Allocate and initialize a new phase object + * + * @param irg The graph the phase will run on. + * @param irn_data_init A callback that is called to initialize newly created + * node data. Must be non-null. You could use + * @return A new phase object. + */ +ir_phase *new_phase(ir_graph *irg, phase_irn_init *data_init); + +/** + * Variant for custom memory-management/classes. Just initialize given phase + * structure (performs no allocation, you do not need to call this for phases + * allocated wiht new_phase) + */ +void phase_init(ir_phase *phase, ir_graph *irg, phase_irn_init *data_init); + +/** + * frees all internal memory used by the phase but does not free the + * phase struct itself. + */ +void phase_deinit(ir_phase *phase); + +/** + * free memory allocated by a phase + */ +void phase_free(ir_phase *phase); + +/** + * Re-initialize the irn data for all nodes in the node => data map using the given callback. + * + * @param phase The phase. + */ +void phase_reinit_irn_data(ir_phase *phase); + +/** + * Re-initialize the irn data for all nodes having phase data in the given block. + * + * @param phase The phase. + * @param block The block. + * + * @note Beware: iterates over all nodes in the graph to find the nodes of the given block. + */ +void phase_reinit_block_irn_data(ir_phase *phase, ir_node *block); + +/** + * A default node initializer. + * It does nothing and returns NULL. + */ +extern phase_irn_init phase_irn_init_default; + +#endif diff --git a/ir/ir/irphase_t.h b/ir/ir/irphase_t.h index b6f3b5f04..e1abca35a 100644 --- a/ir/ir/irphase_t.h +++ b/ir/ir/irphase_t.h @@ -30,41 +30,20 @@ #include "obst.h" #include "irgraph_t.h" #include "irtools.h" -#include "irphases_t.h" - -struct _ir_phase_info { - ir_phase_id id; - const char buf[128]; -}; - -typedef struct _ir_phase_info ir_phase_info; - -typedef void *(phase_irn_init)(ir_phase *phase, const ir_node *irn, void *old); - -/** - * A default node initializer. - * It does nothing and returns NULL. - */ -extern phase_irn_init phase_irn_init_default; +#include "irphase.h" /** * A phase object. */ -struct _ir_phase { - struct obstack obst; /**< The obstack where the irn phase data will be stored on. */ - ir_phase_id id; /**< The phase ID. */ - const char *name; /**< The name of the phase. */ - ir_graph *irg; /**< The irg this phase will we applied to. */ - unsigned growth_factor; /**< The factor to leave room for additional nodes. 256 means 1.0. */ - void *priv; /**< Some pointer private to the user of the phase. */ - size_t n_data_ptr; /**< The length of the data_ptr array. */ - void **data_ptr; /**< Map node indexes to irn data on the obstack. */ - phase_irn_init *data_init; /**< A callback that is called to initialize newly created node data. */ +struct ir_phase { + void **data_ptr; /**< Map node indexes to irn data on the obstack. */ + ir_graph *irg; /**< The irg this phase will we applied to. */ + phase_irn_init *data_init; /**< A callback that is called to initialize newly created node data. */ + size_t n_data_ptr; /**< The length of the data_ptr array. */ + struct obstack obst; /**< The obstack where the irn phase data will be stored on. */ + void *priv; /**< Some pointer private to the user of the phase. */ }; -#define PHASE_DEFAULT_GROWTH (256) - - /** * For statistics: A type containing statistic data of a phase object. */ @@ -83,62 +62,6 @@ typedef struct { */ phase_stat_t *phase_stat(const ir_phase *phase, phase_stat_t *stat); -/** - * Initialize a phase object. - * - * @param name The name of the phase. Just for debugging. - * @param irg The graph the phase will run on. - * @param growth_factor A factor denoting how many node slots will be additionally allocated, - * if the node => data is full. The factor is given in units of 1/256, so - * 256 means 1.0. - * @param irn_data_init A callback that is called to initialize newly created node data. - * Must be non-null. - * @param priv Some private pointer which is kept in the phase and can be retrieved with phase_get_private(). - * @return A new phase object. - */ -ir_phase *phase_init(ir_phase *ph, const char *name, ir_graph *irg, unsigned growth_factor, phase_irn_init *data_init, void *priv); - -/** - * Init an irg managed phase. - * - * The first sizeof(ir_phase) bytes will be considered to be a phase object; - * they will be properly initialized. The remaining bytes are at the user's disposal. - * The returned phase object will be inserted in the phase slot of the @p irg designated by the phase ID (@p id). - * Note that you cannot allocate phases with an ID PHASE_NOT_IRG_MANAGED. - * - * @param irg The irg. - * @param id The ID of the irg-managed phase (see irphaselist.h). - * @param size The size of the phase - * @param data_init The node data initialization function. - * @return The allocated phase object. - */ -ir_phase *init_irg_phase(ir_graph *irg, ir_phase_id id, size_t size, phase_irn_init *data_init); - -void free_irg_phase(ir_graph *irg, ir_phase_id id); - -/** - * Free the phase and all node data associated with it. - * - * @param phase The phase. - */ -void phase_free(ir_phase *phase); - -/** - * Re-initialize the irn data for all nodes in the node => data map using the given callback. - * - * @param phase The phase. - */ -void phase_reinit_irn_data(ir_phase *phase); - -/** - * Re-initialize the irn data for all nodes having phase data in the given block. - * - * @param phase The phase. - * @param block The block. - * - * @note Beware: iterates over all nodes in the graph to find the nodes of the given block. - */ -void phase_reinit_block_irn_data(ir_phase *phase, ir_node *block); /** * Re-initialize the irn data for the given node. @@ -187,16 +110,6 @@ ir_node *phase_get_next_node(const ir_phase *phase, ir_node *start); #define foreach_phase_irn(phase, irn) \ for (irn = phase_get_first_node(phase); irn; irn = phase_get_next_node(phase, irn)) -/** - * Get the name of the phase. - * - * @param phase The phase. - */ -static inline const char *phase_get_name(const ir_phase *phase) -{ - return phase->name; -} - /** * Get the irg the phase runs on. * @@ -218,11 +131,13 @@ static inline void *phase_get_private(const ir_phase *phase) } /** - * Allocate memory in the phase's memory pool. - * - * @param phase The phase. - * @param size Number of bytes to allocate. + * Attach pointer with private data to phase */ +static inline void phase_set_private(ir_phase *phase, void *priv) +{ + phase->priv = priv; +} + static inline void *phase_alloc(ir_phase *phase, size_t size) { return obstack_alloc(&phase->obst, size); @@ -263,7 +178,7 @@ static inline void private_phase_enlarge(ir_phase *phase, unsigned max_idx) /* make the maximum index at least as big as the largest index in the graph. */ max_idx = MAX(max_idx, last_irg_idx); - new_cap = (size_t) (max_idx * phase->growth_factor / 256); + new_cap = (size_t) (max_idx + 256); phase->data_ptr = XREALLOC(phase->data_ptr, void*, new_cap); @@ -335,22 +250,14 @@ static inline void *phase_set_irn_data(ir_phase *ph, const ir_node *irn, return res; } + /** - * Get the irg-managed phase for a given phase ID. - * @param irg The irg. - * @param id The ID. - * @return The corresponding phase, or NULL if there is none. + * convenience function that returns phase information attached to a node */ -static inline ir_phase *get_irg_phase(const ir_graph *irg, ir_phase_id id) -{ - return irg->phases[id]; -} - static inline void *get_irn_phase_info(const ir_node *irn, ir_phase_id id) { const ir_graph *irg = get_irn_irg(irn); - const ir_phase *ph = get_irg_phase(irg, id); - assert(ph && "phase info has to be computed"); + const ir_phase *ph = irg_get_phase(irg, id); return phase_get_irn_data(ph, irn); } @@ -364,17 +271,18 @@ static inline void *get_irn_phase_info(const ir_node *irn, ir_phase_id id) static inline void *get_or_set_irn_phase_info(const ir_node *irn, ir_phase_id id) { const ir_graph *irg = get_irn_irg(irn); - ir_phase *ph = get_irg_phase(irg, id); - assert(ph && "phase info has to be computed"); + ir_phase *ph = irg_get_phase(irg, id); return phase_get_or_set_irn_data(ph, irn); } static inline void *set_irn_phase_info(const ir_node *irn, ir_phase_id id, void *data) { const ir_graph *irg = get_irn_irg(irn); - ir_phase *ph = get_irg_phase(irg, id); - assert(ph && "phase info has to be computed"); + ir_phase *ph = irg_get_phase(irg, id); return phase_set_irn_data(ph, irn, data); } + + + #endif diff --git a/ir/ir/irphaselist.h b/ir/ir/irphaselist.h deleted file mode 100644 index 732765902..000000000 --- a/ir/ir/irphaselist.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Do not delete! */ -PH(NOT_IRG_MANAGED, "A phase not managed by an IRG") - -/* BEGIN Enter your phases here */ -/* The name of the phase, A description */ - -PH(BE_ARCH, "Backend architecture abstraction") -PH(BE_SCHED, "Scheduler") -PH(BE_REG_ALLOC, "Register allocation") -PH(VRP, "Value Range Propagation") - -/* END Enter your phases here */ - -/* Do not delete! */ -PH(LAST, "The last phase") diff --git a/ir/ir/irphases_t.h b/ir/ir/irphases_t.h deleted file mode 100644 index 584985357..000000000 --- a/ir/ir/irphases_t.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file irphases_t.h - * @date 18.11.2007 - * @author Sebastian Hack - * - * Copyright (C) 2007 Inria Rhone-Alpes - * Released under the GPL - */ - -#ifndef _IRPHASES_T_H -#define _IRPHASES_T_H - -enum _ir_phase_id { -#define PH(name, description) PHASE_ ## name, -#include "irphaselist.h" -#undef PH -}; - -typedef enum _ir_phase_id ir_phase_id; - -#endif /* _IRPHASES_T_H */ diff --git a/ir/ir/irtypes.h b/ir/ir/irtypes.h index b78cdd9d7..55c6b0ebe 100644 --- a/ir/ir/irtypes.h +++ b/ir/ir/irtypes.h @@ -39,7 +39,7 @@ #include "callgraph.h" #include "irprog.h" #include "field_temperature.h" -#include "irphases_t.h" +#include "irphase.h" #include "pset.h" #include "set.h" @@ -47,6 +47,15 @@ #include "obst.h" #include "vrp.h" +/** + * List of phases. (We will add a register/unregister interface if managing + * this gets too tedious) + */ +typedef enum ir_phase_id { + PHASE_VRP, + PHASE_LAST = PHASE_VRP +} ir_phase_id; + /** The type of an ir_op. */ struct ir_op { unsigned code; /**< The unique opcode of the op. */ @@ -508,7 +517,7 @@ struct ir_graph { ir_node **idx_irn_map; /**< Array mapping node indexes to nodes. */ int index; /**< a unique number for each graph */ - ir_phase *phases[PHASE_LAST]; /**< Phase information. */ + ir_phase *phases[PHASE_LAST+1]; /**< Phase information. */ void *be_data; /**< backend can put in private data here */ #ifdef DEBUG_libfirm int n_outs; /**< Size wasted for outs */ diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index a1abfb624..3fd3800c0 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -423,10 +423,6 @@ static int verify_node_Proj_Call(ir_node *n, ir_node *p) ASSERT_AND_RET( !is_NoMem(get_Call_mem(n)), "Exception Proj from FunctionCall", 0); - else if (proj == pn_Call_M) - ASSERT_AND_RET( - (!is_NoMem(get_Call_mem(n)) || 1), - "Memory Proj from FunctionCall", 0); return 1; } @@ -918,7 +914,7 @@ static int verify_node_Block(ir_node *n, ir_graph *irg) } for (i = get_Block_n_cfgpreds(n) - 1; i >= 0; --i) { - ir_node *pred = get_Block_cfgpred(n, i); + ir_node *pred = get_Block_cfgpred(n, i); ASSERT_AND_RET( is_Bad(pred) || (get_irn_mode(pred) == mode_X), "Block node must have a mode_X predecessor", 0); @@ -940,9 +936,7 @@ static int verify_node_Block(ir_node *n, ir_graph *irg) "End Block node", 0); } /* irg attr must == graph we are in. */ - if (! get_interprocedural_view()) { - ASSERT_AND_RET(((get_irn_irg(n) && get_irn_irg(n) == irg)), "Block node has wrong irg attribute", 0); - } + ASSERT_AND_RET(((get_irn_irg(n) && get_irn_irg(n) == irg)), "Block node has wrong irg attribute", 0); return 1; } @@ -2002,28 +1996,27 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) if (!get_node_verification_mode()) return 1; - if (!get_interprocedural_view()) { - /* - * do NOT check placement in interprocedural view, as we don't always know - * the "right" graph ... - */ + /* + * do NOT check placement in interprocedural view, as we don't always + * know the "right" graph ... + */ #ifndef NDEBUG - /* this seems to be an expensive check in VS compile (9% over all runtime), - so do NOT run it in release mode */ - ASSERT_AND_RET_DBG( - node_is_in_irgs_storage(irg, n), - "Node is not stored on proper IR graph!", 0, - show_node_on_graph(irg, n); - ); + /* this is an expensive check for large graphs (it has a quadratic + * runtime but with a small constant); so do NOT run it in release mode + */ + ASSERT_AND_RET_DBG( + node_is_in_irgs_storage(irg, n), + "Node is not stored on proper IR graph!", 0, + show_node_on_graph(irg, n); + ); #endif - assert(get_irn_irg(n) == irg); - { - unsigned idx = get_irn_idx(n); - ir_node *node_from_map = get_idx_irn(irg, idx); - ASSERT_AND_RET_DBG(node_from_map == n, "Node index and index map entry differ", 0, - ir_printf("node %+F node in map %+F(%p)\n", n, node_from_map, node_from_map)); - } + assert(get_irn_irg(n) == irg); + { + unsigned idx = get_irn_idx(n); + ir_node *node_from_map = get_idx_irn(irg, idx); + ASSERT_AND_RET_DBG(node_from_map == n, "Node index and index map entry differ", 0, + ir_printf("node %+F node in map %+F(%p)\n", n, node_from_map, node_from_map)); } op = get_irn_op(n); diff --git a/ir/opt/dead_code_elimination.c b/ir/opt/dead_code_elimination.c index 924ff3cd4..87556535a 100644 --- a/ir/opt/dead_code_elimination.c +++ b/ir/opt/dead_code_elimination.c @@ -70,8 +70,8 @@ static void copy_node_dce(ir_node *node, void *env) new_node->node_nr = node->node_nr; /* copy phase information for this node */ - for (i = PHASE_NOT_IRG_MANAGED+1; i < PHASE_LAST; i++) { - ir_phase *phase = get_irg_phase(irg, i); + for (i = 0; i <= PHASE_LAST; i++) { + ir_phase *phase = irg_get_phase(irg, i); if (phase == NULL) continue; if (!phase_get_irn_data(phase, node)) @@ -94,18 +94,19 @@ static void copy_node_dce(ir_node *node, void *env) */ static void copy_graph_env(ir_graph *irg) { - ir_node *new_anchor; + ir_node *new_anchor; int i; /* init the new_phases array */ - for (i = PHASE_NOT_IRG_MANAGED+1; i < PHASE_LAST; i++) { - ir_phase *old_ph = get_irg_phase(irg, i); + /* TODO: this is wrong, it should only allocate a new data_ptr inside + * the phase! */ + for (i = 0; i <= PHASE_LAST; i++) { + ir_phase *old_ph = irg_get_phase(irg, i); if (old_ph == NULL) { new_phases[i] = NULL; } else { - new_phases[i] = xmalloc(sizeof(ir_phase)); - phase_init(new_phases[i], "", irg, old_ph->growth_factor, - old_ph->data_init, old_ph->priv); + new_phases[i] = new_phase(irg, old_ph->data_init); + new_phases[i]->priv = old_ph->priv; } } @@ -118,12 +119,12 @@ static void copy_graph_env(ir_graph *irg) irg->anchor = new_anchor; /* copy the new phases into the irg */ - for (i = PHASE_NOT_IRG_MANAGED+1; i < PHASE_LAST; i++) { - ir_phase *old_ph = get_irg_phase(irg, i); + for (i = 0; i <= PHASE_LAST; i++) { + ir_phase *old_ph = irg_get_phase(irg, i); if (old_ph == NULL) continue; - free_irg_phase(irg, i); + phase_free(old_ph); irg->phases[i] = new_phases[i]; } } diff --git a/ir/opt/escape_ana.c b/ir/opt/escape_ana.c index 8c3d0f816..6f4acd963 100644 --- a/ir/opt/escape_ana.c +++ b/ir/opt/escape_ana.c @@ -47,6 +47,7 @@ #include "ircons.h" #include "irprintf.h" #include "debug.h" +#include "error.h" /** * walker environment @@ -91,16 +92,14 @@ static int is_method_leaving_raise(ir_node *raise) /* Hmm: no ProjX from a Raise? This should be a verification * error. For now we just assert and return. */ - assert(! "No ProjX after Raise found"); - return 1; + panic("No ProjX after Raise found"); } if (get_irn_n_outs(proj) != 1) { /* Hmm: more than one user of ProjX: This is a verification * error. */ - assert(! "More than one user of ProjX"); - return 1; + panic("More than one user of ProjX"); } n = get_irn_out(proj, 0); diff --git a/ir/opt/ldstopt.c b/ir/opt/ldstopt.c index 7ac484a57..8e703d150 100644 --- a/ir/opt/ldstopt.c +++ b/ir/opt/ldstopt.c @@ -2231,13 +2231,13 @@ static int optimize_loops(ir_graph *irg) env.nextDFSnum = 0; env.POnum = 0; env.changes = 0; - phase_init(&env.ph, "ldstopt", irg, PHASE_DEFAULT_GROWTH, init_loop_data, NULL); + phase_init(&env.ph, irg, init_loop_data); /* calculate the SCC's and drive loop optimization. */ do_dfs(irg, &env); DEL_ARR_F(env.stack); - phase_free(&env.ph); + phase_deinit(&env.ph); return env.changes; } /* optimize_loops */ diff --git a/ir/opt/opt_osr.c b/ir/opt/opt_osr.c index 63b4c327c..e30307248 100644 --- a/ir/opt/opt_osr.c +++ b/ir/opt/opt_osr.c @@ -330,7 +330,6 @@ static ir_node *do_apply(ir_opcode code, dbg_info *db, ir_node *op1, ir_node *op break; default: panic("Unsupported opcode"); - result = NULL; } return result; } /* do_apply */ @@ -1159,7 +1158,6 @@ static ir_node *applyOneEdge(ir_node *iv, ir_node *rc, LFTR_edge *e, iv_env *env break; default: panic("Unsupported opcode"); - tv = tarval_bad; } if (pscc->code == iro_Add) { diff --git a/ir/stat/pattern.c b/ir/stat/pattern.c index 564213dca..d116f2ddc 100644 --- a/ir/stat/pattern.c +++ b/ir/stat/pattern.c @@ -39,6 +39,7 @@ #include "counter.h" #include "pattern_dmp.h" #include "hashptr.h" +#include "error.h" #ifdef FIRM_STATISTICS @@ -331,9 +332,7 @@ static unsigned get_code(CODE_BUFFER *buf) return code; } /* if */ /* should not happen */ - assert(0 && "Wrong code in buffer"); - - return 0; + panic("Wrong code in buffer"); } /* get_code */ /** diff --git a/ir/tr/entity.c b/ir/tr/entity.c index dddb2d19d..65af77b8f 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -609,9 +609,7 @@ ir_node *copy_const_value(dbg_info *dbg, ir_node *n) case iro_Unknown: nn = new_Unknown(m); break; default: - assert(0 && "opcode invalid or not implemented"); - nn = NULL; - break; + panic("opcode invalid or not implemented"); } return nn; } /* copy_const_value */ diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c index 2a8687550..893b93079 100644 --- a/ir/tv/fltcalc.c +++ b/ir/tv/fltcalc.c @@ -28,6 +28,7 @@ #include "fltcalc.h" #include "strcalc.h" +#include "error.h" #include /* undef some reused constants defined by math.h */ @@ -1547,10 +1548,7 @@ fp_value *fc_rnd(const fp_value *a, fp_value *result) TRACEPRINTF(("%s ", fc_print(a, buffer, sizeof(buffer), FC_PACKED))); TRACEPRINTF(("rounded to integer ")); - assert(!"fc_rnd() not yet implemented"); - - TRACEPRINTF(("= %s\n", fc_print(result, buffer, sizeof(buffer), FC_PACKED))); - return result; + panic("fc_rnd() not yet implemented"); } /* diff --git a/ir/tv/tv.c b/ir/tv/tv.c index afb06da9b..bf320318b 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -59,12 +59,12 @@ #define N_CONSTANTS 2048 /* unused, float to int doesn't work yet */ -enum float_to_int_mode { +typedef enum float_to_int_mode { TRUNCATE, ROUND -}; +} float_to_int_mode; -#define GET_FLOAT_TO_INT_MODE() TRUNCATE +static float_to_int_mode current_float_to_int_mode = TRUNCATE; #define SWITCH_NOINFINITY 0 #define SWITCH_NODENORMALS 0 @@ -268,15 +268,19 @@ static tarval *get_tarval_overflow(const void *value, int length, ir_mode *mode) break; case irms_float_number: - if (SWITCH_NOINFINITY && fc_is_inf(value)) { +#ifdef SWITCH_NOINFINITY + if (fc_is_inf(value)) { /* clip infinity to maximum value */ return fc_is_negative(value) ? get_mode_min(mode) : get_mode_max(mode); } +#endif - if (SWITCH_NODENORMALS && fc_is_subnormal(value)) { +#ifdef SWITCH_NODENORMALS + if (fc_is_subnormal(value)) { /* clip denormals to zero */ return get_mode_null(mode); } +#endif break; default: @@ -314,7 +318,6 @@ static const ieee_descriptor_t *get_descriptor(const ir_mode *mode) /* case 128: return &quad_desc; */ default: panic("Unsupported mode in get_descriptor()"); - return NULL; } } @@ -448,9 +451,8 @@ tarval *new_tarval_from_long(long l, ir_mode *mode) return new_tarval_from_double((long double)l, mode); default: - assert(0 && "unsupported mode sort"); + panic("unsupported mode sort"); } - return NULL; } /* returns non-zero if can be converted to long */ @@ -852,7 +854,6 @@ pn_Cmp tarval_cmp(tarval *a, tarval *b) if (a == tarval_bad || b == tarval_bad) { panic("Comparison with tarval_bad"); - return pn_Cmp_False; } if (a == tarval_undefined || b == tarval_undefined) @@ -863,7 +864,7 @@ pn_Cmp tarval_cmp(tarval *a, tarval *b) if (get_mode_n_vector_elems(a->mode) > 1) { /* vector arithmetic not implemented yet */ - assert(0 && "cmp not implemented for vector modes"); + panic("cmp not implemented for vector modes"); } /* Here the two tarvals are unequal and of the same mode */ @@ -942,16 +943,13 @@ tarval *tarval_convert_to(tarval *src, ir_mode *dst_mode) return get_tarval(fc_get_buffer(), fc_get_buffer_length(), dst_mode); case irms_int_number: - switch (GET_FLOAT_TO_INT_MODE()) { + switch (current_float_to_int_mode) { case TRUNCATE: res = fc_int(src->value, NULL); break; case ROUND: res = fc_rnd(src->value, NULL); break; - default: - panic("Unsupported float to int conversion mode in tarval_convert_to()"); - break; } buffer = alloca(sc_get_buffer_length()); if (! fc_flt2int(res, buffer, dst_mode)) @@ -1044,8 +1042,7 @@ tarval *tarval_not(tarval *a) return tarval_bad; default: - assert(0 && "bitwise negation is only allowed for integer and boolean"); - return tarval_bad; + panic("bitwise negation is only allowed for integer and boolean"); } } @@ -1336,7 +1333,7 @@ tarval *tarval_abs(tarval *a) return a; default: - return tarval_bad; + break; } return tarval_bad; } @@ -1360,8 +1357,7 @@ tarval *tarval_and(tarval *a, tarval *b) return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode); default: - assert(0 && "operation not defined on mode"); - return tarval_bad; + panic("operation not defined on mode"); } } @@ -1381,8 +1377,7 @@ tarval *tarval_andnot(tarval *a, tarval *b) return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode); default: - assert(0 && "operation not defined on mode"); - return tarval_bad; + panic("operation not defined on mode"); } } @@ -1405,8 +1400,7 @@ tarval *tarval_or(tarval *a, tarval *b) return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode); default: - assert(0 && "operation not defined on mode"); - return tarval_bad; + panic("operation not defined on mode"); } } @@ -1429,8 +1423,7 @@ tarval *tarval_eor(tarval *a, tarval *b) return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode); default: - assert(0 && "operation not defined on mode"); - return tarval_bad;; + panic("operation not defined on mode"); } } -- 2.20.1