Chapter 13: Native Code Generation
This chapter shows how to take the intermediate code from Chapter 9, Intermediate Code Generation, and generate native code. The term native refers to whatever instruction set is provided in hardware on a given machine. This chapter presents a simple native code generator for x64, the dominant architecture on laptops and desktops.
This chapter covers the following main topics:
- Deciding whether to generate native code
- Introducing the x64 instruction set
- Using registers
- Converting intermediate code to x64 code
- Generating x64 output
The skills developed here include basic register allocation, instruction selection, writing assembler files, and invoking the assembler and linker to produce a native executable. The functionality built into this chapter generates code that runs natively on typical computers.