Implement coloring::iterate_solution().
It can happen that the currently live registers are blocking a smaller register class completely, so the only way of solving the allocation problem is to turn some of the live-through registers into solver variables. When the quick_solve attempt fails, try to free up registers in the critical register class by turning live-through values into solver variables.
This commit is contained in:
@@ -590,6 +590,18 @@ impl Solver {
|
||||
self.find_solution()
|
||||
}
|
||||
|
||||
/// Try harder to find a solution.
|
||||
///
|
||||
/// Call this method after `quick_solve()` fails.
|
||||
///
|
||||
/// This may return an error with a register class that has run out of registers. If registers
|
||||
/// can be freed up in the starving class, this method can be called again after adding
|
||||
/// variables for the freed registers.
|
||||
pub fn real_solve(&mut self) -> Result<AllocatableSet, RegClass> {
|
||||
// TODO: Sort variables to assign smallest register classes first.
|
||||
self.find_solution()
|
||||
}
|
||||
|
||||
/// Search for a solution with the current list of variables.
|
||||
///
|
||||
/// If a solution was found, returns `Ok(regs)` with the set of available registers on the
|
||||
@@ -623,6 +635,11 @@ impl Solver {
|
||||
pub fn vars(&self) -> &[Variable] {
|
||||
&self.vars
|
||||
}
|
||||
|
||||
/// Check if `value` can be added as a variable to help find a solution.
|
||||
pub fn can_add_var(&mut self, _value: Value, constraint: RegClass, from: RegUnit) -> bool {
|
||||
!self.regs_in.is_avail(constraint, from)
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface for working with parallel copies once a solution has been found.
|
||||
|
||||
Reference in New Issue
Block a user