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 2356 - (view) (download)

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

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