X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbenode.c;h=b1ed7e6b63b496befba0bd8903914d7b47b68d38;hb=9bc8c6e3500cd526c3b278a47a354719280e4636;hp=8f0fb8e733ccb083769a303d7b1cf15b79edc8ae;hpb=8b76d0442b62176e562d9dbffbb469d804273392;p=libfirm diff --git a/ir/be/benode.c b/ir/be/benode.c index 8f0fb8e73..b1ed7e6b6 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -218,6 +218,12 @@ static ir_node *find_a_spill_walker(ir_node *irn, unsigned visited_nr) return NULL; } +ir_node *get_Spill_context(const ir_node *irn) { + be_spill_attr_t *a = (be_spill_attr_t *) &irn->attr; + assert(is_be_kind(irn, node_kind_spill)); + return a->spill_ctx; +} + /** * Finds a spill for a reload. * If the reload is directly using the spill, this is simple, @@ -234,7 +240,8 @@ static INLINE ir_node *find_a_spill(ir_node *irn) return find_a_spill_walker(irn, visited_nr); } -unsigned get_irn_spill_offset(ir_node *irn) + +unsigned get_Spill_offset(ir_node *irn) { be_node_attr_t *a = (be_node_attr_t *) &irn->attr; assert(is_be_node(irn)); @@ -242,7 +249,7 @@ unsigned get_irn_spill_offset(ir_node *irn) switch(a->op->kind) { case node_kind_reload: assert(0 && "not yet implemented"); - return get_irn_spill_offset(find_a_spill(irn)); + return get_Spill_offset(find_a_spill(irn)); case node_kind_spill: return ((be_spill_attr_t *) a)->offset; default: @@ -334,7 +341,7 @@ ir_node *be_reload(const be_node_factory_t *factory, ir_node *bl = get_nodes_block(irn); ir_graph *irg = get_irn_irg(bl); - assert(is_Spill(spill) + assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M)); reload = new_Reload(factory, cls, irg, bl, mode, spill); @@ -344,17 +351,6 @@ ir_node *be_reload(const be_node_factory_t *factory, return reload; } -static INLINE arch_register_req_t *get_Perm_reqs(ir_node *perm) -{ - be_node_attr_t *attr = (be_node_attr_t *) &perm->attr; - char *ptr = (char *) &perm->attr; - - ptr += sizeof(be_node_attr_t); - ptr += sizeof(arch_register_t *) * attr->n_regs; - - return (arch_register_req_t *) ptr; -} - /** * If the node is a proj, reset the node to the proj's target and return * the proj number. @@ -380,10 +376,6 @@ static const arch_register_req_t * be_node_get_irn_reg_req(const arch_irn_ops_t *_self, arch_register_req_t *req, const ir_node *irn, int pos) { - be_op_t *bo; - const be_node_factory_t *factory = - container_of(_self, const be_node_factory_t, irn_ops); - /* We cannot get output requirements for tuple nodes. */ if(get_irn_mode(irn) == mode_T && pos < 0) return NULL; @@ -394,10 +386,9 @@ be_node_get_irn_reg_req(const arch_irn_ops_t *_self, if(pos < 0) pos = redir_proj((const ir_node **) &irn, pos); - /* look if the node is one of ours. */ - bo = pmap_get(factory->irn_op_map, get_irn_op(irn)); - - if(bo) { + if(is_be_node(irn)) { + const be_node_attr_t *a = (const be_node_attr_t *) &irn->attr; + const be_op_t *bo = a->op; int i; for(i = 0; i < bo->n_pos; ++i) { @@ -414,10 +405,8 @@ be_node_get_irn_reg_req(const arch_irn_ops_t *_self, * if an output requirement is requested, * return the one stored in the node. */ - else { - be_node_attr_t *attr = (be_node_attr_t *) &irn->attr; - *req = attr->reg_data[pos].req; - } + else + *req = a->reg_data[-pos - 1].req; return req; } @@ -429,12 +418,8 @@ be_node_get_irn_reg_req(const arch_irn_ops_t *_self, void be_set_Perm_out_req(ir_node *irn, int pos, const arch_register_req_t *req) { - be_op_t *bo; be_node_attr_t *a = get_attr_and_check(irn, node_kind_perm); - assert(pos >= 0 && pos < get_irn_arity(irn) && "position out of range"); - assert(a->op->kind == node_kind_perm && "node must be a perm node"); - a->reg_data[pos].req = *req; } @@ -535,12 +520,22 @@ const arch_irn_handler_t *be_node_get_irn_handler(const be_node_factory_t *f) return &f->handler; } -int is_Spill(const ir_node *irn) +int be_is_Spill(const ir_node *irn) { return is_be_kind(irn, node_kind_spill); } -int is_Perm(const ir_node *irn) +int be_is_Reload(const ir_node *irn) +{ + return is_be_kind(irn, node_kind_reload); +} + +int be_is_Copy(const ir_node *irn) +{ + return is_be_kind(irn, node_kind_copy); +} + +int be_is_Perm(const ir_node *irn) { return is_be_kind(irn, node_kind_perm); } @@ -649,13 +644,12 @@ ir_node *insert_Perm_after(const be_main_env_t *env, ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos); ir_graph *irg = get_irn_irg(bl); pset *live = pset_new_ptr_default(); - firm_dbg_module_t *dbg = firm_dbg_register("firm.be.node"); + firm_dbg_module_t *dbg = firm_dbg_register("be.node"); irn_live_t *li; ir_node *curr, *irn, *perm, **nodes; int i, n; - firm_dbg_set_mask(dbg, DBG_LEVEL); DBG((dbg, LEVEL_1, "Insert Perm after: %+F\n", pos));