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

Annotation of /sml/trunk/src/MLRISC/sparc/ra/sparcRewrite.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 889 - (view) (download)

1 : monnier 245 functor SparcRewrite(Instr:SPARCINSTR) =
2 :     struct
3 :     structure I = Instr
4 : leunga 657 structure C = I.C
5 : george 889 structure CB = CellsBasis
6 : monnier 245
7 : leunga 744 fun rewriteUse(instr,rs,rt) =
8 : george 889 let fun match r = CB.sameColor(r,rs)
9 : leunga 744 fun R r = if match r then rt else r
10 :     fun O(i as I.REG r) = if match r then I.REG rt else i
11 : monnier 245 | O i = i
12 :     in case instr of
13 :     I.LOAD{l,r,i,d,mem} => I.LOAD{l=l,r=R r,i=O i,d=d,mem=mem}
14 :     | I.STORE{s,d,r,i,mem} => I.STORE{s=s,d=R d,r=R r,i=O i,mem=mem}
15 :     | I.FLOAD{l,r,i,d,mem} => I.FLOAD{l=l,r=R r,i=O i,d=d,mem=mem}
16 :     | I.FSTORE{s,d,r,i,mem} => I.FSTORE{s=s,d=d,r=R r,i=O i,mem=mem}
17 : monnier 411 | I.ARITH{a,r,i,d} => I.ARITH{a=a,r=R r,i=O i,d=d}
18 : monnier 245 | I.SHIFT{s,r,i,d} => I.SHIFT{s=s,r=R r,i=O i,d=d}
19 : monnier 411 | I.BR{r,p,rcond,a,nop,label} =>
20 :     I.BR{r=R r,p=p,rcond=rcond,a=a,nop=nop,label=label}
21 :     | I.MOVicc{b,i,d} => I.MOVicc{b=b,i=O i,d=R d}
22 :     | I.MOVfcc{b,i,d} => I.MOVfcc{b=b,i=O i,d=R d}
23 :     | I.MOVR{rcond,r,i,d} => I.MOVR{rcond=rcond,r=R r,i=O i,d=R d}
24 : monnier 245 | I.JMP{r,i,labs,nop} => I.JMP{r=R r,i=O i,labs=labs,nop=nop}
25 : leunga 796 | I.JMPL{r,i,d,defs,uses,cutsTo,nop,mem} =>
26 : leunga 744 I.JMPL{r=R r,i=O i,d=d,defs=defs,
27 : leunga 796 uses=C.CellSet.map {from=rs,to=rt} uses,
28 :     cutsTo=cutsTo,nop=nop,mem=mem}
29 :     | I.CALL{defs,uses,label,cutsTo,nop,mem} =>
30 : leunga 744 I.CALL{defs=defs,uses=C.CellSet.map {from=rs,to=rt} uses,
31 : leunga 796 label=label,cutsTo=cutsTo,nop=nop,mem=mem}
32 : monnier 245 | I.SAVE{r,i,d} => I.SAVE{r=R r,i=O i,d=d}
33 :     | I.RESTORE{r,i,d} => I.RESTORE{r=R r,i=O i,d=d}
34 :     | I.WRY{r,i} => I.WRY{r=R r,i=O i}
35 : monnier 411 | I.Ticc{t,cc,r,i} => I.Ticc{t=t,cc=cc,r=R r,i=O i}
36 : monnier 245 | I.COPY{src,dst,tmp,impl} =>
37 :     I.COPY{src=map R src,dst=dst,tmp=tmp,impl=impl}
38 : leunga 657 | I.ANNOTATION{i,a} =>
39 : leunga 744 I.ANNOTATION{i=rewriteUse(i,rs,rt),
40 : leunga 657 a=case a of
41 : george 889 CB.DEF_USE{cellkind=CB.GP,defs,uses} =>
42 :     CB.DEF_USE{cellkind=CB.GP,uses=map R uses,
43 : leunga 657 defs=defs}
44 :     | _ => a}
45 : monnier 245 | _ => instr
46 :     end
47 :    
48 : leunga 744 fun rewriteDef(instr,rs,rt) =
49 : george 889 let fun match r = CB.sameColor(r,rs)
50 : leunga 744 fun R r = if match r then rt else r
51 : monnier 245 fun ea(SOME(I.Direct r)) = SOME(I.Direct(R r))
52 :     | ea x = x
53 :     in case instr of
54 :     I.LOAD{l,r,i,d,mem} => I.LOAD{l=l,r=r,i=i,d=R d,mem=mem}
55 : monnier 411 | I.ARITH{a,r,i,d} => I.ARITH{a=a,r=r,i=i,d=R d}
56 : monnier 245 | I.SHIFT{s,r,i,d} => I.SHIFT{s=s,r=r,i=i,d=R d}
57 :     | I.SETHI{i,d} => I.SETHI{i=i,d=R d}
58 : monnier 411 | I.MOVicc{b,i,d} => I.MOVicc{b=b,i=i,d=R d}
59 :     | I.MOVfcc{b,i,d} => I.MOVfcc{b=b,i=i,d=R d}
60 :     | I.MOVR{rcond,r,i,d} => I.MOVR{rcond=rcond,r=r,i=i,d=R d}
61 : leunga 796 | I.JMPL{r,i,d,defs,uses,cutsTo,nop,mem} =>
62 : leunga 744 I.JMPL{r=r,i=i,d=R d,defs=C.CellSet.map {from=rs,to=rt} defs,
63 : leunga 796 uses=uses,cutsTo=cutsTo,nop=nop,mem=mem}
64 :     | I.CALL{defs,uses,label,cutsTo,nop,mem} =>
65 : leunga 744 I.CALL{defs=C.CellSet.map {from=rs,to=rt} defs,
66 : leunga 796 uses=uses,label=label,cutsTo=cutsTo,nop=nop,mem=mem}
67 : monnier 245 | I.SAVE{r,i,d} => I.SAVE{r=r,i=i,d=R d}
68 :     | I.RESTORE{r,i,d} => I.RESTORE{r=r,i=i,d=R d}
69 :     | I.RDY{d} => I.RDY{d=R d}
70 :     | I.COPY{src,dst,tmp,impl} =>
71 :     I.COPY{src=src,dst=map R dst,tmp=ea tmp,impl=impl}
72 : leunga 657 | I.ANNOTATION{i,a} =>
73 : leunga 744 I.ANNOTATION{i=rewriteDef(i,rs,rt),
74 : leunga 657 a=case a of
75 : george 889 CB.DEF_USE{cellkind=CB.GP,defs,uses} =>
76 :     CB.DEF_USE{cellkind=CB.GP,uses=uses,
77 : leunga 657 defs=map R defs}
78 :     | _ => a}
79 : monnier 245 | _ => instr
80 :     end
81 :    
82 : leunga 744 fun frewriteUse(instr,rs,rt) =
83 : george 889 let fun match r = CB.sameColor(r,rs)
84 : leunga 744 fun R r = if match r then rt else r
85 : monnier 245 in case instr of
86 :     I.FPop1{a,r,d} => I.FPop1{a=a,r=R r,d=d}
87 :     | I.FPop2{a,r1,r2,d} => I.FPop2{a=a,r1=R r1,r2=R r2,d=d}
88 :     | I.FCMP{cmp,r1,r2,nop} => I.FCMP{cmp=cmp,r1=R r1,r2=R r2,nop=nop}
89 :     | I.FSTORE{s,r,i,d,mem} => I.FSTORE{s=s,r=r,i=i,d=R d,mem=mem}
90 : monnier 411 | I.FMOVicc{sz,b,r,d} => I.FMOVicc{sz=sz,b=b,r=R r,d=R d}
91 :     | I.FMOVfcc{sz,b,r,d} => I.FMOVfcc{sz=sz,b=b,r=R r,d=R d}
92 : leunga 796 | I.JMPL{r,i,d,defs,uses,cutsTo,nop,mem} =>
93 : leunga 744 I.JMPL{r=r,i=i,d=d,defs=defs,
94 : leunga 796 uses=C.CellSet.map {from=rs,to=rt} uses,
95 :     cutsTo=cutsTo,nop=nop,mem=mem}
96 :     | I.CALL{defs,uses,label,cutsTo,nop,mem} =>
97 : leunga 744 I.CALL{defs=defs,uses=C.CellSet.map {from=rs,to=rt} uses,
98 : leunga 796 label=label,cutsTo=cutsTo,nop=nop,mem=mem}
99 : monnier 245 | I.FCOPY{src,dst,tmp,impl} =>
100 :     I.FCOPY{src=map R src,dst=dst,tmp=tmp,impl=impl}
101 : leunga 657 | I.ANNOTATION{i,a} =>
102 : leunga 744 I.ANNOTATION{i=frewriteUse(i,rs,rt),
103 : leunga 657 a=case a of
104 : george 889 CB.DEF_USE{cellkind=CB.FP,defs,uses} =>
105 :     CB.DEF_USE{cellkind=CB.FP,uses=map R uses,
106 : leunga 657 defs=defs}
107 :     | _ => a}
108 : monnier 245 | _ => instr
109 :     end
110 :    
111 : leunga 744 fun frewriteDef(instr,rs,rt) =
112 : george 889 let fun match r = CB.sameColor(r,rs)
113 : leunga 744 fun R r = if match r then rt else r
114 : monnier 245 fun ea(SOME(I.FDirect r)) = SOME(I.FDirect(R r))
115 :     | ea x = x
116 :     in case instr of
117 :     I.FPop1{a,r,d} => I.FPop1{a=a,r=r,d=R d}
118 :     | I.FPop2{a,r1,r2,d} => I.FPop2{a=a,r1=r1,r2=r2,d=R d}
119 :     | I.FLOAD{l,r,i,d,mem} => I.FLOAD{l=l,r=r,i=i,d=R d,mem=mem}
120 : monnier 411 | I.FMOVicc{sz,b,r,d} => I.FMOVicc{sz=sz,b=b,r=r,d=R d}
121 :     | I.FMOVfcc{sz,b,r,d} => I.FMOVfcc{sz=sz,b=b,r=r,d=R d}
122 : leunga 796 | I.JMPL{r,i,d,defs,uses,cutsTo,nop,mem} =>
123 : leunga 744 I.JMPL{r=r,i=i,d=d,defs=C.CellSet.map {from=rs,to=rt} defs,
124 : leunga 796 uses=uses,cutsTo=cutsTo,nop=nop,mem=mem}
125 :     | I.CALL{defs,uses,label,cutsTo,nop,mem} =>
126 : leunga 744 I.CALL{defs=C.CellSet.map {from=rs,to=rt} defs,
127 : leunga 796 uses=uses,label=label,cutsTo=cutsTo,nop=nop,mem=mem}
128 : monnier 245 | I.FCOPY{src,dst,tmp,impl} =>
129 :     I.FCOPY{src=src,dst=map R dst,tmp=ea tmp,impl=impl}
130 : leunga 657 | I.ANNOTATION{i,a}=>
131 : leunga 744 I.ANNOTATION{i=frewriteDef(i,rs,rt),
132 : leunga 657 a=case a of
133 : george 889 CB.DEF_USE{cellkind=CB.FP,defs,uses} =>
134 :     CB.DEF_USE{cellkind=CB.FP,uses=uses,
135 : leunga 657 defs=map R defs}
136 :     | _ => a}
137 : monnier 245 | _ => instr
138 :     end
139 :    
140 :     end
141 :    

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