📄 8.7.0.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.6.2c.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.7.0b.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>8.7 从dag生成目标代码</b></font>
<table><tr><td>    </td>
<td class="content">
<P>本节我们将考虑如何利用一个基本块的dag表示来生成目标代码。通过一个dag而非三地址语句或四元式的线性序列,我们可以很容易地了解如何重新组织最终的计算顺序。</P>
<P><font class="definition2">重排序</font></P>
<P>我们先简单地考虑一下什么样的计算顺序会影响目标代码的开销呢?考虑如下基本块:<br>
t<SPAN class=down><sub>1</sub></SPAN>:=a +b <BR>
t<SPAN
class=down><sub>2</sub></SPAN>:=c +d <BR>
t<SPAN class=down><sub>3</sub></SPAN>:=e-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>3</sub><br>
</SPAN>它的dag表示见图8.12(这个dag正好为一棵树)。 </P>
<P>这里的顺序是我们根据7.3节的语法制导翻译算法,对表达式(a+b)-(e-(c+d))生成的代码的自然顺序。</P>
<P align=center><IMG height=254 src="8.12.gif" width=248><BR><BR>图8.
12基本块的dag</P>
<P>如果我们运用8.5节的算法对此三地址语句序列生成目标代码,我们得到下页图8.13的代码序列(这里假定仅两个寄存器R0和R1可用,并且仅t<SPAN class=down><sub>4</sub></SPAN>在出口是活跃的)。<br>
</P>
</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.6.2c.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.7.0b.htm'"></img></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -