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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/driver/main.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/driver/main.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3711, Fri Apr 1 22:57:00 2016 UTC revision 3753, Thu Apr 14 06:02:18 2016 UTC
# Line 18  Line 18 
18    
19      fun quitWithError srcFile = raise Error.ERROR      fun quitWithError srcFile = raise Error.ERROR
20    
21      (* messages in verbose mode *)
22    (* FIXME: perhaps we should include timing info? *)
23        fun verbosePrint msg = if Controls.get Ctl.verbose
24              then TextIO.output(TextIO.stdErr, concat msg)
25              else ()
26    
27    (* check for errors and report them if there are any *)    (* check for errors and report them if there are any *)
28      fun checkForErrors errStrm =      fun checkForErrors errStrm =
29            if Error.anyErrors errStrm            if Error.anyErrors errStrm
# Line 39  Line 45 
45                    err(concat["source file \"", filename, "\" does not exist or is not readable\n"]);                    err(concat["source file \"", filename, "\" does not exist or is not readable\n"]);
46                    raise Error.ERROR)                    raise Error.ERROR)
47          (***** PARSING *****)          (***** PARSING *****)
48              val _ = verbosePrint["parsing ... "];
49            val parseTree = PhaseTimer.withTimer Timers.timeParser (fn () => let            val parseTree = PhaseTimer.withTimer Timers.timeParser (fn () => let
50                  val inS = TextIO.openIn filename                  val inS = TextIO.openIn filename
51                  val pt = Parser.parseFile (errStrm, inS)                  val pt = Parser.parseFile (errStrm, inS)
# Line 47  Line 54 
54                    checkForErrors errStrm;                    checkForErrors errStrm;
55                    valOf pt                    valOf pt
56                  end) ()                  end) ()
57              val _ = verbosePrint["done\n"];
58            val _ = dump Ctl.dumpPT (ParseTreePP.output errStrm) "parsing" parseTree            val _ = dump Ctl.dumpPT (ParseTreePP.output errStrm) "parsing" parseTree
59          (***** TYPECHECKING *****)          (***** TYPECHECKING *****)
60              val _ = verbosePrint["type checking ... "];
61            val _ = PhaseTimer.start Timers.timeTypechecker            val _ = PhaseTimer.start Timers.timeTypechecker
62            val ast = (Typechecker.check errStrm parseTree)            val ast = (Typechecker.check errStrm parseTree)
63            val _ = PhaseTimer.stop Timers.timeTypechecker            val _ = PhaseTimer.stop Timers.timeTypechecker
64              val _ = verbosePrint["done\n"];
65            val _ = checkForErrors errStrm            val _ = checkForErrors errStrm
66  (* TODO: check AST for consistency *)  (* TODO: check AST for consistency *)
67            val _ = dump Ctl.dumpAST ASTPP.output "typechecking" ast            val _ = dump Ctl.dumpAST ASTPP.output "typechecking" ast
68          (***** SIMPLIFY *****)          (***** SIMPLIFY *****)
69              val _ = verbosePrint["simplifying AST ... "];
70            val simple = SimpleOpt.checkAfter ("simplify", Simplify.transform (errStrm, ast))            val simple = SimpleOpt.checkAfter ("simplify", Simplify.transform (errStrm, ast))
71            val simple = SimpleOpt.transform simple            val simple = SimpleOpt.transform simple
72              val _ = verbosePrint["done\n"];
73            in            in
74              simple              simple
75            end            end
# Line 83  Line 95 
95                  (* end case *))                  (* end case *))
96            val simple = PhaseTimer.withTimer Timers.timeFront frontEnd filename            val simple = PhaseTimer.withTimer Timers.timeFront frontEnd filename
97          (***** TRANSLATION TO HIGH IR*****)          (***** TRANSLATION TO HIGH IR*****)
98              val _ = verbosePrint["translating to HighIR ... "];
99            val high = Translate.translate simple            val high = Translate.translate simple
100              val _ = verbosePrint["done\n"];
101            val _ = dump Ctl.dumpHighIR HighPP.output "translate" high            val _ = dump Ctl.dumpHighIR HighPP.output "translate" high
102          (***** HIGH-IR OPTIMIZATION *****)          (***** HIGH-IR OPTIMIZATION *****)
103              val _ = verbosePrint["optimizing HighIR ... "];
104            val high = HighOptimizer.optimize high            val high = HighOptimizer.optimize high
105              val _ = verbosePrint["done\n"];
106          (***** TRANSLATION TO MID IR *****)          (***** TRANSLATION TO MID IR *****)
107              val _ = verbosePrint["translating to MidIR ... "];
108            val mid = HighToMid.translate high            val mid = HighToMid.translate high
109              val _ = verbosePrint["done\n"];
110            val _ = dump Ctl.dumpMidIR MidPP.output "high-to-mid" mid            val _ = dump Ctl.dumpMidIR MidPP.output "high-to-mid" mid
111          (***** MID-IR OPTIMIZATION *****)          (***** MID-IR OPTIMIZATION *****)
112              val _ = verbosePrint["optimizing MidIR ... "];
113            val mid = MidOptimizer.optimize mid            val mid = MidOptimizer.optimize mid
114              val _ = verbosePrint["done\n"];
115          (***** TRANSLATION TO LOW IR *****)          (***** TRANSLATION TO LOW IR *****)
116              val _ = verbosePrint["translating to LowIR ... "];
117            val low = MidToLow.translate mid            val low = MidToLow.translate mid
118              val _ = verbosePrint["done\n"];
119            val _ = dump Ctl.dumpLowIR LowPP.output "mid-to-low" low            val _ = dump Ctl.dumpLowIR LowPP.output "mid-to-low" low
120  (* TODO *)          (***** LOW-IR OPTIMIZATION *****)
121              val _ = verbosePrint["optimizing LowIR ... "];
122              val low = LowOptimizer.optimize low
123              val _ = verbosePrint["done\n"];
124            (***** TRANSLATION TO TREE IR *****)
125    (* TODO *
126              val _ = verbosePrint["translating to TreeIR ... "];
127              val tree = LowToTree.translate low
128              val _ = verbosePrint["done\n"];
129              val _ = dump Ctl.dumpLowIR TreePP.output "low-to-tree" tree
130    *)
131            in            in
132            (***** CODE GENERATION *****)            (***** CODE GENERATION *****)
133  (* TODO *)()  (* TODO *)()
# Line 127  Line 159 
159                    then (print(Version.message ^ "\n"); OS.Process.success)                    then (print(Version.message ^ "\n"); OS.Process.success)
160                    else let                    else let
161                      val {base, ...} = OS.Path.splitBaseExt file                      val {base, ...} = OS.Path.splitBaseExt file
162                        val logging = Controls.get Ctl.enableLog
163                      in                      in
164                      (* set the default real type *)                      (* set the default real type *)
165                        if #double target then (RawTypes.realTy := RawTypes.RT_Double) else ();                        if #double target then (RawTypes.realTy := RawTypes.RT_Double) else ();
166                        if CmdLineConstants.initFromArgs defs                        if CmdLineConstants.initFromArgs defs
167                          then (                          then (
168                            if Controls.get Ctl.enableLog                            if logging
169                              then Log.init(base ^ ".log")                              then Log.init(base ^ ".log")
170                              else ();                              else ();
171                            PhaseTimer.withTimer Timers.timeCompiler                            PhaseTimer.withTimer Timers.timeCompiler
172                              doFile (target, file);                              doFile (target, file);
173                            Stats.report ();                            if Controls.get Ctl.collectStats
174                                then (
175                                  if (not logging)
176                                    then Log.init(base ^ ".stats")
177                                    else ();
178                                  Stats.report ())
179                                else ();
180                            Log.reportTiming Timers.timeCompiler;                            Log.reportTiming Timers.timeCompiler;
181                            OS.Process.success                            OS.Process.success
182                          ) handle exn => handleExn exn                          ) handle exn => handleExn exn

Legend:
Removed from v.3711  
changed lines
  Added in v.3753

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