📄 8.3.1.htm
字号:
<html>
<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>
<body>
<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.3.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.3.1b.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>8.3 基本块和流图</b></font>
<table><tr><td>  </td>
<td class="content">
<p>三地址语句序列的一种图表示法称为流图,它对理解代码生成算法是很有用的,即使该图并未由一个代码生成算法明显地构造出来。流图中的结点表示计算,边表示控制流向。</p>
</td></tr></table>
<hr size=2 color=red width=90%>
<font class="title2"><b>8.3.1 基本块</b></font>
<table><tr><td>  </td>
<td class="content">
<p>一个<font class="emphasize">基本块</font>是这样一个连续语句序列:其中控制流从第一条语句(称为入口〕进入,从最后一条语句(称为出口)离开,没有中途停止或分枝。例如下面的三地址语句序列就形成了一个基本块:<br>
<center>t<SPAN class=down><sub>1</sub></SPAN>:=a * a<BR>t<SPAN
class=down><sub>2</sub></SPAN>:=a * b<BR>t<SPAN class=down><sub>3</sub></SPAN>:=2 *t<SPAN
class=down><sub>2</sub></SPAN><BR>t<SPAN class=down><sub>4</sub></SPAN>:=t<SPAN
class=down><sub>1</sub></SPAN>+t<SPAN class=down><sub>2</sub></SPAN><BR>t<SPAN class=down><sub>5</sub></SPAN>:=b
* b<BR>t<SPAN class=down><sub>6</sub></SPAN>:=t<SPAN class=down><sub>4</sub></SPAN>+t<SPAN
class=down><sub>5</sub></SPAN><P></center>
<p>一条三地址语句x:=y+z称为对x定值并引用y和z。在一个基本块中的一个名字,所谓在程序中的某个给定点是活跃的,是指如果在程序中(包括在本基本块或在其它基本块中〕它的值在该点以后被引用。</P>
<P><img class="dingyi" src="images/dingyi.gif"><B><FONT class=example>算法 8.1 </FONT> </B>划分三地址程序形成基本块
<br> 输入:一个三地址语句序列。
<br> 输出:一个基本块表,其中每一条三地址语句仅在一个块中。
<br> 方法:
<br> 1.我们首先确定各个基本块的入口语句。我们采用如下规则:
<br> (a)代码序列的第一个语句是一个入口语句。
<br> (b)任何一个条件或无条件转移语句转移到的那条语句是一个入口语句。
<br> (c)任何紧接在一个条件或无条件转移语句之后的那条语句是一个入口语句。
<br> 2.对上述求出的每一个入口语句。其基本块是由该入口语句到下一个入口语句(不包括此入口语句)、或到一个转移语句(包括此转移语句)、或到一个停语句(包括此停语句)之间的语句序列组成。
<table>
<tr>
<td><font class="yanshi">     观看演示 </font></td>
<td>
<font color=blue onmouseover="javascript:style.cursor='hand';" onclick="javascript:open('images/test8_1/Page1.htm','_blank','left=100,top=100,scrollbars=yes,resizable=yes,width=850,height=600')">
划分三地址程序行程基本块</font>
</td>
<td><img src="../images/yanshi.gif"></img></td>
</tr>
</td></tr></table>
<br>
<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.3.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.3.1b.htm'"></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -