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

SCM Repository

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

View of /branches/charisee/src/compiler/low-il/low-opt.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2525 - (download) (annotate)
Tue Jan 21 19:14:22 2014 UTC (5 years, 7 months ago) by cchiw
File size: 1704 byte(s)
eintypes->mid-iltypes
(* low-opt.sml
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

structure LowOptimizer : sig

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

    val optimize : LowIL.program -> LowIL.program

  end = struct

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

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

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

    val timeCheck = PhaseTimer.withTimer Timers.timeLowCheck (fn arg => CheckLowIL.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"
		]);
              LowPP.output (Log.logFile(), "LowIL after " ^ phase, prog);
	      OS.Process.exit OS.Process.failure)
          else *)if !debugFlag
            then (
              LowPP.output (Log.logFile(), "LowIL after " ^ phase, prog);
              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 = transform (vnFlag, Timers.timeLowVN, "value numbering", VN.transform, prog)
	  in
	    prog
	  end

  end

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