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

SCM Repository

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

Annotation of /branches/vis15/src/compiler/low-to-tree/low-to-tree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3851 - (view) (download)

1 : jhr 3828 (* low-to-tree.sml
2 :     *
3 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2016 The University of Chicago
6 :     * All rights reserved.
7 :     *)
8 :    
9 :     structure LowToTree : sig
10 :    
11 : jhr 3851 val translate : LowIR.program * Env.target_info -> TreeIR.program
12 : jhr 3828
13 :     end = struct
14 :    
15 : jhr 3834 structure IR = LowIR
16 :     structure V = LowIR.Var
17 :     structure Ty = LowTypes
18 :     structure Op = LowOps
19 : jhr 3835 structure GV = IR.GlobalVar
20 :     structure SV = IR.StateVar
21 : jhr 3834 structure T = TreeIR
22 :     structure TTy = TreeTypes
23 :     structure TOp = TreeOps
24 :     structure TV = TreeVar
25 :     structure TGV = TreeGlobalVar
26 :     structure TSV = TreeStateVar
27 : jhr 3828
28 : jhr 3835 (* associate Tree IL globals variables with Low IL variables using properties *)
29 :     local
30 :     val {setFn, peekFn, ...} =
31 :     GV.newProp (fn x => raise Fail(concat["getGlobalVar(", GV.uniqueName x, ")"]))
32 :     in
33 :     fun mkGlobalVar x = (case peekFn x
34 :     of NONE => let
35 :     val x' = TGV.new {
36 :     name = GV.name x,
37 : jhr 3843 ty = Util.trType (GV.ty x),
38 : jhr 3835 input = GV.isInput x,
39 :     output = false, (* FIXME: change once we support output globals *)
40 : jhr 3843 varying = GV.isVarying x,
41 :     apiTy = if GV.isInput x
42 :     then SOME(Util.toAPIType (GV.ty x))
43 :     else NONE
44 : jhr 3835 }
45 :     in
46 :     setFn (x, x');
47 :     x'
48 :     end
49 :     | SOME x' => x'
50 :     (* end case *))
51 :     end
52 :    
53 :     (* associate Tree IL state variables with Low IL variables using properties *)
54 :     local
55 :     fun mkStateVar x = TSV.new {
56 :     name = SV.name x,
57 : jhr 3843 ty = Util.trType (SV.ty x),
58 :     varying = SV.isVarying x,
59 :     apiTy = if (SV.isOutput x)
60 :     then SOME(Util.toAPIType (SV.ty x))
61 :     else NONE
62 : jhr 3835 }
63 :     in
64 :     val {getFn = getStateVar, ...} = SV.newProp mkStateVar
65 :     end
66 :    
67 : jhr 3848 fun mkBlock stms = T.Block{locals = ref [], body = stms}
68 : jhr 3834 fun mkIf (x, stms, []) = T.S_IfThen(x, mkBlock stms)
69 :     | mkIf (x, stms1, stms2) = T.S_IfThenElse(x, mkBlock stms1, mkBlock stms2)
70 : jhr 3828
71 : jhr 3834 fun cvtScalarTy Ty.BoolTy = TTy.BoolTy
72 :     | cvtScalarTy Ty.IntTy = TTy.IntTy
73 : jhr 3835 | cvtScalarTy (Ty.TensorTy[]) = TTy.realTy
74 : jhr 3834 | cvtScalarTy ty = raise Fail(concat["cvtScalarTy(", Ty.toString ty, ")"])
75 :    
76 : jhr 3850 fun singleArg env x = (case Env.useVar env x
77 :     of Env.TREE e => e
78 :     | Env.VEC(layout, es) => T.E_Pack(layout, es)
79 :     (* end case *))
80 :    
81 : jhr 3834 fun vectorArg (env, x) = (case Env.useVar env x
82 : jhr 3843 of Env.TREE e => (case IR.Var.ty x
83 :     of Ty.TensorTy[d] => let
84 :     val layout = Env.layoutVec env d
85 :     (* QUESTION: can "e" be a complicated expression or are we guaranteed that it will just
86 :     * be a memory reference?
87 :     *)
88 :     val es = List.tabulate (
89 :     List.length(#pieces layout),
90 :     fn i => T.E_VLoad(layout, e, i))
91 :     in
92 :     (layout, es)
93 :     end
94 :     | ty => raise Fail("expected TensorTy[_], but found " ^ Ty.toString ty)
95 :     (* end case *))
96 : jhr 3834 | Env.VEC(layout, es) => (layout, es)
97 :     (* end case *))
98 :    
99 :     (* convert a list of LowIR variables, each of which are mapped
100 :     * to lists of of vector expressions, to a list of list of expressions
101 :     *)
102 :     fun vectorArgs (env, []) = raise Fail "unexpected empty argument list"
103 :     | vectorArgs (env, x::xs) = let
104 :     val (layout, exps) = vectorArg (env, x)
105 :     fun doArg (x, argLists) = let
106 :     val (_, exps) = vectorArg (env, x)
107 :     in
108 :     ListPair.mapEq (op ::) (exps, argLists)
109 :     end
110 : jhr 3843 val argLists = List.foldl doArg [exps] xs
111 : jhr 3834 in
112 :     (layout, List.map List.rev argLists)
113 :     end
114 :    
115 :     fun trOp (env, lhs, srcRator, args) = let
116 : jhr 3851 fun getBinding x = (case Env.useVar env x
117 :     of Env.TREE e => e
118 :     | _ => raise Fail("expected single binding for " ^ IR.Var.toString x)
119 :     (* end case *))
120 :     fun assignOp rator = let
121 :     val stm = T.S_Assign(??, T.E_Op(rator, List.map getBinding args))
122 : jhr 3843 in
123 : jhr 3851 [stm]
124 : jhr 3843 end
125 : jhr 3851 (* FIXME: if the use count of lhs is > 1, then we should bind to a local variable *)
126 :     fun bindOp rator = (
127 :     Env.bindVar (env, lhs, Env.TREE(T.E_Op(rator, List.map getBinding args)));
128 :     [])
129 : jhr 3835 fun bindVOp rator = let
130 : jhr 3834 val (layout, argss) = vectorArgs (env, args)
131 : jhr 3829 val exps = ListPair.map
132 : jhr 3835 (fn (w, args) => T.E_Op(rator w, args))
133 : jhr 3834 (#pieces layout, argss)
134 : jhr 3829 in
135 : jhr 3851 Env.bindVar (env, lhs, Env.VEC(layout, exps));
136 :     []
137 : jhr 3829 end
138 :     in
139 : jhr 3834 case srcRator
140 :     of Op.IAdd => bindOp TOp.IAdd
141 :     | Op.ISub => bindOp TOp.ISub
142 :     | Op.IMul => bindOp TOp.IMul
143 :     | Op.IDiv => bindOp TOp.IDiv
144 :     | Op.IMod => bindOp TOp.IMod
145 :     | Op.INeg => bindOp TOp.INeg
146 : jhr 3843 (* QUESTION: should we just use VAdd 1, etc ?*)
147 : jhr 3834 | Op.RAdd => bindOp TOp.RAdd
148 :     | Op.RSub => bindOp TOp.RSub
149 :     | Op.RMul => bindOp TOp.RMul
150 :     | Op.RDiv => bindOp TOp.RDiv
151 :     | Op.RNeg => bindOp TOp.RNeg
152 :     | Op.LT ty => bindOp (TOp.LT (cvtScalarTy ty))
153 :     | Op.LTE ty => bindOp (TOp.LTE (cvtScalarTy ty))
154 :     | Op.EQ ty => bindOp (TOp.EQ (cvtScalarTy ty))
155 :     | Op.NEQ ty => bindOp (TOp.NEQ (cvtScalarTy ty))
156 :     | Op.GT ty => bindOp (TOp.GT (cvtScalarTy ty))
157 :     | Op.GTE ty => bindOp (TOp.GTE (cvtScalarTy ty))
158 :     | Op.Not => bindOp TOp.Not
159 :     | Op.Abs ty => bindOp (TOp.Abs (cvtScalarTy ty))
160 :     | Op.Max ty => bindOp (TOp.Max (cvtScalarTy ty))
161 :     | Op.Min ty => bindOp (TOp.Min (cvtScalarTy ty))
162 :     | Op.RClamp => bindOp TOp.RClamp
163 :     | Op.RLerp => bindOp TOp.RLerp
164 :     | Op.VAdd _ => bindVOp TOp.VAdd
165 :     | Op.VSub _ => bindVOp TOp.VSub
166 :     | Op.VScale _ => bindVOp TOp.VScale
167 :     | Op.VMul _ => bindVOp TOp.VMul
168 :     | Op.VNeg _ => bindVOp TOp.VNeg
169 :     | Op.VSum _ => ??
170 : jhr 3844 | Op.VIndex(_, i) => let
171 :     (* FIXME: more efficient to lookup the variable and avoid expanding TREE args *)
172 :     val ({pieces, ...}, es) = vectorArg (env, hd args)
173 :     fun select (i, w::ws, e::es) =
174 :     if (i < w)
175 : jhr 3851 (* FIXME: what if lhs is used more than once? *)
176 :     then Env.bindVar (env, lhs, Env.TREE(T.E_Op(TOp.VIndex(w, i), [e])))
177 : jhr 3844 else select (i-w, ws, es)
178 :     | select _ = raise Fail("bogus " ^ Op.toString srcRator)
179 :     in
180 : jhr 3851 select (i, pieces, es);
181 :     []
182 : jhr 3844 end
183 : jhr 3834 | Op.VClamp n => bindVOp TOp.VClamp
184 :     | Op.VMapClamp n => bindVOp TOp.VMapClamp
185 :     | Op.VLerp n => bindVOp TOp.VLerp
186 :     | Op.TensorIndex(ty, idxs) => ??
187 :     | Op.ProjectLast(ty, idxs) => ??
188 : jhr 3851 | Op.EigenVecs2x2 => assignOp TOp.EigenVecs2x2
189 :     | Op.EigenVecs3x3 => assignOp TOp.EigenVecs3x3
190 :     | Op.EigenVals2x2 => assignOp TOp.EigenVals2x2
191 :     | Op.EigenVals3x3 => assignOp TOp.EigenVals3x3
192 : jhr 3834 | Op.Zero ty => ??
193 :     | Op.Select(Ty.TupleTy tys, i) => ??
194 :     | Op.Subscript(Ty.SeqTy(ty, NONE)) => ??
195 :     | Op.Subscript(Ty.SeqTy(ty, SOME _)) => ??
196 :     | Op.MkDynamic(ty, n) => ??
197 :     | Op.Append ty => ??
198 :     | Op.Prepend ty => ??
199 :     | Op.Concat ty => ??
200 :     | Op.Range => ??
201 :     | Op.Length ty => ??
202 :     | Op.SphereQuery(ty1, ty2) => ??
203 :     | Op.Sqrt => bindOp TOp.Sqrt
204 :     | Op.Cos => bindOp TOp.Cos
205 :     | Op.ArcCos => bindOp TOp.ArcCos
206 :     | Op.Sin => bindOp TOp.Sin
207 :     | Op.ArcSin => bindOp TOp.ArcSin
208 :     | Op.Tan => bindOp TOp.Tan
209 :     | Op.ArcTan => bindOp TOp.ArcTan
210 :     | Op.Ceiling 1 => bindOp (TOp.Ceiling 1)
211 : jhr 3851 | Op.Ceiling d => bindVOp TOp.Ceiling
212 : jhr 3834 | Op.Floor 1 => bindOp (TOp.Floor 1)
213 : jhr 3851 | Op.Floor d => bindVOp TOp.Floor
214 :     | Op.Round 1 => bindOp (TOp.Round 1)
215 :     | Op.Round d => bindVOp TOp.Round
216 : jhr 3834 | Op.Trunc 1 => bindOp (TOp.Trunc 1)
217 : jhr 3851 | Op.Trunc d => bindVOp TOp.Trunc
218 : jhr 3835 | Op.IntToReal => bindOp TOp.IntToReal
219 : jhr 3851 | Op.RealToInt 1 => bindOp (TOp.RealToInt 1)
220 : jhr 3834 | Op.RealToInt d => ??
221 : jhr 3844 (* FIXME
222 : jhr 3834 | Op.R_All ty => ??
223 :     | Op.R_Exists ty => ??
224 :     | Op.R_Max ty => ??
225 :     | Op.R_Min ty => ??
226 :     | Op.R_Sum ty => ??
227 :     | Op.R_Product ty => ??
228 :     | Op.R_Mean ty => ??
229 :     | Op.R_Variance ty => ??
230 : jhr 3844 *)
231 : jhr 3851 | Op.Transform info => bindOp (TOp.Transform info)
232 :     | Op.Translate info => bindOp (TOp.Translate info)
233 :     | Op.ControlIndex(info, ctl, d) => bindOp (TOp.ControlIndex(info, ctl, d))
234 :     | Op.LoadVoxel info => bindOp (TOp.LoadVoxel info)
235 : jhr 3834 | Op.Inside(info, s) => ??
236 : jhr 3835 | Op.ImageDim(info, d) => bindOp(TOp.ImageDim(info, d))
237 : jhr 3834 | Op.LoadSeq(ty, file) => ??
238 :     | Op.LoadImage(ty, file) => ??
239 :     | Op.MathFn f => bindOp (TOp.MathFn f)
240 : jhr 3844 | rator => raise Fail("bogus operator " ^ Op.toString srcRator)
241 : jhr 3829 (* end case *)
242 :     end
243 :    
244 : jhr 3834 fun trAssign (env, lhs, rhs) = let
245 : jhr 3836 (* simple binding for lhs variable; we check to see if it is part of an merged
246 :     * equivalence class, in which case we need to generate the assigment.
247 :     *)
248 :     fun bindSimple rhs = (case UnifyVars.eqClassOf lhs
249 :     of SOME x => ??
250 : jhr 3851 | NONE => (Env.bindSimple (env, lhs, rhs); [])
251 : jhr 3836 (* end case *))
252 : jhr 3834 in
253 :     case rhs
254 : jhr 3844 of IR.GLOBAL x => bindSimple (T.E_Global(mkGlobalVar x))
255 : jhr 3848 | IR.STATE(NONE, fld) => bindSimple (T.E_State(NONE, getStateVar fld))
256 :     | IR.STATE(SOME x, fld) => ??
257 : jhr 3836 | IR.VAR x => (case Env.useVar env x
258 :     of Env.TREE e => ??
259 :     | Env.VEC(layout, es) => ??
260 :     (* end case *))
261 : jhr 3850 | IR.LIT lit => bindSimple (T.E_Lit lit)
262 : jhr 3848 | IR.OP(rator, args) => trOp (env, lhs, rator, args)
263 : jhr 3834 | IR.CONS(args, ty) => ??
264 :     | IR.SEQ(args, ty) => ??
265 :     | IR.EINAPP _ => raise Fail "unexpected EINAPP in LowIR code"
266 :     (* end case *)
267 :     end
268 :    
269 :     (* In order to reconstruct the block-structure from the CFG, we keep a stack of open ifs.
270 :     * the items on this stack distinguish between when we are processing the then and else
271 :     * branches of the if.
272 :     *)
273 :     datatype open_if
274 :     (* working on the "then" branch. The fields are statments that preceed the if, the condition,
275 :     * and the else-branch node.
276 :     *)
277 :     = THEN_BR of T.stm list * T.exp * IR.node
278 :     (* working on the "else" branch. The fields are statments that preceed the if, the condition,
279 :     * the "then" branch statements, and the node kind that terminated the "then" branch (will be
280 :     * a JOIN or EXIT(DIE, STABILIZE, or UNREACHABLE)).
281 :     *)
282 :     | ELSE_BR of T.stm list * T.exp * T.stm list * IR.node_kind
283 :    
284 : jhr 3835 fun trCFGWithEnv (env, prefix, cfg) = let
285 :     fun useScalar x = (case Env.useVar env x
286 :     of Env.TREE e => e
287 :     | _ => raise Fail("expected scalar binding for " ^ V.toString x)
288 :     (* end case *))
289 : jhr 3834 val _ = UnifyVars.analyze cfg
290 : jhr 3851 (* join (stk, stms, k): handle a control-flow join, where env is the
291 : jhr 3834 * current environment, stk is the stack of open ifs (the top of stk specifies
292 :     * which branch we are in), stms are the TreeIL statements preceding the join
293 :     * on the current path, and k is the kind of the join node (either JOIN or EXIT).
294 :     *)
295 : jhr 3851 fun join ([], _, IR.JOIN _) = raise Fail "JOIN with no open if"
296 :     | join ([], stms, _) = mkBlock (prefix @ List.rev stms)
297 :     | join (THEN_BR(stms1, cond, elseBr)::stk, thenBlk, k) = let
298 :     val thenBlk = Env.flushPending (env, thenBlk)
299 : jhr 3834 in
300 : jhr 3851 doNode (elseBr, ELSE_BR(stms1, cond, thenBlk, k)::stk, [])
301 : jhr 3834 end
302 : jhr 3851 | join (ELSE_BR(stms, cond, thenBlk, k1)::stk, elseBlk, k2) = let
303 :     val elseBlk = Env.flushPending (env, elseBlk)
304 : jhr 3834 in
305 :     case (k1, k2)
306 : jhr 3848 of (IR.JOIN{succ, ...}, IR.JOIN _) => let
307 : jhr 3834 val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
308 :     in
309 : jhr 3851 doNode (!succ, stk, stm::stms)
310 : jhr 3834 end
311 : jhr 3848 | (IR.JOIN{succ, ...}, _) => let
312 : jhr 3834 val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
313 :     in
314 : jhr 3851 doNode (!succ, stk, stm::stms)
315 : jhr 3834 end
316 : jhr 3848 | (_, IR.JOIN{succ, ...}) => let
317 : jhr 3834 val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
318 :     in
319 : jhr 3851 doNode (!succ, stk, stm::stms)
320 : jhr 3834 end
321 :     | (_, _) => let
322 :     val stm = mkIf(cond, List.rev thenBlk, List.rev elseBlk)
323 :     in
324 : jhr 3848 mkBlock (prefix @ List.rev(stm::stms))
325 : jhr 3834 end
326 :     (* end case *)
327 :     end
328 : jhr 3851 and doNode (nd : IR.node, ifStk : open_if list, stms) = (case IR.Node.kind nd
329 : jhr 3834 of IR.NULL => raise Fail "unexpected NULL"
330 : jhr 3851 | IR.ENTRY{succ} => doNode (!succ, ifStk, stms)
331 :     | k as IR.JOIN _ => join (ifStk, stms, k)
332 : jhr 3834 | IR.COND{cond, trueBranch, falseBranch, ...} => let
333 : jhr 3835 val cond = useScalar (!cond)
334 : jhr 3851 val stms = Env.flushPending (env, stms)
335 : jhr 3834 in
336 : jhr 3851 doNode (!trueBranch, THEN_BR(stms, cond, !falseBranch)::ifStk, [])
337 : jhr 3834 end
338 : jhr 3835 | IR.FOREACH{var, src, bodyEntry, succ, ...} => let
339 :     val src = useScalar (!src)
340 : jhr 3844 val var = Util.newIterVar var
341 : jhr 3851 val stms = Env.flushPending (env, stms)
342 :     val body = doNode (!bodyEntry, [], [])
343 : jhr 3834 val stm = T.S_Foreach(var, src, body)
344 :     in
345 : jhr 3851 doNode (!succ, ifStk, stm::stms)
346 : jhr 3834 end
347 : jhr 3848 | IR.NEXT _ => mkBlock (List.rev stms)
348 : jhr 3834 | IR.COM {text, succ, ...} =>
349 : jhr 3851 doNode (!succ, ifStk, T.S_Comment text :: stms)
350 : jhr 3834 | IR.ASSIGN{stm=(lhs, rhs), succ, ...} => let
351 : jhr 3848 val (env, stms') = trAssign (env, lhs, rhs)
352 : jhr 3834 in
353 : jhr 3851 doNode (!succ, ifStk, stms' @ stms)
354 : jhr 3834 end
355 :     | IR.MASSIGN{stm=(ys, rator, xs), succ, ...} => let
356 : jhr 3848 fun doLHSVar (y, (env, ys)) = let
357 :     val t = Util.newLocalVar y
358 :     in
359 : jhr 3850 (rename (env, y, t), t::ys)
360 : jhr 3848 end
361 :     val (env, ys) = List.foldr doLHSVar (env, []) ys
362 :     val rator = (case rator
363 :     of Op.Print tys => TOp.Print(List.map Util.trType tys)
364 :     | _ => raise Fail(concat[
365 :     "unexepected operator ", Op.toString rator, " for MASSIGN"
366 :     ])
367 :     (* end case *))
368 : jhr 3850 val stm = T.S_MAssign(ys, T.E_Op(rator, List.map (singleArg env) xs))
369 : jhr 3848 in
370 : jhr 3851 doNode (!succ, ifStk, stm :: stms)
371 : jhr 3848 end
372 : jhr 3834 | IR.GASSIGN{lhs, rhs, succ, ...} => let
373 :     val stm = (case useAsInput(env, rhs)
374 : jhr 3850 of NONE => T.S_GAssign(mkGlobalVar lhs, singleArg env rhs)
375 : jhr 3844 | SOME mkStm => mkStm(mkGlobalVar lhs)
376 : jhr 3834 (* end case *))
377 :     in
378 : jhr 3851 doNode (!succ, ifStk, stm::stms)
379 : jhr 3834 end
380 : jhr 3851 | IR.NEW{strand, args, succ, ...} => let
381 :     val stm = T.S_New(strand, List.map (singleArg env) args)
382 :     in
383 :     doNode (!succ, ifStk, stm::stms)
384 :     end
385 : jhr 3834 | IR.SAVE{lhs, rhs, succ, ...} => let
386 : jhr 3850 val stm = T.S_Save(getStateVar lhs, singleArg env rhs)
387 : jhr 3834 in
388 : jhr 3851 doNode (!succ, ifStk, stm::stms)
389 : jhr 3834 end
390 :     | k as IR.EXIT{kind, succ, ...} => (case (!succ, kind)
391 :     of (NONE, ExitKind.RETURN) => let
392 : jhr 3835 val suffix = [T.S_Exit]
393 : jhr 3834 in
394 : jhr 3848 mkBlock (prefix @ List.revAppend(stms, suffix))
395 : jhr 3834 end
396 :     | (NONE, ExitKind.ACTIVE) => let
397 : jhr 3835 val suffix = [T.S_Active]
398 : jhr 3834 in
399 : jhr 3848 mkBlock (prefix @ List.revAppend(stms, suffix))
400 : jhr 3834 end
401 :     | (NONE, ExitKind.STABILIZE) => let
402 :     val stms = T.S_Stabilize :: stms
403 :     in
404 : jhr 3851 join (ifStk, stms, k)
405 : jhr 3834 end
406 : jhr 3851 | (NONE, ExitKind.DIE) => join (ifStk, T.S_Die :: stms, k)
407 :     | (NONE, ExitKind.UNREACHABLE) => join (ifStk, stms, k)
408 :     | (SOME nd, ExitKind.ACTIVE) => doNode (nd, ifStk, T.S_Active :: stms)
409 :     | (SOME nd, ExitKind.STABILIZE) => doNode (nd, ifStk, T.S_Stabilize :: stms)
410 :     | (SOME nd, ExitKind.DIE) => doNode (nd, ifStk, T.S_Die :: stms)
411 :     | (SOME nd, ExitKind.UNREACHABLE) => doNode (nd, ifStk, stms)
412 : jhr 3834 | _ => raise Fail("unexpected continuation edge from "^IR.Node.toString nd)
413 :     (* end case *))
414 :     (* end case *))
415 :     in
416 : jhr 3851 ScopeVars.assignScopes (doNode (IR.CFG.entry cfg, [], []))
417 : jhr 3834 end
418 :    
419 : jhr 3851 fun trCFG info (prefix, cfg) = trCFGWithEnv (Env.new info, prefix, cfg)
420 : jhr 3835
421 : jhr 3851 fun trStrand info strand = let
422 :     val trCFG = trCFG info
423 : jhr 3835 val IR.Strand{name, params, state, stateInit, initM, updateM, stabilizeM} = strand
424 : jhr 3844 val params' = List.map Util.newParamVar params
425 : jhr 3835 val env = ListPair.foldlEq
426 : jhr 3851 (fn (x, x', env) => rename(env, x, x')) (Env.new info) (params, params')
427 : jhr 3835 val state' = List.map getStateVar state
428 :     in
429 :     T.Strand{
430 :     name = name,
431 :     params = params',
432 :     state = state',
433 : jhr 3848 stateInit = trCFGWithEnv (env, [], stateInit),
434 : jhr 3835 initM = Option.map (fn cfg => trCFG ([], cfg)) initM,
435 :     updateM = trCFG ([], updateM),
436 :     stabilizeM = Option.map (fn cfg => trCFG ([], cfg)) stabilizeM
437 :     }
438 :     end
439 :    
440 : jhr 3851 fun translate (prog, info) = let
441 : jhr 3834 val LowIR.Program{
442 :     props, consts, inputs, constInit, globals, globalInit, strand, create, update
443 :     } = prog
444 :     in
445 :     TreeIR.Program{
446 :     props = props,
447 :     consts = ??,
448 :     inputs = ??,
449 :     constInit = ??,
450 :     globals = ??,
451 :     globalInit = ??,
452 : jhr 3851 strand = trStrand info strand,
453 : jhr 3834 create = ??,
454 :     update = ??
455 :     }
456 :     end
457 :    
458 : jhr 3828 end

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