Chapter 2: Introduction to compilers

Code Generation

. Usually a two step process

- Generate intermediate code from the semantic representation of the program

- Generate machine code from the intermediate code

. The advantage is that each phase is simple

. Requires design of intermediate language

. Most compilers perform translation between successive intermediate representations

. Intermediate languages are generally ordered in decreasing level of abstraction from highest (source) to lowest (machine)

. However, typically the one after the intermediate code generation is the most important

 

The final phase of the compiler is generation of the relocatable target code. First of all, Intermediate code is generated from the semantic representation of the source program, and this intermediate code is used to generate machine code.