- if(b->is_def)
- seen[nr] = b->step;
- else {
- int col = get_irn_color(irn);
-
- int pos = last_pos - seen[nr];
- int end_pos = last_pos - b->step;
- int live_in = is_live_in(block, irn);
- int live_out = is_live_out(block, irn);
- int y_val = y_dist * col;
-
- int red = 0;
- int green = live_out;
- int blue = live_in;
-
- fprintf(f, "0 0 0 setrgbcolor\n");
- fprintf(f, "%d %d moveto\n", x_dist * pos + 2, y_val + 2);
- ir_fprintf(f, "(%n/%d%s) show\n", irn, nr, is_phi_operand(irn) ? "*" : "");
- fprintf(f, "%d %d %d setrgbcolor\n", red, green, blue);
- fprintf(f, "%d %d moveto\n", x_dist * pos, y_val);
- fprintf(f, "%d %d lineto\n", (x_dist * end_pos) - 5, y_val);
- fprintf(f, "stroke\n");
+ /* also allocate the def and tie it to the use. */
+ def = obstack_alloc(&env->obst, sizeof(*def));
+ memset(def, 0, sizeof(*def));
+ b->other_end = def;
+ def->other_end = b;
+
+ /*
+ * Set the link field of the irn to the def.
+ * This strongly relies on the fact, that the use is always
+ * made before the def.
+ */
+ set_irn_link(irn, def);
+
+ b->magic = BORDER_FOURCC;
+ def->magic = BORDER_FOURCC;
+ }
+
+ /*
+ * If the def is encountered, the use was made and so was the
+ * the def node (see the code above). It was placed into the
+ * link field of the irn, so we can get it there.
+ */
+ else {
+ b = get_irn_link(irn);
+
+ assert(b && b->magic == BORDER_FOURCC && "Illegal border encountered");
+ }
+
+ b->pressure = pressure;
+ b->is_def = is_def;
+ b->is_real = is_real;
+ b->irn = irn;
+ b->step = step;
+ list_add_tail(&b->list, head);
+ DBG((env->dbg, LEVEL_5, "\t\t%s adding %+F, step: %d\n", is_def ? "def" : "use", irn, step));
+
+
+ return b;
+}
+
+/**
+ * Check, if an irn is of the register class currently under processing.
+ * @param env The chordal environment.
+ * @param irn The node.
+ * @return 1, if the node is of that register class, 0 if not.
+ */
+static INLINE int has_reg_class(const be_chordal_env_t *env, const ir_node *irn)
+{
+ // return arch_irn_has_reg_class(env->main_env->arch_env, irn, -1, env->cls);
+ return arch_irn_consider_in_reg_alloc(env->birg->main_env->arch_env, env->cls, irn);
+}
+
+#define has_limited_constr(req, irn) \
+ (arch_get_register_req(arch_env, (req), irn, -1) && (req)->type == arch_register_req_type_limited)
+
+typedef struct _operand_t operand_t;
+
+struct _operand_t {
+ ir_node *irn;
+ ir_node *carrier;
+ operand_t *partner;
+ int pos;
+ arch_register_req_t req;
+};
+
+typedef struct {
+ operand_t *ops;
+ int n_ops;
+ int use_start;
+ ir_node *next_insn;
+ unsigned has_constraints : 1;
+} insn_t;
+
+static insn_t *scan_insn(be_chordal_env_t *env, ir_node *irn, struct obstack *obst)
+{
+ const arch_env_t *arch_env = env->birg->main_env->arch_env;
+ operand_t o;
+ insn_t *insn;
+ int i, n;
+
+ insn = obstack_alloc(obst, sizeof(insn[0]));
+ memset(insn, 0, sizeof(insn[0]));
+
+ insn->next_insn = sched_next(irn);
+ if(get_irn_mode(irn) == mode_T) {
+ ir_node *p;
+
+ for(p = sched_next(irn); is_Proj(p); p = sched_next(p)) {
+ if(arch_irn_consider_in_reg_alloc(arch_env, env->cls, p)) {
+ o.carrier = p;
+ o.irn = irn;
+ o.pos = -(get_Proj_proj(p) + 1);
+ o.partner = NULL;
+ arch_get_register_req(arch_env, &o.req, p, -1);
+ obstack_grow(obst, &o, sizeof(o));
+ insn->n_ops++;
+ insn->has_constraints |= arch_register_req_is(&o.req, limited);