From: Christoph Mallon Date: Wed, 15 Oct 2008 06:13:40 +0000 (+0000) Subject: Marginally reduce the number of calls to arch_get_irn_reg_class(). X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=4c875e72735d6f438c64a9e0d8de71a5ceb838c8;p=libfirm Marginally reduce the number of calls to arch_get_irn_reg_class(). [r22894] --- diff --git a/ir/be/bechordal.c b/ir/be/bechordal.c index 4f54e7b75..693646829 100644 --- a/ir/be/bechordal.c +++ b/ir/be/bechordal.c @@ -241,7 +241,8 @@ static ir_node *prepare_constr_insn(be_chordal_env_t *env, ir_node *irn) const arch_register_t *reg; const arch_register_req_t *req; - if (arch_get_irn_reg_class(irn, i) != env->cls) + req = arch_get_register_req(irn, i); + if (req->cls != env->cls) continue; reg = arch_get_irn_register(op); @@ -251,7 +252,6 @@ static ir_node *prepare_constr_insn(be_chordal_env_t *env, ir_node *irn) if(arch_register_type_is(reg, joker)) continue; - req = arch_get_register_req(irn, i); if (!arch_register_req_is(req, limited)) continue; diff --git a/ir/be/becopyopt.c b/ir/be/becopyopt.c index ca32b86b7..afc6043e5 100644 --- a/ir/be/becopyopt.c +++ b/ir/be/becopyopt.c @@ -229,8 +229,11 @@ static int co_is_optimizable_root(ir_node *irn) if (arch_register_type_is(reg, ignore)) return 0; + if (is_Reg_Phi(irn) || is_Perm_Proj(irn)) + return 1; + req = arch_get_register_req(irn, -1); - if (is_Reg_Phi(irn) || is_Perm_Proj(irn) || is_2addr_code(req)) + if (is_2addr_code(req)) return 1; return 0; @@ -376,11 +379,13 @@ static int ou_max_ind_set_costs(unit_t *ou) { return safe_costs+best_weight; } -static void co_collect_units(ir_node *irn, void *env) { - copy_opt_t *co = env; +static void co_collect_units(ir_node *irn, void *env) +{ + const arch_register_req_t *req = arch_get_register_req(irn, -1); + copy_opt_t *co = env; unit_t *unit; - if (!is_curr_reg_class(co, irn)) + if (req->cls != co->cls) return; if (!co_is_optimizable_root(irn)) return; @@ -406,7 +411,7 @@ static void co_collect_units(ir_node *irn, void *env) { int o, arg_pos; ir_node *arg = get_irn_n(irn, i); - assert(is_curr_reg_class(co, arg) && "Argument not in same register class."); + assert(arch_get_irn_reg_class(arg, -1) == co->cls && "Argument not in same register class."); if (arg == irn) continue; if (nodes_interfere(co->cenv, irn, arg)) { @@ -450,8 +455,6 @@ static void co_collect_units(ir_node *irn, void *env) { unit->nodes[1] = get_Perm_src(irn); unit->costs[1] = co->get_costs(co, irn, unit->nodes[1], -1); } else { - const arch_register_req_t *req = arch_get_register_req(irn, -1); - /* Src == Tgt of a 2-addr-code instruction */ if (is_2addr_code(req)) { const unsigned other = req->other_same; @@ -769,11 +772,12 @@ static inline void add_edges(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs } static void build_graph_walker(ir_node *irn, void *env) { - copy_opt_t *co = env; + const arch_register_req_t *req = arch_get_register_req(irn, -1); + copy_opt_t *co = env; int pos, max; const arch_register_t *reg; - if (!is_curr_reg_class(co, irn) || arch_irn_is(irn, ignore)) + if (req->cls != co->cls || arch_irn_is(irn, ignore)) return; reg = arch_get_irn_register(irn); @@ -788,9 +792,7 @@ static void build_graph_walker(ir_node *irn, void *env) { } else if (is_Perm_Proj(irn)) { /* Perms */ ir_node *arg = get_Perm_src(irn); add_edges(co, irn, arg, co->get_costs(co, irn, arg, 0)); - } - else { /* 2-address code */ - const arch_register_req_t *req = arch_get_register_req(irn, -1); + } else { /* 2-address code */ if (is_2addr_code(req)) { const unsigned other = req->other_same; int i; diff --git a/ir/be/becopyopt_t.h b/ir/be/becopyopt_t.h index 13a9f86a7..2519c6487 100644 --- a/ir/be/becopyopt_t.h +++ b/ir/be/becopyopt_t.h @@ -58,9 +58,8 @@ struct _copy_opt_t { #define ASSERT_OU_AVAIL(co) assert((co)->units.next && "Representation as optimization-units not build") #define ASSERT_GS_AVAIL(co) assert((co)->nodes && "Representation as graph not build") -#define get_irn_col(irn) arch_register_get_index(arch_get_irn_register(irn)) -#define set_irn_col(co, irn, col) arch_set_irn_register(irn, arch_register_for_index((co)->cls, col)) -#define is_curr_reg_class(co, irn) (arch_get_irn_reg_class(irn, -1) == (co)->cls) +#define get_irn_col(irn) arch_register_get_index(arch_get_irn_register(irn)) +#define set_irn_col(co, irn, col) arch_set_irn_register(irn, arch_register_for_index((co)->cls, col)) #define list_entry_units(lh) list_entry(lh, unit_t, units) diff --git a/ir/be/bessadestr.c b/ir/be/bessadestr.c index 041c9d780..d1b4bd235 100644 --- a/ir/be/bessadestr.c +++ b/ir/be/bessadestr.c @@ -232,22 +232,19 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) { /* Consider all phis of this block */ for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { - int i, max; - ir_node *arg, *phi_block, *arg_block; - const arch_register_t *phi_reg, *arg_reg; - const arch_register_class_t *cls; + ir_node *phi_block = get_nodes_block(phi); + const arch_register_t *phi_reg = get_reg(phi); + const arch_register_class_t *cls = phi_reg->reg_class; + int max; + int i; assert(is_Phi(phi) && "Can only handle phi-destruction :)"); - phi_block = get_nodes_block(phi); - phi_reg = get_reg(phi); - cls = arch_get_irn_reg_class(phi, -1); - /* process all arguments of the phi */ for (i = 0, max = get_irn_arity(phi); i < max; ++i) { - arg = get_irn_n(phi, i); - arg_block = get_Block_cfgpred_block(phi_block, i); - arg_reg = get_reg(arg); + ir_node *arg = get_irn_n(phi, i); + ir_node *arg_block = get_Block_cfgpred_block(phi_block, i); + const arch_register_t *arg_reg = get_reg(arg); if (arch_irn_is(arg, ignore)) continue; diff --git a/ir/be/ia32/ia32_transform.c b/ir/be/ia32/ia32_transform.c index 2b85751ae..ca77451f0 100644 --- a/ir/be/ia32/ia32_transform.c +++ b/ir/be/ia32/ia32_transform.c @@ -4306,8 +4306,7 @@ static ir_node *gen_Proj_be_Call(ir_node *node) long proj = get_Proj_proj(node); ir_mode *mode = get_irn_mode(node); ir_node *sse_load; - const arch_register_class_t *cls; - ir_node *res; + ir_node *res; /* The following is kinda tricky: If we're using SSE, then we have to * move the result value of the call in floating point registers to an @@ -4371,7 +4370,7 @@ static ir_node *gen_Proj_be_Call(ir_node *node) /* transform call modes */ if (mode_is_data(mode)) { - cls = arch_get_irn_reg_class(node, -1); + const arch_register_class_t *cls = arch_get_irn_reg_class(node, -1); mode = cls->mode; }