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 545, Thu Feb 24 13:56:44 2000 UTC
# Line 6  Line 6 
6  functor AlphaRewrite(Instr : ALPHAINSTR) = struct  functor AlphaRewrite(Instr : ALPHAINSTR) = struct
7    structure I=Instr    structure I=Instr
8    
9    fun rewriteUse(mapr, instr, rs, rt) = let    fun rewriteUse(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let
10      fun isRegOp (opnd as I.REGop r) = mapr r=rs      fun isRegOp (opnd as I.REGop r) = mapr r=rs
11        | isRegOp _ = false        | isRegOp _ = false
12      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 46 
46       | I.FSTORE farg => fstore(I.FSTORE, farg)       | I.FSTORE farg => fstore(I.FSTORE, farg)
47       | I.JMPL({r, b, d}, labs) =>       | I.JMPL({r, b, d}, labs) =>
48         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
49       | I.JSR({r,b,d}, defs, (i,f), mem) =>       | I.JSR{r, b, d, defs, uses=(i,f), mem} =>
50           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),
51                   mem=mem}
52       | 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}
53       | I.BRANCH(I.BR, _, _) => instr       | I.BRANCH{b=I.BR, ...} => instr
54       | 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}
55                                  else instr
56       | I.OPERATE arg => operate(I.OPERATE, arg)       | I.OPERATE arg => operate(I.OPERATE, arg)
57       | I.OPERATEV arg => operate(I.OPERATEV, arg)       | I.OPERATEV arg => operate(I.OPERATEV, arg)
58       | I.CMOVE{oper,ra,rb,rc} =>       | I.CMOVE{oper,ra,rb,rc} =>
# Line 63  Line 65 
65       | _ => instr       | _ => instr
66    end    end
67    
68    fun frewriteUse(mapr, instr, fs, ft) = let    fun frewriteUse(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let
69      fun replace f = if mapr f=fs then ft else f      fun replace f = if mapr f=fs then ft else f
70      fun foperate(opClass, {oper, fa, fb, fc}) =      fun foperate(opClass, {oper, fa, fb, fc}) =
71        if mapr fa=fs then        if mapr fa=fs then
# Line 72  Line 74 
74        else instr        else instr
75    in    in
76      case instr      case instr
77      of I.FBRANCH(br, f, lab) =>      of I.FBRANCH{b, f, lab} =>
78         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
79       | I.FCOPY{dst, src, impl, tmp} =>       | I.FCOPY{dst, src, impl, tmp} =>
80          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,
81                  tmp=tmp, impl=impl}                  tmp=tmp, impl=impl}
# Line 85  Line 87 
87          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
88       | I.FCMOVE{oper,fa,fb,fc} =>       | I.FCMOVE{oper,fa,fb,fc} =>
89           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}
90       | 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} =>
91             I.JSR{r=r, b=b, d=d, defs=defs, uses=(i, map replace f), mem=mem}
92       | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteUse(mapr,i,fs,ft),a=a}       | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteUse(mapr,i,fs,ft),a=a}
93       | _ => instr       | _ => instr
94    end    end
95    
96    fun rewriteDef(mapr, instr, rs, rt) = let    fun rewriteDef(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let
97      fun rewrite r = if mapr r = rs then rt else r      fun rewrite r = if mapr r = rs then rt else r
98      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))
99        | ea x = x        | ea x = x
# Line 102  Line 105 
105         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
106       | I.JMPL({r, b, d}, labs) =>       | I.JMPL({r, b, d}, labs) =>
107         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
108       | I.JSR({r, b, d}, (i,f), uses, mem) =>       | I.JSR{r, b, d, defs=(i,f), uses, mem} =>
109           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,
110                   mem=mem}
111       | 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}
112       | I.BRANCH(I.BR, r, lab) =>       | I.BRANCH{b=I.BR, r, lab} =>
113         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
114       | I.OPERATE{oper, ra, rb, rc} =>       | I.OPERATE{oper, ra, rb, rc} =>
115         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
116       | I.OPERATEV{oper, ra, rb, rc} =>       | I.OPERATEV{oper, ra, rb, rc} =>
# Line 120  Line 124 
124       | _ => instr       | _ => instr
125    end    end
126    
127    fun frewriteDef(mapr, instr, fs, ft) = let    fun frewriteDef(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let
128      fun rewrite f = if mapr f = fs then ft else f      fun rewrite f = if mapr f = fs then ft else f
129      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))
130        | ea x  = x        | ea x  = x
# Line 138  Line 142 
142       | I.FCOPY{dst, src, tmp, impl} =>       | I.FCOPY{dst, src, tmp, impl} =>
143          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}
144       | 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}
145       | 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} =>
146            I.JSR{r=r, b=b, d=d, defs=(i, map rewrite f), uses=uses, mem=mem}
147    
148       | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteDef(mapr,i,fs,ft),a=a}       | I.ANNOTATION{i,a} => I.ANNOTATION{i=frewriteDef(mapr,i,fs,ft),a=a}
149       | _  => instr       | _  => instr

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

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