hamburger

Study Notes on Intermediate Code Generation

By BYJU'S Exam Prep

Updated on: September 25th, 2023

Intermediate codes are machine-independent codes, but they are close to machine instructions. The given program in a source language is converted to an equivalent program in an intermediate language by the intermediate code generator.

Intermediate codes are machine-independent codes, but they are close to machine instructions. The given program in a source language is converted to an equivalent program in an intermediate language by the intermediate code generator.
  • The designer of the compiler decides the intermediate language.
  • Syntax trees can be used as an intermediate language.
  • Postfix notations, three address codes (quadruples) can be used as an intermediate language.

Syntax Tree

Syntax tree is a variant of the parse tree, where each leaf represents an operand and each interior node represent an operator.

image001

A sentence a * (b +d) would have the following syntax tree

image002

image003

Three-Address Code

When each statement contains three addresses (two for operands and one for result), Most general kind of three-address code is

x = yop z

Where x, y and z are names, constants or compiler generated temporaries and op is any operator.

But we can also use the following notation for quadruples (much better notation because it looks like a machine code instruction)

Op y, z, x

Apply operator op to y and z and store the result in x.

Representation of Three-Address Codes

Three-address code can be represented in various forms i.e., quadruples, triples and indirect triples. These forms are demonstrated by way of examples below.

e.g., A = – B*(C +0)

Three address code is as follow

T1 = – B

T2 = C + D

T3 = T1* T2

A = T3

Quadruples

image004

Triples

image005

Indirect triple

image006

You can follow the detailed champion study plan for GATE CS 2022 from the following link:

Detailed GATE CSE 2022 Champion Study Plan

Candidates can also practice 110+ Mock tests for exams like GATE, NIELIT with BYJU’S Exam Prep Test Series check the following link:

Click Here to Avail GATE CSE Test Series!(100+ Mock Tests)

Get unlimited access to 21+ structured Live Courses all 112+ mock tests with Online Classroom Program for GATE CS & PSU Exams:

Click here to avail Online Classroom Program for Computer Science Engineering

Thanks.

Download BYJU’S Exam Prep, Best gate exam app for Preparation
Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium