As currently implemented, the decision whether a particular switch instruction is suitable for a jump table is made in the base class of TargetLowering. So the only control a target has is to allow or disallow emission of jump tables.
However, there is at least one target (PowerPC) and possibly others for which that decision depends on a bit more context than just the range and density.
This patch allows the targets to override these functions as well as provides the PowerPC overrides.
The PPC specific portion:
- No jump tables for small switches - there's a lot of overhead to set up a jump table due to use of the CTR and high-latency sign-extending load
- Avoid chaining moves to the CTR and branches on the CTR (when the target of a case has an indirect call, a CTR loop or another possible jump table)
- Avoid multiple CTR branches close together to avoid the possibility of branch aliasing (when the block terminated by the switch has an indirect call or explicit use of the CTR)
This isn't used currently but I was asked to use it. In any case, either this or #include <set> will be removed depending on which one I end up using.