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
 [smlnj] / sml / trunk / src / MLRISC / ppc / ra / ppcRewrite.sml

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

revision 657, Fri Jun 9 05:20:54 2000 UTC revision 744, Fri Dec 8 04:11:42 2000 UTC
# Line 2  Line 2
2    structure I = Instr    structure I = Instr
3    structure C = I.C    structure C = I.C
4
5    fun ea(NONE, _, _, _) = NONE    fun ea(NONE, _, _) = NONE
6      | ea(e as SOME(I.Direct r), rs, rt, mapr : I.C.cell -> I.C.cell) =      | ea(e as SOME(I.Direct r), rs, rt) =
7         if mapr r=rs then SOME(I.Direct rt) else e         if C.sameColor(r,rs) then SOME(I.Direct rt) else e
8      | ea(e as SOME(I.FDirect r), rs, rt, mapr) =      | ea(e as SOME(I.FDirect r), rs, rt) =
9         if mapr r=rs then SOME(I.FDirect rt) else e         if C.sameColor(r,rs) then SOME(I.FDirect rt) else e
10      | ea(e as SOME(I.Displace{base, disp}), rs, rt, mapr) =      | ea(e as SOME(I.Displace{base, disp}), rs, rt) =
11         if mapr base=rs then SOME(I.Displace{base=rt, disp=disp})         if C.sameColor(base,rs) then SOME(I.Displace{base=rt, disp=disp})
12         else e         else e
13
14    fun rewriteUse(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let    fun rewriteUse(instr, rs, rt) = let
15      fun rplac r = if mapr r=rs then rt else r      fun rplac r = if C.sameColor(r,rs) then rt else r
16      fun rwOperand(opnd as I.RegOp r) =      fun rwOperand(opnd as I.RegOp r) =
17           if mapr r = rs then I.RegOp rt else opnd           if C.sameColor(r,rs) then I.RegOp rt else opnd
18        | rwOperand opnd = opnd        | rwOperand opnd = opnd
19    in    in
20      case instr      case instr
# Line 41  Line 41
41       | I.MTSPR{rs, spr} => I.MTSPR{rs=rplac rs, spr=spr}       | I.MTSPR{rs, spr} => I.MTSPR{rs=rplac rs, spr=spr}
42       | I.TW {to, ra, si} => I.TW{to=to, ra=rplac ra, si=rwOperand si}       | I.TW {to, ra, si} => I.TW{to=to, ra=rplac ra, si=rwOperand si}
43       | I.TD {to, ra, si} => I.TD{to=to, ra=rplac ra, si=rwOperand si}       | I.TD {to, ra, si} => I.TD{to=to, ra=rplac ra, si=rwOperand si}
44       | I.CALL {def, use=(r,f,c), mem} =>       | I.CALL {def, use, mem} =>
45            I.CALL{def=def, use=(map rplac r,f,c), mem=mem}            I.CALL{def=def, use=C.CellSet.map {from=rs,to=rt} use, mem=mem}
46       | I.COPY{dst, src, impl, tmp} =>       | I.COPY{dst, src, impl, tmp} =>
47          I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}          I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
48       | I.FCOPY{dst, src, impl, tmp} =>       | I.FCOPY{dst, src, impl, tmp} =>
49          I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt, mapr)}          I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt)}
50       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
51           I.ANNOTATION{i=rewriteUse(mapr,i,rs,rt),           I.ANNOTATION{i=rewriteUse(i,rs,rt),
52                          a=case a of                          a=case a of
53                             C.DEF_USE{cellkind=C.GP,defs,uses} =>                             C.DEF_USE{cellkind=C.GP,defs,uses} =>
54                               C.DEF_USE{cellkind=C.GP,uses=map rplac uses,                               C.DEF_USE{cellkind=C.GP,uses=map rplac uses,
# Line 57  Line 57
57       | _ => instr       | _ => instr
58    end    end
59
60    fun rewriteDef(mapr : I.C.cell -> I.C.cell, instr, rs, rt) = let    fun rewriteDef(instr, rs, rt) = let
61      fun rplac r = if mapr r = rs then rt else r      fun rplac r = if C.sameColor(r,rs) then rt else r
62    in    in
63      case instr      case instr
64      of I.L {ld, rt, ra, d, mem} =>      of I.L {ld, rt, ra, d, mem} =>
# Line 74  Line 74
74       | I.ROTATEI {oper, ra, rs, sh, mb, me} =>       | I.ROTATEI {oper, ra, rs, sh, mb, me} =>
75          I.ROTATEI {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}          I.ROTATEI {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}
76       | I.MFSPR {rt, spr} => I.MFSPR{rt=rplac rt, spr=spr}       | I.MFSPR {rt, spr} => I.MFSPR{rt=rplac rt, spr=spr}
77       | I.CALL {def=(r,f,c), use, mem} =>       | I.CALL {def, use, mem} =>
78          I.CALL{def=(map rplac r, f, c), use=use, mem=mem}          I.CALL{def=C.CellSet.map {from=rs,to=rt} def, use=use, mem=mem}
79       | I.COPY {dst, src, impl, tmp} =>       | I.COPY {dst, src, impl, tmp} =>
80          I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt,mapr)}          I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt)}
81       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
82          I.ANNOTATION{i=rewriteDef(mapr,i,rs,rt),          I.ANNOTATION{i=rewriteDef(i,rs,rt),
83                          a=case a of                          a=case a of
84                             C.DEF_USE{cellkind=C.GP,defs,uses} =>                             C.DEF_USE{cellkind=C.GP,defs,uses} =>
85                               C.DEF_USE{cellkind=C.GP,uses=uses,                               C.DEF_USE{cellkind=C.GP,uses=uses,
# Line 88  Line 88
88       | _ => instr       | _ => instr
89    end    end
90
91    fun frewriteUse(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let    fun frewriteUse(instr, fs, ft) = let
92      fun rplac r = if mapr r = fs then ft else r      fun rplac r = if C.sameColor(r,fs) then ft else r
93    in    in
94      case instr      case instr
95      of I.STF {st, fs, ra, d, mem} =>      of I.STF {st, fs, ra, d, mem} =>
96           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}
97       | I.CALL{def, use=(r,f,c), mem} =>       | I.CALL{def, use, mem} =>
98           I.CALL{def=def, use=(r, map rplac f, c), mem=mem}           I.CALL{def=def, use=C.CellSet.map {from=fs,to=ft} use, mem=mem}
99       | I.FCOMPARE {cmp, bf, fa, fb} =>       | I.FCOMPARE {cmp, bf, fa, fb} =>
100           I.FCOMPARE{cmp=cmp, bf=bf, fa=rplac fa, fb=rplac fb}           I.FCOMPARE{cmp=cmp, bf=bf, fa=rplac fa, fb=rplac fb}
101       | I.FUNARY {oper, ft, fb, Rc} =>       | I.FUNARY {oper, ft, fb, Rc} =>
# Line 107  Line 107
107       | I.FCOPY {dst, src, impl, tmp} =>       | I.FCOPY {dst, src, impl, tmp} =>
108           I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}           I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
109       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
110           I.ANNOTATION{i=frewriteUse(mapr,i,fs,ft),           I.ANNOTATION{i=frewriteUse(i,fs,ft),
111                          a=case a of                          a=case a of
112                             C.DEF_USE{cellkind=C.FP,defs,uses} =>                             C.DEF_USE{cellkind=C.FP,defs,uses} =>
113                               C.DEF_USE{cellkind=C.FP,uses=map rplac uses,                               C.DEF_USE{cellkind=C.FP,uses=map rplac uses,
# Line 117  Line 117
117    end    end
118
119
120    fun frewriteDef(mapr : I.C.cell -> I.C.cell, instr, fs, ft) = let    fun frewriteDef(instr, fs, ft) = let
121      fun rplac r = if mapr r = fs then ft else r      fun rplac r = if C.sameColor(r,fs) then ft else r
122    in    in
123      case instr      case instr
124      of I.LF{ld, ft, ra, d, mem} =>      of I.LF{ld, ft, ra, d, mem} =>
# Line 130  Line 130
130       | I.FARITH3{oper, ft, fa, fb, fc, Rc} =>       | I.FARITH3{oper, ft, fa, fb, fc, Rc} =>
131          I.FARITH3{oper=oper, ft=rplac ft, fa=fa, fb=fb, fc=fc, Rc=Rc}          I.FARITH3{oper=oper, ft=rplac ft, fa=fa, fb=fb, fc=fc, Rc=Rc}
132      (* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *)      (* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *)
133       | I.CALL{def=(r,f,c), use, mem} =>       | I.CALL{def, use, mem} =>
134          I.CALL{def=(r, map rplac f, c), use=use, mem=mem}          I.CALL{def=C.CellSet.map {from=fs,to=ft} def, use=use, mem=mem}
135       | I.FCOPY {dst, src, impl, tmp} =>       | I.FCOPY {dst, src, impl, tmp} =>
136          I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft,mapr)}          I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft)}
137       | I.ANNOTATION{i,a} =>       | I.ANNOTATION{i,a} =>
138          I.ANNOTATION{i=frewriteDef(mapr,i,fs,ft),          I.ANNOTATION{i=frewriteDef(i,fs,ft),
139                          a=case a of                          a=case a of
140                             C.DEF_USE{cellkind=C.FP,defs,uses} =>                             C.DEF_USE{cellkind=C.FP,defs,uses} =>
141                               C.DEF_USE{cellkind=C.FP,uses=uses,                               C.DEF_USE{cellkind=C.FP,uses=uses,

Legend:
 Removed from v.657 changed lines Added in v.744