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

SCM Repository

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

View of /branches/pure-cfg/src/compiler/low-il/low-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: 1510 byte(s)
  Adding general support for command-line options
(* 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]")

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

    fun checkIL (phase, prog) = if !checkFlag
	  then if CheckLowIL.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 = transform (vnFlag, "value numbering", VN.transform, prog)


ViewVC Help
Powered by ViewVC 1.0.0