Use a constraint solver for register coloring.

Most of the time, register coloring is almost trivial: just pick
available registers for the values defined by the current instruction.
However, some instructions have register operand constraints, and it may
be necessary to move live registers around to satisfy the constraints.
Sometimes the instruction's own operands can interfere with each other
in a way that you can't just pick a register assignment for each output
in order.

This is complicated enough that it is worthwhile to represent as a
constraint satisfaction problem in a separate solver module. The
representation is chosen to be very fast in the common case where the
constraints are trivial to solve.

The current implementation is still incomplete, but as functional as the
code it's replacing. Missing features:

- Handle tied operand constraints.
- Handle ABI constraints on calls and return instructions.
- Execute a constraint solution by emitting regmove instructions.
- Handling register diversions before leaving the EBB.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-28 15:41:28 -07:00
parent 2873019779
commit 6b4c28d554
4 changed files with 763 additions and 105 deletions

View File

@@ -11,6 +11,7 @@ pub mod coloring;
mod affinity;
mod context;
mod diversion;
mod solver;
pub use self::allocatable_set::AllocatableSet;
pub use self::context::Context;