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/branches/idlbasis-devel/src/MLRISC/alpha/ra/alphaRewrite.sml
ViewVC logotype

Diff of /sml/branches/idlbasis-devel/src/MLRISC/alpha/ra/alphaRewrite.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 409, Fri Sep 3 00:21:52 1999 UTC revision 657, Fri Jun 9 05:20:54 2000 UTC
# Line 5  Line 5 
5    
6  functor AlphaRewrite(Instr : ALPHAINSTR) = struct  functor AlphaRewrite(Instr : ALPHAINSTR) = struct
7    structure I=Instr    structure I=Instr
8      structure C=I.C
9    
10    fun rewriteUse(mapr, instr, rs, rt) = let    fun rewriteUse(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let
11      fun isRegOp (opnd as I.REGop r) = mapr r=rs      fun isRegOp (opnd as I.REGop r) = mapr r=rs
12        | isRegOp _ = false        | isRegOp _ = false
13      fun rwOperand(opnd as I.REGop r) = if mapr r=rs then I.REGop rt else opnd      fun rwOperand(opnd as I.REGop r) = if mapr r=rs then I.REGop rt else opnd
# Line 46  Line 47 
47       | I.FSTORE farg => fstore(I.FSTORE, farg)       | I.FSTORE farg => fstore(I.FSTORE, farg)
48       | I.JMPL({r, b, d}, labs) =>       | I.JMPL({r, b, d}, labs) =>
49         if mapr b=rs then I.JMPL({r=r, b=rt, d=d}, labs) else instr         if mapr b=rs then I.JMPL({r=r, b=rt, d=d}, labs) else instr
50       | I.JSR({r,b,d}, defs, (i,f), mem) =>       | I.JSR{r, b, d, defs, uses=(i,f), mem} =>
51           I.JSR({r=r, b=replace b, d=d}, defs, (map replace i, f), mem)           I.JSR{r=r, b=replace b, d=d, defs=defs, uses=(map replace i, f),
52                   mem=mem}
53         | I.BSR{r, lab, defs, uses=(i,f), mem} =>
54             I.BSR{r=r, lab=lab, defs=defs, uses=(map replace i, f), mem=mem}
55       | I.RET{r,b,d} => I.RET{r=r, b=replace b, d=d}       | I.RET{r,b,d} => I.RET{r=r, b=replace b, d=d}
56       | I.BRANCH(I.BR, _, _) => instr       | I.BRANCH{b=I.BR, ...} => instr
57       | I.BRANCH(br, r, lab) => if mapr r=rs then I.BRANCH(br, rt, lab) else instr       | I.BRANCH{b, r, lab} => if mapr r=rs then I.BRANCH{b=b, r=rt, lab=lab}
58                                  else instr
59       | I.OPERATE arg => operate(I.OPERATE, arg)       | I.OPERATE arg => operate(I.OPERATE, arg)
60       | I.OPERATEV arg => operate(I.OPERATEV, arg)       | I.OPERATEV arg => operate(I.OPERATEV, arg)
61       | I.CMOVE{oper,ra,rb,rc} =>       | I.CMOVE{oper,ra,rb,rc} =>
# Line 59  Line 64 
64           I.COPY{dst=dst, src=map replace src, tmp=tmp, impl=impl}           I.COPY{dst=dst, src=map replace src, tmp=tmp, impl=impl}
65       | I.CALL_PAL{code, def, use } =>       | I.CALL_PAL{code, def, use } =>
66           I.CALL_PAL{code=code, def=def, use=map replace use}           I.CALL_PAL{code=code, def=def, use=map replace use}
67       | I.ANNOTATION{i,a} => I.ANNOTATION{i=rewriteUse(mapr,i,rs,rt),a=a}       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
68             I.PSEUDOARITH{oper=oper, ra=replace ra, rb=rwOperand rb, rc=rc,
69                           tmps=tmps}
70         | I.ANNOTATION{i,a} =>
71               I.ANNOTATION{i=rewriteUse(mapr,i,rs,rt),
72                            a=case a of
73                               C.DEF_USE{cellkind=C.GP,defs,uses} =>
74                                 C.DEF_USE{cellkind=C.GP,defs=defs,
75                                           uses=map replace uses}
76                              | _ => a}
77       | _ => instr       | _ => instr
78    end    end
79    
80    fun frewriteUse(mapr, instr, fs, ft) = let    fun frewriteUse(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let
81      fun replace f = if mapr f=fs then ft else f      fun replace f = if mapr f=fs then ft else f
82      fun foperate(opClass, {oper, fa, fb, fc}) =      fun foperate(opClass, {oper, fa, fb, fc}) =
83        if mapr fa=fs then        if mapr fa=fs then
# Line 72  Line 86 
86        else instr        else instr
87    in    in
88      case instr      case instr
89      of I.FBRANCH(br, f, lab) =>      of I.FBRANCH{b, f, lab} =>
90         if mapr f=fs then I.FBRANCH(br, ft, lab) else instr         if mapr f=fs then I.FBRANCH{b=b, f=ft, lab=lab} else instr
91       | I.FCOPY{dst, src, impl, tmp} =>       | I.FCOPY{dst, src, impl, tmp} =>
92          I.FCOPY{dst=dst, src=map(fn f => if mapr f=fs then ft else f) src,          I.FCOPY{dst=dst, src=map(fn f => if mapr f=fs then ft else f) src,
93                  tmp=tmp, impl=impl}                  tmp=tmp, impl=impl}
# Line 85  Line 99 
99          if mapr fb=fs then I.FUNARY{oper=oper,fb=ft,fc=fc} else instr          if mapr fb=fs then I.FUNARY{oper=oper,fb=ft,fc=fc} else instr
100       | I.FCMOVE{oper,fa,fb,fc} =>       | I.FCMOVE{oper,fa,fb,fc} =>
101           I.FCMOVE{oper=oper,fa=replace fa,fb=replace fb,fc=replace fc}           I.FCMOVE{oper=oper,fa=replace fa,fb=replace fb,fc=replace fc}
102       | I.JSR(opnds, defs, (i,f), mem) => I.JSR(opnds, defs, (i, map replace f), mem)       | I.JSR{r, b, d, defs, uses=(i,f), mem} =>
103       | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteUse(mapr,i,fs,ft),a=a}           I.JSR{r=r, b=b, d=d, defs=defs, uses=(i, map replace f), mem=mem}
104         | I.BSR{r, lab, defs, uses=(i,f), mem} =>
105             I.BSR{r=r, lab=lab, defs=defs, uses=(i, map replace f), mem=mem}
106         | I.ANNOTATION{i,a} =>
107             I.ANNOTATION{i=frewriteUse(mapr,i,fs,ft),
108                          a=case a of
109                             C.DEF_USE{cellkind=C.FP,defs,uses} =>
110                               C.DEF_USE{cellkind=C.FP,defs=defs,
111                                         uses=map replace uses}
112                            | _ => a}
113    
114       | _ => instr       | _ => instr
115    end    end
116    
117    fun rewriteDef(mapr, instr, rs, rt) = let    fun rewriteDef(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let
118      fun rewrite r = if mapr r = rs then rt else r      fun rewrite r = if mapr r = rs then rt else r
119      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))
120        | ea x = x        | ea x = x
# Line 102  Line 126 
126         if mapr r=rs then I.LOAD{ldOp=ldOp, r=rt, b=b, d=d, mem=mem} else instr         if mapr r=rs then I.LOAD{ldOp=ldOp, r=rt, b=b, d=d, mem=mem} else instr
127       | I.JMPL({r, b, d}, labs) =>       | I.JMPL({r, b, d}, labs) =>
128         if mapr r=rs then I.JMPL({r=rt, b=b, d=d}, labs) else instr         if mapr r=rs then I.JMPL({r=rt, b=b, d=d}, labs) else instr
129       | I.JSR({r, b, d}, (i,f), uses, mem) =>       | I.JSR{r, b, d, defs=(i,f), uses, mem} =>
130           I.JSR({r=rewrite r, b=b, d=d}, (map rewrite i, f), uses, mem)           I.JSR{r=rewrite r, b=b, d=d, defs=(map rewrite i, f), uses=uses,
131                   mem=mem}
132         | I.BSR{r, lab, defs=(i,f), uses, mem} =>
133             I.BSR{r=rewrite r, lab=lab, defs=(map rewrite i, f), uses=uses,
134                   mem=mem}
135       | I.RET{r, b, d} => I.RET{r=rewrite r, b=b, d=d}       | I.RET{r, b, d} => I.RET{r=rewrite r, b=b, d=d}
136       | I.BRANCH(I.BR, r, lab) =>       | I.BRANCH{b=I.BR, r, lab} =>
137         if mapr r=rs then I.BRANCH(I.BR, rt, lab) else instr         if mapr r=rs then I.BRANCH{b=I.BR, r=rt, lab=lab} else instr
138       | I.OPERATE{oper, ra, rb, rc} =>       | I.OPERATE{oper, ra, rb, rc} =>
139         if mapr rc=rs then I.OPERATE{oper=oper, ra=ra, rb=rb, rc=rt} else instr         if mapr rc=rs then I.OPERATE{oper=oper, ra=ra, rb=rb, rc=rt} else instr
140       | I.OPERATEV{oper, ra, rb, rc} =>       | I.OPERATEV{oper, ra, rb, rc} =>
# Line 116  Line 144 
144          I.COPY{dst=map rewrite dst, src=src, tmp=ea tmp, impl=impl}          I.COPY{dst=map rewrite dst, src=src, tmp=ea tmp, impl=impl}
145       | I.CALL_PAL{code, def, use } =>       | I.CALL_PAL{code, def, use } =>
146           I.CALL_PAL{code=code, def=map rewrite def, use=use}           I.CALL_PAL{code=code, def=map rewrite def, use=use}
147       | I.ANNOTATION{i,a} => I.ANNOTATION{i=rewriteDef(mapr,i,rs,rt),a=a}       | I.PSEUDOARITH{oper, ra, rb, rc, tmps=(i,f)} =>
148             I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rewrite rc,
149                           tmps=(map rewrite i,f)}
150         | I.ANNOTATION{i,a} =>
151             I.ANNOTATION{i=rewriteDef(mapr,i,rs,rt),
152                            a=case a of
153                               C.DEF_USE{cellkind=C.GP,defs,uses} =>
154                                 C.DEF_USE{cellkind=C.GP,uses=uses,
155                                           defs=map rewrite defs}
156                              | _ => a}
157       | _ => instr       | _ => instr
158    end    end
159    
160    fun frewriteDef(mapr, instr, fs, ft) = let    fun frewriteDef(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let
161      fun rewrite f = if mapr f = fs then ft else f      fun rewrite f = if mapr f = fs then ft else f
162      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))
163        | ea x  = x        | ea x  = x
# Line 138  Line 175 
175       | I.FCOPY{dst, src, tmp, impl} =>       | I.FCOPY{dst, src, tmp, impl} =>
176          I.FCOPY{dst=map rewrite dst, src=src, tmp=ea tmp, impl=impl}          I.FCOPY{dst=map rewrite dst, src=src, tmp=ea tmp, impl=impl}
177       | I.FCMOVE{oper,fa,fb,fc} => I.FCMOVE{oper=oper,fa=fa,fb=fb,fc=rewrite fc}       | I.FCMOVE{oper,fa,fb,fc} => I.FCMOVE{oper=oper,fa=fa,fb=fb,fc=rewrite fc}
178       | I.JSR(opnds, (i,f), uses, mem) => I.JSR(opnds, (i, map rewrite f), uses, mem)       | I.JSR{r, b, d, defs=(i,f), uses, mem} =>
179            I.JSR{r=r, b=b, d=d, defs=(i, map rewrite f), uses=uses, mem=mem}
180       | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteDef(mapr,i,fs,ft),a=a}       | I.BSR{r, lab, defs=(i,f), uses, mem} =>
181            I.BSR{r=r, lab=lab, defs=(i, map rewrite f), uses=uses, mem=mem}
182         | I.PSEUDOARITH{oper, ra, rb, rc, tmps=(i,f)} =>
183             I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rc, tmps=(i,map rewrite f)}
184         | I.ANNOTATION{i,a} =>
185             I.ANNOTATION{i=frewriteDef(mapr,i,fs,ft),
186                            a=case a of
187                               C.DEF_USE{cellkind=C.FP,defs,uses} =>
188                                 C.DEF_USE{cellkind=C.FP,uses=uses,
189                                           defs=map rewrite defs}
190                              | _ => a}
191       | _  => instr       | _  => instr
192    end    end
193  end  end

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

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0