Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/sparc/instructions/sparcPeephole.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 651, Thu Jun 1 18:34:03 2000 UTC revision 744, Fri Dec 8 04:11:42 2000 UTC
# Line 1  Line 1 
1    (* WARNING: this is generated by running 'wheregen sparcPeephole.peep'.
2     * Do not edit this file directly.
3     *)
4    
5    (*#line 7.1 "sparcPeephole.peep"*)
6  functor SparcPeephole(SparcInstr : SPARCINSTR) : PEEPHOLE =  functor SparcPeephole(SparcInstr : SPARCINSTR) : PEEPHOLE =
7  struct  struct
8    
9    (*#line 9.4 "sparcPeephole.peep"*)
10     structure I = SparcInstr     structure I = SparcInstr
11    
12     (* IMPORTANT: instructions are given in reversed order *)  (*#line 10.4 "sparcPeephole.peep"*)
13     fun peephole regmap instrs =     structure C = I.C
14     let fun isZero(I.LAB le)  = I.LabelExp.valueOf le = 0  
15           | isZero(I.REG r)   = regmap r = 0  (*#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           | isZero(I.IMMED i) = i = 0
22           | isZero _ = false           | isZero _ = false
23    
24         fun removable(I.ARITH{a=(I.ADD | I.SUB), r, i, d}) =  (*#line 19.8 "sparcPeephole.peep"*)
25               regmap r = regmap d andalso isZero i             fun removable (I.ARITH{a=(I.ADD | I.SUB), r, i, d}) = (C.sameColor (r,
26                      d)) andalso (isZero i)
27           | removable(I.ANNOTATION{i,a}) = removable i           | removable(I.ANNOTATION{i,a}) = removable i
28           | removable _ = false           | removable _ = false
29    
30         fun loop([], instrs) = rev instrs  (*#line 24.8 "sparcPeephole.peep"*)
31           | loop(i::rest, instrs) =             fun loop (current, instrs) =
32             if removable i then loop(rest, instrs)                 let val v_3 = current
33             else loop(rest, i::instrs)                 in
34                      (case v_3 of
35                        nil => instrs
36                      | op :: v_2 =>
37                        let val (v_0, v_1) = v_2
38                        in
39                           let val i = v_0
40                               and rest = v_1
41                           in (if (removable i)
42                                 then (loop (rest, instrs))
43                                 else
44                                 let val i = v_0
45                                     and rest = v_1
46                                 in loop (rest, i :: instrs)
47                                 end)
48                           end
49                        end
50                      )
51                   end
52     in  loop(instrs, [])     in  loop(instrs, [])
53     end     end
54  end  end
55    

Legend:
Removed from v.651  
changed lines
  Added in v.744

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