Legalization overview
In the LLVM infrastructure, legalization is completely driven by the target. This means that the LLVM infrastructure provides some functionalities to do legalization, but it is the target’s responsibility to provide the strategies for how these functionalities are used to produce legal code.
Note
The code produced by the legalization phase is considered legal if you can lower it to an actual sequence of instructions. In other words, the output IR of the legalization phase does not need to be natively supported to be considered legal; it only needs to be supported in your implementation of the selection phase. For instance, if you fancy supplying a complete emulation of the i3
type yourself, you can tell the legalization phase that all the operations on this type are legal but then you will need to be able to handle these operations directly in the selection phase. Therefore, what we call legal code is whatever IR that can be handled by...