
246 CHAPTER 5 Program Design and Analysis
5.5.7 Instruction Selection
Selecting the instructions to use to implement each operation is not trivial. There
may be several different instructions that can be used to accomplish the same goal,
but they may have different execution times. Moreover, using one instruction for
one part of the program may affect the instructions that can be used in adjacent
code.Although we cannot discuss all the problems and methods for code generation
here, a little bit of knowledge helps us envision what the compiler is doing.
One useful technique for generating code is template matching, illustrated in
Figure 5.20. We have ...