Chapter 10: Intermediate Representations


Compilers translate programs from their source form into a representation that is suitable for interpretation or execution. The chapters of this book have thus far considered the scanning, parsing, and semantic analysis of programs written in source languages such as Java and C++. The Abstract Syntax Tree (AST) was introduced in Chapter 7 to represent the source program in a form that omits unnecessary syntactic detail. Semantic information was developed in Chapter 8 and Chapter 9 to prepare the AST for code generation. The next and final step of a simple compiler is code generation. Code generation for a virtual machine is considered in Chapter 11. Chapter 12 and Chapter 13 consider runtime support and code-generation techniques for low-level targets.

Preparation for generating code for a given architecture should include gaining some familiarity with the architecture. Such studies may include reading a specification of the code that will be generated, examining code sequences from other compilers, and writing some sample sequences by hand. In this chapter, we examine a form of code known as an Intermediate Representation. The studio for this chapter helps the student gain familiarity with the Java Virtual Machine instruction set.