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

SCM Repository

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

View of /branches/vis15/src/compiler/mid-opt/mid-opt.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3584 - (download) (annotate)
Wed Jan 13 22:43:14 2016 UTC (4 years, 2 months ago) by jhr
File size: 1405 byte(s)
working on merge
(* mid-opt.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *
 * Optimization of the MidIR representation of Diderot terms.  The main
 * task of this phase is to statically resolve field definitions.
 *)

structure MidOptimizer : sig

    val optimize : MidIR.program -> MidIR.program

    val checkAfter : string * MidIR.program -> MidIR.program

  end = struct

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

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

    val checkAfter = Log.after {
	    dumpCtl = Ctl.dumpMidIR,
	    checkCtl = Ctl.checkMidIR,
	    output = MidPP.output,
	    checkIR = PhaseTimer.withTimer Timers.timeMidCheck (fn arg => CheckMid.check arg)
	  }

    fun transform (flag, timer, phase, transform, prog) =
	  if flag
	    then checkAfter (phase, PhaseTimer.withTimer timer transform prog)
	    else prog

    fun optimize prog = let
	  val prog = transform (Controls.get Ctl.midVN, Timers.timeMidVN, "value numbering", VN.transform, prog)
	  val prog = transform (Controls.get Ctl.midContract, Timers.timeMidContract, "contraction", MidContract.transform, prog)
	  in
	    prog
	  end

  end

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