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

1 : leunga 601 functor SparcPeepHole(SparcInstr : SPARCINSTR) : PEEPHOLE =
2 :     struct
3 :     structure I = SparcInstr
4 :    
5 :     (* IMPORTANT: instructions are given in reversed order *)
6 :     fun peephole regmap instrs =
7 :     let fun isZero(I.LAB le) = I.LabelExp.valueOf le = 0
8 :     | isZero(I.REG r) = regmap r = 0
9 :     | isZero(I.IMMED i) = i = 0
10 :     | isZero _ = false
11 :    
12 :     fun removable(I.ARITH{a=(I.ADD | I.SUB), r, i, d}) =
13 :     regmap r = regmap d andalso isZero i
14 :     | removable(I.ANNOTATION{i,a}) = removable i
15 :     | removable _ = false
16 :    
17 :     fun loop([], instrs) = rev instrs
18 :     | loop(i::rest, instrs) =
19 :     if removable i then loop(rest, instrs)
20 :     else loop(rest, i::instrs)
21 :     in loop(instrs, [])
22 :     end
23 :     end

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