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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2682 - (download) (annotate)
Mon Aug 25 17:20:56 2014 UTC (6 years, 1 month ago) by jhr
File size: 1989 byte(s)
  more accurate description of command-line options when "-h" is given
(* mid-opt.sml
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

structure MidOptimizer : sig

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

    val optimize : MidIL.program -> MidIL.program

  end = struct

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

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

    val controls = [
	    ("mid-contract", contractFlag, "contraction for MidIL"),
	    ("mid-vn",       vnFlag,       "value-numbering for MidIL"),
	    ("mid-debug",    debugFlag,    "printing MidIL to log file [debug]"),
	    ("mid-check",    checkFlag,    "consistency checking for MidIL [debug]")

    val timeCheck = PhaseTimer.withTimer Timers.timeMidCheck (fn arg => CheckMidIL.check arg)

    fun checkIL (phase, prog) =
          if !checkFlag andalso timeCheck ("after " ^ phase, prog)
	    then (
	      TextIO.output(TextIO.stdErr, concat[
		  "***** Internal error after ", phase,
		  ": see log file for details\n"
              MidPP.output (Log.logFile(), "MidIL after " ^ phase, prog);
	      OS.Process.exit OS.Process.failure)
          else if !debugFlag
            then (
              MidPP.output (Log.logFile(), "MidIL after " ^ phase, prog);
            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 MidIL", prog)
	  val prog = transform (vnFlag, Timers.timeMidVN, "value numbering", VN.transform, prog)
	  val prog = transform (contractFlag, Timers.timeMidCheck, "contraction", MidContract.transform, prog)


ViewVC Help
Powered by ViewVC 1.0.0