1.0 Introduction

1.1 History

1.2 Characteristics

1.3 Scanner Generators

1.4 Parser Generators

1.5 Semantic Analyzer Generators

1.6 Optimization

1.7 Code Generation

1.8 Summary

Web References

Exercises

1.6 Optimization and Optimization Generators

The line between semantic analysis and optimization is fuzzy. If the information about use and definition of variables from Section 1.5 were used to eliminate variables defined, but never used, then we might consider this part of optimization. But, if this information were used to report to the programmer that a variable is used, but not first defined, then we would consider this semantic analysis.

Also, the code generation phase may make optimizations, both before and after executable code is selected. Optimizations on the generated code are called peephole optimizations.

The optimization phase changes the intermediate representation so that the code ultimately generated executes faster or takes up less space or uses special machine parts in improved ways.

Optimization can calculate attribute values (as in the calculation of use def in Section 1.5. ), or it can make structural changes to the tree, or it may even change the intermediate representation to a graph and make changes to the graph.

Modules 6, 7 and 8 discuss these various options. We will defer examples until those sections.