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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 775 - (download) (annotate)
Fri Jan 12 01:17:51 2001 UTC (20 years, 1 month ago) by leunga
File size: 2816 byte(s)

    Merging the types labexp and mltree.
    tag leunga-20010111-labexp=mltree
(* WARNING: this is generated by running 'nowhere sparcPeephole.peep'.
 * Do not edit this file directly.
 * Version 1.1
 *)

(*#line 10.1 "sparcPeephole.peep"*)
functor SparcPeephole(SparcInstr : SPARCINSTR): PEEPHOLE =
struct

(*#line 12.4 "sparcPeephole.peep"*)
   structure I = SparcInstr

(*#line 13.4 "sparcPeephole.peep"*)
   structure C = I.C

(*#line 16.4 "sparcPeephole.peep"*)
   fun peephole instrs = 
       let 
(*#line 17.8 "sparcPeephole.peep"*)
           fun isZero (I.LAB le) = (I.LabelExp.valueOf le) = 0
             | isZero (I.REG r) = (C.registerNum r) = 0
             | isZero (I.IMMED i) = i = 0
             | isZero _ = false

(*#line 22.8 "sparcPeephole.peep"*)
           fun removable p_0 = 
               let val v_6 = p_0
                   fun state_5 () = false
                   fun state_2 (v_0, v_1, v_2) = 
                       let val d = v_0
                           and i = v_1
                           and r = v_2
                       in (C.sameColor (r, d)) andalso (isZero i)
                       end
               in 
                  let val v_5 = v_6
                  in 
                     (case v_5 of
                       I.ANNOTATION v_4 => 
                       let val {a=v_3, i=v_1, ...} = v_4
                       in 
                          let val a = v_3
                              and i = v_1
                          in removable i
                          end
                       end
                     | I.ARITH v_4 => 
                       let val {a=v_3, d=v_0, i=v_1, r=v_2, ...} = v_4
                       in 
                          (case v_3 of
                            I.ADD => state_2 (v_0, v_1, v_2)
                          | I.SUB => state_2 (v_0, v_1, v_2)
                          | _ => state_5 ()
                          )
                       end
                     | _ => state_5 ()
                     )
                  end
               end

(*#line 27.8 "sparcPeephole.peep"*)
           fun loop (current, instrs) = 
               let val v_3 = current
               in 
                  (case v_3 of
                    op :: v_2 => 
                    let val (v_1, v_0) = v_2
                    in 
                       let val i = v_1
                           and rest = v_0
                       in (if (removable i)
                             then (loop (rest, instrs))
                             else 
                             let val i = v_1
                                 and rest = v_0
                             in loop (rest, i :: instrs)
                             end)
                       end
                    end
                  | nil => instrs
                  )
               end
       in loop (instrs, [])
       end
end


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