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

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