Question
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.
Official answer and solution
- Official answer
- B
- From
- Official GATE 2023 answer key
Solution
Recall the division of responsibility between compiler front-end and back-end.
- Front-End: Consists of lexical analysis, syntax analysis, semantic analysis, and intermediate code generation. These phases depend strictly on the source programming language and are completely independent of the target machine/hardware. Thus, S1 is TRUE.
- Back-End: Consists of target code generation, register allocation, instruction selection, and target-specific optimizations. These phases depend directly on the target machine architecture and instruction set, but are independent of the source language (operating only on the intermediate representation). Thus, S2 is TRUE, and S3 is FALSE.
Therefore, only S1 and S2 are TRUE.
Option (B)
Thinking the back-end depends on the source language syntax, forgetting that intermediate code decouples the front-end from the back-end.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2023 Computer Science and Information Technology (CS)
- Question
- 11 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.