X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbenode.c;h=da00f73851db0ed3bc25f773b571f5296c0d8c46;hb=3dc176702165e8a201aad7ec1adefe28c3df7e07;hp=432ba1de4ad34c5266bc0b7ecc011e8e74dc8ab3;hpb=75f468ecd02d392bc08492a343cc3fc1f58cbab4;p=libfirm diff --git a/ir/be/benode.c b/ir/be/benode.c index 432ba1de4..da00f7385 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -32,6 +32,7 @@ #include "ircons_t.h" #include "irprintf.h" #include "irgwalk.h" +#include "iropt_t.h" #include "be_t.h" #include "belive_t.h" @@ -158,6 +159,40 @@ static const ir_op_ops be_node_op_ops; #define M irop_flag_machine +/** + * Compare two node attributes. + * + * @return zero if both attributes are identically + */ +static int cmp_node_attr(be_node_attr_t *a, be_node_attr_t *b) { + if (a->max_reg_data == b->max_reg_data) { + int i; + + for (i = 0; i < a->max_reg_data; ++i) { + if (a->reg_data[i].reg != b->reg_data[i].reg || + memcmp(&a->reg_data[i].in_req, &b->reg_data[i].in_req, sizeof(b->reg_data[i].in_req)) || + memcmp(&a->reg_data[i].req, &b->reg_data[i].req, sizeof(a->reg_data[i].req))) + return 1; + } + return 0; + } + return 1; +} + +/** + * Compare the attributes of two FrameAddr nodes. + * + * @return zero if both attributes are identically + */ +static int FrameAddr_cmp_attr(ir_node *a, ir_node *b) { + be_frame_attr_t *a_attr = get_irn_attr(a); + be_frame_attr_t *b_attr = get_irn_attr(b); + + if (a_attr->ent == b_attr->ent && a_attr->offset == b_attr->offset) + return cmp_node_attr(&a_attr->node_attr, &b_attr->node_attr); + return 1; +} + void be_node_init(void) { static int inited = 0; @@ -182,7 +217,7 @@ void be_node_init(void) { op_be_IncSP = new_ir_op(beo_base + beo_IncSP, "be_IncSP", op_pin_state_pinned, N, oparity_binary, 0, sizeof(be_stack_attr_t), &be_node_op_ops); op_be_RegParams = new_ir_op(beo_base + beo_RegParams, "be_RegParams", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_node_attr_t), &be_node_op_ops); op_be_StackParam = new_ir_op(beo_base + beo_StackParam, "be_StackParam", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); - op_be_FrameAddr = new_ir_op(beo_base + beo_FrameAddr, "be_FrameAddr", op_pin_state_pinned, N, oparity_binary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); + op_be_FrameAddr = new_ir_op(beo_base + beo_FrameAddr, "be_FrameAddr", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops); op_be_FrameLoad = new_ir_op(beo_base + beo_FrameLoad, "be_FrameLoad", op_pin_state_pinned, N, oparity_any, 0, sizeof(be_frame_attr_t), &be_node_op_ops); op_be_FrameStore = new_ir_op(beo_base + beo_FrameStore, "be_FrameStore", op_pin_state_pinned, N, oparity_any, 0, sizeof(be_frame_attr_t), &be_node_op_ops); op_be_Barrier = new_ir_op(beo_base + beo_Barrier, "be_Barrier", op_pin_state_pinned, N, oparity_any, 0, sizeof(be_node_attr_t), &be_node_op_ops); @@ -204,6 +239,8 @@ void be_node_init(void) { set_op_tag(op_be_FrameStore, &be_node_tag); set_op_tag(op_be_FrameAddr, &be_node_tag); set_op_tag(op_be_Barrier, &be_node_tag); + + op_be_FrameAddr->ops.node_cmp_attr = FrameAddr_cmp_attr; } /** @@ -383,7 +420,7 @@ ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *bl, ir_node *mem, ir real_in[be_pos_Call_ptr] = ptr; memcpy(&real_in[be_pos_Call_first_arg], in, n * sizeof(in[0])); - irn = new_ir_node(NULL, irg, bl, op_be_Call, mode_T, real_n, real_in); + irn = new_ir_node(dbg, irg, bl, op_be_Call, mode_T, real_n, real_in); a = init_node_attr(irn, (n_outs > real_n ? n_outs : real_n)); a->ent = NULL; a->call_tp = call_tp; @@ -579,7 +616,8 @@ ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame, ir_graph *irg, a->offset = 0; be_node_set_reg_class(irn, 0, cls_frame); be_node_set_reg_class(irn, OUT_POS(0), cls_frame); - return irn; + + return optimize_node(irn); } 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) @@ -794,6 +832,13 @@ void be_set_Spill_entity(ir_node *irn, entity *ent) a->frame_attr.ent = ent; } +void be_set_Spill_context(ir_node *irn, ir_node *ctx) +{ + be_spill_attr_t *a = get_irn_attr(irn); + assert(be_is_Spill(irn)); + a->spill_ctx = ctx; +} + static ir_node *find_a_spill_walker(ir_node *irn, unsigned visited_nr) { unsigned nr = get_irn_visited(irn); @@ -1279,6 +1324,7 @@ static void dump_node_req(FILE *f, int idx, be_req_t *req) const char *prefix = buf; snprintf(buf, sizeof(buf), "#%d ", idx); + buf[sizeof(buf) - 1] = '\0'; if(req->flags != arch_irn_flags_none) { fprintf(f, "%sflags: ", prefix);