Summary
In this chapter, you learned how to set up an instruction selector using one of the two instruction selection frameworks that the LLVM infrastructure provides.
You learned that the instruction selectors worked by executing different phases: translating the input LLVM IR to a generic IR while introducing elements of the ABI, legalizing this IR toward something that the backend can support, and finally selecting the instructions by producing the Machine IR of your backend.
We presented you with the different characteristics of the selectors and provided recommendations so that you can decide which selector to use based on your use cases and preferences.
You learned the specificities of the generic IR used by each selector, namely the SelectionDAG
representation for SDISel and the generic Machine IR for GlobalISel, and discovered which APIs to use to manipulate these IRs.
Now that you understand the phases involved in the selectors, we can start going deeper into...