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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1640 - (view) (download)
Original Path: trunk/src/compiler/mid-il/mid-opt.sml

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 1640 ("mid-contract", contractFlag, "enable contraction for MidIL"),
25 : jhr 1232 ("mid-vn", vnFlag, "enable value-numbering for MidIL"),
26 :     ("mid-debug", debugFlag, "enable printing MidIL to log file [debug]"),
27 :     ("mid-check", checkFlag, "enable consistency checking for MidIL [debug]")
28 :     ]
29 :    
30 : jhr 1640 fun checkIL (phase, prog) =
31 :     if !checkFlag andalso CheckMidIL.check ("after " ^ phase, prog)
32 : jhr 1232 then (
33 :     TextIO.output(TextIO.stdErr, concat[
34 :     "***** Internal error after ", phase,
35 :     ": see log file for details\n"
36 :     ]);
37 : jhr 1640 MidPP.output (Log.logFile(), "MidIL after " ^ phase, prog);
38 : jhr 1232 OS.Process.exit OS.Process.failure)
39 : jhr 1640 else if !debugFlag
40 :     then (
41 :     MidPP.output (Log.logFile(), "MidIL after " ^ phase, prog);
42 :     prog)
43 :     else prog
44 : jhr 1232
45 :     fun transform (ctl, phase, transform, prog) =
46 :     if !ctl
47 : jhr 1640 then checkIL (phase, transform prog)
48 : jhr 1232 else prog
49 :    
50 :     fun optimize prog = let
51 :     val prog = transform (vnFlag, "value numbering", VN.transform, prog)
52 : jhr 1640 val prog = transform (contractFlag, "contraction", MidContract.transform, prog)
53 : jhr 1232 in
54 :     prog
55 :     end
56 :    
57 : jhr 1115 end

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