Chapter 8. Writing an LLVM Backend

In this chapter, we will cover the following recipes:

  • Defining registers and register sets
  • Defining the calling convention
  • Defining the instruction set
  • Implementing frame lowering
  • Printing an instruction
  • Selecting an instruction
  • Adding instruction encoding
  • Supporting a subtarget
  • Lowering to multiple instructions
  • Registering a target

Introduction

The ultimate goal of a compiler is to produce a target code, or an assembly code that can be converted into object code and executed on the actual hardware. To generate the assembly code, the compiler needs to know the various aspects of the architecture of the target machine—the registers, instruction set, calling convention, pipeline, and so on. There are lots of optimizations ...

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.