bescripts: Copy all common node attributes into the constructor variants.
[libfirm] / ir / be / belive.c
index 3ccd831..acf32c2 100644 (file)
 #include "belive_t.h"
 #include "besched.h"
 #include "bemodule.h"
-#include "bedump.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
 #define LV_STD_SIZE             64
 
-/**
- * Filter out some nodes for which we never need liveness.
- *
- * @param irn  the node t check
- * @return 0 if no liveness info is needed, 1 else
- */
-static inline int is_liveness_node(const ir_node *irn)
-{
-       switch (get_irn_opcode(irn)) {
-       case iro_Block:
-       case iro_Bad:
-       case iro_End:
-       case iro_Anchor:
-       case iro_NoMem:
-               return 0;
-       default:
-               return 1;
-       }
-}
-
 int (be_is_live_in)(const be_lv_t *lv, const ir_node *block, const ir_node *irn)
 {
        return _be_is_live_xxx(lv, block, irn, be_lv_state_in);
@@ -384,7 +363,6 @@ static void collect_liveness_nodes(ir_node *irn, void *data)
 
 void be_liveness_compute_sets(be_lv_t *lv)
 {
-       ir_node **nodes;
        int       i;
        int       n;
 
@@ -396,8 +374,7 @@ void be_liveness_compute_sets(be_lv_t *lv)
        obstack_init(&lv->obst);
 
        n = get_irg_last_idx(lv->irg);
-       nodes = NEW_ARR_F(ir_node *, n);
-       memset(nodes, 0, sizeof(nodes[0]) * n);
+       ir_node **const nodes = NEW_ARR_FZ(ir_node*, n);
 
        /* inserting the variables sorted by their ID is probably
         * more efficient since the binary sorted set insertion
@@ -414,7 +391,6 @@ void be_liveness_compute_sets(be_lv_t *lv)
 
        DEL_ARR_F(nodes);
        free(re.visited);
-       register_hook(hook_node_info, &lv->hook_info);
 
        be_timer_pop(T_LIVE);
 
@@ -432,7 +408,6 @@ void be_liveness_invalidate_sets(be_lv_t *lv)
 {
        if (!lv->sets_valid)
                return;
-       unregister_hook(hook_node_info, &lv->hook_info);
        obstack_free(&lv->obst, NULL);
        ir_nodehashmap_destroy(&lv->map);
        lv->sets_valid = false;
@@ -453,8 +428,6 @@ be_lv_t *be_liveness_new(ir_graph *irg)
        be_lv_t *lv = XMALLOCZ(be_lv_t);
 
        lv->irg = irg;
-       lv->hook_info.context = lv;
-       lv->hook_info.hook._hook_node_info = be_dump_liveness_block;
 
        return lv;
 }
@@ -507,21 +480,13 @@ void be_liveness_transfer(const arch_register_class_t *cls,
         * function. */
        assert(!is_Phi(node) && "liveness_transfer produces invalid results for phi nodes");
 
-       be_foreach_definition(node, cls, value,
+       be_foreach_definition(node, cls, value, req,
                ir_nodeset_remove(nodeset, value);
        );
 
-       int arity = get_irn_arity(node);
-       for (int i = 0; i < arity; ++i) {
-               const arch_register_req_t *in_req = arch_get_irn_register_req_in(node, i);
-               if (in_req->cls != cls)
-                       continue;
-               ir_node                   *op     = get_irn_n(node, i);
-               const arch_register_req_t *op_req = arch_get_irn_register_req(op);
-               if (arch_register_req_is(op_req, ignore))
-                       continue;
+       be_foreach_use(node, cls, in_req, op, op_req,
                ir_nodeset_insert(nodeset, op);
-       }
+       );
 }
 
 
@@ -531,10 +496,7 @@ void be_liveness_end_of_block(const be_lv_t *lv,
                               const ir_node *block, ir_nodeset_t *live)
 {
        assert(lv->sets_valid && "live sets must be computed");
-       be_lv_foreach(lv, block, be_lv_state_end, node) {
-               if (!arch_irn_consider_in_reg_alloc(cls, node))
-                       continue;
-
+       be_lv_foreach_cls(lv, block, be_lv_state_end, cls, node) {
                ir_nodeset_insert(live, node);
        }
 }