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 1008, Fri Dec 14 21:01:29 2001 UTC revision 1009, Wed Jan 9 19:44:22 2002 UTC
# Line 5  Line 5 
5    structure CS = CB.CellSet    structure CS = CB.CellSet
6    
7    fun error msg = MLRiscErrorMsg.error ("PPCRewrite", msg)    fun error msg = MLRiscErrorMsg.error ("PPCRewrite", msg)
   
8    fun ea(NONE, _, _) = NONE    fun ea(NONE, _, _) = NONE
9      | ea(e as SOME(I.Direct r), rs, rt) =      | ea(e as SOME(I.Direct r), rs, rt) =
10         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 16  Line 15 
15         else e         else e
16    
17    fun rewriteUse(instr, rs, rt) = let    fun rewriteUse(instr, rs, rt) = let
     fun ppcUse(instr) = let  
18        fun rplac r = if CB.sameColor(r,rs) then rt else r        fun rplac r = if CB.sameColor(r,rs) then rt else r
19        fun rwOperand(opnd as I.RegOp r) =        fun rwOperand(opnd as I.RegOp r) =
20             if CB.sameColor(r,rs) then I.RegOp rt else opnd             if CB.sameColor(r,rs) then I.RegOp rt else opnd
21          | rwOperand opnd = opnd          | rwOperand opnd = opnd
22      in      fun ea(SOME(I.Displace{base, disp})) =
23        case instr          SOME(I.Displace{base=rplac base, disp=disp})
24          | ea x = x
25    
26        fun ppcUse(instr) =
27         (case instr
28        of I.L {ld, rt, ra, d, mem} =>        of I.L {ld, rt, ra, d, mem} =>
29            I.L{ld=ld, rt=rt, ra=rplac ra, d=rwOperand d, mem=mem}            I.L{ld=ld, rt=rt, ra=rplac ra, d=rwOperand d, mem=mem}
30         | I.LF {ld, ft, ra, d, mem} =>         | I.LF {ld, ft, ra, d, mem} =>
# Line 49  Line 51 
51         | I.CALL {def, use, cutsTo, mem} =>         | I.CALL {def, use, cutsTo, mem} =>
52              I.CALL{def=def, use=CS.map {from=rs,to=rt} use,              I.CALL{def=def, use=CS.map {from=rs,to=rt} use,
53                     cutsTo=cutsTo, mem=mem}                     cutsTo=cutsTo, mem=mem}
        | I.COPY{dst, src, impl, tmp} =>  
           I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}  
        | I.FCOPY{dst, src, impl, tmp} =>  
           I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt)}  
54         | _ => instr         | _ => instr
55      end      (*esac*))
56    in    in
57        case instr        case instr
58         of (I.ANNOTATION{i, ...}) => rewriteUse(i, rs, rt)         of (I.ANNOTATION{i, ...}) => rewriteUse(i, rs, rt)
59          | I.INSTR(i) => I.INSTR(ppcUse(i))          | I.INSTR(i) => I.INSTR(ppcUse(i))
60            | I.COPY{k, sz, dst, src, tmp} =>
61              I.COPY{k=k, sz=sz, dst=dst, tmp= ea tmp,
62                     src=case k of CB.GP => map rplac src | _ => src}
63          | I.LIVE{regs, spilled} =>          | I.LIVE{regs, spilled} =>
64              I.LIVE{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}              I.LIVE{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}
65          | _ => error "rewriteUse"          | _ => error "rewriteUse"
# Line 66  Line 67 
67    
68    
69    fun rewriteDef(instr, rs, rt) = let    fun rewriteDef(instr, rs, rt) = let
     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      fun ea (SOME(I.Direct r)) = SOME(I.Direct(rplac r))
72        case instr        | ea x = x
73        fun ppcDef(instr) =
74         (case instr
75        of I.L {ld, rt, ra, d, mem} =>        of I.L {ld, rt, ra, d, mem} =>
76            I.L{ld=ld, rt=rplac rt, ra=ra, d=d, mem=mem}            I.L{ld=ld, rt=rplac rt, ra=ra, d=d, mem=mem}
77         | I.UNARY {oper, rt, ra, Rc, OE} =>         | I.UNARY {oper, rt, ra, Rc, OE} =>
# Line 86  Line 88 
88         | I.CALL {def, use, cutsTo, mem} =>         | I.CALL {def, use, cutsTo, mem} =>
89            I.CALL{def=CS.map {from=rs,to=rt} def, use=use,            I.CALL{def=CS.map {from=rs,to=rt} def, use=use,
90                   cutsTo=cutsTo, mem=mem}                   cutsTo=cutsTo, mem=mem}
        | I.COPY {dst, src, impl, tmp} =>  
           I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt)}  
