Summary
In this chapter, we looked at all the ways you can inject target-specific constructs at the LLVM IR level.
To get started, you saw how to add a target to the LLVM project. The process involved creating a new directory in llvm/lib/Target
and connecting it to the build system. You learned how to do the same thing with Clang such that it can produce LLVM IR for your backend.
You also discovered how to create your own built-in functions, called intrinsics, and connect them at the source language level via Clang.
Then, you saw how to tell the LLVM optimizers about your target-specific constraints by creating your own implementation of the TargetTransformInfo
class. While what was presented in this chapter remain toy examples, they gave you concrete illustrations of how to connect things in the LLVM infrastructure.
Finally, you learned how you can inject your own LLVM IR passes into the default pass pipelines, used by tools such as Clang. In the process, you learned...