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.

75.

Which of the following is/are type of data supported/added by/in typical object file formats in code generation phase of a compiler ?

(i) Data segment
(ii) Block started by symbol
(iii) Text segment

Exam Year(s)

MH SET - 2020, SET Exam - 2020,

Answer: C

All three are supported, so the answer is (i), (ii) and (iii) only.

Typical object file formats (such as ELF or COFF) produced by a compiler's code generation phase contain a text segment holding the machine code, a data segment holding initialised global and static data, and a BSS segment ('block started by symbol') recording the size of uninitialised data, which takes no space in the file and is zeroed at load time.

Each narrower option leaves out one of these standard sections.

Please log in or register to report this question.

76.

Which one of the following cannot be the input to the code generation process ?

Exam Year(s)

Tripura Public Service Commission - 2019,

Answer: D

The answer is Machine code.

Code generation is the final phase of a compiler: it takes the program in an earlier form and produces target code. Machine code is what comes out of the process, so it cannot be its input.

The code generator normally works on the intermediate code; the source program is what that intermediate code was made from and is the input to the translation as a whole; and an assembly program is translated into machine code by an assembler. Each can stand at the input side of code generation, while machine code never does.

Please log in or register to report this question.

Loading…

Other Subjects

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