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.peep
ViewVC logotype

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

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: 886 byte(s)

    Merging the types labexp and mltree.
    tag leunga-20010111-labexp=mltree
local

   structure I =
   struct
     include "sparcInstr.sml"
   end

in

functor SparcPeephole(SparcInstr : SPARCINSTR) : PEEPHOLE =
struct
   structure I = SparcInstr
   structure C = I.C

   (* IMPORTANT: instructions are now given in forward order *)
   fun peephole instrs =
   let 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

       fun removable(I.ARITH{a=(I.ADD | I.SUB), r, i, d}) =
             C.sameColor(r,d) andalso isZero i
         | removable(I.ANNOTATION{i,a}) = removable i
         | removable _ = false

       fun loop(current, instrs) = 
           case current of
             [] => instrs
           | i::rest where removable i => loop(rest, instrs)
           | i::rest => loop(rest, i::instrs)
   in  loop(instrs, [])
   end
end 

end

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