Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/ppc/ra/ppcRewrite.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 901 - (view) (download)

1 : monnier 245 functor PPCRewrite(Instr : PPCINSTR) = struct
2 :     structure I = Instr
3 : leunga 657 structure C = I.C
4 : george 889 structure CB = CellsBasis
5 : george 901 structure CS = CB.CellSet
6 : monnier 245
7 : leunga 744 fun ea(NONE, _, _) = NONE
8 :     | ea(e as SOME(I.Direct r), rs, rt) =
9 : george 889 if CB.sameColor(r,rs) then SOME(I.Direct rt) else e
10 : leunga 744 | ea(e as SOME(I.FDirect r), rs, rt) =
11 : george 889 if CB.sameColor(r,rs) then SOME(I.FDirect rt) else e
12 : leunga 744 | ea(e as SOME(I.Displace{base, disp}), rs, rt) =
13 : george 889 if CB.sameColor(base,rs) then SOME(I.Displace{base=rt, disp=disp})
14 : monnier 245 else e
15 :    
16 : leunga 744 fun rewriteUse(instr, rs, rt) = let
17 : george 889 fun rplac r = if CB.sameColor(r,rs) then rt else r
18 : monnier 245 fun rwOperand(opnd as I.RegOp r) =
19 : george 889 if CB.sameColor(r,rs) then I.RegOp rt else opnd
20 : monnier 245 | rwOperand opnd = opnd
21 :     in
22 :     case instr
23 : monnier 411 of I.L {ld, rt, ra, d, mem} =>
24 :     I.L{ld=ld, rt=rt, ra=rplac ra, d=rwOperand d, mem=mem}
25 :     | I.LF {ld, ft, ra, d, mem} =>
26 :     I.LF{ld=ld, ft=ft, ra=rplac ra, d=rwOperand d, mem=mem}
27 :     | I.ST {st, rs, ra, d, mem} =>
28 :     I.ST{st=st, rs=rplac rs, ra=rplac ra, d=rwOperand d, mem=mem}
29 :     | I.STF {st, fs, ra, d, mem} =>
30 :     I.STF{st=st, fs=fs, ra=rplac ra, d=rwOperand d, mem=mem}
31 :     | I.UNARY {oper, rt, ra, Rc, OE} =>
32 :     I.UNARY{oper=oper, rt=rt, ra=rplac ra, Rc=Rc, OE=OE}
33 : monnier 245 | I.ARITH{oper, rt, ra, rb, Rc, OE} =>
34 :     I.ARITH{oper=oper, rt=rt, ra=rplac ra, rb=rplac rb, Rc=Rc, OE=OE}
35 :     | I.ARITHI{oper, rt, ra, im} =>
36 :     I.ARITHI{oper=oper, rt=rt, ra=rplac ra, im=rwOperand im}
37 :     | I.ROTATE {oper, ra, rs, sh, mb, me} =>
38 : monnier 411 I.ROTATE{oper=oper, ra=ra, rs=rplac rs, sh=rplac sh, mb=mb, me=me}
39 :     | I.ROTATEI {oper, ra, rs, sh, mb, me} =>
40 :     I.ROTATEI{oper=oper, ra=ra, rs=rplac rs, sh=rwOperand sh, mb=mb, me=me}
41 :     | I.COMPARE {cmp, bf, l, ra, rb} =>
42 :     I.COMPARE{cmp=cmp, bf=bf, l=l, ra=rplac ra, rb=rwOperand rb}
43 : monnier 245 | I.MTSPR{rs, spr} => I.MTSPR{rs=rplac rs, spr=spr}
44 : monnier 411 | I.TW {to, ra, si} => I.TW{to=to, ra=rplac ra, si=rwOperand si}
45 :     | I.TD {to, ra, si} => I.TD{to=to, ra=rplac ra, si=rwOperand si}
46 : leunga 796 | I.CALL {def, use, cutsTo, mem} =>
47 : george 901 I.CALL{def=def, use=CS.map {from=rs,to=rt} use,
48 : leunga 796 cutsTo=cutsTo, mem=mem}
49 : monnier 245 | I.COPY{dst, src, impl, tmp} =>
50 :     I.COPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
51 :     | I.FCOPY{dst, src, impl, tmp} =>
52 : leunga 744 I.FCOPY{dst=dst, src=src, impl=impl, tmp=ea(tmp, rs, rt)}
53 : leunga 657 | I.ANNOTATION{i,a} =>
54 : leunga 744 I.ANNOTATION{i=rewriteUse(i,rs,rt),
55 : leunga 657 a=case a of
56 : george 889 CB.DEF_USE{cellkind=CB.GP,defs,uses} =>
57 :     CB.DEF_USE{cellkind=CB.GP,uses=map rplac uses,
58 : leunga 657 defs=defs}
59 :     | _ => a}
60 : monnier 245 | _ => instr
61 :     end
62 :    
63 : leunga 744 fun rewriteDef(instr, rs, rt) = let
64 : george 889 fun rplac r = if CB.sameColor(r,rs) then rt else r
65 : monnier 245 in
66 :     case instr
67 : monnier 411 of I.L {ld, rt, ra, d, mem} =>
68 :     I.L{ld=ld, rt=rplac rt, ra=ra, d=d, mem=mem}
69 : monnier 245 | I.UNARY {oper, rt, ra, Rc, OE} =>
70 :     I.UNARY{oper=oper, rt=rplac rt, ra=ra, Rc=Rc, OE=OE}
71 :     | I.ARITH {oper, rt, ra, rb, Rc, OE} =>
72 :     I.ARITH{oper=oper, rt=rplac rt, ra=ra, rb=rb, Rc=Rc, OE=OE}
73 :     | I.ARITHI {oper, rt, ra, im} =>
74 :     I.ARITHI {oper=oper, rt=rplac rt, ra=ra, im=im}
75 :     | I.ROTATE {oper, ra, rs, sh, mb, me} =>
76 :     I.ROTATE {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}
77 : monnier 411 | I.ROTATEI {oper, ra, rs, sh, mb, me} =>
78 :     I.ROTATEI {oper=oper, ra=rplac ra, rs=rs, sh=sh, mb=mb, me=me}
79 : monnier 245 | I.MFSPR {rt, spr} => I.MFSPR{rt=rplac rt, spr=spr}
80 : leunga 796 | I.CALL {def, use, cutsTo, mem} =>
81 : george 901 I.CALL{def=CS.map {from=rs,to=rt} def, use=use,
82 : leunga 796 cutsTo=cutsTo, mem=mem}
83 : monnier 245 | I.COPY {dst, src, impl, tmp} =>
84 : leunga 744 I.COPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,rs,rt)}
85 : leunga 657 | I.ANNOTATION{i,a} =>
86 : leunga 744 I.ANNOTATION{i=rewriteDef(i,rs,rt),
87 : leunga 657 a=case a of
88 : george 889 CB.DEF_USE{cellkind=CB.GP,defs,uses} =>
89 :     CB.DEF_USE{cellkind=CB.GP,uses=uses,
90 : leunga 657 defs=map rplac defs}
91 :     | _ => a}
92 : monnier 245 | _ => instr
93 :     end
94 :    
95 : leunga 744 fun frewriteUse(instr, fs, ft) = let
96 : george 889 fun rplac r = if CB.sameColor(r,fs) then ft else r
97 : monnier 245 in
98 :     case instr
99 : monnier 411 of I.STF {st, fs, ra, d, mem} =>
100 :     I.STF{st=st, fs=rplac fs, ra=ra, d=d, mem=mem}
101 : leunga 796 | I.CALL{def, use, cutsTo, mem} =>
102 : george 901 I.CALL{def=def, use=CS.map {from=fs,to=ft} use,
103 : leunga 796 cutsTo=cutsTo, mem=mem}
104 : monnier 245 | I.FCOMPARE {cmp, bf, fa, fb} =>
105 :     I.FCOMPARE{cmp=cmp, bf=bf, fa=rplac fa, fb=rplac fb}
106 :     | I.FUNARY {oper, ft, fb, Rc} =>
107 :     I.FUNARY{oper=oper, ft=ft, fb=rplac fb, Rc=Rc}
108 :     | I.FARITH {oper, ft, fa, fb, Rc} =>
109 :     I.FARITH{oper=oper, ft=ft, fa=rplac fa, fb=rplac fb, Rc=Rc}
110 : monnier 411 | I.FARITH3 {oper, ft, fa, fb, fc, Rc} =>
111 :     I.FARITH3{oper=oper,ft=ft,fa=rplac fa, fb=rplac fb, fc=rplac fc,Rc=Rc}
112 : monnier 245 | I.FCOPY {dst, src, impl, tmp} =>
113 :     I.FCOPY{dst=dst, src=map rplac src, impl=impl, tmp=tmp}
114 : leunga 657 | I.ANNOTATION{i,a} =>
115 : leunga 744 I.ANNOTATION{i=frewriteUse(i,fs,ft),
116 : leunga 657 a=case a of
117 : george 889 CB.DEF_USE{cellkind=CB.FP,defs,uses} =>
118 :     CB.DEF_USE{cellkind=CB.FP,uses=map rplac uses,
119 : leunga 657 defs=defs}
120 :     | _ => a}
121 : monnier 245 | _ => instr
122 :     end
123 :    
124 :    
125 : leunga 744 fun frewriteDef(instr, fs, ft) = let
126 : george 889 fun rplac r = if CB.sameColor(r,fs) then ft else r
127 : monnier 245 in
128 :     case instr
129 : monnier 411 of I.LF{ld, ft, ra, d, mem} =>
130 :     I.LF{ld=ld, ft=rplac ft, ra=ra, d=d, mem=mem}
131 : monnier 245 | I.FUNARY {oper, ft, fb, Rc} =>
132 :     I.FUNARY{oper=oper, ft=rplac ft, fb=fb, Rc=Rc}
133 :     | I.FARITH{oper, ft, fa, fb, Rc} =>
134 :     I.FARITH{oper=oper, ft=rplac ft, fa=fa, fb=fb, Rc=Rc}
135 : monnier 411 | I.FARITH3{oper, ft, fa, fb, fc, Rc} =>
136 :     I.FARITH3{oper=oper, ft=rplac ft, fa=fa, fb=fb, fc=fc, Rc=Rc}
137 : monnier 245 (* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *)
138 : leunga 796 | I.CALL{def, use, cutsTo, mem} =>
139 : george 901 I.CALL{def=CS.map {from=fs,to=ft} def, use=use,
140 : leunga 796 cutsTo=cutsTo, mem=mem}
141 : monnier 245 | I.FCOPY {dst, src, impl, tmp} =>
142 : leunga 744 I.FCOPY{dst=map rplac dst, src=src, impl=impl, tmp=ea(tmp,fs,ft)}
143 : leunga 657 | I.ANNOTATION{i,a} =>
144 : leunga 744 I.ANNOTATION{i=frewriteDef(i,fs,ft),
145 : leunga 657 a=case a of
146 : george 889 CB.DEF_USE{cellkind=CB.FP,defs,uses} =>
147 :     CB.DEF_USE{cellkind=CB.FP,uses=uses,
148 : leunga 657 defs=map rplac defs}
149 :     | _ => a}
150 : monnier 245 | _ => instr
151 :     end
152 :     end
153 :    

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