-/**
- * Handle register targeting constraints signaled by a Perm.
- * @param alloc_env Private data for the allocation phase.
- * @param perm The Perm node guarding the constrained node.
- * @return The constrained node.
-
- Pro-coloring works as follows:
-
- +-----------------------------------+
- | Perm |
- +---.-------.--------.---------.----+
- | | | |
- +---+--+ | | |
- | Proj | | | |
- +------+ | | |
- | | |
- +--+---+ | |
- | Proj | | |
- +--.---+ | |
- | | |
- | +--+---+ |
- | | Proj | |
- | +------+ |
- | |
- | +---+--+
- `-. | Proj | Result:
- `._ +---.--+ R1
- `. |
- `-. |
- `._ |
- +`.-+--+
- |Constr| Result:
- +------+ R2
-
- 1) Look at all Projs of the Perm if they have output constraints.
- If one has an output constraint, pre-color it, else record it
- in the set leftover. Its color has to be chosen after all
- constrained nodes are colored. Furthermore record all colors
- used in the pre-coloring in the set colors_used.
-
- 2) Look whether the first node not a Proj (this is the constrained
- node due to which the Perm has been inserted) has an output
- constraint. If yes, pre-color the node accordingly else do nothing
- since the node's input constraints are modelled by the Proj's
- output constraint.
-
- There's one subtle point here: If thenode has an output constraint
- and the live range of some Proj ends at that node, we must give
- that Proj the color of the constrained node. Otherwise the
- available colors may not suffice for the rest of the projs.
-
- 3) At last, color the Projs which have not been colored yet with the
- left over colors.
-
- So afterwards, everything including the constrained node will
- be colored and the assign() phase can complete this coloring.
- Note that therefore, we put the pre-colored nodes in a set
- called pre_colored().
+static operand_t *find_unpaired_use(insn_t *insn, const operand_t *op, int can_be_constrained)
+{
+ int i;
+ operand_t *res = NULL;
+
+ for(i = insn->use_start; i < insn->n_ops; ++i) {
+ operand_t *op = &insn->ops[i];
+ int has_constraint = arch_register_req_is(&op->req, limited);
+
+ if(!values_interfere(op->carrier, op->irn) && !op->partner && (!has_constraint || can_be_constrained)) {
+ if(arch_register_req_is(&op->req, should_be_same) && op->req.other == op->carrier)
+ return op;
+ else
+ res = op;
+ }
+ }