IAE Academy

GATE 2023 CS Q.11: solution and answer

GATE 2023 · CSQ.11 · 1 mark · MCQ

Consider the following statements regarding the front-end and back-end of a compiler.
S1: The front-end includes phases that are independent of the target hardware.
S2: The back-end includes phases that are specific to the target hardware.
S3: The back-end includes phases that are specific to the programming language used in the source code.
Identify the CORRECT option.

  1. (A)

    Only S1 is TRUE.

  2. (B)

    Only S1 and S2 are TRUE.

  3. (C)

    S1, S2, and S3 are all TRUE.

  4. (D)

    Only S1 and S3 are TRUE.

See the question in the paper

Answer and solution

ANSWER

Only S1 and S2 are TRUE, which is option (B).

Official answer: BSource: Official answer key, GATE 2023 CS (IIT Kanpur)

  1. A compiler is split into a front-end (analysis) and a back-end (synthesis). The front-end covers lexical analysis, parsing, semantic analysis and intermediate-code generation.

  2. The front-end works from the source language and produces an intermediate representation. It does not depend on the target machine, so S1 is TRUE.

  3. The back-end covers code optimisation and target code generation, including instruction selection, register allocation and instruction scheduling. These depend on the target hardware, so S2 is TRUE.

  4. The language-specific work (syntax, type rules, scoping) is done in the front-end. The back-end takes a language-independent intermediate representation, so S3 is FALSE.

  5. Only S1 and S2 are true, which is option (B).

KEY IDEA

The front-end is tied to the source language and independent of the target machine. The back-end is tied to the target machine and independent of the source language.

WATCH OUT FOR

Thinking the back-end also holds language-specific phases, because it follows the front-end in the pipeline. The back-end only sees the intermediate representation, which has no source-language details.

From the GATE 2023 CS paper. Every question of this paper · Download the full paper · All 8 Lexical analysis questions, with notes

More Lexical analysis questions