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

Annotation of /sml/trunk/src/MLRISC/sparc/instructions/sparcPeephole.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 775 - (view) (download)

1 : leunga 752 (* WARNING: this is generated by running 'nowhere sparcPeephole.peep'.
2 : leunga 744 * Do not edit this file directly.
3 : leunga 775 * Version 1.1
4 : leunga 744 *)
5 :    
6 : leunga 775 (*#line 10.1 "sparcPeephole.peep"*)
7 : leunga 744 functor SparcPeephole(SparcInstr : SPARCINSTR): PEEPHOLE =
8 : leunga 601 struct
9 : leunga 744
10 : leunga 775 (*#line 12.4 "sparcPeephole.peep"*)
11 : leunga 601 structure I = SparcInstr
12 :    
13 : leunga 775 (*#line 13.4 "sparcPeephole.peep"*)
14 : leunga 744 structure C = I.C
15 : leunga 601
16 : leunga 775 (*#line 16.4 "sparcPeephole.peep"*)
17 : leunga 744 fun peephole instrs =
18 :     let
19 : leunga 775 (*#line 17.8 "sparcPeephole.peep"*)
20 : leunga 744 fun isZero (I.LAB le) = (I.LabelExp.valueOf le) = 0
21 :     | isZero (I.REG r) = (C.registerNum r) = 0
22 :     | isZero (I.IMMED i) = i = 0
23 :     | isZero _ = false
24 : leunga 601
25 : leunga 775 (*#line 22.8 "sparcPeephole.peep"*)
26 :     fun removable p_0 =
27 :     let val v_6 = p_0
28 :     fun state_5 () = false
29 :     fun state_2 (v_0, v_1, v_2) =
30 :     let val d = v_0
31 :     and i = v_1
32 :     and r = v_2
33 :     in (C.sameColor (r, d)) andalso (isZero i)
34 :     end
35 :     in
36 :     let val v_5 = v_6
37 :     in
38 :     (case v_5 of
39 :     I.ANNOTATION v_4 =>
40 :     let val {a=v_3, i=v_1, ...} = v_4
41 :     in
42 :     let val a = v_3
43 :     and i = v_1
44 :     in removable i
45 :     end
46 :     end
47 :     | I.ARITH v_4 =>
48 :     let val {a=v_3, d=v_0, i=v_1, r=v_2, ...} = v_4
49 :     in
50 :     (case v_3 of
51 :     I.ADD => state_2 (v_0, v_1, v_2)
52 :     | I.SUB => state_2 (v_0, v_1, v_2)
53 :     | _ => state_5 ()
54 :     )
55 :     end
56 :     | _ => state_5 ()
57 :     )
58 :     end
59 :     end
60 : leunga 744
61 : leunga 775 (*#line 27.8 "sparcPeephole.peep"*)
62 : leunga 744 fun loop (current, instrs) =
63 :     let val v_3 = current
64 :     in
65 :     (case v_3 of
66 : leunga 775 op :: v_2 =>
67 :     let val (v_1, v_0) = v_2
68 : leunga 744 in
69 : leunga 775 let val i = v_1
70 :     and rest = v_0
71 : leunga 744 in (if (removable i)
72 :     then (loop (rest, instrs))
73 :     else
74 : leunga 775 let val i = v_1
75 :     and rest = v_0
76 : leunga 744 in loop (rest, i :: instrs)
77 :     end)
78 :     end
79 :     end
80 : leunga 775 | nil => instrs
81 : leunga 744 )
82 :     end
83 :     in loop (instrs, [])
84 :     end
85 :     end
86 :    

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