-\f
-/* Try to find an available hard register of mode MODE at
- CURRENT_INSN, matching the register class in CLASS_STR. Registers
- that already have bits set in REG_SET will not be considered.
-
- If an appropriate register is available, it will be returned and the
- corresponding bit(s) in REG_SET will be set; otherwise, NULL_RTX is
- returned. */
-
-rtx
-find_free_register (current_insn, class_str, mode, reg_set)
- rtx current_insn;
- char *class_str;
- int mode;
- HARD_REG_SET *reg_set;
-{
- int i, j;
- struct resources used;
- unsigned char clet = class_str[0];
- enum reg_class class
- = (clet == 'r' ? GENERAL_REGS : REG_CLASS_FROM_LETTER (clet));
-
- mark_target_live_regs (get_insns (), current_insn, &used);
-
- for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- {
- int success = 1;
-
- if (! TEST_HARD_REG_BIT (reg_class_contents[class], i))
- continue;
- for (j = HARD_REGNO_NREGS (i, mode) - 1; j >= 0; j--)
- {
- if (TEST_HARD_REG_BIT (*reg_set, i + j)
- || TEST_HARD_REG_BIT (used.regs, i + j))
- {
- success = 0;
- break;
- }
- }
- if (success)
- {
- for (j = HARD_REGNO_NREGS (i, mode) - 1; j >= 0; j--)
- {
- SET_HARD_REG_BIT (*reg_set, i + j);
- }
- return gen_rtx_REG (mode, i);
- }
- }
- return NULL_RTX;
-}