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

SCM Repository

[diderot] Annotation of /branches/charisee/src/compiler/tree-il/low-to-tree-fn.sml
ViewVC logotype

Annotation of /branches/charisee/src/compiler/tree-il/low-to-tree-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1640 - (view) (download)
Original Path: trunk/src/compiler/tree-il/low-to-tree-fn.sml

1 : jhr 1115 (* low-to-tree-fn.sml
2 :     *
3 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * This module translates the LowIL representation of a program (i.e., a pure CFG) to
7 :     * a block-structured AST with nested expressions.
8 :     *
9 :     * NOTE: this translation is pretty dumb about variable coalescing (i.e., it doesn't do any).
10 :     *)
11 :    
12 :     functor LowToTreeFn (Target : sig
13 :    
14 : jhr 1640 val supportsPrinting : unit -> bool (* does the target support the Print op? *)
15 :    
16 : jhr 1115 (* tests for whether various expression forms can appear inline *)
17 :     val inlineCons : int -> bool (* can n'th-order tensor construction appear inline *)
18 :     val inlineMatrixExp : bool (* can matrix-valued expressions appear inline? *)
19 :    
20 :     end) : sig
21 :    
22 :     val translate : LowIL.program -> TreeIL.program
23 :    
24 :     end = struct
25 :    
26 :     structure IL = LowIL
27 :     structure Ty = LowILTypes
28 :     structure V = LowIL.Var
29 : jhr 1640 structure StV = LowIL.StateVar
30 : jhr 1115 structure Op = LowOps
31 :     structure Nd = LowIL.Node
32 :     structure CFG = LowIL.CFG
33 :     structure T = TreeIL
34 :     structure VA = VarAnalysis
35 :    
36 :     (* create new tree IL variables *)
37 :     local
38 :     fun newVar (name, kind, ty) = T.V{
39 :     name = name,
40 :     id = Stamp.new(),
41 :     kind = kind,
42 :     ty = ty
43 :     }
44 :     val cnt = ref 0
45 :     fun genName prefix = let
46 :     val n = !cnt
47 :     in
48 :     cnt := n+1;
49 :     String.concat[prefix, "_", Int.toString n]
50 :     end
51 :     in
52 :     fun newGlobal x = newVar ("G_" ^ V.name x, T.VK_Global, V.ty x)
53 :     fun newParam x = newVar (genName("p_" ^ V.name x), T.VK_Local, V.ty x)
54 :     fun newLocal x = newVar (genName("l_" ^ V.name x), T.VK_Local, V.ty x)
55 :     fun newIter x = newVar (genName("i_" ^ V.name x), T.VK_Local, V.ty x)
56 :     end
57 :    
58 : jhr 1640 (* associate Tree IL state variables with Low IL variables using properties *)
59 :     local
60 :     fun mkStateVar x = T.SV{
61 :     name = StV.name x,
62 :     id = Stamp.new(),
63 :     ty = StV.ty x,
64 :     varying = VA.isVarying x,
65 :     output = StV.isOutput x
66 :     }
67 :     in
68 :     val {getFn = getStateVar, ...} = StV.newProp mkStateVar
69 :     end
70 :    
71 : jhr 1115 fun mkBlock stms = T.Block{locals=[], body=stms}
72 :     fun mkIf (x, stms, []) = T.S_IfThen(x, mkBlock stms)
73 :     | mkIf (x, stms1, stms2) = T.S_IfThenElse(x, mkBlock stms1, mkBlock stms2)
74 :    
75 :     (* an environment that tracks bindings of variables to target expressions and the list
76 :     * of locals that have been defined.
77 :     *)
78 :     local
79 :     structure VT = V.Tbl
80 :     fun decCount (IL.V{useCnt, ...}) = let
81 :     val n = !useCnt - 1
82 :     in
83 :     useCnt := n; (n <= 0)
84 :     end
85 :     datatype target_binding
86 :     = GLOB of T.var (* variable is global *)
87 :     | TREE of T.exp (* variable bound to target expression tree *)
88 :     | DEF of T.exp (* either a target variable or constant for a defined variable *)
89 :     datatype env = E of {
90 :     tbl : target_binding VT.hash_table,
91 :     locals : T.var list
92 :     }
93 :     in
94 :     (* DEBUG *)
95 :     fun bindToString binding = (case binding
96 :     of GLOB y => "GLOB " ^ T.Var.name y
97 :     | TREE e => "TREE"
98 :     | DEF(T.E_Var y) => "DEF " ^ T.Var.name y
99 :     | DEF e => "DEF"
100 :     (* end case *))
101 :     fun dumpEnv (E{tbl, ...}) = let
102 :     fun prEntry (x, binding) =
103 :     print(concat[" ", IL.Var.toString x, " --> ", bindToString binding, "\n"])
104 :     in
105 :     print "*** dump environment\n";
106 :     VT.appi prEntry tbl;
107 :     print "***\n"
108 :     end
109 :     (* DEBUG *)
110 :    
111 :     fun newEnv () = E{tbl = VT.mkTable (512, Fail "tbl"), locals=[]}
112 :    
113 :     (* use a variable. If it is a pending expression, we remove it from the table *)
114 :     fun useVar (env as E{tbl, ...}) x = (case VT.find tbl x
115 :     of SOME(GLOB x') => T.E_Var x'
116 :     | SOME(TREE e) => (
117 :     (*print(concat["useVar ", V.toString x, " ==> TREE\n"]);*)
118 :     ignore(VT.remove tbl x);
119 :     e)
120 :     | SOME(DEF e) => (
121 :     (*print(concat["useVar ", V.toString x, " ==> ", bindToString(DEF e), "; use count = ", Int.toString(V.useCount x), "\n"]);*)
122 :     (* if this is the last use of x, then remove it from the table *)
123 :     if (decCount x) then ignore(VT.remove tbl x) else ();
124 :     e)
125 :     | NONE => (
126 :     dumpEnv env;
127 :     raise Fail(concat ["useVar(", V.toString x, ")"])
128 :     )
129 :     (* end case *))
130 :    
131 :     (* record a local variable *)
132 :     fun addLocal (E{tbl, locals}, x) = E{tbl=tbl, locals=x::locals}
133 :    
134 :     fun global (E{tbl, ...}, x, x') = VT.insert tbl (x, GLOB x')
135 :    
136 :     (* insert a pending expression into the table. Note that x should only be used once! *)
137 :     fun insert (env as E{tbl, ...}, x, exp) = (
138 :     VT.insert tbl (x, TREE exp);
139 :     env)
140 :    
141 :     fun rename (env as E{tbl, ...}, x, x') = (
142 :     VT.insert tbl (x, DEF(T.E_Var x'));
143 :     env)
144 :    
145 :     fun peekGlobal (E{tbl, ...}, x) = (case VT.find tbl x
146 :     of SOME(GLOB x') => SOME x'
147 :     | _ => NONE
148 :     (* end case *))
149 :    
150 :     fun bindLocal (env, lhs, rhs) = if (V.useCount lhs = 1)
151 :     then (insert(env, lhs, rhs), [])
152 :     else let
153 :     val t = newLocal lhs
154 :     in
155 : jhr 1640 (rename(addLocal(env, t), lhs, t), [T.S_Assign([t], rhs)])
156 : jhr 1115 end
157 :    
158 :     fun bind (env, lhs, rhs) = (case peekGlobal (env, lhs)
159 : jhr 1640 of SOME x => (env, [T.S_Assign([x], rhs)])
160 : jhr 1115 | NONE => bindLocal (env, lhs, rhs)
161 :     (* end case *))
162 :    
163 :     (* set the definition of a variable, where the RHS is either a literal constant or a variable *)
164 :     fun bindSimple (env as E{tbl, ...}, lhs, rhs) = (
165 :     case peekGlobal (env, lhs)
166 : jhr 1640 of SOME x => (env, [T.S_Assign([x], rhs)])
167 : jhr 1115 | NONE => (VT.insert tbl (lhs, DEF rhs); (env, []))
168 :     (* end case *))
169 :    
170 :     (* at the end of a block, we need to assign any pending expressions to locals. The
171 :     * blkStms list and the resulting statement list are in reverse order.
172 :     *)
173 :     fun flushPending (E{tbl, locals}, blkStms) = let
174 :     fun doVar (x, TREE e, (locals, stms)) = let
175 :     val t = newLocal x
176 :     in
177 :     VT.insert tbl (x, DEF(T.E_Var t));
178 : jhr 1640 (t::locals, T.S_Assign([t], e)::stms)
179 : jhr 1115 end
180 :     | doVar (_, _, acc) = acc
181 :     val (locals, stms) = VT.foldi doVar (locals, blkStms) tbl
182 :     in
183 :     (E{tbl=tbl, locals=locals}, stms)
184 :     end
185 :    
186 :     fun doPhi ((lhs, rhs), (env, predBlks : T.stm list list)) = let
187 :     (* t will be the variable in the continuation of the JOIN *)
188 :     val t = newLocal lhs
189 :     val predBlks = ListPair.map
190 : jhr 1640 (fn (x, stms) => T.S_Assign([t], useVar env x)::stms)
191 : jhr 1115 (rhs, predBlks)
192 :     in
193 :     (rename (addLocal(env, t), lhs, t), predBlks)
194 :     end
195 :    
196 :     fun endScope (E{locals, ...}, stms) = T.Block{
197 :     locals = List.rev locals,
198 :     body = stms
199 :     }
200 :    
201 :     end
202 :    
203 :     (* Certain IL operators cannot be compiled to inline expressions. Return
204 :     * false for those and true for all others.
205 :     *)
206 :     fun isInlineOp rator = let
207 :     fun chkTensorTy (Ty.TensorTy[]) = true
208 :     | chkTensorTy (Ty.TensorTy[_]) = true
209 :     | chkTensorTy (Ty.TensorTy _) = Target.inlineMatrixExp
210 :     | chkTensorTy _ = true
211 :     in
212 :     case rator
213 :     of Op.LoadVoxels(_, 1) => true
214 :     | Op.LoadVoxels _ => false
215 :     | Op.Add ty => chkTensorTy ty
216 :     | Op.Sub ty => chkTensorTy ty
217 :     | Op.Neg ty => chkTensorTy ty
218 :     | Op.Scale ty => chkTensorTy ty
219 :     | Op.MulMatMat _ => Target.inlineMatrixExp
220 : jhr 1640 | Op.EigenVecs2x2 => false
221 :     | Op.EigenVecs3x3 => false
222 :     | Op.EigenVals2x2 => false
223 :     | Op.EigenVals3x3 => false
224 : jhr 1115 | Op.Identity _ => Target.inlineMatrixExp
225 :     | Op.Zero _ => Target.inlineMatrixExp
226 :     | Op.TensorToWorldSpace(_, ty) => chkTensorTy ty
227 :     | _ => true
228 :     (* end case *)
229 :     end
230 :    
231 :     (* translate a LowIL assignment to a list of zero or more target statements *)
232 :     fun doAssign (env, (lhs, rhs)) = let
233 :     fun doLHS () = (case peekGlobal(env, lhs)
234 :     of SOME lhs' => (env, lhs')
235 :     | NONE => let
236 :     val t = newLocal lhs
237 :     in
238 :     (rename (addLocal(env, t), lhs, t), t)
239 :     end
240 :     (* end case *))
241 :     (* for expressions that are going to be compiled to a call statement *)
242 :     fun assignExp (env, exp) = let
243 :     (* operations that return matrices may not be supported inline *)
244 :     val (env, t) = doLHS()
245 :     in
246 : jhr 1640 (env, [T.S_Assign([t], exp)])
247 : jhr 1115 end
248 :     in
249 :     case rhs
250 : jhr 1640 of IL.STATE x => bindSimple (env, lhs, T.E_State(getStateVar x))
251 :     | IL.VAR x => bindSimple (env, lhs, useVar env x)
252 : jhr 1115 | IL.LIT lit => bindSimple (env, lhs, T.E_Lit lit)
253 :     | IL.OP(Op.LoadImage info, [a]) => let
254 :     val (env, t) = doLHS()
255 :     in
256 :     (env, [T.S_LoadImage(t, ImageInfo.dim info, useVar env a)])
257 :     end
258 : jhr 1301 | IL.OP(Op.Input(ty, name, desc), []) => let
259 : jhr 1115 val (env, t) = doLHS()
260 :     in
261 : jhr 1301 (env, [T.S_Input(t, name, desc, NONE)])
262 : jhr 1115 end
263 : jhr 1301 | IL.OP(Op.InputWithDefault(ty, name, desc), [a]) => let
264 : jhr 1115 val (env, t) = doLHS()
265 :     in
266 : jhr 1301 (env, [T.S_Input(t, name, desc, SOME(useVar env a))])
267 : jhr 1115 end
268 :     | IL.OP(rator, args) => let
269 :     val exp = T.E_Op(rator, List.map (useVar env) args)
270 :     in
271 :     if isInlineOp rator
272 :     then bind (env, lhs, exp)
273 :     else assignExp (env, exp)
274 :     end
275 :     | IL.APPLY(f, args) =>
276 :     bind (env, lhs, T.E_Apply(f, List.map (useVar env) args))
277 :     | IL.CONS(ty, args) => let
278 :     val inline = (case ty
279 : jhr 1640 of Ty.SeqTy(Ty.IntTy, _) => true
280 : jhr 1115 | Ty.TensorTy dd => Target.inlineCons(List.length dd)
281 :     (* end case *))
282 :     val exp = T.E_Cons(ty, List.map (useVar env) args)
283 :     in
284 :     if inline
285 :     then bind (env, lhs, exp)
286 :     else assignExp (env, exp)
287 :     end
288 :     (* end case *)
289 :     end
290 :    
291 :     (* In order to reconstruct the block-structure from the CFG, we keep a stack of open ifs.
292 :     * the items on this stack distinguish between when we are processing the then and else
293 :     * branches of the if.
294 :     *)
295 :     datatype open_if
296 :     (* working on the "then" branch. The fields are statments that preceed the if, the condition,
297 :     * and the else-branch node.
298 :     *)
299 :     = THEN_BR of T.stm list * T.exp * IL.node
300 :     (* working on the "else" branch. The fields are statments that preceed the if, the condition,
301 :     * the "then" branch statements, and the node that terminated the "then" branch (will be
302 :     * a JOIN, DIE, or STABILIZE).
303 :     *)
304 :     | ELSE_BR of T.stm list * T.exp * T.stm list * IL.node_kind
305 :    
306 :     fun trCFG (env, prefix, finish, cfg) = let
307 :     fun join (env, [], _, IL.JOIN _) = raise Fail "JOIN with no open if"
308 :     | join (env, [], stms, _) = endScope (env, prefix @ List.rev stms)
309 :     | join (env, THEN_BR(stms1, cond, elseBr)::stk, thenBlk, k) = let
310 :     val (env, thenBlk) = flushPending (env, thenBlk)
311 :     in
312 :     doNode (env, ELSE_BR(stms1, cond, thenBlk, k)::stk, [], elseBr)
313 :     end
314 :     | join (env, ELSE_BR(stms, cond, thenBlk, k1)::stk, elseBlk, k2) = let
315 :     val (env, elseBlk) = flushPending (env, elseBlk)
316 :     in
317 :     case (k1, k2)
318 :     of (IL.JOIN{phis, succ, ...}, IL.JOIN _) => let
319 :     val (env, [thenBlk, elseBlk]) =
320 :     List.foldl doPhi (env, [thenBlk, elseBlk]) (!phis)
321 :     val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
322 :     in
323 :     doNode (env, stk, stm::stms, !succ)
324 :     end
325 :     | (IL.JOIN{phis, succ, ...}, _) => let
326 :     val (env, [thenBlk]) = List.foldl doPhi (env, [thenBlk]) (!phis)
327 :     val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
328 :     in
329 :     doNode (env, stk, stm::stms, !succ)
330 :     end
331 :     | (_, IL.JOIN{phis, succ, ...}) => let
332 :     val (env, [elseBlk]) = List.foldl doPhi (env, [elseBlk]) (!phis)
333 :     val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
334 :     in
335 :     doNode (env, stk, stm::stms, !succ)
336 :     end
337 :     | (_, _) => raise Fail "no path to exit unimplemented" (* FIXME *)
338 :     (* end case *)
339 :     end
340 :     and doNode (env, ifStk : open_if list, stms, nd) = (
341 :     case Nd.kind nd
342 :     of IL.NULL => raise Fail "unexpected NULL"
343 :     | IL.ENTRY{succ} => doNode (env, ifStk, stms, !succ)
344 :     | k as IL.JOIN{phis, succ, ...} => join (env, ifStk, stms, k)
345 :     | IL.COND{cond, trueBranch, falseBranch, ...} => let
346 :     val cond = useVar env cond
347 :     val (env, stms) = flushPending (env, stms)
348 :     in
349 :     doNode (env, THEN_BR(stms, cond, !falseBranch)::ifStk, [], !trueBranch)
350 :     end
351 :     | IL.COM {text, succ, ...} =>
352 :     doNode (env, ifStk, T.S_Comment text :: stms, !succ)
353 :     | IL.ASSIGN{stm, succ, ...} => let
354 :     val (env, stms') = doAssign (env, stm)
355 :     in
356 :     doNode (env, ifStk, stms' @ stms, !succ)
357 :     end
358 : jhr 1640 | IL.MASSIGN{stm=(ys, rator, xs), succ, ...} => let
359 :     fun doit () = let
360 :     fun doLHSVar (y, (env, ys)) = (case peekGlobal(env, y)
361 :     of SOME y' => (env, y'::ys)
362 :     | NONE => let
363 :     val t = newLocal y
364 :     in
365 :     (rename (addLocal(env, t), y, t), t::ys)
366 :     end
367 :     (* end case *))
368 :     val (env, ys) = List.foldr doLHSVar (env, []) ys
369 :     val exp = T.E_Op(rator, List.map (useVar env) xs)
370 :     val stm = T.S_Assign(ys, exp)
371 :     in
372 :     doNode (env, ifStk, stm :: stms, !succ)
373 :     end
374 :     in
375 :     case rator
376 :     of Op.Print _ => if Target.supportsPrinting()
377 :     then doit ()
378 :     else doNode (env, ifStk, stms, !succ)
379 :     | _ => doit()
380 :     (* end case *)
381 :     end
382 : jhr 1115 | IL.NEW{strand, args, succ, ...} => raise Fail "NEW unimplemented"
383 : jhr 1640 | IL.SAVE{lhs, rhs, succ, ...} => let
384 :     val stm = T.S_Save([getStateVar lhs], useVar env rhs)
385 :     in
386 :     doNode (env, ifStk, stm::stms, !succ)
387 :     end
388 : jhr 1115 | k as IL.EXIT{kind, live, ...} => (case kind
389 :     of ExitKind.FRAGMENT =>
390 :     endScope (env, prefix @ List.revAppend(stms, finish env))
391 : jhr 1232 | ExitKind.SINIT => let
392 :     (* FIXME: we should probably call flushPending here! *)
393 : jhr 1640 val suffix = finish env @ [T.S_Exit[]]
394 : jhr 1232 in
395 :     endScope (env, prefix @ List.revAppend(stms, suffix))
396 :     end
397 : jhr 1115 | ExitKind.RETURN => let
398 :     (* FIXME: we should probably call flushPending here! *)
399 :     val suffix = finish env @ [T.S_Exit(List.map (useVar env) live)]
400 :     in
401 :     endScope (env, prefix @ List.revAppend(stms, suffix))
402 :     end
403 :     | ExitKind.ACTIVE => let
404 :     (* FIXME: we should probably call flushPending here! *)
405 : jhr 1640 val suffix = finish env @ [T.S_Active]
406 : jhr 1115 in
407 :     endScope (env, prefix @ List.revAppend(stms, suffix))
408 :     end
409 :     | ExitKind.STABILIZE => let
410 :     (* FIXME: we should probably call flushPending here! *)
411 : jhr 1640 val stms = T.S_Stabilize :: stms
412 : jhr 1115 in
413 :     (* FIXME: we should probably call flushPending here! *)
414 :     join (env, ifStk, stms, k)
415 :     end
416 :     | ExitKind.DIE => join (env, ifStk, T.S_Die :: stms, k)
417 :     (* end case *))
418 :     (* end case *))
419 :     in
420 :     doNode (env, [], [], CFG.entry cfg)
421 :     end
422 :    
423 :     fun trInitially (env, IL.Initially{isArray, rangeInit, iters, create=(createInit, strand, args)}) =
424 :     let
425 :     val iterPrefix = trCFG (env, [], fn _ => [], rangeInit)
426 :     fun cvtIter ((param, lo, hi), (env, iters)) = let
427 :     val param' = newIter param
428 :     val env = rename (env, param, param')
429 :     in
430 :     (env, (param', useVar env lo, useVar env hi)::iters)
431 :     end
432 :     val (env, iters) = List.foldr cvtIter (env, []) iters
433 :     val createPrefix = trCFG (env, [], fn _ => [], createInit)
434 :     in {
435 :     isArray = isArray,
436 :     iterPrefix = iterPrefix,
437 :     iters = iters,
438 :     createPrefix = createPrefix,
439 :     strand = strand,
440 :     args = List.map (useVar env) args
441 :     } end
442 :    
443 : jhr 1640 fun trMethod env (IL.Method{name, body}) = T.Method{
444 :     name = name,
445 :     body = trCFG (env, [], fn _ => [], body)
446 :     }
447 : jhr 1115
448 : jhr 1640 fun trStrand globalEnv (IL.Strand{name, params, state, stateInit, methods}) = let
449 : jhr 1115 val params' = List.map newParam params
450 : jhr 1640 val env = ListPair.foldlEq (fn (x, x', env) => rename(env, x, x')) globalEnv (params, params')
451 : jhr 1115 in
452 :     T.Strand{
453 :     name = name,
454 :     params = params',
455 : jhr 1640 state = List.map getStateVar state,
456 : jhr 1115 stateInit = trCFG (env, [], fn _ => [], stateInit),
457 : jhr 1640 methods = List.map (trMethod env) methods
458 : jhr 1115 }
459 :     end
460 :    
461 : jhr 1301 (* split the globalInit into the part that specifies the inputs and the rest of
462 :     * the global initialization.
463 :     *)
464 :     fun splitGlobalInit globalInit = let
465 :     fun walk (nd, lastInput, live) = (case Nd.kind nd
466 :     of IL.ENTRY{succ} => walk (!succ, lastInput, live)
467 :     | IL.COM{succ, ...} => walk (!succ, lastInput, live)
468 :     | IL.ASSIGN{stm=(lhs, rhs), succ, ...} => (case rhs
469 :     of IL.OP(Op.Input _, _) => walk (!succ, nd, lhs::live)
470 :     | IL.OP(Op.InputWithDefault _, _) => walk (!succ, nd, lhs::live)
471 :     | _ => walk (!succ, lastInput, live)
472 :     (* end case *))
473 :     | _ => if Nd.isNULL lastInput
474 :     then let (* no inputs *)
475 :     val entry = Nd.mkENTRY()
476 :     val exit = Nd.mkEXIT(ExitKind.RETURN, [])
477 :     in
478 :     Nd.addEdge (entry, exit);
479 :     {inputInit = IL.CFG{entry=entry, exit=exit}, globalInit = globalInit}
480 :     end
481 :     else let (* split at lastInput *)
482 :     val inputExit = Nd.mkEXIT(ExitKind.RETURN, live)
483 :     val globalEntry = Nd.mkENTRY()
484 :     val [gFirst] = Nd.succs lastInput
485 :     in
486 :     Nd.replaceInEdge {src = lastInput, oldDst = gFirst, dst = inputExit};
487 :     Nd.replaceOutEdge {oldSrc = lastInput, src = globalEntry, dst = gFirst};
488 :     {
489 :     inputInit = IL.CFG{entry = IL.CFG.entry globalInit, exit = inputExit},
490 :     globalInit = IL.CFG{entry = globalEntry, exit = IL.CFG.exit globalInit}
491 :     }
492 :     end
493 :     (* end case *))
494 :     in
495 :     walk (IL.CFG.entry globalInit, Nd.dummy, [])
496 :     end
497 :    
498 : jhr 1115 fun translate prog = let
499 :     (* first we do a variable analysis pass on the Low IL *)
500 : jhr 1640 val prog as IL.Program{props, globalInit, initially, strands} = VA.optimize prog
501 : jhr 1115 (* FIXME: here we should do a contraction pass to eliminate unused variables that VA may have created *)
502 : jhr 1232 val _ = (* DEBUG *)
503 :     LowPP.output (Log.logFile(), "LowIL after variable analysis", prog)
504 : jhr 1115 val env = newEnv()
505 :     val globals = List.map
506 :     (fn x => let val x' = newGlobal x in global(env, x, x'); x' end)
507 :     (IL.CFG.liveAtExit globalInit)
508 : jhr 1301 val {inputInit, globalInit} = splitGlobalInit globalInit
509 : jhr 1131 val strands = List.map (trStrand env) strands
510 : jhr 1115 in
511 :     T.Program{
512 : jhr 1640 props = props,
513 : jhr 1115 globals = globals,
514 : jhr 1301 inputInit = trCFG (env, [], fn _ => [], inputInit),
515 : jhr 1115 globalInit = trCFG (env, [], fn _ => [], globalInit),
516 : jhr 1131 strands = strands,
517 : jhr 1115 initially = trInitially (env, initially)
518 :     }
519 :     end
520 :    
521 :     end

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