- fix most of the -Wunreachable-code and -Wlogical-op warnings
authorMatthias Braun <matze@braunis.de>
Wed, 10 Mar 2010 17:25:21 +0000 (17:25 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 10 Mar 2010 17:25:21 +0000 (17:25 +0000)
- rework ir_phase API
(sorry for mixing these 2 things into 1 commit)

[r27285]

70 files changed:
include/libfirm/firm_types.h
include/libfirm/iredges.h
include/libfirm/irgraph.h
ir/adt/pqueue.c
ir/ana/execution_frequency.c
ir/ana/height.c
ir/ana/irbackedge.c
ir/ana/ircfscc.c
ir/ana/irlivechk.c
ir/ana/irloop.c
ir/ana/irmemory.c
ir/ana/irscc.c
ir/ana/vrp.c
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/arm/arm_emitter.c
ir/be/arm/arm_transform.c
ir/be/beabi.c
ir/be/beblocksched.c
ir/be/becopyheur2.c
ir/be/becopyheur4.c
ir/be/beifg.c
ir/be/beifg_pointer.c
ir/be/beilpsched.c
ir/be/belive.c
ir/be/bemain.c
ir/be/beschedmris.c
ir/be/beschedrss.c
ir/be/bespillbelady2.c
ir/be/betranshlp.c
ir/be/beuses.c
ir/be/beutil.c
ir/be/beutil.h
ir/be/beverify.c
ir/be/beverify.h
ir/be/ia32/bearch_ia32.c
ir/be/ia32/ia32_common_transform.c
ir/be/ia32/ia32_finish.c
ir/be/ia32/ia32_transform.c
ir/be/ia32/ia32_x87.c
ir/be/mips/bearch_mips.c
ir/be/ppc32/bearch_ppc32.c
ir/be/ppc32/ppc32_emitter.c
ir/be/ppc32/ppc32_transform.c
ir/be/sparc/bearch_sparc.c
ir/be/sparc/sparc_emitter.c
ir/debug/dbginfo.c
ir/ir/irarch.c
ir/ir/ircons.c
ir/ir/irdump.c
ir/ir/irdumptxt.c
ir/ir/irgraph.c
ir/ir/irgraph_t.h
ir/ir/irgwalk.c
ir/ir/irmode.c
ir/ir/irnode.c
ir/ir/irphase.c
ir/ir/irphase.h [new file with mode: 0644]
ir/ir/irphase_t.h
ir/ir/irphaselist.h [deleted file]
ir/ir/irphases_t.h [deleted file]
ir/ir/irtypes.h
ir/ir/irvrfy.c
ir/opt/dead_code_elimination.c
ir/opt/escape_ana.c
ir/opt/ldstopt.c
ir/opt/opt_osr.c
ir/stat/pattern.c
ir/tr/entity.c
ir/tv/fltcalc.c
ir/tv/tv.c

index 16da478..f3ef935 100644 (file)
@@ -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;
index 4e51f37..8762228 100644 (file)
@@ -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
index 53a284b..8307504 100644 (file)
@@ -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
 
 /**
index 3fd6a6f..0a7702c 100644 (file)
@@ -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;
index 844ab6a..8765c71 100644 (file)
@@ -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 */
index c45f159..2cebd57 100644 (file)
@@ -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);
 }
index b5f37b0..5cad71d 100644 (file)
@@ -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)
index afb1cda..b112bd2 100644 (file)
@@ -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;
index fc2a1b2..0fa2a27 100644 (file)
@@ -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);
 }
 
index 1722d48..dd2fc3d 100644 (file)
 
 #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);
index c401848..8f30cbd 100644 (file)
@@ -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
 }
index 95a992d..4a360ef 100644 (file)
@@ -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;
index e43af90..a54bb80 100644 (file)
@@ -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);
 }
index 667a082..e4ba0d2 100644 (file)
@@ -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;
 }
 
index 847bd51..4bf4491 100644 (file)
@@ -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");
        }
 }
index 3395891..62e1233 100644 (file)
@@ -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,
index 2daec1f..f5d83b0 100644 (file)
@@ -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. */
index 801db20..ecf3884 100644 (file)
@@ -758,5 +758,4 @@ ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs)
        }
 
        panic("unknown blocksched algo");
