Home My Page Projects Code Snippets Project Openings SML/NJ
 Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

# SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/alpha/instructions/alphaPeephole.sml
 [smlnj] / sml / trunk / src / MLRISC / alpha / instructions / alphaPeephole.sml

# Diff of /sml/trunk/src/MLRISC/alpha/instructions/alphaPeephole.sml

revision 656, Fri Jun 9 03:39:04 2000 UTC revision 657, Fri Jun 9 05:20:54 2000 UTC
# Line 9  Line 9
9           | isZero(I.IMMop i) = i = 0           | isZero(I.IMMop i) = i = 0
10           | isZero _ = false           | isZero _ = false
11
12         fun removable(I.LDA{r, b, d}) = isZero d andalso r = b         fun removable(I.LDA{r, b, d}) = isZero d andalso regmap r = regmap b
13           | removable(I.OPERATE{oper=(I.ADDQ | I.SUBQ), ra, rb, rc}) =           | removable(I.OPERATE{oper=(I.ADDQ | I.SUBQ), ra, rb, rc}) =
14               regmap ra = regmap rc andalso isZero rb               regmap ra = regmap rc andalso isZero rb
15           | removable(I.ANNOTATION{i,a}) = removable i           | removable(I.ANNOTATION{i,a}) = removable i
16           | removable _ = false           | removable _ = false
17
18           fun symmetric(I.STQ, I.LDQ) = true
19             | symmetric(I.STL, I.LDL) = true
20             | symmetric(I.STW, I.LDW) = true
21             | symmetric(I.STB, I.LDB) = true
22             | symmetric _             = false
23
24           fun sameOperand (I.REGop r1, I.REGop r2) = regmap r1 = regmap r2
25             | sameOperand (I.IMMop i1, I.IMMop i2) = i1 = i2
26             | sameOperand (I.LABop l1, I.LABop l2) =
27                    I.LabelExp.valueOf l1 = I.LabelExp.valueOf l2
28             | sameOperand _ = false
29
30         fun loop([], instrs) = rev instrs         fun loop([], instrs) = rev instrs
31             | loop((ld as I.LOAD {ldOp, r=r2, b=b2, d=d2, ...})::
32                    (st as I.STORE{stOp, r=r1, b=b1, d=d1, ...})::rest, instrs) =
33               if symmetric(stOp, ldOp) andalso regmap r1 = regmap r2
34                  andalso regmap b1 = regmap b2 andalso sameOperand(d1,d2)
35               then loop(rest, st::instrs)
36               else loop(rest, st::ld::instrs)
37           | loop(i::rest, instrs) =           | loop(i::rest, instrs) =
38             if removable i then loop(rest, instrs)             if removable i then loop(rest, instrs)
39             else loop(rest, i::instrs)             else loop(rest, i::instrs)

Legend:
 Removed from v.656 changed lines Added in v.657