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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

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

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