Stream: git-cranelift

Topic: cranelift / Issue #499 Coloring: Handle tied constraints ...


view this post on Zulip GitHub (Feb 28 2020 at 23:24):

alexcrichton transferred Issue #499:

Tied constraints are when an input to an instruction has to be in the same register as an output, as is the case for most arithmetic instructions on x86.

Currently, Cranelift's register allocator handles this constraint in the coloring pass. However, the coloring pass is very late, when a lot decisions have already been made, and a lot of other constraints have been saved up to be solved at once.

One idea for doing this would be to extend the concept of CSSA form produced by the coalescing pass. CSSA is essentially about putting "phi-related" values into sets which can be allocated the same virtual register, because whenever the input to a phi and the output to a phi can occupy the same register, we avoid a copy. Tied constraints are very similar: we want the input to an instruction and the output to be in the same register, so coalescing them would also avoid requiring a copy.

In cases where the input and output register conflict, we could insert an explicit copy.

And since coalescing happens before spilling or coloring, this should mean that coloring wouldn't have to worry about these constraints.


Last updated: Nov 22 2024 at 16:03 UTC