Summary
In this chapter, you learned how to implement your own code generator for LLVM IR code. Basic blocks are an important data structure, holding all the instructions and expressing branches. You learned how to create basic blocks for the control statements of the source language and how to add instructions to a basic block. You applied a modern algorithm to handle local variables in functions, leading to less IR code. The goal of a compiler is to generate assembler text or an object file for the input, so you also added a simple compilation pipeline. With this knowledge, you will be able to generate LLVM IR and, subsequently, assembler text or object code for your own language compiler.
In the next chapter, you will learn how to deal with aggregate data structures and how to ensure that function calls comply with the rules of your platform.