Intermediate Code Generation

By : Manglika Tripathi

Updated : Feb 26, 2021, 0:01

The code which is used for the conversion of source code into machine code is termed as intermediate code. Intermediate code lies in the middle of source code & machine code. The intermediate code generator, which is usually the front end of a compiler, is used to generate intermediate code. Intermediate code generation is done for the target machine & are machine-independent codes. Intermediate Code Generation for computer science is important as it is asked in the GATE CS exam. Intermediate Code Generation GATE questions are asked under the ‘Compiler Design’ section of the GATE CS exam. Read on to know more about Intermediate Code Generation GATE syllabus.

Important Intermediate Code Generation Topics for GATE CS

Here are the important topics for intermediate code generation for GATE CS Exam.



Three-Address Code

Three-Address Code is a type of intermediate code that can contain at most three operands. It changes an entered statement into a machine-like statement. For example, let ‘x = y+z’ be an entered statement.

The aforementioned will be written in Three-Address Code as:

‘+ y, z, x’ which means that add y to z and store the result in x.

Syntax Tree

An expression, statement, etc. can be converted into syntax trees which are similar to parse trees. Syntax trees can be used as intermediate code, with each leaf representing an operand. The interior nodes of a syntax tree represent the operators.

Postfix Notations

Postfix Notations are also a type of intermediate code. The position of operators & operands in a postfix notation decides their compiling order. There is no need for parenthesis in a postfix notation. For example, an expression ‘a+b’ will be written in postfix notation as ‘a b +’.

Infix Notation

The ordinary way of writing mathematical expressions/statements is called infix notation, which is changed by the compiler into intermediate codes during compilation.

Tips to Solve Intermediate Code Generation Questions in GATE CS Exam

  • Practice Intermediate code generation quizzes to prepare for the GATE CS exam.
  • You should be well-rehearsed with the various intermediate codes used by the compiler, like Postfix Notification, Syntax Tree, etc. to be able to solve Intermediate code generation MCQ questions.
  • Revise all Intermediate code generation topics for GATE CS before giving the exam.
  • Make sure that you use the correct syntax while expressing a mathematical expression/statement into intermediate code.

Importance of Intermediate Code Generation in GATE

  • Intermediate code generation syllabus for GATE tests the understanding of machine language & compiler.
  • You will have to solve Intermediate Code Generation questions in a limited time in the GATE exam. This will also test your speed of solving GATE CS questions.
  • Intermediate code helps in increasing the portability of computer programs. For each machine, the analysis portion will be the same if they follow a machine-independent intermediate code. Intermediate Code Generation has many applications in the CS field.
  • Intermediate Code Generation topics also introduce us to the functionalities & complexity of various machines/compilers.

Most Recommended Books for Intermediate Code Generation for GATE

You should have the complete Intermediate code generation study material for GATE CS for exam preparation. Some of the best Intermediate code generation books for GATE exam preparation are as follows:

Book Name


Compiler Design

Aho & Ull Man

Engineering a Compiler

Keith D Cooper & Linda Torczon

Advanced Compiler Design & Implementation

Steven Muchnick

Why prepare Intermediate Code Generation from BYJU'S Exam Prep?

BYJU'S Exam Prep is the most trusted exam preparation platform in India, with more than 11 million registered students. You can access Intermediate code generation notes for CS for free via the BYJU'S Exam Prep website. One can also access/download Intermediate code generation notes for GATE PDF & Intermediate code generation GATE questions and answers PDF from BYJU'S Exam Prep. GATE courses for various streams are also available on BYJU'S Exam Prep by expert faculties. You can also test your knowledge by opting for various Intermediate code generation online tests available on BYJU'S Exam Prep. Downloadable Intermediate code generation MCQ PDFs are also available on BYJU'S Exam Prep for GATE CS exam preparation. You can prepare better via the Intermediate Code Generation GATE notes available on BYJU'S Exam Prep. Start preparing for the GATE CS 2021 exam now!


Q. Write the static single assignment form of the given three address code:

p = a – b

q = p * c

p = u * v

q = p + q

The required form is:

P3 = a – b

q4 = p3 * c

p4 = u * c

q5 = p4 + q4

Q. Which type of languages require heap allocation in runtime?

Languages that have dynamic data structures require heap allocation.

Q. Why are code optimisations carried out on an intermediate code?

Code optimisations increase the portability of intermediate codes to other processors.

Q. Why is Live Variable Analysis used in Intermediate Code Generation?

It is used for eliminating dead code. You can learn more about GATE FAQs by opting for Intermediate code generation online quizzes available on BYJU'S Exam Prep.

Q. Why is ‘Available Expression Analysis’ used?

It is used for common subexpression elimination during Intermediate Code Generation.