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

Intermediate Code Generation Questions and Answers

51.

Arrange these steps of partitioning three address code into basic blocks.
1. mark each jump target and each instruction after a jump
2. identify the leaders among the instructions
3. form a block from each leader up to the next leader
4. take the first instruction of the program as a leader

Answer: C

The leaders are found first by the two rules, and each block then runs from one leader to just before the next. The partition is unique for a given instruction sequence. Two compilers applying the rules will always agree on the blocks.

Please log in or register to report this question.

Answer: D

Those three rules identify every point at which control may enter. Applying them to a sequence of instructions yields the partition into blocks directly. No judgement is involved, so the partition can be computed mechanically.

Please log in or register to report this question.

53.

A three address program of 20 instructions has 4 leaders. How many basic blocks does it contain?

Answer: A

A leader is the first instruction of a basic block, and every block has exactly one leader, so the two counts are equal: \[ \text{blocks} = \text{leaders} = 4 \] The 20 instructions are partitioned among those four blocks, with none left over and none belonging to two blocks at once. The instruction count constrains the average block size, \( 20/4 = 5 \), but not the number of blocks.

Please log in or register to report this question.

Answer: B

Correct answer: adding an edge wherever control can pass from one block to another

The nodes are the basic blocks and the edges are the possible transfers between them - a jump, a conditional branch taken or not taken, or simply falling through. That graph is what every data flow analysis propagates its facts over, so building it correctly is a precondition for optimising at all.

Please log in or register to report this question.

Answer: C

A transformation written once at that level benefits every source language and every target. Machine specific optimisations are left for the back end where the instruction set is known. The division keeps the front end usable with any target.

Please log in or register to report this question.

Answer: D

Each instruction names addresses, not expressions, so every intermediate value needs somewhere to live. The number of temporaries equals the number of operators under the simple scheme. Reusing them where lifetimes do not overlap reduces that count considerably.

Please log in or register to report this question.

Answer: A

Correct answer: reduces the number of distinct names the back end must handle

Expression translation generates a great many temporaries, most of them short-lived, and reusing a name once its value is dead cuts the number the register allocator must consider. The program’s meaning is unaffected, since the values never coexist.

Please log in or register to report this question.

58.

State whether the following is true or false.
Every value computed during expression translation must be stored in memory.

Answer: B

Correct answer: False

Most intermediate values are held in temporaries which the register allocator will place in registers, and never reach memory at all. Storing every value would make the generated code far slower than it needs to be, and avoiding that is a large part of what code generation is for.

Please log in or register to report this question.

Answer: C

Correct answer: is often removable by a later copy propagation pass

Copy propagation replaces later uses of x with y, after which the copy itself may be dead and removable. Copies arise in quantity from the translation of assignments and from parameter passing, so this is one of the more productive of the simple optimisations.

Please log in or register to report this question.

Answer: D

Correct answer: x = *y, an indirect assignment reading through the pointer

Three address code needs distinct forms for the pointer operations: taking an address, reading through a pointer, and writing through one. The dereference reads the value at the address held in y. Its presence complicates optimisation greatly, since the compiler may not know what y points at.

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