From: Matthias Braun Date: Mon, 15 Aug 2011 13:24:55 +0000 (+0200) Subject: simplify copy interface and respect double/aligned reqs X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=2fc9b7da16d22e8d0edeec02f4e4100c3c2fa1cc;p=libfirm simplify copy interface and respect double/aligned reqs --- diff --git a/ir/be/arm/arm_transform.c b/ir/be/arm/arm_transform.c index 2c93a45b5..4c8f7b4d0 100644 --- a/ir/be/arm/arm_transform.c +++ b/ir/be/arm/arm_transform.c @@ -1282,8 +1282,8 @@ static ir_node *gen_CopyB(ir_node *node) ir_node *src_copy; ir_node *dst_copy; - src_copy = be_new_Copy(&arm_reg_classes[CLASS_arm_gp], block, new_src); - dst_copy = be_new_Copy(&arm_reg_classes[CLASS_arm_gp], block, new_dst); + src_copy = be_new_Copy(block, new_src); + dst_copy = be_new_Copy(block, new_dst); return new_bd_arm_CopyB(dbg, block, dst_copy, src_copy, new_bd_arm_EmptyReg(dbg, block), diff --git a/ir/be/belower.c b/ir/be/belower.c index aa22621d1..e564ce4a3 100644 --- a/ir/be/belower.c +++ b/ir/be/belower.c @@ -455,7 +455,7 @@ static void lower_perm_node(ir_node *irn, lower_env_t *env) DB((dbg, LEVEL_1, "%+F creating copy node (%+F, %s) -> (%+F, %s)\n", irn, arg1, cycle.elems[i]->name, res2, cycle.elems[i + 1]->name)); - cpyxchg = be_new_Copy(reg_class, block, arg1); + cpyxchg = be_new_Copy(block, arg1); arch_set_irn_register(cpyxchg, cycle.elems[i + 1]); /* exchange copy node and proj */ @@ -526,7 +526,7 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different, /* check if already exists such a copy in the schedule immediately before */ cpy = find_copy(skip_Proj(irn), other_different); if (! cpy) { - cpy = be_new_Copy(cls, block, other_different); + cpy = be_new_Copy(block, other_different); arch_set_irn_flags(cpy, arch_irn_flags_dont_spill); DB((dbg_constr, LEVEL_1, "created non-spillable %+F for value %+F\n", cpy, other_different)); } else { @@ -536,7 +536,7 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different, /* Add the Keep resp. CopyKeep and reroute the users */ /* of the other_different irn in case of CopyKeep. */ if (has_irn_users(other_different)) { - keep = be_new_CopyKeep_single(cls, block, cpy, irn, get_irn_mode(other_different)); + keep = be_new_CopyKeep_single(block, cpy, irn); be_node_set_reg_class_in(keep, 1, cls); } else { ir_node *in[2]; @@ -733,10 +733,10 @@ static void melt_copykeeps(constraint_env_t *cenv) } #ifdef KEEP_ALIVE_COPYKEEP_HACK - new_ck = be_new_CopyKeep(entry->cls, get_nodes_block(ref), be_get_CopyKeep_op(ref), n_melt, new_ck_in, mode_ANY); + new_ck = be_new_CopyKeep(get_nodes_block(ref), be_get_CopyKeep_op(ref), n_melt, new_ck_in); keep_alive(new_ck); #else - new_ck = be_new_CopyKeep(entry->cls, get_nodes_block(ref), be_get_CopyKeep_op(ref), n_melt, new_ck_in, get_irn_mode(ref)); + new_ck = be_new_CopyKeep(get_nodes_block(ref), be_get_CopyKeep_op(ref), n_melt, new_ck_in); #endif /* KEEP_ALIVE_COPYKEEP_HACK */ /* set register class for all kept inputs */ diff --git a/ir/be/benode.c b/ir/be/benode.c index d560bc609..ea8f6b1dd 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -422,13 +422,15 @@ ir_node *be_new_MemPerm(ir_node *block, int n, ir_node *in[]) return irn; } -ir_node *be_new_Copy(const arch_register_class_t *cls, ir_node *bl, ir_node *op) +ir_node *be_new_Copy(ir_node *bl, ir_node *op) { ir_node *in[1]; ir_node *res; arch_register_req_t *req; be_node_attr_t *attr; ir_graph *irg = get_Block_irg(bl); + const arch_register_req_t *in_req = arch_get_irn_register_req(op); + const arch_register_class_t *cls = in_req->cls; in[0] = op; res = new_ir_node(NULL, irg, bl, op_be_Copy, get_irn_mode(op), 1, in); @@ -440,9 +442,10 @@ ir_node *be_new_Copy(const arch_register_class_t *cls, ir_node *bl, ir_node *op) req = allocate_reg_req(res); req->cls = cls; - req->type = arch_register_req_type_should_be_same; + req->type = arch_register_req_type_should_be_same + | (in_req->type & arch_register_req_type_aligned); req->other_same = 1U << 0; - req->width = 1; + req->width = in_req->width; be_set_constr_out(res, 0, req); return res; @@ -738,11 +741,14 @@ ir_entity *be_get_FrameAddr_entity(const ir_node *node) return attr->ent; } -ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_node *bl, ir_node *src, int n, ir_node *in_keep[], ir_mode *mode) +ir_node *be_new_CopyKeep(ir_node *bl, ir_node *src, int n, ir_node *in_keep[]) { ir_node *irn; ir_node **in = ALLOCAN(ir_node*, n + 1); ir_graph *irg = get_Block_irg(bl); + const arch_register_req_t *req = arch_get_irn_register_req(src); + const arch_register_class_t *cls = req->cls; + ir_mode *mode = get_irn_mode(src); be_node_attr_t *attr; in[0] = src; @@ -757,9 +763,9 @@ ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_node *bl, ir_node return irn; } -ir_node *be_new_CopyKeep_single(const arch_register_class_t *cls, ir_node *bl, ir_node *src, ir_node *keep, ir_mode *mode) +ir_node *be_new_CopyKeep_single(ir_node *bl, ir_node *src, ir_node *keep) { - return be_new_CopyKeep(cls, bl, src, 1, &keep, mode); + return be_new_CopyKeep(bl, src, 1, &keep); } ir_node *be_get_CopyKeep_op(const ir_node *cpy) @@ -960,7 +966,8 @@ ir_node *be_spill(ir_node *block, ir_node *irn) return spill; } -ir_node *be_reload(const arch_register_class_t *cls, ir_node *insert, ir_mode *mode, ir_node *spill) +ir_node *be_reload(const arch_register_class_t *cls, ir_node *insert, + ir_mode *mode, ir_node *spill) { ir_node *reload; ir_node *bl = is_Block(insert) ? insert : get_nodes_block(insert); diff --git a/ir/be/benode.h b/ir/be/benode.h index fc01db6ec..348c73b1b 100644 --- a/ir/be/benode.h +++ b/ir/be/benode.h @@ -104,8 +104,7 @@ enum { /** * Make a new Copy node. */ -ir_node *be_new_Copy(const arch_register_class_t *cls, ir_node *block, - ir_node *in); +ir_node *be_new_Copy(ir_node *block, ir_node *in); /** Returns the Copy Argument. */ ir_node *be_get_Copy_op(const ir_node *cpy); /** Sets the Copy Argument. */ @@ -389,13 +388,10 @@ ir_node *be_reload(const arch_register_class_t *cls, ir_node *insert, enum { n_be_CopyKeep_op = 0 }; -ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_node *block, - ir_node *src, int n, ir_node *in_keep[], - ir_mode *mode); +ir_node *be_new_CopyKeep(ir_node *block, ir_node *src, + int n, ir_node *in_keep[]); -ir_node *be_new_CopyKeep_single(const arch_register_class_t *cls, - ir_node *block, ir_node *src, ir_node *keep, - ir_mode *mode); +ir_node *be_new_CopyKeep_single(ir_node *block, ir_node *src, ir_node *keep); ir_node *be_get_CopyKeep_op(const ir_node *cpy); diff --git a/ir/be/beprefalloc.c b/ir/be/beprefalloc.c index b8cb95baf..af2ece4ec 100644 --- a/ir/be/beprefalloc.c +++ b/ir/be/beprefalloc.c @@ -721,7 +721,7 @@ static bool try_optimistic_split(ir_node *to_split, ir_node *before, return false; reg = arch_register_for_index(cls, r); - copy = be_new_Copy(cls, block, to_split); + copy = be_new_Copy(block, to_split); mark_as_copy_of(copy, to_split); /* hacky, but correct here */ if (assignments[arch_register_get_index(from_reg)] == to_split) @@ -922,7 +922,7 @@ static void permute_values(ir_nodeset_t *live_nodes, ir_node *before, /* create a copy */ src = assignments[old_r]; - copy = be_new_Copy(cls, block, src); + copy = be_new_Copy(block, src); sched_add_before(before, copy); reg = arch_register_for_index(cls, r); DB((dbg, LEVEL_2, "Copy %+F (from %+F, before %+F) -> %s\n", diff --git a/ir/be/bespill.c b/ir/be/bespill.c index c83653a0e..07bafe229 100644 --- a/ir/be/bespill.c +++ b/ir/be/bespill.c @@ -97,7 +97,7 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node) if (rbitset_is_set(req->limited, reg->index)) continue; - copy = be_new_Copy(cls, block, op); + copy = be_new_Copy(block, op); stat_ev_int("constr_copy", 1); sched_add_before(node, copy); set_irn_n(node, i, copy); @@ -141,7 +141,7 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node) if (rbitsets_equal(req->limited, req2->limited, cls->n_regs)) continue; - copy = be_new_Copy(cls, block, in); + copy = be_new_Copy(block, in); stat_ev_int("constr_copy", 1); sched_add_before(node, copy); @@ -210,7 +210,7 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node) if (be_is_Copy(in)) continue; - copy = be_new_Copy(cls, block, in); + copy = be_new_Copy(block, in); sched_add_before(node, copy); set_irn_n(node, i, copy); DBG((dbg, LEVEL_3, "inserting constr copy %+F for %+F pos %d\n", diff --git a/ir/be/bessadestr.c b/ir/be/bessadestr.c index 0a393dd5b..b6e309476 100644 --- a/ir/be/bessadestr.c +++ b/ir/be/bessadestr.c @@ -242,7 +242,6 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) phi = (ir_node*)get_irn_link(phi)) { ir_node *phi_block = get_nodes_block(phi); const arch_register_t *phi_reg = arch_get_irn_register(phi); - const arch_register_class_t *cls = phi_reg->reg_class; int max; int i; @@ -280,7 +279,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) insert it into schedule, pin it */ - ir_node *dupl = be_new_Copy(cls, arg_block, arg); + ir_node *dupl = be_new_Copy(arg_block, arg); set_irn_n(phi, i, dupl); arch_set_irn_register(dupl, phi_reg); @@ -336,7 +335,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) pin it */ ir_node *perm = get_Proj_pred(arg); - ir_node *dupl = be_new_Copy(cls, arg_block, arg); + ir_node *dupl = be_new_Copy(arg_block, arg); ir_node *ins; set_irn_n(phi, i, dupl); diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index 741d5cade..5f231f718 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -1277,10 +1277,10 @@ static void introduce_prolog_epilog(ir_graph *irg) sched_add_after(start, push); /* move esp to ebp */ - curr_bp = be_new_Copy(bp->reg_class, block, curr_sp); + curr_bp = be_new_Copy(block, curr_sp); sched_add_after(push, curr_bp); be_set_constr_single_reg_out(curr_bp, 0, bp, arch_register_req_type_ignore); - curr_sp = be_new_CopyKeep_single(sp->reg_class, block, curr_sp, curr_bp, mode_gp); + curr_sp = be_new_CopyKeep_single(block, curr_sp, curr_bp); sched_add_after(curr_bp, curr_sp); be_set_constr_single_reg_out(curr_sp, 0, sp, arch_register_req_type_produces_sp); edges_reroute(initial_bp, curr_bp); diff --git a/ir/be/ia32/ia32_finish.c b/ir/be/ia32/ia32_finish.c index fc0db4fae..2a8cc5884 100644 --- a/ir/be/ia32/ia32_finish.c +++ b/ir/be/ia32/ia32_finish.c @@ -307,7 +307,7 @@ static void assure_should_be_same_requirements(ir_node *node) * (the register can't be live since the operation will override it * anyway) */ if (uses_out_reg == NULL) { - ir_node *copy = be_new_Copy(cls, block, in_node); + ir_node *copy = be_new_Copy(block, in_node); DBG_OPT_2ADDRCPY(copy); /* destination is the out register */