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/x86/instructions/x86Peephole.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/x86/instructions/x86Peephole.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 958 - (view) (download)

1 : leunga 752 (* WARNING: this is generated by running 'nowhere x86Peephole.peep'.
2 : leunga 744 * Do not edit this file directly.
3 : george 958 * Version 1.2
4 : leunga 744 *)
5 :    
6 : leunga 775 (*#line 20.1 "x86Peephole.peep"*)
7 : leunga 744 functor X86Peephole(X86Instr : X86INSTR): PEEPHOLE =
8 : leunga 601 struct
9 : leunga 744
10 : leunga 775 (*#line 22.4 "x86Peephole.peep"*)
11 : leunga 601 structure I = X86Instr
12 :    
13 : leunga 775 (*#line 23.4 "x86Peephole.peep"*)
14 : leunga 744 structure C = I.C
15 : george 958
16 :     (*#line 24.4 "x86Peephole.peep"*)
17 : jhr 899 structure CBase = CellsBasis
18 : leunga 601
19 : george 958 (*#line 27.4 "x86Peephole.peep"*)
20 : leunga 744 fun peephole instrs =
21 :     let
22 : george 958 (*#line 28.8 "x86Peephole.peep"*)
23 : jhr 899 fun isStackPtr (I.Direct r) = CBase.sameColor (r, C.esp)
24 : leunga 744 | isStackPtr _ = false
25 : leunga 646
26 : george 958 (*#line 31.8 "x86Peephole.peep"*)
27 : leunga 744 fun isZero (I.Immed n) = n = 0
28 :     | isZero (I.ImmedLabel le) = (I.LabelExp.valueOf le) = 0
29 :     | isZero _ = false
30 : leunga 660
31 : george 958 (*#line 35.8 "x86Peephole.peep"*)
32 : leunga 744 fun isZeroOpt NONE = true
33 :     | isZeroOpt (SOME opn) = isZero opn
34 : leunga 601
35 : george 958 (*#line 38.8 "x86Peephole.peep"*)
36 : leunga 744 fun loop (code, instrs) =
37 :     let val v_32 = code
38 : leunga 752 fun state_9 (v_0, v_3) =
39 : leunga 744 let val i = v_0
40 :     and rest = v_3
41 :     in loop (rest, i :: instrs)
42 :     end
43 : leunga 752 fun state_21 (v_0, v_16, v_3) =
44 :     let val le = v_16
45 :     and rest = v_3
46 :     in (if ((I.LabelExp.valueOf le) = 0)
47 :     then (loop (rest, instrs))
48 :     else (state_9 (v_0, v_3)))
49 :     end
50 :     fun state_49 (v_0, v_1, v_2, v_3) =
51 : leunga 744 (case v_1 of
52 : leunga 775 I.Direct v_25 =>
53 : leunga 744 let val dst = v_1
54 : leunga 752 and rest = v_3
55 : leunga 744 and src = v_2
56 :     in (if (isZero src)
57 :     then (loop (rest, (I.BINARY {binOp=I.XORL, src=dst, dst=dst}) :: instrs))
58 : leunga 752 else (state_9 (v_0, v_3)))
59 : leunga 744 end
60 : leunga 752 | _ => state_9 (v_0, v_3)
61 : leunga 744 )
62 :     in
63 :     (case v_32 of
64 : leunga 775 op :: v_31 =>
65 : leunga 744 let val (v_0, v_3) = v_31
66 :     in
67 :     (case v_0 of
68 :     I.BINARY v_18 =>
69 : leunga 752 let val {binOp=v_30, dst=v_1, src=v_2, ...} = v_18
70 : leunga 744 in
71 : leunga 752 (case v_30 of
72 :     I.ADDL =>
73 :     (case v_2 of
74 :     I.Immed v_16 =>
75 : leunga 744 (case v_1 of
76 : leunga 775 I.Direct v_25 =>
77 : leunga 744 (case v_3 of
78 : leunga 775 op :: v_13 =>
79 :     let val (v_12, v_4) = v_13
80 : leunga 744 in
81 :     (case v_12 of
82 :     I.BINARY v_11 =>
83 :     let val {binOp=v_10, dst=v_9, src=v_8, ...} = v_11
84 :     in
85 :     (case v_10 of
86 :     I.SUBL =>
87 :     (case v_9 of
88 :     I.Direct v_5 =>
89 :     (case v_8 of
90 :     I.Immed v_7 =>
91 : leunga 775 let val d_i = v_25
92 : leunga 744 and d_j = v_5
93 :     and m = v_7
94 : leunga 752 and n = v_16
95 : leunga 775 and rest = v_4
96 : jhr 899 in (if ((CBase.sameColor (d_i, C.esp)) andalso (CBase.sameColor (d_j, C.esp)))
97 : leunga 744 then (if (m = n)
98 :     then (loop (rest, instrs))
99 :     else (if (m < n)
100 :     then (loop (rest, (I.BINARY {binOp=I.ADDL, src=I.Immed (n - m), dst=I.Direct C.esp}) :: instrs))
101 :     else (loop (rest, (I.BINARY {binOp=I.SUBL, src=I.Immed (m - n), dst=I.Direct C.esp}) :: instrs))))
102 : leunga 752 else (state_9 (v_0, v_3)))
103 : leunga 744 end
104 : leunga 752 | _ => state_9 (v_0, v_3)
105 : leunga 744 )
106 : leunga 752 | _ => state_9 (v_0, v_3)
107 : leunga 744 )
108 : leunga 752 | _ => state_9 (v_0, v_3)
109 : leunga 744 )
110 :     end
111 : leunga 752 | _ => state_9 (v_0, v_3)
112 : leunga 744 )
113 :     end
114 : leunga 775 | nil => state_9 (v_0, v_3)
115 : leunga 744 )
116 : leunga 752 | _ => state_9 (v_0, v_3)
117 : leunga 744 )
118 : leunga 752 | I.ImmedLabel v_16 => state_21 (v_0, v_16, v_3)
119 :     | _ => state_9 (v_0, v_3)
120 :     )
121 :     | I.SUBL =>
122 :     (case v_2 of
123 :     I.Immed v_16 =>
124 : leunga 744 (case v_1 of
125 : leunga 775 I.Direct v_25 =>
126 : leunga 744 (case v_16 of
127 :     4 =>
128 :     (case v_3 of
129 : leunga 775 op :: v_13 =>
130 :     let val (v_12, v_4) = v_13
131 : leunga 744 in
132 :     (case v_12 of
133 :     I.MOVE v_11 =>
134 : leunga 752 let val {dst=v_9, mvOp=v_27, src=v_8, ...} = v_11
135 : leunga 744 in
136 :     (case v_9 of
137 :     I.Displace v_5 =>
138 : leunga 775 let val {base=v_26, disp=v_29, ...} = v_5
139 : leunga 744 in
140 : leunga 752 (case v_29 of
141 :     I.Immed v_28 =>
142 :     (case v_28 of
143 : leunga 744 0 =>
144 : leunga 752 (case v_27 of
145 : leunga 744 I.MOVL =>
146 : leunga 775 let val base = v_26
147 :     and dst_i = v_25
148 :     and rest = v_4
149 : leunga 744 and src = v_8
150 : jhr 899 in (if (((CBase.sameColor (base, C.esp)) andalso (CBase.sameColor (dst_i, C.esp))) andalso (not (isStackPtr src)))
151 : leunga 744 then (loop (rest, (I.PUSHL src) :: instrs))
152 : leunga 752 else (state_9 (v_0, v_3)))
153 : leunga 744 end
154 : leunga 752 | _ => state_9 (v_0, v_3)
155 : leunga 744 )
156 : leunga 752 | _ => state_9 (v_0, v_3)
157 : leunga 744 )
158 : leunga 752 | _ => state_9 (v_0, v_3)
159 : leunga 744 )
160 :     end
161 : leunga 752 | _ => state_9 (v_0, v_3)
162 : leunga 744 )
163 :     end
164 : leunga 752 | _ => state_9 (v_0, v_3)
165 : leunga 744 )
166 :     end
167 : leunga 775 | nil => state_9 (v_0, v_3)
168 : leunga 744 )
169 : leunga 752 | _ => state_9 (v_0, v_3)
170 : leunga 744 )
171 : leunga 752 | _ => state_9 (v_0, v_3)
172 : leunga 744 )
173 : leunga 752 | I.ImmedLabel v_16 => state_21 (v_0, v_16, v_3)
174 :     | _ => state_9 (v_0, v_3)
175 : leunga 744 )
176 : leunga 752 | _ => state_9 (v_0, v_3)
177 : leunga 744 )
178 :     end
179 :     | I.LEA v_18 =>
180 : leunga 775 let val {addr=v_24, r32=v_19, ...} = v_18
181 : leunga 744 in
182 :     (case v_24 of
183 :     I.Displace v_23 =>
184 : leunga 775 let val {base=v_21, disp=v_22, ...} = v_23
185 : leunga 744 in
186 :     (case v_22 of
187 :     I.ImmedLabel v_20 =>
188 : leunga 775 let val base = v_21
189 : leunga 744 and le = v_20
190 : leunga 775 and r32 = v_19
191 : leunga 744 and rest = v_3
192 : jhr 899 in (if (((I.LabelExp.valueOf le) = 0) andalso (CBase.sameColor (r32, base)))
193 : leunga 744 then (loop (rest, instrs))
194 : leunga 752 else (state_9 (v_0, v_3)))
195 : leunga 744 end
196 : leunga 752 | _ => state_9 (v_0, v_3)
197 : leunga 744 )
198 :     end
199 : leunga 752 | _ => state_9 (v_0, v_3)
200 : leunga 744 )
201 :     end
202 :     | I.MOVE v_18 =>
203 :     let val {dst=v_1, mvOp=v_17, src=v_2, ...} = v_18
204 :     in
205 :     (case v_17 of
206 :     I.MOVL =>
207 :     (case v_2 of
208 :     I.Displace v_16 =>
209 : leunga 775 let val {base=v_6, disp=v_15, ...} = v_16
210 : leunga 744 in
211 :     (case v_15 of
212 :     I.Immed v_14 =>
213 :     (case v_14 of
214 :     0 =>
215 :     (case v_3 of
216 : leunga 775 op :: v_13 =>
217 :     let val (v_12, v_4) = v_13
218 : leunga 744 in
219 :     (case v_12 of
220 :     I.BINARY v_11 =>
221 :     let val {binOp=v_10, dst=v_9, src=v_8, ...} = v_11
222 :     in
223 :     (case v_10 of
224 :     I.ADDL =>
225 :     (case v_9 of
226 :     I.Direct v_5 =>
227 :     (case v_8 of
228 :     I.Immed v_7 =>
229 :     (case v_7 of
230 :     4 =>
231 : leunga 775 let val base = v_6
232 : leunga 752 and dst = v_1
233 : leunga 744 and dst_i = v_5
234 : leunga 775 and rest = v_4
235 : jhr 899 in (if (((CBase.sameColor (base, C.esp)) andalso (CBase.sameColor (dst_i, C.esp))) andalso (not (isStackPtr dst)))
236 : leunga 744 then (loop (rest, (I.POP dst) :: instrs))
237 : leunga 752 else (state_49 (v_0, v_1, v_2, v_3)))
238 : leunga 744 end
239 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
240 : leunga 744 )
241 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
242 : leunga 744 )
243 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
244 : leunga 744 )
245 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
246 : leunga 744 )
247 :     end
248 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
249 : leunga 744 )
250 :     end
251 : leunga 775 | nil => state_49 (v_0, v_1, v_2, v_3)
252 : leunga 744 )
253 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
254 : leunga 744 )
255 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
256 : leunga 744 )
257 :     end
258 : leunga 752 | _ => state_49 (v_0, v_1, v_2, v_3)
259 : leunga 744 )
260 : leunga 752 | _ => state_9 (v_0, v_3)
261 : leunga 744 )
262 :     end
263 : leunga 752 | _ => state_9 (v_0, v_3)
264 : leunga 744 )
265 :     end
266 : leunga 775 | nil => instrs
267 : leunga 744 )
268 :     end
269 :     in loop (instrs, [])
270 :     end
271 :     end
272 : leunga 601

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