11.2 PROBLEMS THAT HINDER GOOD CODE GENERATION


11.1 AN INTRODUCTION TO CODE GENERATION

Code generation is the last phase in the compilation process. Being a machine-dependent phase, it is not possible to generate good code without considering the details of the particular machine for which the compiler is expected to generate code. Even so, a carefully selected code-generation algorithm can produce code that is twice as fast as code generated by an ill- considered code-generation algorithm.

In this chapter, we first discuss straightforward code generation from a sequence of three-address statements. This is followed by a discussion of the code-generation algorithm that takes into account the flow of control structures in the program when assigning registers to names . Then we will look at a code-generation algorithm that is capable of generating reasonably good code from a basic block. Finally, various machine-dependent optimizations that are capable of improving the efficiency of object code are discussed. Throughout our discussion, we assume that the input to the code-generation algorithm is a sequence of three-address statements partitioned into basic blocks.




Algorithms for Compiler Design
Algorithms for Compiler Design (Electrical and Computer Engineering Series)
ISBN: 1584501006
EAN: 2147483647
Year: 2005
Pages: 108
Authors: O G Kakde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net