-       return NULL;
 }
index 322d03d..b5b62d5 100644 (file)
@@ -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;
 }
 
index ece1314..b266159 100644 (file)
@@ -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");
index 2a3a5e5..3057287 100644 (file)
@@ -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);
index 48e8aa2..55c76b7 100644 (file)
@@ -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);
index 2324ef8..d083788 100644 (file)
@@ -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 */
index 1cf291f..9977460 100644 (file)
@@ -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);
index 1e2fd19..4af25ed 100644 (file)
@@ -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)
index 82f1513..3891b53 100644 (file)
@@ -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);
 }
index ca23f2d..b04586f 100644 (file)
@@ -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);
index 9216650..4b2386f 100644 (file)
@@ -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);
index 04a8c5f..9da59a9 100644 (file)
@@ -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... */
index 2ad2399..5b9375f 100644 (file)
@@ -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)
index 621da7d..6e6abf2 100644 (file)
@@ -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);
+}
index 72a81fa..0dcd29b 100644 (file)
@@ -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
index 1163528..436af83 100644 (file)
@@ -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;
-}
index 180ad5a..8117f5f 100644 (file)
@@ -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
index 4ff347a..72a94a5 100644 (file)
@@ -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)
index 9f32670..24ee7a7 100644 (file)
@@ -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,
index 011b796..a0656ee 100644 (file)
@@ -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)
index 973e788..bdfc06a 100644 (file)
@@ -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)
index 0559658..09db9d0 100644 (file)
@@ -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);
index c53821e..37904da 100644 (file)
@@ -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);
index 0972131..5d3c70d 100644 (file)
@@ -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;
 }
 
 /**
index faa0e34..92be552 100644 (file)
@@ -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);
index 773c533..982a883 100644 (file)
@@ -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;
 }
 
 /**
index e2ce5af..210cbc3 100644 (file)
@@ -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,
index ccc384a..53585b1 100644 (file)
@@ -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");
        }
 }
index 08591d1..a4fd57c 100644 (file)
@@ -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
 }
index 47b1b2b..c08f3ab 100644 (file)
@@ -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;
        }
 }
 
index 0e2c5a8..413abf4 100644 (file)
@@ -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 */
index 48bf349..24f136e 100644 (file)
@@ -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;
 
index e61d3b3..6857397 100644 (file)
@@ -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);
index 2f9b1c2..a4b8ae5 100644 (file)
@@ -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)
 {
index e0ade39..6640ef2 100644 (file)
@@ -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;
 
index 51bf3ec..6007f92 100644 (file)
@@ -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);
index 41f1de2..bce2fb3 100644 (file)
@@ -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 */
index 4d1ef81..35eb898 100644 (file)
@@ -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");
        }
 }
 
index 44e4615..7edb541 100644 (file)
@@ -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 (file)
index 0000000..3b5ba50
--- /dev/null
@@ -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
index b6f3b5f..e1abca3 100644 (file)
 #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 <code>PHASE_NOT_IRG_MANAGED</code>.
- *
- * @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 (file)
index 7327659..0000000
+++ /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 (file)
index 5849853..0000000
+++ /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 */
index b78cdd9..55c6b0e 100644 (file)
@@ -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"
 #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 */
index a1abfb6..3fd3800 100644 (file)
@@ -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);
index 924ff3c..8755653 100644 (file)
@@ -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];
        }
 }
index 8c3d0f8..6f4acd9 100644 (file)
@@ -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);
index 7ac484a..8e703d1 100644 (file)
@@ -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 */
index 63b4c32..e303072 100644 (file)
@@ -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) {
index 564213d..d116f2d 100644 (file)
@@ -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 */
 
 /**
index dddb2d1..65af77b 100644 (file)
@@ -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 */
index 2a86875..893b930 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "fltcalc.h"
 #include "strcalc.h"
+#include "error.h"
 
 #include <math.h>
 /* 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");
 }
 
 /*
index afb06da..bf32031 100644 (file)
 #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");
        }
 }