Creating your own intrinsics
Intrinsics are special functions that are exposed at the source language level, such as C and C++, that allow to use of target-specific constructs. For instance, the Advanced Encryption Standard (AES) instruction set of the AArch64 or X86 backend exposes hardware-accelerated cryptographic instructions that you can leverage to speed up related algorithms.
In this section, you will learn how to expose your own intrinsics to the users of your backend. This task entails teaching Clang about your intrinsics and registering them as valid LLVM IR built-in functions. The connection to the assembly code will be covered in a later chapter, as it requires setting up some infrastructure at the Machine IR level.
In any case, before diving into how to connect such a construct, let’s address a high-level question – when do you need an intrinsic?
The pros and cons of intrinsics
Before you embark on adding an intrinsic, take the time to think...