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

SCM Repository

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

Annotation of /trunk/src/compiler/high-il/high-opt.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1640 - (view) (download)

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 1640 fun checkIL (phase, prog) = (
32 :     if !debugFlag
33 :     then HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog)
34 :     else ();
35 :     if !checkFlag andalso CheckHighIL.check ("after " ^ phase, prog)
36 : jhr 1232 then (
37 : jhr 1640 if not(!debugFlag)
38 :     then HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog)
39 :     else ();
40 : jhr 1232 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 : jhr 1640 else prog)
46 : jhr 287
47 : jhr 1232 fun transform (ctl, phase, transform, prog) =
48 :     if !ctl
49 : jhr 1640 then checkIL (phase, transform prog)
50 : jhr 1232 else prog
51 : jhr 287
52 : jhr 1232 fun optimize prog = let
53 :     val prog = checkIL ("translation to HighIL", prog)
54 :     val prog = transform (vnFlag, "value numbering", VN.transform, prog)
55 : jhr 1640 val prog = checkIL ("normalization", Normalize.transform prog)
56 : jhr 320 in
57 : jhr 1232 prog
58 : jhr 320 end
59 :    
60 : jhr 287 end

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