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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : jhr 287 (* high-opt.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 287 * All rights reserved.
5 :     *
6 :     * Optimization of the HighIL representation of Diderot terms. The main
7 :     * task of this phase is to statically resolve field definitions.
8 :     *)
9 :    
10 :     structure HighOptimizer : sig
11 :    
12 : jhr 1232 val controls : (string * bool ref * string) list
13 :    
14 : jhr 287 val optimize : HighIL.program -> HighIL.program
15 :    
16 :     end = struct
17 :    
18 : jhr 1232 (* Value numbering for HighIL *)
19 :     structure VN = ValueNumberingFn (DomTreeFn (HighIL))
20 : jhr 287
21 : jhr 1232 val vnFlag = ref true (* controls value numbering *)
22 :     val debugFlag = ref true (* controls printing *)
23 :     val checkFlag = ref true (* controls IL checking *)
24 : jhr 320
25 : jhr 1232 val controls = [
26 :     ("high-vn", vnFlag, "enable value-numbering for HighIL"),
27 :     ("high-debug", debugFlag, "enable printing HighIL to log file [debug]"),
28 :     ("high-check", checkFlag, "enable consistency checking for HighIL [debug]")
29 :     ]
30 : jhr 1116
31 : jhr 1232 fun debugDump (phase, prog) = if !debugFlag
32 :     then (
33 :     HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog);
34 :     prog)
35 :     else prog
36 : jhr 320
37 : jhr 1232 fun checkIL (phase, prog) = if !checkFlag
38 :     then if CheckHighIL.check ("after " ^ phase, prog)
39 :     then (
40 :     TextIO.output(TextIO.stdErr, concat[
41 :     "***** Internal error after ", phase,
42 :     ": see log file for details\n"
43 :     ]);
44 :     OS.Process.exit OS.Process.failure)
45 :     else prog
46 :     else prog
47 : jhr 287
48 : jhr 1232 fun transform (ctl, phase, transform, prog) =
49 :     if !ctl
50 :     then checkIL (phase, debugDump(phase, transform prog))
51 :     else prog
52 : jhr 287
53 : jhr 1232 fun optimize prog = let
54 :     val prog = checkIL ("translation to HighIL", prog)
55 :     val prog = transform (vnFlag, "value numbering", VN.transform, prog)
56 :     val prog = checkIL ("normalization",
57 :     debugDump ("normalization", Normalize.transform prog))
58 : jhr 320 in
59 : jhr 1232 prog
60 : jhr 320 end
61 :    
62 : jhr 287 end

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