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/ppc/ra/ppcRewrite.sml
 [smlnj] / sml / trunk / src / MLRISC / ppc / ra / ppcRewrite.sml

# Diff of /sml/trunk/src/MLRISC/ppc/ra/ppcRewrite.sml

sml/branches/SMLNJ/src/MLRISC/ppc/ra/ppcRewrite.sml revision 245, Sat Apr 17 18:47:12 1999 UTC sml/trunk/src/MLRISC/ppc/ra/ppcRewrite.sml revision 545, Thu Feb 24 13:56:44 2000 UTC
# Line 2  Line 2
2    structure I = Instr    structure I = Instr
3
4    fun ea(NONE, _, _, _) = NONE    fun ea(NONE, _, _, _) = NONE
5      | ea(e as SOME(I.Direct r), rs, rt, mapr) =      | ea(e as SOME(I.Direct r), rs, rt, mapr : I.C.cell -> I.C.cell) =
6         if mapr r=rs then SOME(I.Direct rt) else e         if mapr r=rs then SOME(I.Direct rt) else e
7      | ea(e as SOME(I.FDirect r), rs, rt, mapr) =      | ea(e as SOME(I.FDirect r), rs, rt, mapr) =
8         if mapr r=rs then SOME(I.FDirect rt) else e         if mapr r=rs then SOME(I.FDirect rt) else e
# Line 10  Line 10
10         if mapr base=rs then SOME(I.Displace{base=rt, disp=disp})         if mapr base=rs then SOME(I.Displace{base=rt, disp=disp})
11         else e         else e
12
13    fun rewriteUse(mapr, instr, rs, rt) = let    fun rewriteUse(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let
14      fun rplac r = if mapr r=rs then rt else r      fun rplac r = if mapr r=rs then rt else r
15      fun rwOperand(opnd as I.RegOp r) =      fun rwOperand(opnd as I.RegOp r) =
16           if mapr r = rs then I.RegOp rt else opnd           if mapr r = rs then I.RegOp rt else opnd
17        | rwOperand opnd = opnd        | rwOperand opnd = opnd
18    in    in
19      case instr      case instr
20      of I.L {sz, rt, ra, d, mem} =>      of I.L {ld, rt, ra, d, mem} =>
21          I.L{sz=sz, rt=rt, ra=rplac ra, d=rwOperand d, mem=mem}          I.L{ld=ld, rt=rt, ra=rplac ra, d=rwOperand d, mem=mem}
22       | I.ST {sz, rs, ra, d, mem} =>       | I.LF {ld, ft, ra, d, mem} =>
23          I.ST{sz=sz, rs=rplac rs, ra=rplac ra, d=rwOperand d, mem=mem}          I.LF{ld=ld, ft=ft, ra=rplac ra, d=rwOperand d, mem=mem}
24         | I.ST {st, rs, ra, d, mem} =>
25            I.ST{st=st, rs=rplac rs, ra=rplac ra, d=rwOperand d, mem=mem}
26         | I.STF {st, fs, ra, d, mem} =>
27            I.STF{st=st, fs=fs, ra=rplac ra, d=rwOperand d, mem=mem}
28         | I.UNARY {oper, rt, ra, Rc, OE} =>
29            I.UNARY{oper=oper, rt=rt, ra=rplac ra, Rc=Rc, OE=OE}
30       | I.ARITH{oper, rt, ra, rb, Rc, OE} =>       | I.ARITH{oper, rt, ra, rb, Rc, OE} =>
31          I.ARITH{oper=oper, rt=rt, ra=rplac ra, rb=rplac rb, Rc=Rc, OE=OE}          I.ARITH{oper=oper, rt=rt, ra=rplac ra, rb=rplac rb, Rc=Rc, OE=OE}
32       | I.ARITHI{oper, rt, ra, im} =>       | I.ARITHI{oper, rt, ra, im} =>
33          I.ARITHI{oper=oper, rt=rt, ra=rplac ra, im=rwOperand im}          I.ARITHI{oper=oper, rt=rt, ra=rplac ra, im=rwOperand im}
34       | I.ROTATE {oper, ra, rs, sh, mb, me} =>       | I.ROTATE {oper, ra, rs, sh, mb, me} =>
35          I.ROTATE{oper=oper, ra=ra, rs=rplac rs, sh=rwOperand sh, mb=mb, me=me}          I.ROTATE{oper=oper, ra=ra, rs=rplac rs, sh=rplac sh, mb=mb, me=me}
36       | I.COMPARE {cmp, bf, ra, rb} =>       | I.ROTATEI {oper, ra, rs, sh, mb, me} =>
37          I.COMPARE{cmp=cmp, bf=bf, ra=rplac ra, rb=rwOperand rb}          I.ROTATEI{oper=oper, ra=ra, rs=rplac rs, sh=rwOperand sh, mb=mb, me=me}
38         | I.COMPARE {cmp, bf, l, ra, rb} =>
39            I.COMPARE{cmp=cmp, bf=bf, l=l, ra=rplac ra, rb=rwOperand rb}
40       | I.MTSPR{rs, spr} => I.MTSPR{rs=rplac rs, spr=spr}       | I.MTSPR{rs, spr} => I.MTSPR{rs=rplac rs, spr=spr}
41       | I.TWI {to, ra, si} => I.TWI{to=to, ra=rplac ra, si=si}       | I.TW {to, ra, si} => I.TW{to=to, ra=rplac ra, si=rwOperand si}
42       | I.CALL {def, use=(r,f,c)} => I.CALL{def=def, use=(map rplac r,f,c)}       | I.TD {to, ra, si} => I.TD{to=to, ra=rplac ra, si=rwOperand si}
43         | I.CALL {def, use=(r,f,c), mem} =>
44              I.CALL{def=def, use=(map rplac r,f,c), mem=mem}
45       | I.COPY{dst, src, impl, tmp} =>       | I.COPY{dst, src, impl, tmp} =>
46          I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}          I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
47       | I.FCOPY{dst, src, impl, tmp} =>       | I.FCOPY{dst, src, impl, tmp} =>
48          I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt, mapr)}          I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt, mapr)}
49         | I.ANNOTATION{i,a} => I.ANNOTATION{i=rewriteUse(mapr,i,rs,rt),a=a}
50       | _ => instr       | _ => instr
51    end    end
52
53    fun rewriteDef(mapr, instr, rs, rt) = let    fun rewriteDef(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let
54      fun rplac r = if mapr r = rs then rt else r      fun rplac r = if mapr r = rs then rt else r
55    in    in
56      case instr      case instr
57      of I.L {sz, rt, ra, d, mem} =>      of I.L {ld, rt, ra, d, mem} =>
58          I.L{sz=sz, rt=rplac rt, ra=ra, d=d, mem=mem}          I.L{ld=ld, rt=rplac rt, ra=ra, d=d, mem=mem}
59       | I.UNARY {oper, rt, ra, Rc, OE} =>       | I.UNARY {oper, rt, ra, Rc, OE} =>
60          I.UNARY{oper=oper, rt=rplac rt, ra=ra, Rc=Rc, OE=OE}          I.UNARY{oper=oper, rt=rplac rt, ra=ra, Rc=Rc, OE=OE}
61       | I.ARITH {oper, rt, ra, rb, Rc, OE} =>       | I.ARITH {oper, rt, ra, rb, Rc, OE} =>
# Line 53  Line 64
64          I.ARITHI {oper=oper, rt=rplac rt, ra=ra, im=im}          I.ARITHI {oper=oper, rt=rplac rt, ra=ra, im=im}
65       | I.ROTATE {oper, ra, rs, sh, mb, me} =>       | I.ROTATE {oper, ra, rs, sh, mb, me} =>
66          I.ROTATE {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}          I.ROTATE {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}
67         | I.ROTATEI {oper, ra, rs, sh, mb, me} =>
68            I.ROTATEI {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}
69       | I.MFSPR {rt, spr} => I.MFSPR{rt=rplac rt, spr=spr}       | I.MFSPR {rt, spr} => I.MFSPR{rt=rplac rt, spr=spr}
70       | I.CALL {def=(r,f,c), use} => I.CALL{def=(map rplac r, f, c), use=use}       | I.CALL {def=(r,f,c), use, mem} =>
71            I.CALL{def=(map rplac r, f, c), use=use, mem=mem}
72       | I.COPY {dst, src, impl, tmp} =>       | I.COPY {dst, src, impl, tmp} =>
73          I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt,mapr)}          I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt,mapr)}
74         | I.ANNOTATION{i,a} => I.ANNOTATION{i=rewriteDef(mapr,i,rs,rt),a=a}
75       | _ => instr       | _ => instr
76    end    end
77
78    fun frewriteUse(mapr, instr, fs, ft) = let    fun frewriteUse(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let
79      fun rplac r = if mapr r = fs then ft else r      fun rplac r = if mapr r = fs then ft else r
80    in    in
81      case instr      case instr
82      of I.ST {sz, rs, ra, d, mem} =>      of I.STF {st, fs, ra, d, mem} =>
83           I.ST{sz=sz, rs=rplac rs, ra=ra, d=d, mem=mem}           I.STF{st=st, fs=rplac fs, ra=ra, d=d, mem=mem}
84       | I.CALL{def, use=(r,f,c)} => I.CALL{def=def, use=(r, map rplac f, c)}       | I.CALL{def, use=(r,f,c), mem} =>
85             I.CALL{def=def, use=(r, map rplac f, c), mem=mem}
86       | I.FCOMPARE {cmp, bf, fa, fb} =>       | I.FCOMPARE {cmp, bf, fa, fb} =>
87           I.FCOMPARE{cmp=cmp, bf=bf, fa=rplac fa, fb=rplac fb}           I.FCOMPARE{cmp=cmp, bf=bf, fa=rplac fa, fb=rplac fb}
88       | I.FUNARY {oper, ft, fb, Rc} =>       | I.FUNARY {oper, ft, fb, Rc} =>
89           I.FUNARY{oper=oper, ft=ft, fb=rplac fb, Rc=Rc}           I.FUNARY{oper=oper, ft=ft, fb=rplac fb, Rc=Rc}
90       | I.FARITH {oper, ft, fa, fb, Rc} =>       | I.FARITH {oper, ft, fa, fb, Rc} =>
91           I.FARITH{oper=oper, ft=ft, fa=rplac fa, fb=rplac fb, Rc=Rc}           I.FARITH{oper=oper, ft=ft, fa=rplac fa, fb=rplac fb, Rc=Rc}
92         | I.FARITH3 {oper, ft, fa, fb, fc, Rc} =>
93             I.FARITH3{oper=oper,ft=ft,fa=rplac fa, fb=rplac fb, fc=rplac fc,Rc=Rc}
94       | I.FCOPY {dst, src, impl, tmp} =>       | I.FCOPY {dst, src, impl, tmp} =>
95           I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}           I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
96         | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteUse(mapr,i,fs,ft),a=a}
97       | _ => instr       | _ => instr
98    end    end
99
100
101    fun frewriteDef(mapr, instr, fs, ft) = let    fun frewriteDef(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let
102      fun rplac r = if mapr r = fs then ft else r      fun rplac r = if mapr r = fs then ft else r
103    in    in
104      case instr      case instr
105      of I.L{sz, rt, ra, d, mem} =>      of I.LF{ld, ft, ra, d, mem} =>
106          I.L{sz=sz, rt=rplac rt, ra=ra, d=d, mem=mem}          I.LF{ld=ld, ft=rplac ft, ra=ra, d=d, mem=mem}
107       | I.FUNARY {oper, ft, fb, Rc} =>       | I.FUNARY {oper, ft, fb, Rc} =>
108          I.FUNARY{oper=oper, ft=rplac ft, fb=fb, Rc=Rc}          I.FUNARY{oper=oper, ft=rplac ft, fb=fb, Rc=Rc}
109       | I.FARITH{oper, ft, fa, fb, Rc} =>       | I.FARITH{oper, ft, fa, fb, Rc} =>
110          I.FARITH{oper=oper, ft=rplac ft, fa=fa, fb=fb, Rc=Rc}          I.FARITH{oper=oper, ft=rplac ft, fa=fa, fb=fb, Rc=Rc}
111         | I.FARITH3{oper, ft, fa, fb, fc, Rc} =>
112            I.FARITH3{oper=oper, ft=rplac ft, fa=fa, fb=fb, fc=fc, Rc=Rc}
113      (* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *)      (* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *)
114       | I.CALL{def=(r,f,c), use} => I.CALL{def=(r, map rplac f, c), use=use}       | I.CALL{def=(r,f,c), use, mem} =>
115            I.CALL{def=(r, map rplac f, c), use=use, mem=mem}
116       | I.FCOPY {dst, src, impl, tmp} =>       | I.FCOPY {dst, src, impl, tmp} =>
117          I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft,mapr)}          I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft,mapr)}
118         | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteDef(mapr,i,fs,ft),a=a}
119       | _ => instr       | _ => instr
120    end    end
121  end  end

Legend:
 Removed from v.245 changed lines Added in v.545