Next: Structure of a compiler
Up: The Analysis-Synthesis Model
Previous: Tokens, patterns and lexemes
- The CODE OPTIMIZATION attempts to improve the intermediate
code in order to reduce the running time and the running space of the target executable program.
- Some optimizations are trivial. In our example
- the conversion of the integer 10 to the float 10.0 can be avoided,
- the creation of the TEMPORARY VARIABLES temp1 and temp3
can be avoided too.
- Other optimizations require more sophisticated techniques ...
- The CODE GENERATION consists of
- selecting memory location for each variable used by the (optimized) program
- translating the IR into a sequence of target instructions.
- In our example
- registers R1 and R2 are chosen,
- the first and the second operand of each instruction specify
a source and a destination, respectively.
- the F of each instruction specifies that the instruction deals with floats
- ...
Next: Structure of a compiler
Up: The Analysis-Synthesis Model
Previous: Tokens, patterns and lexemes
Marc Moreno Maza
2004-12-02