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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1202 - (download) (annotate)
Thu May 12 18:49:23 2011 UTC (10 years, 1 month ago) by jhr
File size: 1819 byte(s)
  Adding general support for command-line options
(* 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 controls = [
	    ("high-vn", vnFlag, "enable value-numbering for HighIL"),
	    ("high-debug", debugFlag, "enable printing HighIL to log file [debug]"),
	    ("high-check", checkFlag, "enable consistency checking for HighIL [debug]")

    fun debugDump (phase, prog) = if !debugFlag
	  then (
	    HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog);
	  else prog

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

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

    fun optimize prog = let
	  val prog = checkIL ("translation to HighIL", prog)
	  val prog = transform (vnFlag, "value numbering", VN.transform, prog)
	  val prog = checkIL ("normalization",
		debugDump ("normalization", Normalize.transform prog))


ViewVC Help
Powered by ViewVC 1.0.0