-
-be_node_factory_t *be_node_factory_init(be_node_factory_t *factory, const arch_isa_t *isa)
-{
- 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(be_reg_data_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;
-}