Getting Started with the Machine Code Layer
So far in this book, we started with high-level concepts and progressively, chapter by chapter, we explained how a concept is brought down to the next, lower level of abstraction. In this chapter, we break away from this top-down approach by making a detour to the machine code (MC) layer, which is the final stage of an LLVM backend.
We thought it was important to look at this layer now for two reasons.
First, this makes the instruction description you have been doing throughout Chapter 11 more concrete because you can see the connection to the hardware.
Second, adding the support for the MC layer to your target description (the .td
files that you wrote for your registers and instructions) can be disruptive if you did not think it through beforehand. In other words, if you do not consider the MC layer now, you may need to severely rewrite how your instruction records are structured in TableGen. For example, Figure 12.1 shows a...