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 752 - (view) (download)

1 : leunga 752 (* WARNING: this is generated by running 'nowhere sparcPeephole.peep'.
2 : leunga 744 * Do not edit this file directly.
3 :     *)
4 :    
5 :     (*#line 7.1 "sparcPeephole.peep"*)
6 :     functor SparcPeephole(SparcInstr : SPARCINSTR): PEEPHOLE =
7 : leunga 601 struct
8 : leunga 744
9 :     (*#line 9.4 "sparcPeephole.peep"*)
10 : leunga 601 structure I = SparcInstr
11 :    
12 : leunga 744 (*#line 10.4 "sparcPeephole.peep"*)
13 :     structure C = I.C
14 : leunga 601
15 : leunga 744 (*#line 13.4 "sparcPeephole.peep"*)
16 :     fun peephole instrs =
17 :     let
18 :     (*#line 14.8 "sparcPeephole.peep"*)
19 :     fun isZero (I.LAB le) = (I.LabelExp.valueOf le) = 0
20 :     | isZero (I.REG r) = (C.registerNum r) = 0
21 :     | isZero (I.IMMED i) = i = 0
22 :     | isZero _ = false
23 : leunga 601
24 : leunga 744 (*#line 19.8 "sparcPeephole.peep"*)
25 : leunga 752 fun removable (I.ARITH{a=(I.ADD | I.SUB), r, i, d}) = (C.sameColor (r, d)) andalso (isZero i)
26 : leunga 744 | removable (I.ANNOTATION{i, a}) = removable i
27 :     | removable _ = false
28 :    
29 :     (*#line 24.8 "sparcPeephole.peep"*)
30 :     fun loop (current, instrs) =
31 :     let val v_3 = current
32 :     in
33 :     (case v_3 of
34 :     nil => instrs
35 :     | op :: v_2 =>
36 :     let val (v_0, v_1) = v_2
37 :     in
38 :     let val i = v_0
39 :     and rest = v_1
40 :     in (if (removable i)
41 :     then (loop (rest, instrs))
42 :     else
43 :     let val i = v_0
44 :     and rest = v_1
45 :     in loop (rest, i :: instrs)
46 :     end)
47 :     end
48 :     end
49 :     )
50 :     end
51 :     in loop (instrs, [])
52 :     end
53 :     end
54 :    

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