Write a flag allocation and lowering pass
As per the in-person meeting, what we think we want to do is to simply allow ALU ops on flag results (logical registers with bit_size == 1
) and then lower later. We need a pass which does the following;
- Allocate and assign HW flag registers to flag results and uses
- Determine when we can use the flag directly vs. when to spill to a bitfield scalar vs. when to spill to a D3D style 0/-1 integer boolean.
- Lower ALU logic ops on flag values to something reasonable
Exactly what values should be used directly as flags, when to lower to a bitfield scalar vs. D3D style 0/-1 integer, how to best lower ALU logic ops, etc. is going to have to be very heuristic. We can probably start simple with something that always uses D3D booleans unless the direct flag result can obviously be used. Getting something no worse than the naïve thing we do today shouldn't be too hard. Over time, we can get more complex and add better heuristics.
Along with this, we likely want to disable boolean to 32-bit int lowering and begin consuming 1-bit booleans from NIR directly.