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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1546 - (download) (annotate)
Wed Oct 19 14:28:57 2011 UTC (7 years, 9 months ago) by jhr
File size: 1561 byte(s)
  Re-enable value numbering, which got turned off by accident.
(* 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 vnFlag = ref true		(* controls value numbering *)
    val debugFlag = ref true		(* controls printing *)
    val checkFlag = ref true		(* controls IL checking *)

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

    fun checkIL (phase, prog) =
          if !checkFlag andalso CheckMidIL.check ("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);
              prog)
            else prog

    fun transform (ctl, phase, transform, prog) =
	  if !ctl
	    then checkIL (phase, transform prog)
	    else prog

    fun optimize prog = let
	  val prog = transform (vnFlag, "value numbering", VN.transform, prog)
	  in
	    prog
	  end

  end

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