alle ops are now pinned
[libfirm] / ir / be / benode.c
index b7a53f0..9285525 100644 (file)
@@ -251,8 +251,16 @@ be_node_set_irn_reg(const arch_irn_ops_t *_self, ir_node *irn,
     int idx, const arch_register_t *reg)
 {
   const arch_register_t **regs;
+  be_op_t *bo;
+  const be_node_factory_t *factory =
+    container_of(_self, const be_node_factory_t, irn_ops);
 
   idx = redir_proj((const ir_node **) &irn, idx);
+  bo = pmap_get(factory->irn_op_map, get_irn_op(irn));
+
+       if(!bo)
+               return;
+
   regs = (const arch_register_t **) &irn->attr;
   regs[idx] = reg;
 }
@@ -261,10 +269,25 @@ const arch_register_t *
 be_node_get_irn_reg(const arch_irn_ops_t *_self, const ir_node *irn, int idx)
 {
   const arch_register_t **regs;
+  be_op_t *bo;
+  int i, pos = arch_pos_make_out(idx);
+  const be_node_factory_t *factory =
+    container_of(_self, const be_node_factory_t, irn_ops);
 
   idx = redir_proj(&irn, idx);
-  regs = (const arch_register_t **) &irn->attr;
-  return regs[idx];
+  bo = pmap_get(factory->irn_op_map, get_irn_op(irn));
+
+  if(!bo)
+       return NULL;
+
+  for(i = 0; i < bo->n_pos; ++i) {
+       if(bo->pos[i] == pos) {
+         regs = (const arch_register_t **) &irn->attr;
+         return regs[idx];
+       }
+  }
+
+  return NULL;
 }
 
 arch_irn_class_t be_node_classify(const arch_irn_ops_t *_self, const ir_node *irn)
@@ -346,7 +369,7 @@ be_node_factory_t *be_node_factory_init(be_node_factory_t *factory,
     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);
+        0, oparity_unary, 0, 0, NULL);
     ent->n_pos = ARRSIZE(templ_pos_Spill);
     ent->pos = templ_pos_Spill;
     pmap_insert(factory->irn_op_map, ent->op, ent);
@@ -354,7 +377,7 @@ be_node_factory_t *be_node_factory_init(be_node_factory_t *factory,
     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 *));
+        oparity_unary, 0, sizeof(const arch_register_t *), NULL);
     ent->n_pos = ARRSIZE(templ_pos_Reload);
     ent->pos = templ_pos_Reload;
     pmap_insert(factory->irn_op_map, ent->op, ent);
@@ -362,7 +385,7 @@ be_node_factory_t *be_node_factory_init(be_node_factory_t *factory,
     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 *));
+        oparity_unary, 0, sizeof(const arch_register_t *), NULL);
     ent->n_pos = ARRSIZE(templ_pos_Copy);
     ent->pos = templ_pos_Copy;
     pmap_insert(factory->irn_op_map, ent->op, ent);
@@ -370,7 +393,7 @@ be_node_factory_t *be_node_factory_init(be_node_factory_t *factory,
     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);
+        oparity_variable, 0, sizeof(const arch_register_t) * cls->n_regs, NULL);
     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) {