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/alpha/instructions/alphaPeephole.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/alpha/instructions/alphaPeephole.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 752 - (download) (annotate)
Fri Dec 8 23:32:37 2000 UTC (18 years, 8 months ago) by leunga
File size: 4394 byte(s)

    Slight improvements to a code generator tool.
(* WARNING: this is generated by running 'nowhere alphaPeephole.peep'.
 * Do not edit this file directly.
 *)

(*#line 5.1 "alphaPeephole.peep"*)
functor AlphaPeephole(AlphaInstr : ALPHAINSTR): PEEPHOLE =
struct

(*#line 7.4 "alphaPeephole.peep"*)
   structure I = AlphaInstr

(*#line 8.4 "alphaPeephole.peep"*)
   structure C = I.C

(*#line 11.4 "alphaPeephole.peep"*)
   fun peephole instrs = 
       let 
(*#line 12.8 "alphaPeephole.peep"*)
           fun isZero (I.LABop le) = (I.LabelExp.valueOf le) = 0
             | isZero (I.REGop r) = (C.registerNum r) = 31
             | isZero (I.IMMop i) = i = 0
             | isZero _ = false

(*#line 17.8 "alphaPeephole.peep"*)
           fun removable (I.LDA{r, b, d}) = (isZero d) andalso (C.sameColor (r, b))
             | removable (I.OPERATE{oper=(I.ADDQ | I.SUBQ), ra, rb, rc}) = (C.sameColor (ra, rc)) andalso (isZero rb)
             | removable (I.ANNOTATION{i, a}) = removable i
             | removable _ = false

(*#line 23.8 "alphaPeephole.peep"*)
           fun symmetric (I.STQ, I.LDQ) = true
             | symmetric (I.STL, I.LDL) = true
             | symmetric (I.STW, I.LDW) = true
             | symmetric (I.STB, I.LDB) = true
             | symmetric _ = false

(*#line 29.8 "alphaPeephole.peep"*)
           fun sameOperand (I.REGop r1, I.REGop r2) = C.sameColor (r1, r2)
             | sameOperand (I.IMMop i1, I.IMMop i2) = i1 = i2
             | sameOperand (I.LABop l1, I.LABop l2) = (I.LabelExp.valueOf l1) = (I.LabelExp.valueOf l2)
             | sameOperand _ = false

(*#line 35.8 "alphaPeephole.peep"*)
           fun loop (current, instrs) = 
               let val v_16 = current
                   fun state_7 (v_0, v_1) = 
                       let val i = v_0
                           and rest = v_1
                       in (if (removable i)
                             then (loop (rest, instrs))
                             else 
                             let val i = v_0
                                 and rest = v_1
                             in loop (rest, i :: instrs)
                             end)
                       end
               in 
                  (case v_16 of
                    nil => instrs
                  | op :: v_15 => 
                    let val (v_0, v_1) = v_15
                    in 
                       (case v_0 of
                         I.STORE v_14 => 
                         let val {b=v_2, d=v_4, r=v_8, stOp=v_11, ...} = v_14
                         in 
                            (case v_1 of
                              nil => state_7 (v_0, v_1)
                            | op :: v_13 => 
                              let val (v_6, v_10) = v_13
                              in 
                                 (case v_6 of
                                   I.LOAD v_12 => 
                                   let val {b=v_3, d=v_5, ldOp=v_7, r=v_9, ...} = v_12
                                   in 
                                      let val b1 = v_2
                                          and b2 = v_3
                                          and d1 = v_4
                                          and d2 = v_5
                                          and ld = v_6
                                          and ldOp = v_7
                                          and r1 = v_8
                                          and r2 = v_9
                                          and rest = v_10
                                          and st = v_0
                                          and stOp = v_11
                                      in (if ((((symmetric (stOp, ldOp)) andalso (C.sameColor (r1, r2))) andalso (C.sameColor (b1, b2))) andalso (sameOperand (d1, 
                                            d2)))
                                            then (loop (rest, st :: instrs))
                                            else (state_7 (v_0, v_1)))
                                      end
                                   end
                                 | _ => state_7 (v_0, v_1)
                                 )
                              end
                            )
                         end
                       | _ => state_7 (v_0, v_1)
                       )
                    end
                  )
               end
       in loop (instrs, [])
       end
end


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