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 3863, Sun May 15 17:18:04 2016 UTC
# Line 6  Line 6 
6   * All rights reserved.   * All rights reserved.
7   *)   *)
8    
9    (* this is a dummy target for debugging purposes *)
10    structure DummyTarget =
11      struct
12    
13        fun info double = {
14                layout = DefaultLayout.layout (DefaultLayout.gccVectorSizes double),
15                isInline =
16                   fn LowOps.EigenVecs2x2 => false
17                    | LowOps.EigenVecs3x3 => false
18                    | LowOps.EigenVals2x2 => false
19                    | LowOps.EigenVals3x3 => false
20                    | _ => true
21              }
22    
23      end
24    
25  structure Main : sig  structure Main : sig
26    
27      val main : (string * string list) -> OS.Process.status      val main : (string * string list) -> OS.Process.status
# Line 18  Line 34 
34    
35      fun quitWithError srcFile = raise Error.ERROR      fun quitWithError srcFile = raise Error.ERROR
36    
37      (* messages in verbose mode *)
38    (* FIXME: perhaps we should include timing info? *)
39        fun verbosePrint msg = if Controls.get Ctl.verbose
40              then TextIO.output(TextIO.stdErr, concat msg)
41              else ()
42    
43    (* check for errors and report them if there are any *)    (* check for errors and report them if there are any *)
44      fun checkForErrors errStrm =      fun checkForErrors errStrm =
45            if Error.anyErrors errStrm            if Error.anyErrors errStrm
# Line 39  Line 61 
61                    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"]);
62                    raise Error.ERROR)                    raise Error.ERROR)
63          (***** PARSING *****)          (***** PARSING *****)
64              val _ = verbosePrint["parsing ... "];
65            val parseTree = PhaseTimer.withTimer Timers.timeParser (fn () => let            val parseTree = PhaseTimer.withTimer Timers.timeParser (fn () => let
66                  val inS = TextIO.openIn filename                  val inS = TextIO.openIn filename
67                  val pt = Parser.parseFile (errStrm, inS)                  val pt = Parser.parseFile (errStrm, inS)
# Line 47  Line 70 
70                    checkForErrors errStrm;                    checkForErrors errStrm;
71                    valOf pt                    valOf pt
72                  end) ()                  end) ()
73              val _ = verbosePrint["done\n"];
74            val _ = dump Ctl.dumpPT (ParseTreePP.output errStrm) "parsing" parseTree            val _ = dump Ctl.dumpPT (ParseTreePP.output errStrm) "parsing" parseTree
75          (***** TYPECHECKING *****)          (***** TYPECHECKING *****)
76              val _ = verbosePrint["type checking ... "];
77            val _ = PhaseTimer.start Timers.timeTypechecker            val _ = PhaseTimer.start Timers.timeTypechecker
78            val ast = (Typechecker.check errStrm parseTree)            val ast = (Typechecker.check errStrm parseTree)
79            val _ = PhaseTimer.stop Timers.timeTypechecker            val _ = PhaseTimer.stop Timers.timeTypechecker
80              val _ = verbosePrint["done\n"];
81            val _ = checkForErrors errStrm            val _ = checkForErrors errStrm
82  (* TODO: check AST for consistency *)  (* TODO: check AST for consistency *)
83            val _ = dump Ctl.dumpAST ASTPP.output "typechecking" ast            val _ = dump Ctl.dumpAST ASTPP.output "typechecking" ast
84          (***** SIMPLIFY *****)          (***** SIMPLIFY *****)
85              val _ = verbosePrint["simplifying AST ... "];
86            val simple = SimpleOpt.checkAfter ("simplify", Simplify.transform (errStrm, ast))            val simple = SimpleOpt.checkAfter ("simplify", Simplify.transform (errStrm, ast))
87            val simple = SimpleOpt.transform simple            val simple = SimpleOpt.transform simple
88              val _ = verbosePrint["done\n"];
89            in            in
90              simple              simple
91            end            end
# Line 76  Line 104 
104              before finish()              before finish()
105            end            end
106    
107      fun doFile (target : Target.desc, filename) = let      fun doFile (target : TargetOptions.t, filename) = let
108              val {info, generate} = Targets.get target
109            val baseName = (case OS.Path.splitBaseExt filename            val baseName = (case OS.Path.splitBaseExt filename
110                   of {base, ext=SOME "diderot"} => base                   of {base, ext=SOME "diderot"} => base
111                    | _ => (errnl "expected diderot file"; quitWithError filename)                    | _ => (errnl "expected diderot file"; quitWithError filename)
112                  (* end case *))                  (* end case *))
113            val simple = PhaseTimer.withTimer Timers.timeFront frontEnd filename            val simple = PhaseTimer.withTimer Timers.timeFront frontEnd filename
114          (***** TRANSLATION TO HIGH IR*****)          (***** TRANSLATION TO HIGH IR*****)
115            val high = Translate.translate simple            val _ = verbosePrint["translating to HighIR ... "];
116            val _ = dump Ctl.dumpHighIR HighPP.output "translate" high            val high = PhaseTimer.withTimer Timers.timeTranslate Translate.translate simple
117              val _ = verbosePrint["done\n"];
118              val high = HighOptimizer.checkAfter ("simple-to-high translation", high)
119          (***** HIGH-IR OPTIMIZATION *****)          (***** HIGH-IR OPTIMIZATION *****)
120            val high = HighOptimizer.optimize high            val _ = verbosePrint["optimizing HighIR ... "];
121              val high = PhaseTimer.withTimer Timers.timeHigh HighOptimizer.optimize high
122              val _ = verbosePrint["done\n"];
123          (***** TRANSLATION TO MID IR *****)          (***** TRANSLATION TO MID IR *****)
124            val mid = HighToMid.translate high            val _ = verbosePrint["translating to MidIR ... "];
125            val _ = dump Ctl.dumpMidIR MidPP.output "high-to-mid" mid            val mid = PhaseTimer.withTimer Timers.timeHighToMid HighToMid.translate high
126              val _ = verbosePrint["done\n"];
127              val mid = MidOptimizer.checkAfter ("high-to-mid translation", mid)
128          (***** MID-IR OPTIMIZATION *****)          (***** MID-IR OPTIMIZATION *****)
129            val mid = MidOptimizer.optimize mid            val _ = verbosePrint["optimizing MidIR ... "];
130              val mid = PhaseTimer.withTimer Timers.timeMid MidOptimizer.optimize mid
131              val _ = verbosePrint["done\n"];
132          (***** TRANSLATION TO LOW IR *****)          (***** TRANSLATION TO LOW IR *****)
133            val low = MidToLow.translate mid            val _ = verbosePrint["translating to LowIR ... "];
134            val _ = dump Ctl.dumpLowIR LowPP.output "mid-to-low" low            val low = PhaseTimer.withTimer Timers.timeMidToLow MidToLow.translate mid
135  (* TODO *)            val _ = verbosePrint["done\n"];
136              val low = LowOptimizer.checkAfter ("mid-to-low translation", low)
137            (***** LOW-IR OPTIMIZATION *****)
138              val _ = verbosePrint["optimizing LowIR ... "];
139              val low = PhaseTimer.withTimer Timers.timeLow LowOptimizer.optimize low
140              val _ = verbosePrint["done\n"];
141            (***** TRANSLATION TO TREE IR *****)
142              val _ = verbosePrint["translating to TreeIR ... "];
143              val tree = PhaseTimer.withTimer Timers.timeLowToTree LowToTree.translate (low, info)
144              val _ = verbosePrint["done\n"];
145              val tree = TreeOptimizer.checkAfter ("low-to-tree translation", tree)
146            (***** TREE-IR OPTIMIZATION *****)
147              val _ = verbosePrint["optimizing TreeIR ... "];
148              val tree = PhaseTimer.withTimer Timers.timeTree TreeOptimizer.optimize tree
149              val _ = verbosePrint["done\n"];
150            in            in
151            (***** CODE GENERATION *****)            (***** CODE GENERATION *****)
152  (* TODO *)()              PhaseTimer.withTimer Timers.timeCodegen generate tree
153            end            end
154    
155      fun usage (cmd, long) = TextIO.output(TextIO.stdErr, Options.usage (cmd, long))      fun usage (cmd, long) = TextIO.output(TextIO.stdErr, Options.usage (cmd, long))
# Line 113  Line 164 
164            OS.Process.failure)            OS.Process.failure)
165    
166      fun main (name: string, args: string list) = let      fun main (name: string, args: string list) = let
167              val _ = PhaseTimer.start Timers.timeCompiler
168            val {help, version, target, defs, file} =            val {help, version, target, defs, file} =
169                  (Options.parseCmdLine args)                  (Options.parseCmdLine args)
170                    handle Options.Usage msg => (                    handle Options.Usage msg => (
# Line 127  Line 179 
179                    then (print(Version.message ^ "\n"); OS.Process.success)                    then (print(Version.message ^ "\n"); OS.Process.success)
180                    else let                    else let
181                      val {base, ...} = OS.Path.splitBaseExt file                      val {base, ...} = OS.Path.splitBaseExt file
182                        val logging = Controls.get Ctl.enableLog
183                      in                      in
184                      (* set the default real type *)                      (* set the default real type *)
185                        if #double target then (RawTypes.realTy := RawTypes.RT_Double) else ();                        if #double target then (RawTypes.realTy := RawTypes.RT_Double) else ();
186                        if CmdLineConstants.initFromArgs defs                        if CmdLineConstants.initFromArgs defs
187                          then (                          then (
188                            if Controls.get Ctl.enableLog                            if logging
189                              then Log.init(base ^ ".log")                              then Log.init(base ^ ".log")
190                              else ();                              else ();
                           PhaseTimer.withTimer Timers.timeCompiler  
191                              doFile (target, file);                              doFile (target, file);
192                            Stats.report ();                            if Controls.get Ctl.collectStats
193                                then (
194                                  if (not logging)
195                                    then Log.init(base ^ ".stats")
196                                    else ();
197                                  Stats.report ())
198                                else ();
199                              PhaseTimer.stop Timers.timeCompiler;
200                            Log.reportTiming Timers.timeCompiler;                            Log.reportTiming Timers.timeCompiler;
201                            OS.Process.success                            OS.Process.success
202                          ) handle exn => handleExn exn                          ) handle exn => handleExn exn

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

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