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

Intermediate Code Generation Questions and Answers

Answer: A

Correct answer: decouple the source language front end from the machine dependent parts

With an intermediate form, m languages and n machines need m front ends and n back ends rather than m times n whole compilers. It also gives the optimiser a single representation to work on, independent of both ends - which is why the same optimisation passes serve every language the compiler accepts.

Please log in or register to report this question.

2.

A team adds an eighth target machine to a compiler suite that already supports 6 languages through a common intermediate representation. How many new components must be written?

Answer: B

A common intermediate representation decouples front ends from back ends, so adding a target costs exactly one component: \[ \text{new components} = 1 \ \text{(back end)} \] Without the shared representation the team would need one translator per language, \( 6 \times 1 = 6 \) new components, and the full matrix for \( m \) languages and \( n \) targets would be \( m \times n \) rather than \( m + n \). Avoiding exactly that multiplication is what the design buys.

Please log in or register to report this question.

Answer: C

The limit is an upper bound rather than a requirement. Copies use two addresses, unconditional jumps one, and only binary operations use the full three, so the name describes the widest instruction rather than every instruction in the set.

Please log in or register to report this question.

Answer: D

Correct answer: a binary assignment naming a destination and two operands

The form is called three address because it names three: the result and the two operands. Every complex expression is broken down into a sequence of such instructions with temporaries linking them, which is what makes the representation simple enough to optimise and to translate.

Please log in or register to report this question.

Answer: A

The first three each name at most three addresses. A nested expression names more, so it must be broken into several instructions with temporaries holding the intermediate results. The flattening is exactly what the intermediate code generator does.

Please log in or register to report this question.

6.

The expression (a + b) * (c - d) is translated into three address code with one operator per instruction. How many instructions are produced?

Answer: B

With one operator per instruction, the instruction count equals the operator count. The expression \( (a+b)*(c-d) \) contains three operators, so \[ n = 3 \] namely \( t_1 = a + b \), \( t_2 = c - d \), and \( t_3 = t_1 * t_2 \). Three temporaries are introduced, the last holding the value of the whole expression.

Please log in or register to report this question.

7.

An expression tree contains 7 binary operators and no unary ones. Translating it with one operator per instruction yields how many temporaries?

Answer: C

Each binary operator yields exactly one result, and each result needs one temporary, so the counts are equal: \[ \text{temporaries} = \text{operators} = 7 \] Optimisation may afterwards reduce how many actually occupy storage, since a temporary that is consumed immediately need not survive; register allocation is where that reduction really happens. The count of 7 is the number generated, not the number ultimately stored.

Please log in or register to report this question.

Answer: D

Correct answer: a compiler generated name holding an intermediate result

Temporaries are invented by the compiler to hold the partial results of an expression, and they appear nowhere in the source. They are not registers - allocating registers to them is a later and separate problem, and there are usually far more temporaries than the machine has registers.

Please log in or register to report this question.

Answer: A

Correct answer: an operator, two operands and a result field

The four fields give the quadruple its name, and the explicit result field is what makes it robust: each instruction names its own destination, so instructions can be moved, deleted or reordered without disturbing anything that refers to them.

Please log in or register to report this question.

Answer: B

Correct answer: omits the result field and refers to instructions by position

A triple saves the result field by letting an instruction be referred to by its own index in the sequence. That is more compact but couples every reference to the instruction’s position, so any reordering breaks it - which is why indirect triples were devised, adding a level of indirection to restore the freedom.

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