Debian Codegraph @

lib/mlrisc-lib/MLRISC/mltree/mltree-simplify.sml

raw
1 (* WARNING: this is generated by running 'nowhere mltree-simplify.in'.
2 * Do not edit this file directly.
3 * Version 1.2.2
4 *)
5
6 (*#line 15.1 "mltree-simplify.in"*)
7 functor MLTreeSimplifier(
8 (*#line 16.4 "mltree-simplify.in"*)
9 structure T : MLTREE
10
11 (*#line 17.4 "mltree-simplify.in"*)
12 structure Size : MLTREE_SIZE (* where T=T *)
13 where type T.Basis.cond = T.Basis.cond
14 and type T.Basis.div_rounding_mode = T.Basis.div_rounding_mode
15 and type T.Basis.ext = T.Basis.ext
16 and type T.Basis.fcond = T.Basis.fcond
17 and type T.Basis.rounding_mode = T.Basis.rounding_mode
18 and type T.Constant.const = T.Constant.const
19 and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) T.Extension.ccx
20 and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) T.Extension.fx
21 and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) T.Extension.rx
22 and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) T.Extension.sx
23 and type T.I.div_rounding_mode = T.I.div_rounding_mode
24 and type T.Region.region = T.Region.region
25 and type T.ccexp = T.ccexp
26 and type T.fexp = T.fexp
27 (* and type T.labexp = T.labexp *)
28 and type T.mlrisc = T.mlrisc
29 and type T.oper = T.oper
30 and type T.rep = T.rep
31 and type T.rexp = T.rexp
32 and type T.stm = T.stm
33
34 (*#line 20.4 "mltree-simplify.in"*)
35 val sext : T.rewriter -> T.sext -> T.sext
36
37 (*#line 21.4 "mltree-simplify.in"*)
38 val rext : T.rewriter -> T.rext -> T.rext
39
40 (*#line 22.4 "mltree-simplify.in"*)
41 val fext : T.rewriter -> T.fext -> T.fext
42
43 (*#line 23.4 "mltree-simplify.in"*)
44 val ccext : T.rewriter -> T.ccext -> T.ccext
45 ): MLTREE_SIMPLIFIER =
46 struct
47
48 (*#line 27.4 "mltree-simplify.in"*)
49 structure T = T
50
51 (*#line 28.4 "mltree-simplify.in"*)
52 structure I = T.I
53
54 (*#line 29.4 "mltree-simplify.in"*)
55 structure R = MLTreeRewrite
56 (
57 (*#line 30.7 "mltree-simplify.in"*)
58 structure T = T
59
60 (*#line 31.7 "mltree-simplify.in"*)
61 val sext = sext
62 and rext = rext
63 and fext = fext
64 and ccext = ccext
65 )
66
67
68 (*#line 34.4 "mltree-simplify.in"*)
69 type simplifier = T.rewriter
70
71 (*#line 36.4 "mltree-simplify.in"*)
72 val lit_11 = (IntInf.fromInt 0)
73 and lit_16 = (IntInf.fromInt 1)
74
75 (*#line 37.4 "mltree-simplify.in"*)
76 val zero = (IntInf.fromInt 0)
77
78 (*#line 38.4 "mltree-simplify.in"*)
79 val zeroT = T.LI zero
80
81 (*#line 40.4 "mltree-simplify.in"*)
82 fun simplify {addressWidth, signedAddress} =
83 let
84 (*#line 43.4 "mltree-simplify.in"*)
85 fun dm (T.DIV_TO_ZERO) = I.DIV_TO_ZERO
86 | dm (T.DIV_TO_NEGINF) = I.DIV_TO_NEGINF
87
88 (*#line 46.4 "mltree-simplify.in"*)
89 fun sim ==> exp =
90 let val v_3 = exp
91 fun state_165 e = e
92 fun state_149 () = zeroT
93 fun state_158 () = zeroT
94 fun state_180 v_3 =
95 let val exp = v_3
96 in exp
97 end
98 fun state_118 (v_1, v_4) =
99 let val b = v_4
100 and ty = v_1
101 in b
102 end
103 fun state_15 (v_1, v_0) =
104 let val a = v_0
105 and ty = v_1
106 in a
107 end
108 fun state_148 v_1 =
109 let val ty = v_1
110 in zeroT
111 end
112 fun state_140 v_1 =
113 let val ty = v_1
114 in zeroT
115 end
116 fun state_157 v_1 =
117 let val ty = v_1
118 in zeroT
119 end
120 fun state_109 v_4 =
121 let val b = v_4
122 in b
123 end
124 fun state_45 (v_1, v_4) =
125 let val ty = v_1
126 and x = v_4
127 in x
128 end
129 fun state_43 v_1 =
130 let val ty = v_1
131 in zeroT
132 end
133 fun state_47 (v_1, v_0) =
134 let val ty = v_1
135 and x = v_0
136 in x
137 end
138 fun state_85 (v_1, v_4) =
139 let val ty = v_1
140 and x = v_4
141 in x
142 end
143 fun state_83 v_1 =
144 let val ty = v_1
145 in zeroT
146 end
147 fun state_87 (v_1, v_0) =
148 let val ty = v_1
149 and x = v_0
150 in x
151 end
152 fun state_23 (v_1, v_4) =
153 let val ty = v_1
154 and x = v_4
155 in x
156 end
157 fun state_21 v_1 =
158 let val ty = v_1
159 in zeroT
160 end
161 fun state_25 (v_1, v_0) =
162 let val ty = v_1
163 and x = v_0
164 in x
165 end
166 fun state_127 (v_1, v_4) =
167 let val b = v_4
168 and ty = v_1
169 in zeroT
170 end
171 fun state_100 v_0 =
172 let val a = v_0
173 in a
174 end
175 fun state_69 (v_1, v_0) =
176 let val ty = v_1
177 and x = v_0
178 in x
179 end
180 fun state_5 (v_1, v_0) =
181 let val ty = v_1
182 and x = v_0
183 in x
184 end
185 fun state_1717 (v_3, v_1, v_10, v_4) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
186 then (state_118 (v_1, v_4))
187 else (state_180 v_3))
188 fun state_1450 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
189 then (state_15 (v_1, v_0))
190 else (state_180 v_3))
191 fun state_1279 (v_3, v_1, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
192 then (state_148 v_1)
193 else (state_180 v_3))
194 fun state_1192 (v_3, v_1, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
195 then (state_140 v_1)
196 else (state_180 v_3))
197 fun state_1021 (v_3, v_1, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
198 then (state_157 v_1)
199 else (state_180 v_3))
200 fun state_916 (v_3, v_10, v_4) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
201 then (state_109 v_4)
202 else (state_180 v_3))
203 fun state_820 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
204 then (state_43 v_1)
205 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
206 then (state_47 (v_1, v_0))
207 else (state_180 v_3)))
208 fun state_731 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
209 then (state_83 v_1)
210 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
211 then (state_87 (v_1, v_0))
212 else (state_180 v_3)))
213 fun state_642 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
214 then (state_21 v_1)
215 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
216 then (state_25 (v_1, v_0))
217 else (state_180 v_3)))
218 fun state_555 (v_3, v_1, v_10, v_4) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
219 then (state_127 (v_1, v_4))
220 else (state_180 v_3))
221 fun state_441 (v_3, v_0, v_10) = (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
222 then (state_100 v_0)
223 else (state_180 v_3))
224 fun state_354 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
225 then (state_69 (v_1, v_0))
226 else (state_180 v_3))
227 fun state_181 (v_3, v_1, v_0, v_2) = (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
228 then (state_5 (v_1, v_0))
229 else (state_180 v_3))
230 fun state_1451 (v_3, v_1, v_0, v_4) =
231 (case v_4 of
232 T.LI v_2 => state_1450 (v_3, v_1, v_0, v_2)
233 | _ => state_180 v_3
234 )
235 fun state_182 (v_3, v_1, v_0, v_4) =
236 (case v_4 of
237 T.LI v_2 => state_181 (v_3, v_1, v_0, v_2)
238 | _ => state_180 v_3
239 )
240 in
241 (case v_3 of
242 T.ADD v_5 =>
243 let val (v_1, v_0, v_4) = v_5
244 in
245 (case v_0 of
246 T.ADD v_10 =>
247 let val (v_7, v_9, v_13) = v_10
248 in
249 (case v_13 of
250 T.LI v_12 =>
251 (case v_4 of
252 T.LI v_2 =>
253 let val a = v_9
254 and ty = v_1
255 and ty' = v_7
256 and x = v_12
257 and y = v_2
258 in (if (ty = ty')
259 then (T.ADD (ty, a, T.LI (I.ADD (ty, x, y))))
260 else (state_181 (v_3, v_1, v_0, v_2)))
261 end
262 | _ => state_180 v_3
263 )
264 | _ => state_182 (v_3, v_1, v_0, v_4)
265 )
266 end
267 | T.LABEXP v_10 =>
268 (case v_4 of
269 T.LABEXP v_2 =>
270 let val ty = v_1
271 and x = v_10
272 and y = v_2
273 in T.LABEXP (T.ADD (ty, x, y))
274 end
275 | T.LI v_2 => state_181 (v_3, v_1, v_0, v_2)
276 | _ => state_180 v_3
277 )
278 | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
279 then
280 let val ty = v_1
281 and x = v_4
282 in x
283 end
284 else
285 (case v_4 of
286 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
287 then (state_5 (v_1, v_0))
288 else
289 let val ty = v_1
290 and x = v_10
291 and y = v_2
292 in T.LI (I.ADD (ty, x, y))
293 end)
294 | _ => state_180 v_3
295 ))
296 | _ => state_182 (v_3, v_1, v_0, v_4)
297 )
298 end
299 | T.ADDT v_5 =>
300 let val (v_1, v_0, v_4) = v_5
301 in
302 (case v_0 of
303 T.LABEXP v_10 =>
304 (case v_4 of
305 T.LABEXP v_2 =>
306 let val ty = v_1
307 and x = v_10
308 and y = v_2
309 in T.LABEXP (T.ADDT (ty, x, y))
310 end
311 | T.LI v_2 => state_354 (v_3, v_1, v_0, v_2)
312 | _ => state_180 v_3
313 )
314 | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
315 then
316 let val ty = v_1
317 and x = v_4
318 in x
319 end
320 else
321 (case v_4 of
322 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
323 then (state_69 (v_1, v_0))
324 else
325 let val ty = v_1
326 and x = v_10
327 and y = v_2
328 in ((T.LI (I.ADDT (ty, x, y))) handle Overflow => exp
329 )
330 end)
331 | _ => state_180 v_3
332 ))
333 | _ =>
334 (case v_4 of
335 T.LI v_2 => state_354 (v_3, v_1, v_0, v_2)
336 | _ => state_180 v_3
337 )
338 )
339 end
340 | T.ANDB v_5 =>
341 let val (v_1, v_0, v_4) = v_5
342 in
343 (case v_4 of
344 T.LABEXP v_2 =>
345 (case v_0 of
346 T.LABEXP v_10 =>
347 let val ty = v_1
348 and x = v_10
349 and y = v_2
350 in T.LABEXP (T.ANDB (ty, x, y))
351 end
352 | T.LI v_10 => state_441 (v_3, v_0, v_10)
353 | _ => state_180 v_3
354 )
355 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
356 then
357 let val b = v_4
358 in b
359 end
360 else
361 (case v_0 of
362 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
363 then (state_100 v_0)
364 else
365 let val ty = v_1
366 and x = v_10
367 and y = v_2
368 in T.LI (I.ANDB (ty, x, y))
369 end)
370 | _ => state_180 v_3
371 ))
372 | T.NOTB v_2 =>
373 (case v_0 of
374 T.LI v_10 => state_441 (v_3, v_0, v_10)
375 | T.NOTB v_10 =>
376 let val (v_7, v_9) = v_10
377 in
378 let val (v_6, v_8) = v_2
379 in
380 let val a = v_9
381 and b = v_8
382 and ty = v_1
383 and ty' = v_7
384 and ty'' = v_6
385 in (if ((ty = ty') andalso (ty' = ty''))
386 then (T.NOTB (ty, T.ORB (ty, a, b)))
387 else (state_180 v_3))
388 end
389 end
390 end
391 | _ => state_180 v_3
392 )
393 | _ =>
394 (case v_0 of
395 T.LI v_10 => state_441 (v_3, v_0, v_10)
396 | _ => state_180 v_3
397 )
398 )
399 end
400 | T.COND v_5 =>
401 let val (v_1, v_0, v_4, v_18) = v_5
402 in
403 (case v_0 of
404 T.FALSE =>
405 let val a = v_4
406 and b = v_18
407 and ty = v_1
408 in b
409 end
410 | T.TRUE =>
411 let val a = v_4
412 and b = v_18
413 and ty = v_1
414 in a
415 end
416 | _ => state_180 v_3
417 )
418 end
419 | T.DIVS v_5 =>
420 let val (v_1, v_0, v_4, v_18) = v_5
421 in
422 (case v_18 of
423 T.LABEXP v_17 =>
424 (case v_4 of
425 T.LABEXP v_2 =>
426 let val m = v_1
427 and ty = v_0
428 and x = v_2
429 and y = v_17
430 in T.LABEXP (T.DIVS (m, ty, x, y))
431 end
432 | _ => state_180 v_3
433 )
434 | T.LI v_17 => (if ((IntInf.compare (v_17, lit_16)) = EQUAL)
435 then
436 let val a = v_4
437 and m = v_1
438 and ty = v_0
439 in a
440 end
441 else
442 (case v_4 of
443 T.LI v_2 =>
444 let val m = v_1
445 and ty = v_0
446 and x = v_2
447 and y = v_17
448 in (if (y <> zero)
449 then (T.LI (I.DIVS (dm m, ty, x, y)))
450 else (state_180 v_3))
451 end
452 | _ => state_180 v_3
453 ))
454 | _ => state_180 v_3
455 )
456 end
457 | T.DIVT v_5 =>
458 let val (v_1, v_0, v_4, v_18) = v_5
459 in
460 (case v_18 of
461 T.LABEXP v_17 =>
462 (case v_4 of
463 T.LABEXP v_2 =>
464 let val m = v_1
465 and ty = v_0
466 and x = v_2
467 and y = v_17
468 in T.LABEXP (T.DIVT (m, ty, x, y))
469 end
470 | _ => state_180 v_3
471 )
472 | T.LI v_17 => (if ((IntInf.compare (v_17, lit_16)) = EQUAL)
473 then
474 let val a = v_4
475 and m = v_1
476 and ty = v_0
477 in a
478 end
479 else
480 (case v_4 of
481 T.LI v_2 =>
482 let val m = v_1
483 and ty = v_0
484 and x = v_2
485 and y = v_17
486 in (if (y <> zero)
487 then (T.LI (I.DIVT (dm m, ty, x, y)))
488 else (state_180 v_3))
489 end
490 | _ => state_180 v_3
491 ))
492 | _ => state_180 v_3
493 )
494 end
495 | T.DIVU v_5 =>
496 let val (v_1, v_0, v_4) = v_5
497 in
498 (case v_4 of
499 T.LABEXP v_2 =>
500 (case v_0 of
501 T.LABEXP v_10 =>
502 let val ty = v_1
503 and x = v_10
504 and y = v_2
505 in T.LABEXP (T.DIVU (ty, x, y))
506 end
507 | _ => state_180 v_3
508 )
509 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
510 then
511 let val a = v_0
512 and ty = v_1
513 in a
514 end
515 else
516 (case v_0 of
517 T.LI v_10 =>
518 let val ty = v_1
519 and x = v_10
520 and y = v_2
521 in (if (y <> zero)
522 then (T.LI (I.DIVU (ty, x, y)))
523 else (state_180 v_3))
524 end
525 | _ => state_180 v_3
526 ))
527 | _ => state_180 v_3
528 )
529 end
530 | T.EQVB v_5 =>
531 let val (v_1, v_0, v_4) = v_5
532 in
533 (case v_4 of
534 T.LABEXP v_2 =>
535 (case v_0 of
536 T.LABEXP v_10 =>
537 let val ty = v_1
538 and x = v_10
539 and y = v_2
540 in T.LABEXP (T.EQVB (ty, x, y))
541 end
542 | T.LI v_10 => state_555 (v_3, v_1, v_10, v_4)
543 | _ => state_180 v_3
544 )
545 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
546 then
547 let val a = v_0
548 and ty = v_1
549 in zeroT
550 end
551 else
552 (case v_0 of
553 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
554 then (state_127 (v_1, v_4))
555 else
556 let val ty = v_1
557 and x = v_10
558 and y = v_2
559 in T.LI (I.EQVB (ty, x, y))
560 end)
561 | _ => state_180 v_3
562 ))
563 | _ =>
564 (case v_0 of
565 T.LI v_10 => state_555 (v_3, v_1, v_10, v_4)
566 | _ => state_180 v_3
567 )
568 )
569 end
570 | T.MULS v_5 =>
571 let val (v_1, v_0, v_4) = v_5
572 in
573 (case v_0 of
574 T.LABEXP v_10 =>
575 (case v_4 of
576 T.LABEXP v_2 =>
577 let val ty = v_1
578 and x = v_10
579 and y = v_2
580 in T.LABEXP (T.MULS (ty, x, y))
581 end
582 | T.LI v_2 => state_642 (v_3, v_1, v_0, v_2)
583 | _ => state_180 v_3
584 )
585 | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
586 then
587 let val ty = v_1
588 in zeroT
589 end
590 else (if ((IntInf.compare (v_10, lit_16)) = EQUAL)
591 then
592 (case v_4 of
593 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
594 then (state_21 v_1)
595 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
596 then (state_23 (v_1, v_4))
597 else (state_23 (v_1, v_4))))
598 | _ => state_23 (v_1, v_4)
599 )
600 else
601 (case v_4 of
602 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
603 then (state_21 v_1)
604 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
605 then (state_25 (v_1, v_0))
606 else
607 let val ty = v_1
608 and x = v_10
609 and y = v_2
610 in T.LI (I.MULS (ty, x, y))
611 end))
612 | _ => state_180 v_3
613 )))
614 | _ =>
615 (case v_4 of
616 T.LI v_2 => state_642 (v_3, v_1, v_0, v_2)
617 | _ => state_180 v_3
618 )
619 )
620 end
621 | T.MULT v_5 =>
622 let val (v_1, v_0, v_4) = v_5
623 in
624 (case v_0 of
625 T.LABEXP v_10 =>
626 (case v_4 of
627 T.LABEXP v_2 =>
628 let val ty = v_1
629 and x = v_10
630 and y = v_2
631 in T.LABEXP (T.MULT (ty, x, y))
632 end
633 | T.LI v_2 => state_731 (v_3, v_1, v_0, v_2)
634 | _ => state_180 v_3
635 )
636 | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
637 then
638 let val ty = v_1
639 in zeroT
640 end
641 else (if ((IntInf.compare (v_10, lit_16)) = EQUAL)
642 then
643 (case v_4 of
644 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
645 then (state_83 v_1)
646 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
647 then (state_85 (v_1, v_4))
648 else (state_85 (v_1, v_4))))
649 | _ => state_85 (v_1, v_4)
650 )
651 else
652 (case v_4 of
653 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
654 then (state_83 v_1)
655 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
656 then (state_87 (v_1, v_0))
657 else
658 let val ty = v_1
659 and x = v_10
660 and y = v_2
661 in ((T.LI (I.MULT (ty, x, y))) handle Overflow => exp
662 )
663 end))
664 | _ => state_180 v_3
665 )))
666 | _ =>
667 (case v_4 of
668 T.LI v_2 => state_731 (v_3, v_1, v_0, v_2)
669 | _ => state_180 v_3
670 )
671 )
672 end
673 | T.MULU v_5 =>
674 let val (v_1, v_0, v_4) = v_5
675 in
676 (case v_0 of
677 T.LABEXP v_10 =>
678 (case v_4 of
679 T.LABEXP v_2 =>
680 let val ty = v_1
681 and x = v_10
682 and y = v_2
683 in T.LABEXP (T.MULU (ty, x, y))
684 end
685 | T.LI v_2 => state_820 (v_3, v_1, v_0, v_2)
686 | _ => state_180 v_3
687 )
688 | T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
689 then
690 let val ty = v_1
691 in zeroT
692 end
693 else (if ((IntInf.compare (v_10, lit_16)) = EQUAL)
694 then
695 (case v_4 of
696 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
697 then (state_43 v_1)
698 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
699 then (state_45 (v_1, v_4))
700 else (state_45 (v_1, v_4))))
701 | _ => state_45 (v_1, v_4)
702 )
703 else
704 (case v_4 of
705 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
706 then (state_43 v_1)
707 else (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
708 then (state_47 (v_1, v_0))
709 else
710 let val ty = v_1
711 and x = v_10
712 and y = v_2
713 in T.LI (I.MULU (ty, x, y))
714 end))
715 | _ => state_180 v_3
716 )))
717 | _ =>
718 (case v_4 of
719 T.LI v_2 => state_820 (v_3, v_1, v_0, v_2)
720 | _ => state_180 v_3
721 )
722 )
723 end
724 | T.NEGT v_5 =>
725 let val (v_1, v_0) = v_5
726 in
727 (case v_0 of
728 T.LABEXP v_10 =>
729 let val ty = v_1
730 and x = v_10
731 in T.LABEXP (T.NEGT (ty, x))
732 end
733 | T.LI v_10 =>
734 let val ty = v_1
735 and x = v_10
736 in ((T.LI (I.NEGT (ty, x))) handle Overflow => exp
737 )
738 end
739 | _ => state_180 v_3
740 )
741 end
742 | T.NOTB v_5 =>
743 let val (v_1, v_0) = v_5
744 in
745 (case v_0 of
746 T.LABEXP v_10 =>
747 let val ty = v_1
748 and x = v_10
749 in T.LABEXP (T.NOTB (ty, x))
750 end
751 | T.LI v_10 =>
752 let val n = v_10
753 and ty = v_1
754 in T.LI (I.NOTB (ty, n))
755 end
756 | T.NOTB v_10 =>
757 let val (v_7, v_9) = v_10
758 in
759 let val a = v_9
760 and ty = v_1
761 and ty' = v_7
762 in (if (ty = ty')
763 then a
764 else (state_180 v_3))
765 end
766 end
767 | _ => state_180 v_3
768 )
769 end
770 | T.ORB v_5 =>
771 let val (v_1, v_0, v_4) = v_5
772 in
773 (case v_4 of
774 T.LABEXP v_2 =>
775 (case v_0 of
776 T.LABEXP v_10 =>
777 let val ty = v_1
778 and x = v_10
779 and y = v_2
780 in T.LABEXP (T.ORB (ty, x, y))
781 end
782 | T.LI v_10 => state_916 (v_3, v_10, v_4)
783 | _ => state_180 v_3
784 )
785 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
786 then
787 let val a = v_0
788 in a
789 end
790 else
791 (case v_0 of
792 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
793 then (state_109 v_4)
794 else
795 let val ty = v_1
796 and x = v_10
797 and y = v_2
798 in T.LI (I.ORB (ty, x, y))
799 end)
800 | _ => state_180 v_3
801 ))
802 | T.NOTB v_2 =>
803 (case v_0 of
804 T.LI v_10 => state_916 (v_3, v_10, v_4)
805 | T.NOTB v_10 =>
806 let val (v_7, v_9) = v_10
807 in
808 let val (v_6, v_8) = v_2
809 in
810 let val a = v_9
811 and b = v_8
812 and ty = v_1
813 and ty' = v_7
814 and ty'' = v_6
815 in (if ((ty = ty') andalso (ty' = ty''))
816 then (T.NOTB (ty, T.ANDB (ty, a, b)))
817 else (state_180 v_3))
818 end
819 end
820 end
821 | _ => state_180 v_3
822 )
823 | _ =>
824 (case v_0 of
825 T.LI v_10 => state_916 (v_3, v_10, v_4)
826 | _ => state_180 v_3
827 )
828 )
829 end
830 | T.REMS v_5 =>
831 let val (v_1, v_0, v_4, v_18) = v_5
832 in
833 (case v_18 of
834 T.LABEXP v_17 =>
835 (case v_4 of
836 T.LABEXP v_2 =>
837 let val m = v_1
838 and ty = v_0
839 and x = v_2
840 and y = v_17
841 in T.LABEXP (T.REMS (m, ty, x, y))
842 end
843 | _ => state_180 v_3
844 )
845 | T.LI v_17 => (if ((IntInf.compare (v_17, lit_16)) = EQUAL)
846 then
847 let val a = v_4
848 and m = v_1
849 and ty = v_0
850 in zeroT
851 end
852 else
853 (case v_4 of
854 T.LI v_2 =>
855 let val m = v_1
856 and ty = v_0
857 and x = v_2
858 and y = v_17
859 in (if (y <> zero)
860 then (T.LI (I.REMS (dm m, ty, x, y)))
861 else (state_180 v_3))
862 end
863 | _ => state_180 v_3
864 ))
865 | _ => state_180 v_3
866 )
867 end
868 | T.REMU v_5 =>
869 let val (v_1, v_0, v_4) = v_5
870 in
871 (case v_4 of
872 T.LABEXP v_2 =>
873 (case v_0 of
874 T.LABEXP v_10 =>
875 let val ty = v_1
876 and x = v_10
877 and y = v_2
878 in T.LABEXP (T.REMU (ty, x, y))
879 end
880 | _ => state_180 v_3
881 )
882 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_16)) = EQUAL)
883 then
884 let val a = v_0
885 and ty = v_1
886 in zeroT
887 end
888 else
889 (case v_0 of
890 T.LI v_10 =>
891 let val ty = v_1
892 and x = v_10
893 and y = v_2
894 in (if (y <> zero)
895 then (T.LI (I.REMU (ty, x, y)))
896 else (state_180 v_3))
897 end
898 | _ => state_180 v_3
899 ))
900 | _ => state_180 v_3
901 )
902 end
903 | T.SLL v_5 =>
904 let val (v_1, v_0, v_4) = v_5
905 in
906 (case v_4 of
907 T.LABEXP v_2 =>
908 (case v_0 of
909 T.LABEXP v_10 =>
910 let val ty = v_1
911 and x = v_10
912 and y = v_2
913 in T.LABEXP (T.SLL (ty, x, y))
914 end
915 | T.LI v_10 => state_1021 (v_3, v_1, v_10)
916 | _ => state_180 v_3
917 )
918 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
919 then
920 let val a = v_0
921 and ty = v_1
922 in a
923 end
924 else
925 (case v_0 of
926 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
927 then (state_157 v_1)
928 else
929 let val n = v_2
930 and ty = v_1
931 in (if (IntInf.<= (IntInf.fromInt ty, n))
932 then (state_158 ())
933 else
934 let val ty = v_1
935 and x = v_10
936 and y = v_2
937 in T.LI (I.SLL (ty, x, y))
938 end)
939 end)
940 | _ =>
941 let val n = v_2
942 and ty = v_1
943 in (if (IntInf.<= (IntInf.fromInt ty, n))
944 then (state_158 ())
945 else (state_180 v_3))
946 end
947 ))
948 | _ =>
949 (case v_0 of
950 T.LI v_10 => state_1021 (v_3, v_1, v_10)
951 | _ => state_180 v_3
952 )
953 )
954 end
955 | T.SRA v_5 =>
956 let val (v_1, v_0, v_4) = v_5
957 in
958 (case v_4 of
959 T.LABEXP v_2 =>
960 (case v_0 of
961 T.LABEXP v_10 =>
962 let val ty = v_1
963 and x = v_10
964 and y = v_2
965 in T.LABEXP (T.SRA (ty, x, y))
966 end
967 | T.LI v_10 => state_1192 (v_3, v_1, v_10)
968 | _ => state_180 v_3
969 )
970 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
971 then
972 let val a = v_0
973 and ty = v_1
974 in a
975 end
976 else
977 (case v_0 of
978 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
979 then (state_140 v_1)
980 else
981 let val ty = v_1
982 and x = v_10
983 and y = v_2
984 in T.LI (I.SRA (ty, x, y))
985 end)
986 | _ => state_180 v_3
987 ))
988 | _ =>
989 (case v_0 of
990 T.LI v_10 => state_1192 (v_3, v_1, v_10)
991 | _ => state_180 v_3
992 )
993 )
994 end
995 | T.SRL v_5 =>
996 let val (v_1, v_0, v_4) = v_5
997 in
998 (case v_4 of
999 T.LABEXP v_2 =>
1000 (case v_0 of
1001 T.LABEXP v_10 =>
1002 let val ty = v_1
1003 and x = v_10
1004 and y = v_2
1005 in T.LABEXP (T.SRL (ty, x, y))
1006 end
1007 | T.LI v_10 => state_1279 (v_3, v_1, v_10)
1008 | _ => state_180 v_3
1009 )
1010 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
1011 then
1012 let val a = v_0
1013 and ty = v_1
1014 in a
1015 end
1016 else
1017 (case v_0 of
1018 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
1019 then (state_148 v_1)
1020 else
1021 let val n = v_2
1022 and ty = v_1
1023 in (if (IntInf.<= (IntInf.fromInt ty, n))
1024 then (state_149 ())
1025 else
1026 let val ty = v_1
1027 and x = v_10
1028 and y = v_2
1029 in T.LI (I.SRL (ty, x, y))
1030 end)
1031 end)
1032 | _ =>
1033 let val n = v_2
1034 and ty = v_1
1035 in (if (IntInf.<= (IntInf.fromInt ty, n))
1036 then (state_149 ())
1037 else (state_180 v_3))
1038 end
1039 ))
1040 | _ =>
1041 (case v_0 of
1042 T.LI v_10 => state_1279 (v_3, v_1, v_10)
1043 | _ => state_180 v_3
1044 )
1045 )
1046 end
1047 | T.SUB v_5 =>
1048 let val (v_1, v_0, v_4) = v_5
1049 in
1050 (case v_0 of
1051 T.LABEXP v_10 =>
1052 (case v_4 of
1053 T.LABEXP v_2 =>
1054 let val ty = v_1
1055 and x = v_10
1056 and y = v_2
1057 in T.LABEXP (T.SUB (ty, x, y))
1058 end
1059 | T.LI v_2 => state_1450 (v_3, v_1, v_0, v_2)
1060 | _ => state_180 v_3
1061 )
1062 | T.LI v_10 =>
1063 (case v_4 of
1064 T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
1065 then (state_15 (v_1, v_0))
1066 else
1067 let val ty = v_1
1068 and x = v_10
1069 and y = v_2
1070 in T.LI (I.SUB (ty, x, y))
1071 end)
1072 | T.SUB v_2 =>
1073 let val (v_6, v_8, v_14) = v_2
1074 in (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
1075 then
1076 (case v_8 of
1077 T.LI v_15 => (if ((IntInf.compare (v_15, lit_11)) = EQUAL)
1078 then
1079 let val a = v_14
1080 and ty = v_1
1081 and ty' = v_6
1082 in (if (ty = ty')
1083 then a
1084 else (state_180 v_3))
1085 end
1086 else (state_180 v_3))
1087 | _ => state_180 v_3
1088 )
1089 else (state_180 v_3))
1090 end
1091 | _ => state_180 v_3
1092 )
1093 | T.SUB v_10 =>
1094 let val (v_7, v_9, v_13) = v_10
1095 in
1096 (case v_13 of
1097 T.LI v_12 =>
1098 (case v_4 of
1099 T.LI v_2 =>
1100 let val a = v_9
1101 and ty = v_1
1102 and ty' = v_7
1103 and x = v_12
1104 and y = v_2
1105 in (if (ty = ty')
1106 then (T.SUB (ty, a, T.LI (I.ADD (ty, x, y))))
1107 else (state_1450 (v_3, v_1, v_0, v_2)))
1108 end
1109 | _ => state_180 v_3
1110 )
1111 | _ => state_1451 (v_3, v_1, v_0, v_4)
1112 )
1113 end
1114 | _ => state_1451 (v_3, v_1, v_0, v_4)
1115 )
1116 end
1117 | T.SUBT v_5 =>
1118 let val (v_1, v_0, v_4) = v_5
1119 in
1120 (case v_4 of
1121 T.LABEXP v_2 =>
1122 (case v_0 of
1123 T.LABEXP v_10 =>
1124 let val ty = v_1
1125 and x = v_10
1126 and y = v_2
1127 in T.LABEXP (T.SUBT (ty, x, y))
1128 end
1129 | _ => state_180 v_3
1130 )
1131 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
1132 then
1133 let val a = v_0
1134 and ty = v_1
1135 in a
1136 end
1137 else
1138 (case v_0 of
1139 T.LI v_10 =>
1140 let val ty = v_1
1141 and x = v_10
1142 and y = v_2
1143 in ((T.LI (I.SUBT (ty, x, y))) handle Overflow => exp
1144 )
1145 end
1146 | _ => state_180 v_3
1147 ))
1148 | _ => state_180 v_3
1149 )
1150 end
1151 | T.SX v_5 =>
1152 let val (v_1, v_0, v_4) = v_5
1153 in
1154 (case v_4 of
1155 T.LABEXP v_2 =>
1156 let val e = v_4
1157 and ty = v_1
1158 and ty' = v_0
1159 in (if (ty = ty')
1160 then (state_165 e)
1161 else
1162 let val ty = v_1
1163 and ty' = v_0
1164 and x = v_2
1165 in T.LABEXP (T.SX (ty, ty', x))
1166 end)
1167 end
1168 | T.LI v_2 =>
1169 let val e = v_4
1170 and ty = v_1
1171 and ty' = v_0
1172 in (if (ty = ty')
1173 then (state_165 e)
1174 else
1175 let val n = v_2
1176 and ty = v_1
1177 and ty' = v_0
1178 in T.LI (I.SX (ty, ty', n))
1179 end)
1180 end
1181 | T.LOAD v_2 =>
1182 let val ty = v_1
1183 and ty' = v_0
1184 in exp
1185 end
1186 | _ =>
1187 let val e = v_4
1188 and ty = v_1
1189 and ty' = v_0
1190 in (if (ty = ty')
1191 then (state_165 e)
1192 else (state_180 v_3))
1193 end
1194 )
1195 end
1196 | T.XORB v_5 =>
1197 let val (v_1, v_0, v_4) = v_5
1198 in
1199 (case v_4 of
1200 T.LABEXP v_2 =>
1201 (case v_0 of
1202 T.LABEXP v_10 =>
1203 let val ty = v_1
1204 and x = v_10
1205 and y = v_2
1206 in T.LABEXP (T.XORB (ty, x, y))
1207 end
1208 | T.LI v_10 => state_1717 (v_3, v_1, v_10, v_4)
1209 | _ => state_180 v_3
1210 )
1211 | T.LI v_2 => (if ((IntInf.compare (v_2, lit_11)) = EQUAL)
1212 then
1213 let val a = v_0
1214 and ty = v_1
1215 in a
1216 end
1217 else
1218 (case v_0 of
1219 T.LI v_10 => (if ((IntInf.compare (v_10, lit_11)) = EQUAL)
1220 then (state_118 (v_1, v_4))
1221 else
1222 let val ty = v_1
1223 and x = v_10
1224 and y = v_2
1225 in T.LI (I.XORB (ty, x, y))
1226 end)
1227 | _ => state_180 v_3
1228 ))
1229 | T.NOTB v_2 =>
1230 (case v_0 of
1231 T.LI v_10 => state_1717 (v_3, v_1, v_10, v_4)
1232 | T.NOTB v_10 =>
1233 let val (v_7, v_9) = v_10
1234 in
1235 let val (v_6, v_8) = v_2
1236 in
1237 let val a = v_9
1238 and b = v_8
1239 and ty = v_1
1240 and ty' = v_7
1241 and ty'' = v_6
1242 in (if ((ty = ty') andalso (ty' = ty''))
1243 then (T.NOTB (ty, T.XORB (ty, a, b)))
1244 else (state_180 v_3))
1245 end
1246 end
1247 end
1248 | _ => state_180 v_3
1249 )
1250 | _ =>
1251 (case v_0 of
1252 T.LI v_10 => state_1717 (v_3, v_1, v_10, v_4)
1253 | _ => state_180 v_3
1254 )
1255 )
1256 end
1257 | T.ZX v_5 =>
1258 let val (v_1, v_0, v_4) = v_5
1259 in
1260 let val e = v_4
1261 and ty = v_1
1262 and ty' = v_0
1263 in (if (ty = ty')
1264 then e
1265 else
1266 (case v_4 of
1267 T.LABEXP v_2 =>
1268 let val ty = v_1
1269 and ty' = v_0
1270 and x = v_2
1271 in T.LABEXP (T.ZX (ty, ty', x))
1272 end
1273 | T.LI v_2 =>
1274 let val n = v_2
1275 and ty = v_1
1276 and ty' = v_0
1277 in T.LI (I.ZX (ty, ty', n))
1278 end
1279 | _ => state_180 v_3
1280 ))
1281 end
1282 end
1283 | _ => state_180 v_3
1284 )
1285 end
1286 and simStm ==> (T.IF(T.TRUE, yes, no)) = yes
1287 | simStm ==> (T.IF(T.FALSE, yes, no)) = no
1288 | simStm ==> (T.SEQ[x]) = x
1289 | simStm ==> s = s
1290 and simF p_0 p_1 =
1291 let val v_29 = (p_0, p_1)
1292 fun state_8 (v_19, v_20) =
1293 let val ==> = v_19
1294 and exp = v_20
1295 in exp
1296 end
1297 in
1298 let val (v_19, v_20) = v_29
1299 in
1300 (case v_20 of
1301 T.CVTF2F v_26 =>
1302 let val (v_22, v_25, v_27) = v_26
1303 in
1304 let val ==> = v_19
1305 and e = v_27
1306 and ty = v_22
1307 and ty' = v_25
1308 in (if (ty = ty')
1309 then e
1310 else (state_8 (v_19, v_20)))
1311 end
1312 end
1313 | T.FCOND v_26 =>
1314 let val (v_22, v_25, v_27, v_28) = v_26
1315 in
1316 (case v_25 of
1317 T.FALSE =>
1318 let val ==> = v_19
1319 and no = v_28
1320 and ty = v_22
1321 and yes = v_27
1322 in no
1323 end
1324 | T.TRUE =>
1325 let val ==> = v_19
1326 and no = v_28
1327 and ty = v_22
1328 and yes = v_27
1329 in yes
1330 end
1331 | _ => state_8 (v_19, v_20)
1332 )
1333 end
1334 | T.FNEG v_26 =>
1335 let val (v_22, v_25) = v_26
1336 in
1337 (case v_25 of
1338 T.FNEG v_24 =>
1339 let val (v_21, v_23) = v_24
1340 in
1341 let val ==> = v_19
1342 and e = v_23
1343 and ty = v_22
1344 and ty' = v_21
1345 in (if (ty = ty')
1346 then e
1347 else (state_8 (v_19, v_20)))
1348 end
1349 end
1350 | _ => state_8 (v_19, v_20)
1351 )
1352 end
1353 | _ => state_8 (v_19, v_20)
1354 )
1355 end
1356 end
1357 and cc false = T.FALSE
1358 | cc true = T.TRUE
1359 and simCC ==> (T.CMP(ty, T.EQ, T.LI x, T.LI y)) = cc (I.EQ (ty, x, y))
1360 | simCC ==> (T.CMP(ty, T.NE, T.LI x, T.LI y)) = cc (I.NE (ty, x, y))
1361 | simCC ==> (T.CMP(ty, T.GT, T.LI x, T.LI y)) = cc (I.GT (ty, x, y))
1362 | simCC ==> (T.CMP(ty, T.GE, T.LI x, T.LI y)) = cc (I.GE (ty, x, y))
1363 | simCC ==> (T.CMP(ty, T.LT, T.LI x, T.LI y)) = cc (I.LT (ty, x, y))
1364 | simCC ==> (T.CMP(ty, T.LE, T.LI x, T.LI y)) = cc (I.LE (ty, x, y))
1365 | simCC ==> (T.CMP(ty, T.GTU, T.LI x, T.LI y)) = cc (I.GTU (ty, x, y))
1366 | simCC ==> (T.CMP(ty, T.LTU, T.LI x, T.LI y)) = cc (I.LTU (ty, x, y))
1367 | simCC ==> (T.CMP(ty, T.GEU, T.LI x, T.LI y)) = cc (I.GEU (ty, x, y))
1368 | simCC ==> (T.CMP(ty, T.LEU, T.LI x, T.LI y)) = cc (I.LEU (ty, x, y))
1369 | simCC ==> (T.AND(T.TRUE, x)) = x
1370 | simCC ==> (T.AND(x, T.TRUE)) = x
1371 | simCC ==> (T.AND(T.FALSE, x)) = T.FALSE
1372 | simCC ==> (T.AND(x, T.FALSE)) = T.FALSE
1373 | simCC ==> (T.OR(T.FALSE, x)) = x
1374 | simCC ==> (T.OR(x, T.FALSE)) = x
1375 | simCC ==> (T.OR(T.TRUE, x)) = T.TRUE
1376 | simCC ==> (T.OR(x, T.TRUE)) = T.TRUE
1377 | simCC ==> (T.XOR(T.TRUE, T.TRUE)) = T.FALSE
1378 | simCC ==> (T.XOR(T.FALSE, x)) = x
1379 | simCC ==> (T.XOR(x, T.FALSE)) = x
1380 | simCC ==> (T.XOR(T.TRUE, x)) = T.NOT x
1381 | simCC ==> (T.XOR(x, T.TRUE)) = T.NOT x
1382 | simCC ==> (T.EQV(T.FALSE, T.FALSE)) = T.TRUE
1383 | simCC ==> (T.EQV(T.TRUE, x)) = x
1384 | simCC ==> (T.EQV(x, T.TRUE)) = x
1385 | simCC ==> (T.EQV(T.FALSE, x)) = T.NOT x
1386 | simCC ==> (T.EQV(x, T.FALSE)) = T.NOT x
1387 | simCC ==> exp = exp
1388 in R.rewrite {rexp=sim, fexp=simF, ccexp=simCC, stm=simStm}
1389 end
1390 end
1391