Algorithm 2.1 Build-Basic-Blocks
Input: IR 表示下的指令序列 .
Output: 所有的基块.
1:Let be a new array. // 用来存放所有的Leader的下标
2:Let be a new array. // 用来表示第条指令是否为Leader,初始化为false
3: // 根据定义2.3, 号结点一定是Leader
4:for to do
5:if the type of is jump then
6: // 根据定理2.1寻找Leader
7: // 跳转指令x的目标指令的序号
8:
9:end if
10:end for
11: // 为Leader的数量
12:for to do
13:if IsLeader[i] then
14:
15:
16:end if
17:end for
18: // 根据定理2.2输出Basic Block
19:for to do
20:output
21:end for