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/ra/alphaRewrite.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/alpha/ra/alphaRewrite.sml

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

revision 1002, Fri Nov 30 17:11:33 2001 UTC revision 1003, Fri Dec 7 02:45:32 2001 UTC
# Line 8  Line 8 
8    structure C=I.C    structure C=I.C
9    structure CB=CellsBasis    structure CB=CellsBasis
10    structure CS=CB.CellSet    structure CS=CB.CellSet
11      fun error msg = MLRiscErrorMsg.error ("AlphaRewrite", msg)
12    
13    fun rewriteUse(instr, rs, rt) = let    fun rewriteUse(instr, rs, rt) = let
14        fun alphaUse(instr) = let
15      fun match r = CB.sameColor(r,rs)      fun match r = CB.sameColor(r,rs)
16      fun isRegOp (I.REGop r) = match r      fun isRegOp (I.REGop r) = match r
17        | isRegOp _ = false        | isRegOp _ = false
# Line 73  Line 75 
75       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
76           I.PSEUDOARITH{oper=oper, ra=replace ra, rb=rwOperand rb, rc=rc,           I.PSEUDOARITH{oper=oper, ra=replace ra, rb=rwOperand rb, rc=rc,
77                         tmps=tmps}                         tmps=tmps}
      | I.ANNOTATION{i,a} =>  
            I.ANNOTATION{i=rewriteUse(i,rs,rt),  
                         a=case a of  
                            CB.DEF_USE{cellkind=CB.GP,defs,uses} =>  
                              CB.DEF_USE{cellkind=CB.GP,defs=defs,  
                                        uses=map replace uses}  
                           | _ => a}  
78       | _ => instr       | _ => instr
79    end    end
80      in
81          case instr
82           of (I.ANNOTATION{i, ...}) => rewriteUse(i, rs, rt)
83            | I.LIVE{regs, spilled} => I.LIVE{regs=C.addReg(rt, C.rmvReg(rs, regs)),
84                                               spilled=spilled}
85            | I.INSTR(i) => I.INSTR(alphaUse(i))
86            | _ => error "rewriteUse"
87      end
88    
89    
90    fun frewriteUse(instr, fs, ft) = let    fun frewriteUse(instr, fs, ft) = let
91        fun alphaUse(instr) = let
92       fun match f = CB.sameColor(f,fs)       fun match f = CB.sameColor(f,fs)
93      fun replace f = if match f then ft else f      fun replace f = if match f then ft else f
94      fun foperate(opClass, {oper, fa, fb, fc}) =      fun foperate(opClass, {oper, fa, fb, fc}) =
# Line 112  Line 117 
117       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>       | I.BSR{r, lab, defs, uses, cutsTo, mem} =>
118           I.BSR{r=r, lab=lab, defs=defs,           I.BSR{r=r, lab=lab, defs=defs,
119                 uses=CS.map {from=fs,to=ft} uses, cutsTo=cutsTo, mem=mem}                 uses=CS.map {from=fs,to=ft} uses, cutsTo=cutsTo, mem=mem}
      | I.ANNOTATION{i,a} =>  
          I.ANNOTATION{i=frewriteUse(i,fs,ft),  
                       a=case a of  
                          CB.DEF_USE{cellkind=CB.FP,defs,uses} =>  
                            CB.DEF_USE{cellkind=CB.FP,defs=defs,  
                                      uses=map replace uses}  
                         | _ => a}  
   
120       | _ => instr       | _ => instr
121    end    end
122      in
123        case instr
124        of I.ANNOTATION{i, ...} => frewriteUse(instr, fs, ft)
125         | I.LIVE{regs, spilled} => I.LIVE{regs=C.addFreg(ft, C.rmvFreg(fs, regs)),
126                                            spilled=spilled}
127         | I.INSTR(i) => I.INSTR(alphaUse(i))
128         | _ => error "frewriteUse"
129      end
130    
131    
132    fun rewriteDef(instr, rs, rt) = let    fun rewriteDef(instr, rs, rt) = let
133        fun alphaDef(instr) = let
134      fun match r = CB.sameColor(r,rs)      fun match r = CB.sameColor(r,rs)
135      fun rewrite r = if match r then rt else r      fun rewrite r = if match r then rt else r
136      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))      fun ea (SOME(I.Direct r)) = SOME(I.Direct (rewrite r))
# Line 157  Line 164 
164       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
165           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rewrite rc,           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rewrite rc,
166                         tmps=CS.map {from=rs,to=rt} tmps}                         tmps=CS.map {from=rs,to=rt} tmps}
      | I.ANNOTATION{i,a} =>  
          I.ANNOTATION{i=rewriteDef(i,rs,rt),  
                         a=case a of  
                            CB.DEF_USE{cellkind=CB.GP,defs,uses} =>  
                              CB.DEF_USE{cellkind=CB.GP,uses=uses,  
                                        defs=map rewrite defs}  
                           | _ => a}  
167       | _ => instr       | _ => instr
168    end    end
169      in
170          case instr
171          of I.ANNOTATION{i, ...} => rewriteDef(i,rs,rt)
172           | I.KILL{regs, spilled} =>
173               I.KILL{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}
174           | I.INSTR(i) => I.INSTR(alphaDef(i))
175           | _ => error "rewriteDef"
176      end
177    
178    fun frewriteDef(instr, fs, ft) = let    fun frewriteDef(instr, fs, ft) = let
179        fun alphaDef(instr) = let
180    
181      fun match f = CB.sameColor(f,fs)      fun match f = CB.sameColor(f,fs)
182      fun rewrite f = if match f then ft else f      fun rewrite f = if match f then ft else f
183      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))      fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(rewrite f))
184        | ea x  = x        | ea x  = x
185    in    in
186      case instr      case instr
187      of I.DEFFREG f => if match f then I.DEFFREG ft else instr        of I.FLOAD{ldOp, r, b, d, mem} =>
      | I.FLOAD{ldOp, r, b, d, mem} =>  
188          if match r then I.FLOAD{ldOp=ldOp, r=ft, b=b, d=d, mem=mem} else instr          if match r then I.FLOAD{ldOp=ldOp, r=ft, b=b, d=d, mem=mem} else instr
189       | I.FOPERATE{oper, fa, fb, fc} =>       | I.FOPERATE{oper, fa, fb, fc} =>
190          if match fc then I.FOPERATE{oper=oper, fa=fa, fb=fb, fc=ft} else instr          if match fc then I.FOPERATE{oper=oper, fa=fa, fb=fb, fc=ft} else instr
# Line 195  Line 204 
204       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>       | I.PSEUDOARITH{oper, ra, rb, rc, tmps} =>
205           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rc,           I.PSEUDOARITH{oper=oper, ra=ra, rb=rb, rc=rc,
206                         tmps=CS.map {from=fs,to=ft} tmps}                         tmps=CS.map {from=fs,to=ft} tmps}
      | I.ANNOTATION{i,a} =>  
          I.ANNOTATION{i=frewriteDef(i,fs,ft),  
                         a=case a of  
                            CB.DEF_USE{cellkind=CB.FP,defs,uses} =>  
                              CB.DEF_USE{cellkind=CB.FP,uses=uses,  
                                        defs=map rewrite defs}  
                           | _ => a}  
207       | _  => instr       | _  => instr
208    end    end
209      in
210          case instr
211           of I.ANNOTATION{i,a} => frewriteDef(i, fs, ft)
212            | I.KILL{regs, spilled} =>
213               I.KILL{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}
214            | I.INSTR(i) => I.INSTR(alphaDef(i))
215            | _  => error "frewriteDef"
216      end
217  end  end
218    

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

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