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

SCM Repository

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

Diff of /branches/vis15/src/compiler/translate/translate.sml

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

revision 3501, Thu Dec 17 20:07:13 2015 UTC revision 3502, Thu Dec 17 23:13:35 2015 UTC
# Line 103  Line 103 
103            }            }
104    
105    (* create a new pending-join node *)    (* create a new pending-join node *)
106      fun newForeach (env, x, xs) = JOIN{      fun newForeach (env, x, xs, phiVars) = let
107              env = env.            fun doVar (x, (env', phiMap)) = (case VMap.find(env, x)
108                     of SOME x' => let
109                          val x'' = newVar x
110                          in
111                            (VMap.insert(env', x, x''), VMap.insert(phiMap, x, (x', [x'', x''])))
112                          end
113                      | NONE => raise Fail(concat["variable ", SV.uniqueNameOf x, " is not bound"])
114                    (* end case *))
115              val (env', phiMap) = List.foldl doVar (env, VMap.empty) phiVars
116              in
117                JOIN{
118                    env = env',
119              arity = ref 2,              arity = ref 2,
120              nd = IR.Node.mkFOREACH(x, xs),              nd = IR.Node.mkFOREACH(x, xs),
121              phiMap = ref VMap.empty,                  phiMap = ref phiMap,
122              predKill = Arry.array(2, false)              predKill = Arry.array(2, false)
123            }            }
124              end
125    
126    (* record that a path to the top join in the stack has been killed because f DIE or STABILIZE *)    (* record that a path to the top join in the stack has been killed because f DIE or STABILIZE *)
127      fun killPath ((i, JOIN{arity, predKill, ...}) :: _) = (      fun killPath ((i, JOIN{arity, predKill, ...}) :: _) = (
# Line 361  Line 373 
373                    | S.S_Foreach(x, xs, b) => let                    | S.S_Foreach(x, xs, b) => let
374                        val x' = newVar x                        val x' = newVar x
375                        val xs' = lookup env xs                        val xs' = lookup env xs
376                      (* we need to create fresh SSA variables for the free locals that are                      (* For any local variable y that is both live on exit of the block b and
377                       * assigned to in the body of the loop.                       * assigned to in b, we will need a phi node for y.
378                       *)                       *)
379                        val assignedVars = freeVarAssignments b                        val phiVars = VSet.intersect(AnalizeSimple.assignedVars b, AnalizeSimple.liveOut b)
380                        val join as JOIN{nd=foreachNd, ...} = newForeach (env, x', xs')                        val join as JOIN{env, nd=foreachNd, ...} = newForeach (env, x', xs', phiVars)
381                        val (body, _) = cvtBlock (state, env, (1, join)::joinStk, b)                        val (body, _) = cvtBlock (state, env, (1, join)::joinStk, b)
382                          val env = commitJoin (joinStk, join)
383                        in                        in
384                        (* link in CFG edges *)                        (* link in CFG edges *)
385                          IR.Node.setBodyBranch(foreachNd, IR.CFG.entry body);                          IR.Node.setBodyEntry (foreachNd, IR.CFG.entry body); (* loop header to body *)
386                          IR.Node.setPred (IR.CFG.entry body, foreachNd);                          IR.Node.setPred (IR.CFG.entry body, foreachNd);      (* back edge *)
387                            IR.Node.setSucc (IR.CFG.exit body, foreachNd);
388  ??                          IR.Node.setBodyExit (foreachNd, IR.CFG.exit body);
389                          (* process the rest of the block *)
390                            cvt (env, IR.CFG.concat (cfg, IR.CFG{entry=foreachNd, exit=foreachNd}), stms)
391                        end                        end
392                    | S.S_New(strandId, args) => let                    | S.S_New(strandId, args) => let
393                        val nd = IR.Node.mkNEW{                        val nd = IR.Node.mkNEW{

Legend:
Removed from v.3501  
changed lines
  Added in v.3502

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