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

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/options/ctl.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/options/ctl.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4317 - (view) (download)

1 : jhr 3351 (* ctl.sml
2 :     *
3 :     * Internal compiler controls. These may be set from the command-line, but are
4 :     * mainly meant to be used by the developers for debugging purposes.
5 :     *
6 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
7 :     *
8 :     * COPYRIGHT (c) 2015 The University of Chicago
9 :     * All rights reserved.
10 :     *)
11 :    
12 :     structure Ctl =
13 :     struct
14 :    
15 :     local
16 :     structure C = Controls
17 :     in
18 : jhr 3513
19 : jhr 3411 val enableLog = C.genControl {
20 : jhr 4317 name = "log",
21 :     pri = [1, 1],
22 :     obscurity = 5,
23 :     help = "output compiler debugging message to a log file",
24 :     default = false
25 :     }
26 : jhr 3411 val collectStats = C.genControl {
27 : jhr 4317 name = "stats",
28 :     pri = [1, 2],
29 :     obscurity = 5,
30 :     help = "collect and report statistics about optimizations, etc.",
31 :     default = false
32 :     }
33 : jhr 3731 val verbose = C.genControl {
34 : jhr 4317 name = "verbose",
35 :     pri = [1, 3],
36 :     obscurity = 5,
37 :     help = "print messages to stderr as each compiler stage starts and ends",
38 :     default = false
39 :     }
40 : jhr 3513
41 : jhr 4171 val inline = C.genControl {
42 : jhr 4317 name = "inlining",
43 :     pri = [2, 0, 0],
44 :     obscurity = 5,
45 :     help = "disable inlining of user-defined functions",
46 :     default = true
47 :     }
48 : jhr 3513 val highVN = C.genControl {
49 : jhr 4317 name = "high-vn",
50 :     pri = [2, 1, 0],
51 :     obscurity = 5,
52 :     help = "disable high-ir value numbering",
53 :     default = true
54 :     }
55 : jhr 3513 val midVN = C.genControl {
56 : jhr 4317 name = "mid-vn",
57 :     pri = [2, 2, 0],
58 :     obscurity = 5,
59 :     help = "disable mid-ir value numbering",
60 :     default = true
61 :     }
62 : jhr 3584 val midContract = C.genControl {
63 : jhr 4317 name = "mid-contract",
64 :     pri = [2, 2, 1],
65 :     obscurity = 5,
66 :     help = "disable mid-ir contraction",
67 :     default = true
68 :     }
69 : jhr 3513 val lowVN = C.genControl {
70 : jhr 4317 name = "low-vn",
71 :     pri = [2, 3, 0],
72 :     obscurity = 5,
73 :     help = "disable low-ir value numbering",
74 :     default = true
75 :     }
76 : jhr 3747 val lowContract = C.genControl {
77 : jhr 4317 name = "low-contract",
78 :     pri = [2, 3, 1],
79 :     obscurity = 5,
80 :     help = "disable low-ir contraction",
81 :     default = true
82 :     }
83 : jhr 3877 val treeContract = C.genControl {
84 :     name = "tree-contract",
85 :     pri = [2, 4, 0],
86 :     obscurity = 5,
87 :     help = "disable tree-ir contraction",
88 :     default = true
89 :     }
90 : jhr 4171 val optimizeControls = [
91 : jhr 4317 inline, highVN, midVN, midContract, lowVN, lowContract, treeContract
92 :     ]
93 : jhr 3513
94 : jhr 3432 val dumpPT = C.genControl {
95 : jhr 4317 name = "dump-pt",
96 :     pri = [3, 0],
97 :     obscurity = 5,
98 :     help = "dump the parse tree to the log file",
99 :     default = false
100 :     }
101 : jhr 3411 val dumpAST = C.genControl {
102 : jhr 4317 name = "dump-ast",
103 :     pri = [3, 1],
104 :     obscurity = 5,
105 :     help = "dump the AST to the log file",
106 :     default = false
107 :     }
108 : jhr 3411 val dumpSimple = C.genControl {
109 : jhr 4317 name = "dump-simple",
110 :     pri = [3, 2],
111 :     obscurity = 5,
112 :     help = "dump the SimpleAST to the log file",
113 :     default = false
114 :     }
115 : jhr 3521 val dumpHighIR = C.genControl {
116 : jhr 4317 name = "dump-high",
117 :     pri = [3, 3],
118 :     obscurity = 5,
119 :     help = "dump the HighIR to the log file",
120 :     default = false
121 :     }
122 : jhr 3521 val dumpMidIR = C.genControl {
123 : jhr 4317 name = "dump-mid",
124 :     pri = [3, 4],
125 :     obscurity = 5,
126 :     help = "dump the MidIR to the log file",
127 :     default = false
128 :     }
129 : jhr 3521 val dumpLowIR = C.genControl {
130 : jhr 4317 name = "dump-low",
131 :     pri = [3, 5],
132 :     obscurity = 5,
133 :     help = "dump the LowIR to the log file",
134 :     default = false
135 :     }
136 : jhr 3521 val dumpTreeIR = C.genControl {
137 : jhr 4317 name = "dump-tree",
138 :     pri = [3, 6],
139 :     obscurity = 5,
140 :     help = "dump the TreeIR to the log file",
141 :     default = false
142 :     }
143 : jhr 3521 val dumpControls = [dumpPT, dumpAST, dumpSimple, dumpHighIR, dumpMidIR, dumpLowIR, dumpTreeIR]
144 : jhr 4101 val compactCFG = ref true
145 :     val dumpCFG = ref false
146 : jhr 3507 val dumpAll = ref false
147 :    
148 : jhr 3411 val checkAST = C.genControl {
149 : jhr 4317 name = "check-ast",
150 :     pri = [4, 1],
151 :     obscurity = 5,
152 :     help = "check the AST after typechecking",
153 :     default = false
154 :     }
155 : jhr 3411 val checkSimple = C.genControl {
156 : jhr 4317 name = "check-simple",
157 :     pri = [4, 2],
158 :     obscurity = 5,
159 :     help = "check the SimpleAST",
160 :     default = false
161 :     }
162 : jhr 3521 val checkHighIR = C.genControl {
163 : jhr 4317 name = "check-high",
164 :     pri = [4, 3],
165 :     obscurity = 5,
166 :     help = "check the HighIR",
167 :     default = false
168 :     }
169 : jhr 3521 val checkMidIR = C.genControl {
170 : jhr 4317 name = "check-mid",
171 :     pri = [4, 4],
172 :     obscurity = 5,
173 :     help = "check the MidIR",
174 :     default = false
175 :     }
176 : jhr 3521 val checkLowIR = C.genControl {
177 : jhr 4317 name = "check-low",
178 :     pri = [4, 5],
179 :     obscurity = 5,
180 :     help = "check the LowIR",
181 :     default = false
182 :     }
183 : jhr 3521 val checkTreeIR = C.genControl {
184 : jhr 4317 name = "check-tree",
185 :     pri = [4, 6],
186 :     obscurity = 5,
187 :     help = "check the TreeIR",
188 :     default = false
189 :     }
190 : jhr 3521 val checkControls = [checkAST, checkSimple, checkHighIR, checkMidIR, checkLowIR, checkTreeIR]
191 : jhr 3507 val checkAll = ref false
192 : jhr 3351
193 : jhr 4277 (* after the controls have been set from the command line, we use this function
194 :     * to enable logging if any of the dump or check options have been selected.
195 :     *)
196 : jhr 3507 fun resolve () = (
197 : jhr 4317 if !dumpAll
198 :     then List.app (fn ctl => C.set(ctl, true)) dumpControls
199 :     else if !dumpCFG
200 :     then List.app (fn ctl => C.set(ctl, true)) [dumpHighIR, dumpMidIR, dumpLowIR]
201 :     else ();
202 :     if !checkAll
203 :     then List.app (fn ctl => C.set(ctl, true)) checkControls
204 :     else ();
205 :     if not(C.get enableLog)
206 :     andalso List.exists C.get (dumpControls @ checkControls)
207 :     then C.set (enableLog, true)
208 :     else ())
209 : jhr 3351
210 :     end (* local *)
211 :    
212 :     end

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