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 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 1232 val controls : (string * bool ref * string) list
15 :    
16 : jhr 287 val optimize : HighIL.program -> HighIL.program
17 :    
18 :     end = struct
19 :    
20 : jhr 1232 (* Value numbering for HighIL *)
21 :     structure VN = ValueNumberingFn (DomTreeFn (HighIL))
22 : jhr 287
23 : jhr 1232 val vnFlag = ref true (* controls value numbering *)
24 :     val debugFlag = ref true (* controls printing *)
25 :     val checkFlag = ref true (* controls IL checking *)
26 : jhr 320
27 : jhr 2356 val timeCheck = PhaseTimer.withTimer Timers.timeHighCheck (fn arg => CheckHighIL.check arg)
28 :    
29 : jhr 1232 val controls = [
30 :     ("high-vn", vnFlag, "enable value-numbering for HighIL"),
31 :     ("high-debug", debugFlag, "enable printing HighIL to log file [debug]"),
32 :     ("high-check", checkFlag, "enable consistency checking for HighIL [debug]")
33 :     ]
34 : jhr 1116
35 : jhr 1640 fun checkIL (phase, prog) = (
36 :     if !debugFlag
37 :     then HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog)
38 :     else ();
39 :     if !checkFlag andalso CheckHighIL.check ("after " ^ phase, prog)
40 : jhr 1232 then (
41 : jhr 1640 if not(!debugFlag)
42 :     then HighPP.output (Log.logFile(), "HighIL after " ^ phase, prog)
43 :     else ();
44 : jhr 1232 TextIO.output(TextIO.stdErr, concat[
45 :     "***** Internal error after ", phase,
46 :     ": see log file for details\n"
47 :     ]);
48 :     OS.Process.exit OS.Process.failure)
49 : jhr 1640 else prog)
50 : jhr 287
51 : jhr 2356 fun transform (ctl, timer, phase, transform, prog) =
52 : jhr 1232 if !ctl
53 : jhr 2356 then checkIL(phase, PhaseTimer.withTimer timer transform prog)
54 : jhr 1232 else prog
55 : jhr 287
56 : jhr 1232 fun optimize prog = let
57 :     val prog = checkIL ("translation to HighIL", prog)
58 : jhr 2356 val prog = transform (vnFlag, Timers.timeHighVN, "value numbering", VN.transform, prog)
59 :     val prog = checkIL ("normalization", PhaseTimer.withTimer Timers.timeHighNorm Normalize.transform prog)
60 : jhr 320 in
61 : jhr 1232 prog
62 : jhr 320 end
63 :    
64 : jhr 287 end

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