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

SCM Repository

[diderot] Annotation of /branches/vis12-cl/src/compiler/mid-il/mid-opt.sml
ViewVC logotype

Annotation of /branches/vis12-cl/src/compiler/mid-il/mid-opt.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2683 - (view) (download)

1 : jhr 1115 (* mid-opt.sml
2 :     *
3 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure MidOptimizer : sig
8 :    
9 : jhr 1232 val controls : (string * bool ref * string) list
10 :    
11 : jhr 1115 val optimize : MidIL.program -> MidIL.program
12 :    
13 :     end = struct
14 :    
15 : jhr 1232 (* Value numbering for MidIL *)
16 :     structure VN = ValueNumberingFn (DomTreeFn(MidIL))
17 : jhr 1115
18 : jhr 1640 val contractFlag = ref true (* controls contraction *)
19 : jhr 1232 val vnFlag = ref true (* controls value numbering *)
20 :     val debugFlag = ref true (* controls printing *)
21 :     val checkFlag = ref true (* controls IL checking *)
22 :    
23 :     val controls = [
24 : jhr 2683 ("mid-contract", contractFlag, "contraction for MidIL"),
25 :     ("mid-vn", vnFlag, "value-numbering for MidIL"),
26 :     ("mid-debug", debugFlag, "printing MidIL to log file [debug]"),
27 :     ("mid-check", checkFlag, "consistency checking for MidIL [debug]")
28 : jhr 1232 ]
29 :    
30 : jhr 1823 val timeCheck = PhaseTimer.withTimer Timers.timeMidCheck (fn arg => CheckMidIL.check arg)
31 :    
32 : jhr 1640 fun checkIL (phase, prog) =
33 : jhr 1823 if !checkFlag andalso timeCheck ("after " ^ phase, prog)
34 : jhr 1232 then (
35 :     TextIO.output(TextIO.stdErr, concat[
36 :     "***** Internal error after ", phase,
37 :     ": see log file for details\n"
38 :     ]);
39 : jhr 1640 MidPP.output (Log.logFile(), "MidIL after " ^ phase, prog);
40 : jhr 1232 OS.Process.exit OS.Process.failure)
41 : jhr 1640 else if !debugFlag
42 :     then (
43 :     MidPP.output (Log.logFile(), "MidIL after " ^ phase, prog);
44 :     prog)
45 :     else prog
46 : jhr 1232
47 : jhr 1823 fun transform (ctl, timer, phase, transform, prog) =
48 : jhr 1232 if !ctl
49 : jhr 1823 then checkIL(phase, PhaseTimer.withTimer timer transform prog)
50 : jhr 1232 else prog
51 :    
52 :     fun optimize prog = let
53 : jhr 1786 val prog = checkIL ("translation to MidIL", prog)
54 : jhr 1823 val prog = transform (vnFlag, Timers.timeMidVN, "value numbering", VN.transform, prog)
55 :     val prog = transform (contractFlag, Timers.timeMidCheck, "contraction", MidContract.transform, prog)
56 : jhr 1232 in
57 :     prog
58 :     end
59 :    
60 : jhr 1115 end

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