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
ViewVC logotype

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

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

revision 901, Tue Aug 14 19:21:17 2001 UTC revision 1003, Fri Dec 7 02:45:32 2001 UTC
# Line 4  Line 4 
4    structure CB = CellsBasis    structure CB = CellsBasis
5    structure CS = CB.CellSet    structure CS = CB.CellSet
6    
7      fun error msg = MLRiscErrorMsg.error ("PPCRewrite", msg)
8    
9    fun ea(NONE, _, _) = NONE    fun ea(NONE, _, _) = NONE
10      | ea(e as SOME(I.Direct r), rs, rt) =      | ea(e as SOME(I.Direct r), rs, rt) =
11         if CB.sameColor(r,rs) then SOME(I.Direct rt) else e         if CB.sameColor(r,rs) then SOME(I.Direct rt) else e
# Line 14  Line 16 
16         else e         else e
17    
18    fun rewriteUse(instr, rs, rt) = let    fun rewriteUse(instr, rs, rt) = let
19        fun ppcUse(instr) = let
20      fun rplac r = if CB.sameColor(r,rs) then rt else r      fun rplac r = if CB.sameColor(r,rs) then rt else r
21      fun rwOperand(opnd as I.RegOp r) =      fun rwOperand(opnd as I.RegOp r) =
22           if CB.sameColor(r,rs) then I.RegOp rt else opnd           if CB.sameColor(r,rs) then I.RegOp rt else opnd
# Line 50  Line 53 
53          I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}          I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
54       | I.FCOPY{dst, src, impl, tmp} =>       | I.FCOPY{dst, src, impl, tmp} =>
55          I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt)}          I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt)}
      | 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,uses=map rplac uses,  
                                        defs=defs}  
                           | _ => a}  
56       | _ => instr       | _ => instr
57    end    end
58      in
59          case instr
60           of (I.ANNOTATION{i, ...}) => rewriteUse(i, rs, rt)
61            | I.INSTR(i) => I.INSTR(ppcUse(i))
62            | I.LIVE{regs, spilled} =>
63                I.LIVE{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}
64            | _ => error "rewriteUse"
65      end
66    
67    
68    fun rewriteDef(instr, rs, rt) = let    fun rewriteDef(instr, rs, rt) = let
69        fun ppcDef(instr) = let
70      fun rplac r = if CB.sameColor(r,rs) then rt else r      fun rplac r = if CB.sameColor(r,rs) then rt else r
71    in    in
72      case instr      case instr
# Line 82  Line 88 
88                 cutsTo=cutsTo, mem=mem}                 cutsTo=cutsTo, mem=mem}
89       | I.COPY {dst, src, impl, tmp} =>       | I.COPY {dst, src, impl, tmp} =>
90          I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt)}          I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt)}
      | 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 rplac defs}  
                           | _ => a}  
91       | _ => instr       | _ => instr
92    end    end
93      in
94          case instr
95           of (I.ANNOTATION{i, ...}) => rewriteDef(i, rs, rt)
96            | I.INSTR(i) => I.INSTR(ppcDef(i))
97            | I.KILL{regs, spilled} =>
98               I.KILL{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}
99            | _ => error "rewriteDef"
100      end
101    
102    
103    fun frewriteUse(instr, fs, ft) = let    fun frewriteUse(instr, fs, ft) = let
104        fun ppcUse(instr) = let
105      fun rplac r = if CB.sameColor(r,fs) then ft else r      fun rplac r = if CB.sameColor(r,fs) then ft else r
106    in    in
107      case instr      case instr
# Line 111  Line 120 
120           I.FARITH3{oper=oper,ft=ft,fa=rplac fa, fb=rplac fb, fc=rplac fc,Rc=Rc}           I.FARITH3{oper=oper,ft=ft,fa=rplac fa, fb=rplac fb, fc=rplac fc,Rc=Rc}
121       | I.FCOPY {dst, src, impl, tmp} =>       | I.FCOPY {dst, src, impl, tmp} =>
122           I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}           I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
      | 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,uses=map rplac uses,  
                                        defs=defs}  
                           | _ => a}  
123       | _ => instr       | _ => instr
124    end    end
125      in
126          case instr
127           of (I.ANNOTATION{i, ...}) => frewriteUse(i, fs, ft)
128            | I.INSTR(i) => I.INSTR(ppcUse(i))
129            | I.LIVE{regs, spilled} =>
130                I.LIVE{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}
131            | _ => error "frewriteUse"
132    
133      end
134    
135    fun frewriteDef(instr, fs, ft) = let    fun frewriteDef(instr, fs, ft) = let
136        fun ppcDef(instr) = let
137      fun rplac r = if CB.sameColor(r,fs) then ft else r      fun rplac r = if CB.sameColor(r,fs) then ft else r
138    in    in
139      case instr      case instr
# Line 140  Line 151 
151                 cutsTo=cutsTo, mem=mem}                 cutsTo=cutsTo, mem=mem}
152       | I.FCOPY {dst, src, impl, tmp} =>       | I.FCOPY {dst, src, impl, tmp} =>
153          I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft)}          I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft)}
      | 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 rplac defs}  
                           | _ => a}  
154       | _ => instr       | _ => instr
155    end    end
156      in
157          case instr
158           of (I.ANNOTATION{i, ...}) => frewriteDef(i, fs, ft)
159            | I.INSTR(i) => I.INSTR(ppcDef(i))
160            | I.KILL{regs, spilled} =>
161               I.KILL{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}
162            | _ => error "frewriteDef"
163      end
164  end  end
165    

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

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