Made to work with troff
This commit is contained in:
@@ -18,12 +18,15 @@ but in general it will save space too.
|
||||
As an example of the application of Common Subexpression Elimination,
|
||||
consider the piece of program in Fig. 7.1(a).
|
||||
.DS
|
||||
x := a * b; TMP := a * b; x := a * b;
|
||||
CODE; x := TMP; CODE
|
||||
y := c + a * b; CODE y := x;
|
||||
y := c + TMP;
|
||||
.TS
|
||||
l l l.
|
||||
x := a * b; TMP := a * b; x := a * b;
|
||||
CODE; x := TMP; CODE
|
||||
y := c + a * b; CODE y := x;
|
||||
y := c + TMP;
|
||||
|
||||
(a) (b) (c)
|
||||
(a) (b) (c)
|
||||
.TE
|
||||
|
||||
Fig. 7.1 Examples of Common Subexpression Elimination
|
||||
.DE
|
||||
|
||||
@@ -70,10 +70,13 @@ a common subexpression,
|
||||
references to the element itself are replaced by
|
||||
indirect references through TMP (see Fig. 7.4).
|
||||
.DS
|
||||
x := A[i]; TMP := &A[i];
|
||||
. . . --> x := *TMP;
|
||||
A[i] := y; . . .
|
||||
*TMP := y;
|
||||
.TS
|
||||
l l l.
|
||||
x := A[i]; TMP := &A[i];
|
||||
. . . --> x := *TMP;
|
||||
A[i] := y; . . .
|
||||
*TMP := y;
|
||||
.TE
|
||||
|
||||
Fig. 7.4 Elimination of an array address computation
|
||||
.DE
|
||||
|
||||
@@ -27,10 +27,13 @@ The value number of the result of an expression depends only
|
||||
on the kind of operator and the value number(s) of the operand(s).
|
||||
The expressions need not be textually equal, as shown in Fig. 7.5.
|
||||
.DS
|
||||
a := c; (1)
|
||||
.TS
|
||||
l l.
|
||||
a := c; (1)
|
||||
use(a * b); (2)
|
||||
d := b; (3)
|
||||
d := b; (3)
|
||||
use(c * d); (4)
|
||||
.TE
|
||||
|
||||
Fig. 7.5 Different expressions with the same value number
|
||||
.DE
|
||||
@@ -43,9 +46,12 @@ and the operator (*) is the same.
|
||||
.PP
|
||||
As another example of the value number method, consider Fig. 7.6.
|
||||
.DS
|
||||
.TS
|
||||
l l.
|
||||
use(a * b); (1)
|
||||
a := 123; (2)
|
||||
use(a * b); (3)
|
||||
.TE
|
||||
|
||||
Fig. 7.6 Identical expressions with the different value numbers
|
||||
.DE
|
||||
@@ -64,7 +70,7 @@ of its operands.
|
||||
A table of "available expressions" is used to do this mapping.
|
||||
.PP
|
||||
CS recognizes the following kinds of EM operands, called \fIentities\fR:
|
||||
.IP
|
||||
.DS
|
||||
- constant
|
||||
- local variable
|
||||
- external variable
|
||||
@@ -81,6 +87,7 @@ CS recognizes the following kinds of EM operands, called \fIentities\fR:
|
||||
- local base
|
||||
- heap pointer
|
||||
- ignore mask
|
||||
.DE
|
||||
.LP
|
||||
Whenever a new entity is encountered in the working window,
|
||||
it is entered in the symbol table and given a brand new value number.
|
||||
|
||||
@@ -26,26 +26,26 @@ There are groups for all sorts of operators:
|
||||
unary, binary, and ternary.
|
||||
The groups of operators are further partitioned according to the size
|
||||
of their operand(s) and result.
|
||||
\" .PP
|
||||
\" The distinction between operators and expensive loads is not always clear.
|
||||
\" The ADP instruction for example,
|
||||
\" might seem a unary operator because it pops one item
|
||||
\" (a pointer) from the stack.
|
||||
\" However, two ADP-instructions which pop an item with the same value number
|
||||
\" need not have the same result,
|
||||
\" because the attributes (an offset, to be added to the pointer)
|
||||
\" can be different.
|
||||
\" Is it then a binary operator?
|
||||
\" That would give rise to the strange, and undesirable,
|
||||
\" situation that some binary operators pop two operands
|
||||
\" and others pop one.
|
||||
\" The conclusion is inevitable:
|
||||
\" we have been fooled by the name (ADd Pointer).
|
||||
\" The ADP-instruction is an expensive load.
|
||||
\" In this context LAF, meaning Load Address of oFfsetted,
|
||||
\" would have been a better name,
|
||||
\" corresponding to LOF, like LAL,
|
||||
\" Load Address of Local, corresponds to LOL.
|
||||
.\" .PP
|
||||
.\" The distinction between operators and expensive loads is not always clear.
|
||||
.\" The ADP instruction for example,
|
||||
.\" might seem a unary operator because it pops one item
|
||||
.\" (a pointer) from the stack.
|
||||
.\" However, two ADP-instructions which pop an item with the same value number
|
||||
.\" need not have the same result,
|
||||
.\" because the attributes (an offset, to be added to the pointer)
|
||||
.\" can be different.
|
||||
.\" Is it then a binary operator?
|
||||
.\" That would give rise to the strange, and undesirable,
|
||||
.\" situation that some binary operators pop two operands
|
||||
.\" and others pop one.
|
||||
.\" The conclusion is inevitable:
|
||||
.\" we have been fooled by the name (ADd Pointer).
|
||||
.\" The ADP-instruction is an expensive load.
|
||||
.\" In this context LAF, meaning Load Address of oFfsetted,
|
||||
.\" would have been a better name,
|
||||
.\" corresponding to LOF, like LAL,
|
||||
.\" Load Address of Local, corresponds to LOL.
|
||||
.PP
|
||||
There are groups for all sorts of stores:
|
||||
direct, indirect, array element.
|
||||
@@ -91,10 +91,13 @@ because EM expressions are postfix.
|
||||
When we find an instruction to load an operand,
|
||||
we load on the fake-stack a struct with the following information:
|
||||
.DS
|
||||
(1) the value number of the operand
|
||||
(2) the size of the operand
|
||||
(3) a pointer to the first line of EM-code
|
||||
that constitutes the operand
|
||||
.TS
|
||||
l l.
|
||||
(1) the value number of the operand
|
||||
(2) the size of the operand
|
||||
(3) a pointer to the first line of EM-code
|
||||
that constitutes the operand
|
||||
.TE
|
||||
.DE
|
||||
In most cases, (3) will point to the line
|
||||
that loaded the operand (e.g. LOL, LOC),
|
||||
@@ -121,9 +124,12 @@ a recurrence of this expression.
|
||||
Not only will the operand(s) be popped from the fake-stack,
|
||||
but the following will be pushed:
|
||||
.DS
|
||||
(1) the value number of the result
|
||||
(2) the size of the result
|
||||
(3) a pointer to the first line of the expression
|
||||
.TS
|
||||
l l.
|
||||
(1) the value number of the result
|
||||
(2) the size of the result
|
||||
(3) a pointer to the first line of the expression
|
||||
.TE
|
||||
.DE
|
||||
In this way an item on the fake-stack always contains
|
||||
the necessary information.
|
||||
|
||||
Reference in New Issue
Block a user