Consider the following code
1. location = -1
2. i=0
3. if (i<100) goto 5
4. goto 13
5. t1 = 4*i
6. go to 3
7. t2 = A[t1]
8. if t2 = x goto 10
9. goto 11
10.location = i
11.t3 = i+1
12.i = t3
13.goto 3
The number of basic blocks from the given code are______
Basic block: The collection of 3AC statements from leader to next leader without including the next leader is known as the basic block.
Steps to find the basic blocks:
Now construct the basic block from leader to line before the next leader.
In the given 3AC $9$ leaders are there: $1,3,4,5,7,9,10,11,13$
There are $9$ basic block are there:
Ref: Basic Block
A number of basic blocks = Number of leaders. Because every basic block will contain 1 leader.
Now, how to find a leader?
So here in this question the number of leaders in the given control flow graph =9, which are 1,3,4,5,7,9,10,11,13.
The number of basic blocks from the given code is =9.
64.3k questions
77.9k answers
244k comments
80.0k users