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:
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:
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:
The three address code for the above source program is given below:
Basic block B1 contains the statement (1) to (2)
Basic block B2 contains the statement (3) to (12)
Next TopicFlow Graph