+typedef struct {
+ int n_outs;
+ const arch_register_class_t *cls;
+ be_reg_data_t *reg_data;
+} be_node_attr_t;
+
+typedef struct {
+ be_node_attr_t node_attr;
+ ir_node *spill_ctx; /**< The node in whose context this spill was introduced. */
+ entity *ent; /**< The entity in the stack frame the spill writes to. */
+} be_spill_attr_t;
+
+static ir_op *op_Spill;
+static ir_op *op_Reload;
+static ir_op *op_Perm;
+static ir_op *op_Copy;
+static ir_op *op_Keep;
+
+static int beo_base = -1;
+
+static const ir_op_ops be_node_op_ops;
+
+void be_node_init(void) {
+ static int inited = 0;
+ int i;
+
+ if(inited)
+ return;
+
+ inited = 1;
+
+ beo_base = get_next_ir_opcode();
+
+ /* Acquire all needed opcodes. We assume that they are consecutive! */
+ for(i = beo_Spill; i < beo_Last; ++i)
+ get_next_ir_opcode();
+
+ op_Spill = new_ir_op(beo_base + beo_Spill, "Spill", op_pin_state_mem_pinned, 0, oparity_unary, 0, sizeof(be_spill_attr_t), &be_node_op_ops);
+ op_Reload = new_ir_op(beo_base + beo_Reload, "Reload", op_pin_state_mem_pinned, 0, oparity_zero, 0, sizeof(be_node_attr_t), &be_node_op_ops);
+ op_Perm = new_ir_op(beo_base + beo_Perm, "Perm", op_pin_state_pinned, 0, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
+ op_Copy = new_ir_op(beo_base + beo_Copy, "Copy", op_pin_state_pinned, 0, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
+ op_Keep = new_ir_op(beo_base + beo_Keep, "Keep", op_pin_state_pinned, 0, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
+
+ set_op_tag(op_Spill, &be_node_tag);
+ set_op_tag(op_Reload, &be_node_tag);
+ set_op_tag(op_Perm, &be_node_tag);
+ set_op_tag(op_Copy, &be_node_tag);
+ set_op_tag(op_Keep, &be_node_tag);
+}
+
+static void *init_node_attr(ir_node* irn, const arch_register_class_t *cls, ir_graph *irg, int n_outs)
+{
+ be_node_attr_t *a = get_irn_attr(irn);
+
+ a->n_outs = n_outs;
+ a->cls = cls;
+ a->reg_data = NULL;
+
+ if(n_outs > 0) {
+ int i;
+
+ a->reg_data = NEW_ARR_D(be_reg_data_t, get_irg_obstack(irg), n_outs);
+ memset(a->reg_data, 0, n_outs * sizeof(a->reg_data[0]));
+ for(i = 0; i < n_outs; ++i) {
+ a->reg_data[i].req.req.cls = cls;
+ a->reg_data[i].req.req.type = arch_register_req_type_normal;
+ }
+ }
+
+ return a;
+}