- char buf[256];
- int i, j, n;
-
- factory->ops = new_set(cmp_op_map, 64);
- factory->irn_op_map = pmap_create();
- obstack_init(&factory->obst);
-
- factory->handler.get_irn_ops = be_node_get_irn_ops;
-
- factory->irn_ops.get_irn_reg_req = be_node_get_irn_reg_req;
- factory->irn_ops.get_n_operands = be_node_get_n_operands;
- factory->irn_ops.set_irn_reg = be_node_set_irn_reg;
- factory->irn_ops.get_irn_reg = be_node_get_irn_reg;
- factory->irn_ops.classify = be_node_classify;
- factory->irn_ops.get_flags = be_node_get_flags;
-
- for(i = 0, n = isa->get_n_reg_class(); i < n; ++i) {
- const arch_register_class_t *cls = isa->get_reg_class(i);
- be_op_t *ent;
-
- ent = get_op(factory, cls, node_kind_spill);
- snprintf(buf, sizeof(buf), "Spill_%s", cls->name);
- ent->op = new_ir_op(get_next_ir_opcode(), buf, op_pin_state_pinned,
- 0, oparity_unary, 0, 0);
- ent->n_pos = ARRSIZE(templ_pos_Spill);
- ent->pos = templ_pos_Spill;
- pmap_insert(factory->irn_op_map, ent->op, ent);
-
- ent = get_op(factory, cls, node_kind_reload);
- snprintf(buf, sizeof(buf), "Reload_%s", cls->name);
- ent->op = new_ir_op(get_next_ir_opcode(), buf, op_pin_state_pinned, 0,
- oparity_unary, 0, sizeof(const arch_register_t *));
- ent->n_pos = ARRSIZE(templ_pos_Reload);
- ent->pos = templ_pos_Reload;
- pmap_insert(factory->irn_op_map, ent->op, ent);
-
- ent = get_op(factory, cls, node_kind_copy);
- snprintf(buf, sizeof(buf), "Copy_%s", cls->name);
- ent->op = new_ir_op(get_next_ir_opcode(), buf, op_pin_state_pinned, 0,
- oparity_unary, 0, sizeof(const arch_register_t *));
- ent->n_pos = ARRSIZE(templ_pos_Copy);
- ent->pos = templ_pos_Copy;
- pmap_insert(factory->irn_op_map, ent->op, ent);
-
- ent = get_op(factory, cls, node_kind_perm);
- snprintf(buf, sizeof(buf), "Perm_%s", cls->name);
- ent->op = new_ir_op(get_next_ir_opcode(), buf, op_pin_state_pinned, 0,
- oparity_variable, 0, sizeof(const arch_register_t) * cls->n_regs);
- ent->n_pos = 2 * cls->n_regs;
- ent->pos = obstack_alloc(&factory->obst, sizeof(ent->pos[0]) * ent->n_pos);
- for(j = 0; j < ent->n_pos; j += 2) {
- ent->pos[j] = arch_pos_make_in(j);
- ent->pos[j + 1] = arch_pos_make_out(j);
- }
- pmap_insert(factory->irn_op_map, ent->op, ent);
-
- }
-
- return factory;
+ int i, j, n;
+
+ factory->ops = new_set(cmp_op_map, 64);
+ factory->irn_op_map = pmap_create();
+ obstack_init(&factory->obst);
+
+ factory->handler.get_irn_ops = be_node_get_irn_ops;
+
+ factory->irn_ops.get_irn_reg_req = be_node_get_irn_reg_req;
+ factory->irn_ops.set_irn_reg = be_node_set_irn_reg;
+ factory->irn_ops.get_irn_reg = be_node_get_irn_reg;
+ factory->irn_ops.classify = be_node_classify;
+ factory->irn_ops.get_flags = be_node_get_flags;
+
+ for(i = 0, n = arch_isa_get_n_reg_class(isa); i < n; ++i) {
+ const arch_register_class_t *cls = arch_isa_get_reg_class(isa, i);
+ be_op_t *ent;
+
+ ent = get_op(factory, cls, node_kind_spill);
+ ent->op = new_ir_op(get_next_ir_opcode(), "Spill", op_pin_state_pinned,
+ 0, oparity_unary, 0, sizeof(be_spill_attr_t), &be_node_ops);
+ ent->n_pos = ARRSIZE(templ_pos_Spill);
+ ent->pos = templ_pos_Spill;
+ pmap_insert(factory->irn_op_map, ent->op, ent);
+
+ ent = get_op(factory, cls, node_kind_reload);
+ ent->op = new_ir_op(get_next_ir_opcode(), "Reload", op_pin_state_pinned, 0,
+ oparity_unary, 0, sizeof(be_node_attr_t), &be_node_ops);
+ ent->n_pos = ARRSIZE(templ_pos_Reload);
+ ent->pos = templ_pos_Reload;
+ pmap_insert(factory->irn_op_map, ent->op, ent);
+
+ ent = get_op(factory, cls, node_kind_copy);
+ ent->op = new_ir_op(get_next_ir_opcode(), "Copy", op_pin_state_pinned, 0,
+ oparity_unary, 0, sizeof(be_node_attr_t), &be_node_ops);
+ ent->n_pos = ARRSIZE(templ_pos_Copy);
+ ent->pos = templ_pos_Copy;
+ pmap_insert(factory->irn_op_map, ent->op, ent);
+
+ ent = get_op(factory, cls, node_kind_perm);
+ ent->op = new_ir_op(get_next_ir_opcode(), "Perm", op_pin_state_pinned, 0,
+ oparity_variable, 0,
+ sizeof(be_node_attr_t) + sizeof(arch_register_t) * cls->n_regs, &be_node_ops);
+ ent->n_pos = 2 * cls->n_regs;
+ ent->pos = obstack_alloc(&factory->obst, sizeof(ent->pos[0]) * ent->n_pos);
+ for(j = 0; j < ent->n_pos; j += 2) {
+ int k = j / 2;
+ ent->pos[j] = k;
+ ent->pos[j + 1] = -(k + 1);
+ }
+ pmap_insert(factory->irn_op_map, ent->op, ent);
+
+ }
+
+ return factory;
+}
+
+static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
+{
+ be_node_attr_t *attr = (be_node_attr_t *) &irn->attr;
+ be_op_t *bo = pmap_get(attr->factory->irn_op_map, get_irn_op(irn));
+
+ int i;
+
+ switch(reason) {
+ case dump_node_opcode_txt:
+ fprintf(f, get_op_name(bo->op));
+ break;
+ case dump_node_mode_txt:
+ fprintf(f, get_mode_name(get_irn_mode(irn)));
+ break;
+ case dump_node_nodeattr_txt:
+ fprintf(f, "%s ", bo->cls->name);
+ break;
+ case dump_node_info_txt:
+ for(i = 0; i < attr->n_regs; ++i) {
+ const arch_register_t *reg = attr->reg[i];
+ fprintf(f, "reg #%d: %s\n", i, reg ? reg->name : "n/a");
+ }
+
+ if(bo->kind == node_kind_spill) {
+ be_spill_attr_t *a = (be_spill_attr_t *) attr;
+ ir_fprintf(f, "spill context: %+F\n", a->spill_ctx);
+ }
+ break;
+ }
+
+ return 1;