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.
View worked solution
Answer: B
A compiler is typically structured into two main parts: the front-end and the back-end, connected by an Intermediate Representation (IR).
- Front-End: This part is responsible for analyzing the source program. It includes lexical analysis, syntax analysis, semantic analysis, and intermediate code generation. These phases depend solely on the source programming language and are completely independent of the target hardware. Thus, S1 is TRUE.
- Back-End: This part is responsible for translating the intermediate representation into the target machine code. It includes target-code optimization and code generation. These phases depend heavily on the specific instruction set, register availability, and memory architecture of the target hardware. Thus, S2 is TRUE.
- Source Language Independence of Back-End: Because the back-end operates on the Intermediate Representation (IR) rather than the raw source code, it is independent of the source programming language. This separation allows a compiler to support multiple source languages using the same back-end (by writing different front-ends that target the same IR). Thus, S3 is FALSE.
Therefore, only statements S1 and S2 are TRUE.
Free practice · Your answers on this page are not saved.
