intel/fs/ra: Do the spill loop inside RA
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -7279,9 +7279,7 @@ fs_visitor::allocate_registers(unsigned min_dispatch_width, bool allow_spilling)
|
|||||||
/* We should only spill registers on the last scheduling. */
|
/* We should only spill registers on the last scheduling. */
|
||||||
assert(!spilled_any_registers);
|
assert(!spilled_any_registers);
|
||||||
|
|
||||||
do {
|
|
||||||
allocated = assign_regs(can_spill, spill_all);
|
allocated = assign_regs(can_spill, spill_all);
|
||||||
} while (!allocated && can_spill && !failed);
|
|
||||||
if (allocated)
|
if (allocated)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1051,32 +1051,36 @@ fs_reg_alloc::spill_reg(unsigned spill_reg)
|
|||||||
bool
|
bool
|
||||||
fs_reg_alloc::assign_regs(bool allow_spilling, bool spill_all)
|
fs_reg_alloc::assign_regs(bool allow_spilling, bool spill_all)
|
||||||
{
|
{
|
||||||
|
while (1) {
|
||||||
build_interference_graph(fs->spilled_any_registers);
|
build_interference_graph(fs->spilled_any_registers);
|
||||||
|
|
||||||
/* Debug of register spilling: Go spill everything. */
|
/* Debug of register spilling: Go spill everything. */
|
||||||
if (unlikely(spill_all)) {
|
if (unlikely(spill_all)) {
|
||||||
int reg = choose_spill_reg();
|
int reg = choose_spill_reg();
|
||||||
|
|
||||||
if (reg != -1) {
|
if (reg != -1) {
|
||||||
spill_reg(reg);
|
spill_reg(reg);
|
||||||
return false;
|
ralloc_free(g);
|
||||||
|
g = NULL;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ra_allocate(g)) {
|
if (ra_allocate(g))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!allow_spilling)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* Failed to allocate registers. Spill a reg, and the caller will
|
/* Failed to allocate registers. Spill a reg, and the caller will
|
||||||
* loop back into here to try again.
|
* loop back into here to try again.
|
||||||
*/
|
*/
|
||||||
int reg = choose_spill_reg();
|
int reg = choose_spill_reg();
|
||||||
|
if (reg == -1)
|
||||||
if (reg == -1) {
|
|
||||||
fs->fail("no register to spill:\n");
|
|
||||||
fs->dump_instructions(NULL);
|
|
||||||
} else if (allow_spilling) {
|
|
||||||
spill_reg(reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
spill_reg(reg);
|
||||||
|
ralloc_free(g);
|
||||||
|
g = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the chosen virtual registers for each node, and map virtual
|
/* Get the chosen virtual registers for each node, and map virtual
|
||||||
@@ -1109,5 +1113,10 @@ bool
|
|||||||
fs_visitor::assign_regs(bool allow_spilling, bool spill_all)
|
fs_visitor::assign_regs(bool allow_spilling, bool spill_all)
|
||||||
{
|
{
|
||||||
fs_reg_alloc alloc(this);
|
fs_reg_alloc alloc(this);
|
||||||
return alloc.assign_regs(allow_spilling, spill_all);
|
bool success = alloc.assign_regs(allow_spilling, spill_all);
|
||||||
|
if (!success && allow_spilling) {
|
||||||
|
fail("no register to spill:\n");
|
||||||
|
dump_instructions(NULL);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user