Adding a new backend in LLVM
In this section, you will learn how to register a new backend in the LLVM build system and plumb the information of that target all the way up to Clang, such that you can enable this target via a Clang invocation.
By the end of this section, you will be able to create a backend that can produce LLVM IR, with the default optimizing and non-optimizing pass pipelines (that is, the O0
, O1
, and so on options that you regularly use with your favorite compiler toolchain). The optimizations used in these pipelines nevertheless still use the default target information currently.
Let’s dive into the details!
Connecting your target to the build system
Each LLVM backend lives in its own directory under llvm/lib/Target/<MyTarget>
, where <MyTarget>
is the name of your backend. In our case, we will create an H2BLB
directory.
Your first task consists of connecting this new directory to the LLVM build system.
The connection to...