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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 1115 (* low-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 1115 * All rights reserved.
7 :     *)
8 :    
9 :     structure LowOptimizer : sig
10 :    
11 : jhr 1232 val controls : (string * bool ref * string) list
12 :    
13 : jhr 1115 val optimize : LowIL.program -> LowIL.program
14 :    
15 :     end = struct
16 :    
17 : jhr 1232 (* Value numbering for LowIL *)
18 :     structure VN = ValueNumberingFn (DomTreeFn(LowIL))
19 : jhr 1115
20 : jhr 1232 val vnFlag = ref true (* controls value numbering *)
21 :     val debugFlag = ref true (* controls printing *)
22 :     val checkFlag = ref true (* controls IL checking *)
23 :    
24 :     val controls = [
25 :     ("low-vn", vnFlag, "enable value-numbering for LowIL"),
26 :     ("low-debug", debugFlag, "enable printing LowIL to log file [debug]"),
27 :     ("low-check", checkFlag, "enable consistency checking for LowIL [debug]")
28 :     ]
29 :    
30 : jhr 2356 val timeCheck = PhaseTimer.withTimer Timers.timeLowCheck (fn arg => CheckLowIL.check arg)
31 :    
32 : jhr 1640 fun checkIL (phase, prog) =
33 : jhr 2356 if !checkFlag andalso timeCheck ("after " ^ phase, prog)
34 : jhr 1232 then (
35 :     TextIO.output(TextIO.stdErr, concat[
36 :     "***** Internal error after ", phase,
37 :     ": see log file for details\n"
38 :     ]);
39 : jhr 1640 LowPP.output (Log.logFile(), "LowIL after " ^ phase, prog);
40 : jhr 1232 OS.Process.exit OS.Process.failure)
41 : jhr 1640 else if !debugFlag
42 :     then (
43 :     LowPP.output (Log.logFile(), "LowIL after " ^ phase, prog);
44 :     prog)
45 :     else prog
46 : jhr 1232
47 : jhr 2356 fun transform (ctl, timer, phase, transform, prog) =
48 : jhr 1232 if !ctl
49 : jhr 2356 then checkIL(phase, PhaseTimer.withTimer timer transform prog)
50 : jhr 1232 else prog
51 :    
52 :     fun optimize prog = let
53 : jhr 2356 val prog = transform (vnFlag, Timers.timeLowVN, "value numbering", VN.transform, prog)
54 : jhr 1232 in
55 :     prog
56 :     end
57 :    
58 : jhr 1115 end

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