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 958 - (download) (annotate)
Fri Oct 12 03:54:43 2001 UTC (17 years, 11 months ago) by george
File size: 5816 byte(s)
The representation of a program point never expected to see more
than 65536 instructions in a basic block!
(* WARNING: this is generated by running 'nowhere alphaPeephole.peep'.
 * Do not edit this file directly.
 * Version 1.2
 *)

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

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

(*#line 11.4 "alphaPeephole.peep"*)
   structure CB = CellsBasis

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

(*#line 20.8 "alphaPeephole.peep"*)
           fun removable p_0 = 
               let val v_11 = p_0
                   fun state_7 () = false
                   fun state_4 (v_0, v_1, v_2) = 
                       let val ra = v_0
                           and rb = v_1
                           and rc = v_2
                       in (CB.sameColor (ra, rc)) andalso (isZero rb)
                       end
               in 
                  let val v_10 = v_11
                  in 
                     (case v_10 of
                       I.ANNOTATION v_4 => 
                       let val {a=v_9, i=v_8, ...} = v_4
                       in 
                          let val a = v_9
                              and i = v_8
                          in removable i
                          end
                       end
                     | I.LDA v_4 => 
                       let val {b=v_7, d=v_6, r=v_5, ...} = v_4
                       in 
                          let val b = v_7
                              and d = v_6
                              and r = v_5
                          in (isZero d) andalso (CB.sameColor (r, b))
                          end
                       end
                     | I.OPERATE v_4 => 
                       let val {oper=v_3, ra=v_0, rb=v_1, rc=v_2, ...} = v_4
                       in 
                          (case v_3 of
                            I.ADDQ => state_4 (v_0, v_1, v_2)
                          | I.SUBQ => state_4 (v_0, v_1, v_2)
                          | _ => state_7 ()
                          )
                       end
                     | _ => state_7 ()
                     )
                  end
               end

(*#line 26.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 32.8 "alphaPeephole.peep"*)
           fun sameOperand (I.REGop r1, I.REGop r2) = CB.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 38.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
                    op :: v_15 => 
                    let val (v_0, v_1) = v_15
                    in 
                       (case v_0 of
                         I.STORE v_14 => 
                         let val {b=v_11, d=v_9, r=v_5, stOp=v_2, ...} = v_14
                         in 
                            (case v_1 of
                              op :: v_13 => 
                              let val (v_7, v_3) = v_13
                              in 
                                 (case v_7 of
                                   I.LOAD v_12 => 
                                   let val {b=v_10, d=v_8, ldOp=v_6, r=v_4, ...} = v_12
                                   in 
                                      let val b1 = v_11
                                          and b2 = v_10
                                          and d1 = v_9
                                          and d2 = v_8
                                          and ld = v_7
                                          and ldOp = v_6
                                          and r1 = v_5
                                          and r2 = v_4
                                          and rest = v_3
                                          and st = v_0
                                          and stOp = v_2
                                      in (if ((((symmetric (stOp, ldOp)) andalso (CB.sameColor (r1, r2))) andalso (CB.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
                            | nil => state_7 (v_0, v_1)
                            )
                         end
                       | _ => state_7 (v_0, v_1)
                       )
                    end
                  | nil => instrs
                  )
               end
       in loop (instrs, [])
       end
end


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