Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/high-il/normalize.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/high-il/normalize.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2971, Fri Mar 6 03:35:49 2015 UTC revision 2972, Fri Mar 6 14:57:49 2015 UTC
# Line 5  Line 5 
5   *   *
6   * TODO:   * TODO:
7   *      simplify composition of border controls   *      simplify composition of border controls
  *      eliminate border controls that are dominated by Inside tests  
8   *)   *)
9    
10  structure Normalize : sig  structure Normalize : sig
# Line 39  Line 38 
38      val cntDiffNeg              = ST.newCounter "high-opt:diff-neg"      val cntDiffNeg              = ST.newCounter "high-opt:diff-neg"
39      val cntCurlScale            = ST.newCounter "high-opt:curl-scale"      val cntCurlScale            = ST.newCounter "high-opt:curl-scale"
40      val cntCurlNeg              = ST.newCounter "high-opt:curl-neg"      val cntCurlNeg              = ST.newCounter "high-opt:curl-neg"
41        val cntBorderBoder          = ST.newCounter "high-opt:border-border"
42      val cntUnused               = ST.newCounter "high-opt:unused"      val cntUnused               = ST.newCounter "high-opt:unused"
43      val firstCounter            = cntInsideScale      val firstCounter            = cntInsideScale
44      val lastCounter             = cntUnused      val lastCounter             = cntUnused
# Line 69  Line 69 
69                  ])                  ])
70            (* end case *))            (* end case *))
71    
72      (* remove a level of border control to get the underlying image, since controls
73       * override earlier controls.
74       *)
75        fun getControledImage img = (case getRHS img
76               of SOME(Op.BorderCtlValue _, [img, _]) => SOME img
77                | SOME(Op.BorderCtlClamp _, [img]) => SOME img
78                | SOME(Op.BorderCtlMirror _, [img]) => SOME img
79                | SOME(Op.BorderCtlWrap _, [img]) => SOME img
80                | SOME(Op.LoadImage _, _) => NONE
81                | _ => raise Fail(concat[
82                      "bogus image binding ", V.toString img, " = ", IL.vbToString(V.binding img)
83                    ])
84              (* end case *))
85    
86    (* optimize the rhs of an assignment, returning NONE if there is no change *)    (* optimize the rhs of an assignment, returning NONE if there is no change *)
87      fun doRHS (lhs, IL.OP rhs) = (case rhs      fun doRHS (lhs, IL.OP rhs) = (case rhs
88             of (Op.Inside dim, [pos, f]) => (case getRHS f             of (Op.Inside dim, [pos, f]) => (case getRHS f
# Line 328  Line 342 
342                    | SOME(Op.DiffField, _) => raise Fail "curl of del"                    | SOME(Op.DiffField, _) => raise Fail "curl of del"
343                    | _ => NONE                    | _ => NONE
344                  (* end case *))                  (* end case *))
345                | (Op.BorderCtlValue info, [img, v]) => (case getControledImage img
346                     of SOME img' => (
347                          ST.tick cntBorderBoder;
348                          decUse img;
349                          SOME[(lhs, IL.OP(Op.BorderCtlValue info, [img', v]))])
350                      | NONE => NONE
351                    (* end case *))
352                | (Op.BorderCtlClamp info, [img]) => (case getControledImage img
353                     of SOME img' => (
354                          ST.tick cntBorderBoder;
355                          decUse img;
356                          SOME[(lhs, IL.OP(Op.BorderCtlClamp info, [img']))])
357                      | NONE => NONE
358                    (* end case *))
359                | (Op.BorderCtlMirror info, [img]) => (case getControledImage img
360                     of SOME img' => (
361                          ST.tick cntBorderBoder;
362                          decUse img;
363                          SOME[(lhs, IL.OP(Op.BorderCtlMirror info, [img']))])
364                      | NONE => NONE
365                    (* end case *))
366                | (Op.BorderCtlWrap info, [img]) => (case getControledImage img
367                     of SOME img' => (
368                          ST.tick cntBorderBoder;
369                          decUse img;
370                          SOME[(lhs, IL.OP(Op.BorderCtlWrap info, [img']))])
371                      | NONE => NONE
372                    (* end case *))
373              | _ => NONE              | _ => NONE
374            (* end case *))            (* end case *))
375        | doRHS _ = NONE        | doRHS _ = NONE

Legend:
Removed from v.2971  
changed lines
  Added in v.2972

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