X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbenode.c;h=2ec36cead83d1de5d90cc809f3881b8c685637cb;hb=cf027c3576652c0f6938130fe89b0f1ea0df706a;hp=5c19be77c410196f0b990019a1dd5f8c764b5d61;hpb=c28fcf22c08f71b02ccd8edb2e091c1b6c22e540;p=libfirm diff --git a/ir/be/benode.c b/ir/be/benode.c index 5c19be77c..2ec36cead 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -27,9 +27,7 @@ * Backend node support for generic backend nodes. * This file provides Perm, Copy, Spill and Reload nodes. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include @@ -43,6 +41,7 @@ #include "bitfiddle.h" #include "raw_bitset.h" #include "error.h" +#include "array_t.h" #include "irop_t.h" #include "irmode_t.h" @@ -258,7 +257,7 @@ static int Call_cmp_attr(ir_node *a, ir_node *b) { return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr); } -static INLINE be_req_t *get_be_req(const ir_node *node, int pos) +static inline be_req_t *get_be_req(const ir_node *node, int pos) { int idx; const be_node_attr_t *attr; @@ -279,7 +278,7 @@ static INLINE be_req_t *get_be_req(const ir_node *node, int pos) return pos < 0 ? &rd->req : &rd->in_req; } -static INLINE arch_register_req_t *get_req(const ir_node *node, int pos) +static inline arch_register_req_t *get_req(const ir_node *node, int pos) { be_req_t *bereq = get_be_req(node, pos); return &bereq->req; @@ -441,7 +440,7 @@ ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *b void be_Perm_reduce(ir_node *perm, int new_size, int *map) { int arity = get_irn_arity(perm); - be_reg_data_t *old_data = alloca(arity * sizeof(old_data[0])); + be_reg_data_t *old_data = ALLOCAN(be_reg_data_t, arity); be_node_attr_t *attr = get_irn_attr(perm); ir_node **new_in; @@ -467,15 +466,15 @@ void be_Perm_reduce(ir_node *perm, int new_size, int *map) ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_graph *irg, ir_node *bl, int n, ir_node *in[]) { - int i; - ir_node *frame = get_irg_frame(irg); - const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1); - ir_node *irn; - const arch_register_t *sp = arch_env->sp; - be_memperm_attr_t *attr; - ir_node **real_in; + ir_node *frame = get_irg_frame(irg); + const arch_register_class_t *cls_frame = arch_get_irn_reg_class_out(frame); + const arch_register_t *sp = arch_env->sp; + ir_node *irn; + be_memperm_attr_t *attr; + ir_node **real_in; + int i; - real_in = alloca((n+1) * sizeof(real_in[0])); + real_in = ALLOCAN(ir_node*, n + 1); real_in[0] = frame; memcpy(&real_in[1], in, n * sizeof(real_in[0])); @@ -761,29 +760,6 @@ ir_node *be_new_RegParams(ir_graph *irg, ir_node *bl, int n_outs) return res; } -ir_node *be_RegParams_append_out_reg(ir_node *regparams, - const arch_env_t *arch_env, - const arch_register_t *reg) -{ - ir_graph *irg = get_irn_irg(regparams); - ir_node *block = get_nodes_block(regparams); - be_node_attr_t *attr = get_irn_attr(regparams); - const arch_register_class_t *cls = arch_register_get_class(reg); - ir_mode *mode = arch_register_class_mode(cls); - int n = ARR_LEN(attr->reg_data); - ir_node *proj; - - assert(be_is_RegParams(regparams)); - proj = new_r_Proj(irg, block, regparams, mode, n); - add_register_req(regparams); - be_set_constr_single_reg(regparams, BE_OUT_POS(n), reg); - arch_set_irn_register(arch_env, proj, reg); - - /* TODO decide, whether we need to set ignore/modify sp flags here? */ - - return proj; -} - ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame, ir_graph *irg, ir_node *bl, ir_node *frame, ir_entity *ent) { be_frame_attr_t *a; @@ -814,8 +790,8 @@ ir_entity *be_get_FrameAddr_entity(const ir_node *node) ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *src, int n, ir_node *in_keep[], ir_mode *mode) { - ir_node *irn; - ir_node **in = (ir_node **) alloca((n + 1) * sizeof(in[0])); + ir_node *irn; + ir_node **in = ALLOCAN(ir_node*, n + 1); in[0] = src; memcpy(&in[1], in_keep, n * sizeof(in[0])); @@ -1053,32 +1029,32 @@ int be_get_IncSP_align(const ir_node *irn) return a->align; } -ir_node *be_spill(const arch_env_t *arch_env, ir_node *block, ir_node *irn) +ir_node *be_spill(ir_node *block, ir_node *irn) { ir_graph *irg = get_irn_irg(block); ir_node *frame = get_irg_frame(irg); - const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, irn, -1); - const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1); + const arch_register_class_t *cls = arch_get_irn_reg_class_out(irn); + const arch_register_class_t *cls_frame = arch_get_irn_reg_class_out(frame); ir_node *spill; spill = be_new_Spill(cls, cls_frame, irg, block, frame, irn); return spill; } -ir_node *be_reload(const arch_env_t *arch_env, 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); ir_graph *irg = get_irn_irg(bl); ir_node *frame = get_irg_frame(irg); - const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1); + const arch_register_class_t *cls_frame = arch_get_irn_reg_class_out(frame); assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M)); reload = be_new_Reload(cls, cls_frame, irg, bl, frame, spill, mode); if (is_Block(insert)) { - insert = sched_skip(insert, 0, sched_skip_cf_predicator, (void *) arch_env); + insert = sched_skip(insert, 0, sched_skip_cf_predicator, NULL); sched_add_after(insert, reload); } else { sched_add_before(insert, reload); @@ -1130,6 +1106,7 @@ be_node_get_irn_reg_req(const ir_node *irn, int pos) if (get_irn_mode(irn) == mode_T) return arch_no_register_req; + assert(pos == -1); out_pos = redir_proj((const ir_node **)&irn); assert(is_be_node(irn)); return get_out_reg_req(irn, out_pos); @@ -1177,12 +1154,10 @@ restart: irn = get_Proj_pred(irn); } goto restart; - break; + default: - return arch_irn_class_normal; + return 0; } - - return 0; } static arch_irn_flags_t be_node_get_flags(const ir_node *node) @@ -1273,14 +1248,13 @@ typedef struct { arch_irn_flags_t flags; } phi_attr_t; -struct { - arch_env_t *arch_env; - pmap *phi_attrs; +static struct { + pmap *phi_attrs; } phi_handler; #define get_phi_handler_from_ops(h) container_of(h, phi_handler_t, irn_ops) -static INLINE +static inline phi_attr_t *get_Phi_attr(const ir_node *phi) { phi_attr_t *attr = pmap_get(phi_handler.phi_attrs, (void*) phi); @@ -1314,7 +1288,7 @@ const arch_register_req_t *get_Phi_reg_req_recursive(const ir_node *phi, /* Matze: don't we unnecessary constraint our phis with this? * we only need to take the regclass IMO*/ if(!is_Phi(op)) - return arch_get_register_req(phi_handler.arch_env, op, BE_OUT_POS(0)); + return arch_get_register_req_out(op); } /* @@ -1364,11 +1338,9 @@ const arch_register_req_t *phi_get_irn_reg_req(const ir_node *irn, int pos) return &attr->req; } -void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node, - const arch_register_req_t *req) +void be_set_phi_reg_req(ir_node *node, const arch_register_req_t *req) { phi_attr_t *attr; - (void) arch_env; assert(mode_is_datab(get_irn_mode(node))); @@ -1376,11 +1348,9 @@ void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node, memcpy(&attr->req, req, sizeof(req[0])); } -void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node, - arch_irn_flags_t flags) +void be_set_phi_flags(ir_node *node, arch_irn_flags_t flags) { phi_attr_t *attr; - (void) arch_env; assert(mode_is_datab(get_irn_mode(node))); @@ -1403,7 +1373,7 @@ static const arch_register_t *phi_get_irn_reg(const ir_node *irn) static arch_irn_class_t phi_classify(const ir_node *irn) { (void) irn; - return arch_irn_class_normal; + return 0; } static arch_irn_flags_t phi_get_flags(const ir_node *irn) @@ -1454,9 +1424,8 @@ static const arch_irn_ops_t phi_irn_ops = { NULL, /* perform_memory_operand */ }; -void be_phi_handler_new(be_main_env_t *env) +void be_phi_handler_new(void) { - phi_handler.arch_env = env->arch_env; phi_handler.phi_attrs = pmap_create(); op_Phi->ops.be_ops = &phi_irn_ops; }