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

SCM Repository

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

View of /branches/vis12-cl/src/compiler/high-il/high-opt.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2683 - (download) (annotate)
Mon Aug 25 18:56:17 2014 UTC (5 years ago) by jhr
File size: 2062 byte(s)
  Port updates from vis12 branch to vis12-cl
(* high-opt.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Optimization of the HighIL representation of Diderot terms.  The main
 * task of this phase is to statically resolve field definitions.
 *)

structure HighOptimizer : sig

    val controls : (string * bool ref * string) list

    val optimize : HighIL.program -> HighIL.program

  end = struct

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

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

    val timeCheck = PhaseTimer.withTimer Timers.timeHighCheck (fn arg => CheckHighIL.check arg)

    val controls = [
	    ("high-vn",    vnFlag,    "value-numbering for HighIL"),
	    ("high-debug", debugFlag, "printing HighIL to log file [debug]"),
	    ("high-check", checkFlag, "consistency checking for HighIL [debug]")
	  ]

    fun checkIL (phase, prog) = (
          if !debugFlag
            then HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog)
            else ();
          if !checkFlag andalso CheckHighIL.check ("after " ^ phase, prog)
	    then (
              if not(!debugFlag)
                then HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog)
                else ();
	      TextIO.output(TextIO.stdErr, concat[
		  "***** Internal error after ", phase,
		  ": see log file for details\n"
		]);
	      OS.Process.exit OS.Process.failure)
            else prog)

    fun transform (ctl, timer, phase, transform, prog) =
	  if !ctl
	    then checkIL(phase, PhaseTimer.withTimer timer transform prog)
	    else prog

    fun optimize prog = let
	  val prog = checkIL ("translation to HighIL", prog)
	  val prog = transform (vnFlag, Timers.timeHighVN, "value numbering", VN.transform, prog)
	  val prog = checkIL ("normalization", PhaseTimer.withTimer Timers.timeHighNorm Normalize.transform prog)
	  in
	    prog
	  end

  end

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