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

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