Compilers
Which describes instruction selection, one stage of code generation?
- ADeciding which of the target CPU's instructions implement each IR operation
- BDeciding the order in which the OS picks processes to run
- CExtracting instructions written as comments in the source code
Show answer and explanation
Answer: A. Deciding which of the target CPU's instructions implement each IR operation
Instruction selection maps sequences of IR operations to concrete instructions of the target CPU. Available instructions differ by CPU; a * b + c, for example, becomes one instruction if the CPU has a fused multiply-add (FMA) and two (multiply and add) otherwise. Making good use of the CPU's instructions, such as folding address calculations into addressing modes, yields faster code. It has nothing to do with OS scheduling or comments.
- A. Correct. It maps IR operations to CPU instructions.
- B. Process order is decided by the OS scheduler.
- C. Comments are removed during lexical analysis.