91         | _ => instr         | _ => instr
92      end      (*esac*))
93    in    in
94        case instr        case instr
95         of (I.ANNOTATION{i, ...}) => rewriteDef(i, rs, rt)         of (I.ANNOTATION{i, ...}) => rewriteDef(i, rs, rt)
96          | I.INSTR(i) => I.INSTR(ppcDef(i))          | I.INSTR(i) => I.INSTR(ppcDef(i))
97          | I.KILL{regs, spilled} =>          | I.KILL{regs, spilled} =>
98             I.KILL{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}             I.KILL{regs=C.addReg(rt, C.rmvReg(rs, regs)), spilled=spilled}
99            | I.COPY {k, sz, dst, src, tmp} =>
100              I.COPY{k=k, sz=sz, src=src, tmp=ea tmp,
101                     dst=case k of CB.GP => map rplac dst | _ => dst}
102          | _ => error "rewriteDef"          | _ => error "rewriteDef"
103    end    end
104    
105    
106    fun frewriteUse(instr, fs, ft) = let    fun frewriteUse(instr, fs, ft) = let
     fun ppcUse(instr) = let  
107        fun rplac r = if CB.sameColor(r,fs) then ft else r        fun rplac r = if CB.sameColor(r,fs) then ft else r
108      in      fun ppcUse(instr) =
109        case instr       (case instr
110        of I.STF {st, fs, ra, d, mem} =>        of I.STF {st, fs, ra, d, mem} =>
111             I.STF{st=st, fs=rplac fs, ra=ra, d=d, mem=mem}             I.STF{st=st, fs=rplac fs, ra=ra, d=d, mem=mem}
112         | I.CALL{def, use, cutsTo, mem} =>         | I.CALL{def, use, cutsTo, mem} =>
# Line 118  Line 120 
120             I.FARITH{oper=oper, ft=ft, fa=rplac fa, fb=rplac fb, Rc=Rc}             I.FARITH{oper=oper, ft=ft, fa=rplac fa, fb=rplac fb, Rc=Rc}
121         | I.FARITH3 {oper, ft, fa, fb, fc, Rc} =>         | I.FARITH3 {oper, ft, fa, fb, fc, Rc} =>
122             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}
        | I.FCOPY {dst, src, impl, tmp} =>  
            I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}  
123         | _ => instr         | _ => instr
124      end      (*esac*))
125    in    in
126        case instr        case instr
127         of (I.ANNOTATION{i, ...}) => frewriteUse(i, fs, ft)         of (I.ANNOTATION{i, ...}) => frewriteUse(i, fs, ft)
128          | I.INSTR(i) => I.INSTR(ppcUse(i))          | I.INSTR(i) => I.INSTR(ppcUse(i))
129          | I.LIVE{regs, spilled} =>          | I.LIVE{regs, spilled} =>
130              I.LIVE{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}              I.LIVE{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}
131            | I.COPY {k as CB.FP, sz, dst, src, tmp} =>
132               I.COPY{k=k, sz=sz, dst=dst, src=map rplac src, tmp=tmp}
133    
134          | _ => error "frewriteUse"          | _ => error "frewriteUse"
135    
136    end    end
137    
138    fun frewriteDef(instr, fs, ft) = let    fun frewriteDef(instr, fs, ft) = let
     fun ppcDef(instr) = let  
139        fun rplac r = if CB.sameColor(r,fs) then ft else r        fun rplac r = if CB.sameColor(r,fs) then ft else r
140      in      fun rplacEA (SOME(I.FDirect f)) = SOME(I.FDirect(rplac f))
141        case instr        | rplacEA ea = ea
142        fun ppcDef(instr) =
143         (case instr
144        of I.LF{ld, ft, ra, d, mem} =>        of I.LF{ld, ft, ra, d, mem} =>
145            I.LF{ld=ld, ft=rplac ft, ra=ra, d=d, mem=mem}            I.LF{ld=ld, ft=rplac ft, ra=ra, d=d, mem=mem}
146         | I.FUNARY {oper, ft, fb, Rc} =>         | I.FUNARY {oper, ft, fb, Rc} =>
# Line 149  Line 153 
153         | I.CALL{def, use, cutsTo, mem} =>         | I.CALL{def, use, cutsTo, mem} =>
154            I.CALL{def=CS.map {from=fs,to=ft} def, use=use,            I.CALL{def=CS.map {from=fs,to=ft} def, use=use,
155                   cutsTo=cutsTo, mem=mem}                   cutsTo=cutsTo, mem=mem}
        | I.FCOPY {dst, src, impl, tmp} =>  
           I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft)}  
156         | _ => instr         | _ => instr
157      end      (*esac*))
158    in    in
159        case instr        case instr
160         of (I.ANNOTATION{i, ...}) => frewriteDef(i, fs, ft)         of (I.ANNOTATION{i, ...}) => frewriteDef(i, fs, ft)
161          | I.INSTR(i) => I.INSTR(ppcDef(i))          | I.INSTR(i) => I.INSTR(ppcDef(i))
162          | I.KILL{regs, spilled} =>          | I.KILL{regs, spilled} =>
163             I.KILL{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}             I.KILL{regs=C.addFreg(ft, C.rmvFreg(fs, regs)), spilled=spilled}
164            | I.COPY {k as CB.FP, sz, dst, src, tmp} =>
165              I.COPY{k=k, sz=sz, dst=map rplac dst, src=src,  tmp=rplacEA tmp}
166          | _ => error "frewriteDef"          | _ => error "frewriteDef"
167    end    end
168  end  end

Legend:
Removed from v.1008  
changed lines
  Added in v.1009

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