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

Intermediate Code Generation Questions and Answers

61.

Assertion (A): Pointer assignments make optimisation of intermediate code harder.
Reason (R): The compiler cannot always determine which variables a pointer might refer to.

Answer: A

Both are true and the reason gives the mechanism, and the difficulty has a name. Alias analysis attempts to bound the set of possible targets, and where it cannot, the optimiser must assume the worst and forgo the transformation.

Please log in or register to report this question.

Answer: B

Two names that may alias cannot be treated independently. The analysis is conservative, reporting a possible alias whenever it cannot prove the absence of one. An unproven possibility must be treated exactly as a certainty would be.

Please log in or register to report this question.

Answer: C

Access to a variable in an enclosing procedure needs the depth difference, which selects how many links to follow. Access links or a display implement the traversal at run time. Languages without nested procedures avoid the whole mechanism.

Please log in or register to report this question.

Answer: D

The calling convention fixes where the result is left. The actual return sequence, including any stack adjustment, is completed by the code generator using target conventions. The intermediate form deliberately leaves those details unspecified.

Please log in or register to report this question.

Answer: A

Optimisation is always optional. Correct translation is the requirement, and an unoptimised construct simply runs more slowly than it might otherwise have done. Correctness is never negotiable in the way performance is.

Please log in or register to report this question.

Answer: B

Correct answer: larger than the number of source statements

One source statement expands into several three address instructions, because each operator and each subexpression becomes an instruction of its own with a temporary to hold the result. An expansion of several times is normal, and it is why the intermediate form is verbose but simple.

Please log in or register to report this question.

Answer: C

Sharing a node instead of creating a duplicate is exactly the elimination. The other three transformations need information beyond the single block the graph describes. A flow graph over the whole procedure is required for those.

Please log in or register to report this question.

Answer: D

Equal numbers mark redundant computations that can be shared. The technique is the algorithmic counterpart of building a directed acyclic graph for the block. Both methods find the same redundancies by different routes.

Please log in or register to report this question.

Answer: A

The first three are all representations of the program's computation. The token stream carries no structure at all and is consumed by the parser rather than passed to the back end. By the time code is generated the tokens have long since been discarded.

Please log in or register to report this question.

Answer: B

Which instruction to emit depends on the operand types, and any coercions must already have been inserted. Generating code first would mean regenerating it once the types became known. Coercions in particular change which instruction must be emitted.

Please log in or register to report this question.

Loading…

Other Subjects

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