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 859, Wed Jun 27 21:43:12 2001 UTC revision 1002, Fri Nov 30 17:11:33 2001 UTC
# Line 6  Line 6 
6  functor AlphaRewrite(Instr : ALPHAINSTR) = struct  functor AlphaRewrite(Instr : ALPHAINSTR) = struct
7    structure I=Instr    structure I=Instr
8    structure C=I.C    structure C=I.C
9      structure CB=CellsBasis
10      structure CS=CB.CellSet
11    
12    fun rewriteUse(instr, rs, rt) = let    fun rewriteUse(instr, rs, rt) = let
13      fun match r = C.sameColor(r,rs)      fun match r = CB.sameColor(r,rs)
14      fun isRegOp (I.REGop r) = match r      fun isRegOp (I.REGop r) = match r
15        | isRegOp _ = false        | isRegOp _ = false
16      fun rwOperand(opnd as I.REGop r) =      fun rwOperand(opnd as I.REGop r) =
# Line 52  Line 54 
54         if match b then I.JMPL({r=r, b=rt, d=d}, labs) else instr         if match b then I.JMPL({r=r, b=rt, d=d}, labs) else instr
55       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>
56           I.JSR{r=r, b=replace b, d=d, defs=defs,           I.JSR{r=r, b=replace b, d=d, defs=defs,
57                 uses=C.CellSet.map {from=rs,to=rt} uses, cutsTo=cutsTo, mem=mem}                 uses=CS.map {from=rs,to=rt} uses, cutsTo=cutsTo, mem=mem}
58       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>
59           I.BSR{r=r, lab=lab, defs=defs,           I.BSR{r=r, lab=lab, defs=defs,
60                 uses=C.CellSet.map {from=rs,to=rt} uses, cutsTo=cutsTo, mem=mem}                 uses=CS.map {from=rs,to=rt} uses, cutsTo=cutsTo, mem=mem}
61       | 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}
62       | I.BRANCH{b=I.BR, ...} => instr       | I.BRANCH{b=I.BR, ...} => instr
63       | I.BRANCH{b, r, lab} => if match r then I.BRANCH{b=b, r=rt, lab=lab}       | I.BRANCH{b, r, lab} => if match r then I.BRANCH{b=b, r=rt, lab=lab}
# Line 67  Line 69 
69       | I.COPY{dst, src, tmp, impl} =>       | I.COPY{dst, src, tmp, impl} =>
70           I.COPY{dst=dst, src=map replace src, tmp=tmp, impl=impl}           I.COPY{dst=dst, src=map replace src, tmp=tmp, impl=impl}
71       | I.CALL_PAL{code, def, use } =>       | I.CALL_PAL{code, def, use } =>
72           I.CALL_PAL{code=code, def=def, use=C.CellSet.map {from=rs,to=rt} use}           I.CALL_PAL{code=code, def=def, use=CS.map {from=rs,to=rt} use}
73       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
74           I.PSEUDOARITH{oper=oper, ra=replace ra, rb=rwOperand rb, rc=rc,           I.PSEUDOARITH{oper=oper, ra=replace ra, rb=rwOperand rb, rc=rc,
75                         tmps=tmps}                         tmps=tmps}
76       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
77             I.ANNOTATION{i=rewriteUse(i,rs,rt),             I.ANNOTATION{i=rewriteUse(i,rs,rt),
78                          a=case a of                          a=case a of
79                             C.DEF_USE{cellkind=C.GP,defs,uses} =>                             CB.DEF_USE{cellkind=CB.GP,defs,uses} =>
80                               C.DEF_USE{cellkind=C.GP,defs=defs,                               CB.DEF_USE{cellkind=CB.GP,defs=defs,
81                                         uses=map replace uses}                                         uses=map replace uses}
82                            | _ => a}                            | _ => a}
83       | _ => instr       | _ => instr
84    end    end
85    
86    fun frewriteUse(instr, fs, ft) = let    fun frewriteUse(instr, fs, ft) = let
87       fun match f = C.sameColor(f,fs)       fun match f = CB.sameColor(f,fs)
88      fun replace f = if match f then ft else f      fun replace f = if match f then ft else f
89      fun foperate(opClass, {oper, fa, fb, fc}) =      fun foperate(opClass, {oper, fa, fb, fc}) =
90        if match fa then        if match fa then
# Line 106  Line 108 
108           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}
109       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>
110           I.JSR{r=r, b=b, d=d, defs=defs,           I.JSR{r=r, b=b, d=d, defs=defs,
111                 uses=C.CellSet.map {from=fs,to=ft} uses, cutsTo=cutsTo, mem=mem}                 uses=CS.map {from=fs,to=ft} uses, cutsTo=cutsTo, mem=mem}
112       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>
113           I.BSR{r=r, lab=lab, defs=defs,           I.BSR{r=r, lab=lab, defs=defs,
114                 uses=C.CellSet.map {from=fs,to=ft} uses, cutsTo=cutsTo, mem=mem}                 uses=CS.map {from=fs,to=ft} uses, cutsTo=cutsTo, mem=mem}
115       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
116           I.ANNOTATION{i=frewriteUse(i,fs,ft),           I.ANNOTATION{i=frewriteUse(i,fs,ft),
117                        a=case a of                        a=case a of
118                           C.DEF_USE{cellkind=C.FP,defs,uses} =>                           CB.DEF_USE{cellkind=CB.FP,defs,uses} =>
119                             C.DEF_USE{cellkind=C.FP,defs=defs,                             CB.DEF_USE{cellkind=CB.FP,defs=defs,
120                                       uses=map replace uses}                                       uses=map replace uses}
121                          | _ => a}                          | _ => a}
122    
# Line 122  Line 124 
124    end    end
125    
126    fun rewriteDef(instr, rs, rt) = let    fun rewriteDef(instr, rs, rt) = let
127      fun match r = C.sameColor(r,rs)      fun match r = CB.sameColor(r,rs)
128      fun rewrite r = if match r then rt else r      fun rewrite r = if match r then rt else r
129      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))
130        | ea x = x        | ea x = x
# Line 135  Line 137 
137       | I.JMPL({r, b, d}, labs) =>       | I.JMPL({r, b, d}, labs) =>
138         if match r then I.JMPL({r=rt, b=b, d=d}, labs) else instr         if match r then I.JMPL({r=rt, b=b, d=d}, labs) else instr
139       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>
140           I.JSR{r=rewrite r, b=b, d=d, defs=C.CellSet.map {from=rs,to=rt} defs,           I.JSR{r=rewrite r, b=b, d=d, defs=CS.map {from=rs,to=rt} defs,
141                 uses=uses, cutsTo=cutsTo, mem=mem}                 uses=uses, cutsTo=cutsTo, mem=mem}
142       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>
143           I.BSR{r=rewrite r, lab=lab, defs=C.CellSet.map {from=rs,to=rt} defs,           I.BSR{r=rewrite r, lab=lab, defs=CS.map {from=rs,to=rt} defs,
144                 uses=uses, cutsTo=cutsTo, mem=mem}                 uses=uses, cutsTo=cutsTo, mem=mem}
145       | 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}
146       | I.BRANCH{b=I.BR, r, lab} =>       | I.BRANCH{b=I.BR, r, lab} =>
# Line 151  Line 153 
153       | I.COPY{dst, src, impl, tmp} =>       | I.COPY{dst, src, impl, tmp} =>
154          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}
155       | I.CALL_PAL{code, def, use} =>       | I.CALL_PAL{code, def, use} =>
156           I.CALL_PAL{code=code, def=C.CellSet.map {from=rs,to=rt} def, use=use}           I.CALL_PAL{code=code, def=CS.map {from=rs,to=rt} def, use=use}
157       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
158           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rewrite rc,           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rewrite rc,
159                         tmps=C.CellSet.map {from=rs,to=rt} tmps}                         tmps=CS.map {from=rs,to=rt} tmps}
160       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
161           I.ANNOTATION{i=rewriteDef(i,rs,rt),           I.ANNOTATION{i=rewriteDef(i,rs,rt),
162                          a=case a of                          a=case a of
163                             C.DEF_USE{cellkind=C.GP,defs,uses} =>                             CB.DEF_USE{cellkind=CB.GP,defs,uses} =>
164                               C.DEF_USE{cellkind=C.GP,uses=uses,                               CB.DEF_USE{cellkind=CB.GP,uses=uses,
165                                         defs=map rewrite defs}                                         defs=map rewrite defs}
166                            | _ => a}                            | _ => a}
167       | _ => instr       | _ => instr
168    end    end
169    
170    fun frewriteDef(instr, fs, ft) = let    fun frewriteDef(instr, fs, ft) = let
171      fun match f = C.sameColor(f,fs)      fun match f = CB.sameColor(f,fs)
172      fun rewrite f = if match f then ft else f      fun rewrite f = if match f then ft else f
173      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))
174        | ea x  = x        | ea x  = x
# Line 185  Line 187 
187          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}
188       | 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}
189       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>       | I.JSR{r, b, d, defs, uses, cutsTo, mem} =>
190          I.JSR{r=r, b=b, d=d, defs=C.CellSet.map {from=fs,to=ft} defs,          I.JSR{r=r, b=b, d=d, defs=CS.map {from=fs,to=ft} defs,
191                uses=uses, cutsTo=cutsTo, mem=mem}                uses=uses, cutsTo=cutsTo, mem=mem}
192       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>
193          I.BSR{r=r, lab=lab, defs=C.CellSet.map {from=fs,to=ft} defs,          I.BSR{r=r, lab=lab, defs=CS.map {from=fs,to=ft} defs,
194                uses=uses, cutsTo=cutsTo, mem=mem}                uses=uses, cutsTo=cutsTo, mem=mem}
195       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
196           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rc,           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rc,
197                         tmps=C.CellSet.map {from=fs,to=ft} tmps}                         tmps=CS.map {from=fs,to=ft} tmps}
198       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
199           I.ANNOTATION{i=frewriteDef(i,fs,ft),           I.ANNOTATION{i=frewriteDef(i,fs,ft),
200                          a=case a of                          a=case a of
201                             C.DEF_USE{cellkind=C.FP,defs,uses} =>                             CB.DEF_USE{cellkind=CB.FP,defs,uses} =>
202                               C.DEF_USE{cellkind=C.FP,uses=uses,                               CB.DEF_USE{cellkind=CB.FP,uses=uses,
203                                         defs=map rewrite defs}                                         defs=map rewrite defs}
204                            | _ => a}                            | _ => a}
205       | _  => instr       | _  => instr

Legend:
Removed from v.859  
changed lines
  Added in v.1002

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