As suggested in D21534, I've split off the class deciding on how legalization should proceed (plus the legalizeInstr stub) into a separate unit-tested patch.
I've addressed most of the relevant comments from the original diff, with two outstanding issues:
- We'll need a richer setAction interface to cope with multiple types on instructions.
- Similarly, we'll need to be able to cope with per-address-space legalization.
I fully agree with both of these, but think they'll probably be added organically as we grow (certainly the first is needed for AArch64, and I'll make sure the second doesn't get neglected).
As with most of the other GlobalISel things, it's pretty rough around the edges as a prototype and I'm hoping to fill in the details as-needed and as-testable.