Chapter 9:Code generation

Instruction Selection

. Instruction selection

. uniformity

. completeness

. Instruction speed

. Register allocation Instructions with register operands are faster

- store long life time and counters in registers

- temporary locations

- Even odd register pairs

. Evaluation order

The nature of the instruction set of the target machine determines the difficulty of instruction selection. The uniformity and completeness of the instruction set are important factors. So, the instruction selection depends upon:

1. Instructions used i.e. which instructions should be used in case there are multiple instructions that do the same job.

2. Uniformity i.e. support for different object/data types, what op-codes are applicable on what data types etc.

3. Completeness: Not all source programs can be converted/translated in to machine code for all architectures/machines. E.g., 80x86 doesn't support multiplication.

4. Instruction Speed: This is needed for better performance.

5. Register Allocation:

. Instructions involving registers are usually faster than those involving operands memory.

. Store long life time values that are often used in registers.

6. Evaluation Order: The order in which the instructions will be executed. This increases performance of the code.