(8.3.1)--第08章-代码生成3-基本块和流图_en.pdf
《(8.3.1)--第08章-代码生成3-基本块和流图_en.pdf》由会员分享,可在线阅读,更多相关《(8.3.1)--第08章-代码生成3-基本块和流图_en.pdf(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Compilers TechniquesCode GenerationHow to Generate Object Code for three address statement sequences?prod=0;i=1;do prod=prod+ai bi;i=i+1;while(i=20);(1)prod=0(2)i=1(3)t1=4 i(4)t2=at1(5)t3=4 i(6)t4=bt3(7)t5=t2 t4(8)t6=prod+t5(9)prod=t6(10)t7=i+1(11)i=t7(12)if i=20 goto(3)The three address code is sho
2、wn on the right.Basic Blocks and Flow GraphsBasic BlockBasic blocksA sequence of successive statements in which the control flow enters from its beginning and leaves from its end.Flow graphsThe directed edges are used to represent the control flow information between the basic blocks,and the flow gr
3、aph of the program can be obtained.Basic Blocks and Flow Graphs(1)prod=0(2)i=1(3)t1=4 i(4)t2=at1(5)t3=4 i(6)t4=bt3(7)t5=t2 t4(8)t6=prod+t5(9)prod=t6(10)t7=i+1(11)i=t7(12)if i=20 goto(3)The method of dividing basic blocks(1)First,determine all entry statements.(1)prod=0(2)i=1(3)t1=4 i(4)t2=at1(5)t3=4
4、 i(6)t4=bt3(7)t5=t2 t4(8)t6=prod+t5(9)prod=t6(10)t7=i+1(11)i=t7(12)if i=20 goto(3)The first statement in the sequence is an entry statement.Any statement that can be transferred from the transfer statement is an entry statement.Any statement immediately following the transfer statement is an entry s
5、tatement.(2)The sequence of statements from each entry statement to the next(or to the end of the program)constitutes a basic blockBasic Blocks and Flow Graphs(1)prod=0(2)i=1(3)t1=4 i(4)t2=at1(5)t3=4 i(6)t4=bt3(7)t5=t2 t4(8)t6=prod+t5(9)prod=t6(10)t7=i+1(11)i=t7(12)if i=20 goto(3)Basic Blocks and Fl
6、ow Graphsprod:=0i:=1t1:=4*it2:=at1t3:=4*It4:=bt3t5:=t2*t4t6:=prod+t5prod:=t6t7:=i+1i:=t7if i=20 goto(3)B1B2Term The three-address statement x=y+z refer to y and z and values x.If the value of a name is referenced after a certain point in the basic block,the name(variable)is said to be active at that
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 8.3 08 代码 生成 基本 _en
限制150内