Machine-translated by Google. Questions are authored in English.
Top

Code Generation Questions and Answers

71.

Consider the following statements about code generation.
1. Instruction selection depends on the target instruction set.
2. Register allocation depends on the number of machine registers.
3. Both are independent of the source language being compiled.

Answer: C

All three hold. The back end sees only the intermediate representation and the machine description, which is precisely what allows one back end to serve several source languages. The machine description is the only thing that changes between targets.

Please log in or register to report this question.

Answer: D

Correct answer: intractable, so heuristics are used throughout the back end

Instruction selection over a graph, register allocation by colouring, and instruction scheduling are each NP-hard on their own, and they interact so that solving one well can worsen another. Every production compiler therefore uses heuristics, and the quality of its code is the quality of those heuristics.

Please log in or register to report this question.

Answer: A

Readability greatly eases development and debugging of the compiler itself. The cost is an extra assembly step, which matters mainly for compilation speed. Most production compilers still take that cost for the sake of maintainability.

Please log in or register to report this question.

Answer: B

The three decisions interact, and a good result requires them to be coordinated rather than each optimised in isolation. The front end has almost no bearing on the outcome. This is why back end work dominates the effort in an optimising compiler.

Please log in or register to report this question.

Loading…
Tags: Code Generation Questions and Answers || Code Generation MCQ Questions and Answers || Code Generation GK Questions and Answers || Code Generation GK MCQ Questions || Code Generation Multiple Choice Questions and Answers || Code Generation GK || GK on Code Generation || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design