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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/high-opt/high-opt.sml
ViewVC logotype

View of /branches/vis15/src/compiler/high-opt/high-opt.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4822 - (download) (annotate)
Tue Nov 1 22:43:08 2016 UTC (3 years, 3 months ago) by jhr
File size: 2100 byte(s)
  Working on merge: fixed a bug in promote-fn.sml (no promotions were done if there were no
  globals).  This bug was exposed by fixing the use-count bugs in normalize.
(* high-opt.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *
 * Optimization of the HighIR representation of Diderot terms.  The main
 * task of this phase is to statically resolve field definitions.
 *)

structure HighOptimizer : sig

    val optimize : HighIR.program -> HighIR.program

    val checkAfter : string * HighIR.program -> HighIR.program

  end = struct

  (* Value numbering for HighIR *)
    structure VN = ValueNumberingFn (DomTreeFn (HighIR))

    val vnFlag = ref true               (* controls value numbering *)
    val debugFlag = ref true            (* controls printing *)
    val checkFlag = ref true            (* controls IR checking *)

    val checkAfter = Log.after {
            dumpCtl = Ctl.dumpHighIR,
            checkCtl = Ctl.checkHighIR,
            output = HighPP.output,
            checkIR = PhaseTimer.withTimer Timers.timeHighCheck (fn arg => CheckHigh.check arg)
          }

  (* used to run the Normalize.rewrite phase; we cannot run checks, since some locals
   * may have had their scopes extended and thus would trigger use-count failures.
   * The Normalize.promote phase will fix those issues.
   *)
    val noCheckAfter = Log.after {
            dumpCtl = Ctl.dumpHighIR,
            checkCtl = Ctl.checkHighIR,
            output = HighPP.output,
            checkIR = fn arg => false
          }

    fun transform (flag, timer, phase, transform, prog) =
          if flag
            then checkAfter (phase, PhaseTimer.withTimer timer transform prog)
            else prog

    fun optimize prog = let
          val prog = transform (Controls.get Ctl.highVN, Timers.timeHighVN, "value numbering", VN.transform, prog)
          val prog = noCheckAfter ("normalization rewriting",
                PhaseTimer.withTimer Timers.timeHighNorm Normalize.rewrite prog)
          val prog = transform (true, Timers.timeHighNorm, "normalization promotion", Normalize.promote, prog)
          in
            prog
          end

  end

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