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 958 - (download) (annotate)
Fri Oct 12 03:54:43 2001 UTC (17 years, 11 months ago) by george
File size: 896 byte(s)
The representation of a program point never expected to see more
than 65536 instructions in a basic block!
local

   structure I =
   struct
     include "sparcInstr.sml"
   end

in

functor SparcPeephole(SparcInstr : SPARCINSTR) : PEEPHOLE =
struct
   structure I = SparcInstr
   structure CB = CellsBasis

   (* 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)   = CB.registerNum r = 0
         | isZero(I.IMMED i) = i = 0
         | isZero _ = false

       fun removable(I.ARITH{a=(I.ADD | I.SUB), r, i, d}) =
             CB.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