Preparing to generate code
Generating intermediate code produces enough information to enable the task of generating the final code that can be run. Like many things in life, a daunting task becomes possible when you prepare well. Eager developers might want to skip this phase and jump straight to final code generation, so let's consider why intermediate code generation is so advantageous. Generating final machine code is a complex task and most compilers use intermediate code to break the work up into stages to complete it successfully. This section will show you the details of what and why, starting with some specific technical motivations to generate intermediate code.
Why generate intermediate code?
The goal of this phase of your compiler is to produce a list of machine-independent instructions for each method in the program. Generating preliminary machine-neutral code as an intermediate representation of a program's instructions has the following benefits:
- ...