0% found this document useful (0 votes)
30 views7 pages

Basic Block

The document discusses basic blocks in compiler design. It defines what a basic block is and provides an example of partitioning code into basic blocks. It also shows the three address code and corresponding basic blocks for a dot product example.

Uploaded by

rajch14587
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

Basic Block

The document discusses basic blocks in compiler design. It defines what a basic block is and provides an example of partitioning code into basic blocks. It also shows the three address code and corresponding basic blocks for a dot product example.

Uploaded by

rajch14587
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

12/10/22, 10:08 AM Basic Block - javatpoint

Home Compiler Data Structure C C++ C# Java SQL HTML CSS JavaScript

Bengaluru to New Delhi

from Rs6,650 Info


*

https://www.javatpoint.com/basic-block 1/7
12/10/22, 10:08 AM Basic Block - javatpoint

Basic Block
Basic block contains a sequence of statement. The flow of control enters at the beginning of the
statement and leave at the end without any halt (except may be the last instruction of the block).

The following sequence of three address statements forms a basic block:

t1:= x * x
t2:= x * y
t3:= 2 * t2
t4:= t1 + t3
t5:= y * y
t6:= t4 + t5

Basic block construction:


Algorithm: Partition into basic blocks

Input: It contains the sequence of three address statements

Output: it contains a list of basic blocks with each three address statement in exactly one block

Method: First identify the leader in the code. The rules for finding leaders are as follows:

The first statement is a leader.

Statement L is a leader if there is an conditional or unconditional goto statement like: if....goto


L or goto L

Instruction L is a leader if it immediately follows a goto or conditional goto statement like: if


goto B or goto B

https://www.javatpoint.com/basic-block 2/7
12/10/22, 10:08 AM Basic Block - javatpoint

For each leader, its basic block consists of the leader and all statement up to. It doesn't include the
next leader or end of the program.

Consider the following source code for dot product of two vectors a and b of length 10:

begin
prod :=0;
i:=1;
do begin
prod :=prod+ a[i] * b[i];
i :=i+1;
end
while i <= 10
end

The three address code for the above source program is given below:

B1

(1) prod := 0
(2) i := 1

B2

(3) t1 := 4* i
(4) t2 := a[t1]
(5) t3 := 4* i
(6) t4 := b[t3]
(7) t5 := t2*t4
(8) t6 := prod+t5
(9) prod := t6
(10) t7 := i+1
(11) i := t7
(12) if i<=10 goto (3)

Basic block B1 contains the statement (1) to (2)

https://www.javatpoint.com/basic-block 3/7
12/10/22, 10:08 AM Basic Block - javatpoint

Basic block B2 contains the statement (3) to (12)

← Prev Next →

With Love For Adam


& Cartier - Watch…
Zee Zest

Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

Send your Feedback to [email protected]

Help Others, Please Share

https://www.javatpoint.com/basic-block 4/7
12/10/22, 10:08 AM Basic Block - javatpoint

Learn Latest Tutorials

Splunk tutorial SPSS tutorial Swagger T-SQL tutorial


tutorial
Splunk SPSS Transact-SQL
Swagger

Tumblr tutorial React tutorial Regex tutorial Reinforcement


learning tutorial
Tumblr ReactJS Regex
Reinforcement
Learning

R Programming RxJS tutorial React Native Python Design


tutorial tutorial Patterns
RxJS
R Programming React Native Python Design
Patterns

Python Pillow Python Turtle Keras tutorial


tutorial tutorial
Keras
Python Pillow Python Turtle

Preparation

Aptitude Logical Verbal Ability Interview


Reasoning Questions
Aptitude Verbal Ability
Reasoning Interview Questions
https://www.javatpoint.com/basic-block 5/7
12/10/22, 10:08 AM Basic Block - javatpoint

Company
Interview
Questions
Company Questions

Trending Technologies

Artificial AWS Tutorial Selenium Cloud


Intelligence tutorial Computing
AWS
Tutorial tutorial
Selenium
Artificial Cloud Computing
Intelligence

Hadoop tutorial ReactJS Data Science Angular 7


Tutorial Tutorial Tutorial
Hadoop
ReactJS Data Science Angular 7

Blockchain Git Tutorial Machine DevOps


Tutorial Learning Tutorial Tutorial
Git
Blockchain Machine Learning DevOps

B.Tech / MCA

DBMS tutorial Data Structures DAA tutorial Operating


tutorial System tutorial
DBMS DAA
Data Structures Operating System

Computer Compiler Computer Discrete


Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
Computer Discrete
Organization Mathematics
https://www.javatpoint.com/basic-block 6/7
12/10/22, 10:08 AM Basic Block - javatpoint

Computer Network Compiler Design

Ethical Hacking Computer Software html tutorial


Tutorial Graphics Tutorial Engineering
Web Technology
Tutorial
Ethical Hacking Computer Graphics
Software
Engineering

Cyber Security Automata C Language C++ tutorial


tutorial Tutorial tutorial
C++
Cyber Security Automata C Programming

Java tutorial .Net Python tutorial List of


Framework Programs
Java Python
tutorial
Programs
.Net

Control Data Mining Data


Systems tutorial Tutorial Warehouse
Tutorial
Control System Data Mining
Data Warehouse

Sponsored

Kolhapur - City of Wrestlers - Watch


Full Episode
Zee Zest

https://www.javatpoint.com/basic-block 7/7

You might also like