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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/translate/translate.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/translate/translate.sml

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

revision 495, Fri Jan 28 20:43:10 2011 UTC revision 496, Sun Jan 30 03:52:13 2011 UTC
# Line 58  Line 58 
58      datatype join = JOIN of {      datatype join = JOIN of {
59          arity : int,                    (* number of predecessors *)          arity : int,                    (* number of predecessors *)
60          nd : IL.node,                   (* the CFG node for this pending join *)          nd : IL.node,                   (* the CFG node for this pending join *)
61          phiMap : IL.phi VMap.map ref    (* a mapping from Simple AST variables that are assigned *)          phiMap : IL.phi VMap.map ref,   (* a mapping from Simple AST variables that are assigned *)
62                                          (* to their phi nodes. *)                                          (* to their phi nodes. *)
63            predKill : int list ref         (* killed predecessor edges (because of DIE or STABILIZE *)
64        }        }
65    
66    (* create a new pending-join node *)    (* create a new pending-join node *)
67      fun newJoin arity = JOIN{arity = arity, nd = IL.Node.mkJOIN [], phiMap = ref VMap.empty}      fun newJoin arity = JOIN{
68                arity = arity, nd = IL.Node.mkJOIN [], phiMap = ref VMap.empty, predKill = ref []
69              }
70    
71      (* a stack of pending joins.  The first component specifies the path index of the current
72       * path to the join.
73       *)
74        type pending_joins = (int * join) list
75    
76        fun killPath (i, JOIN{predKill, ...}) = predKill := i :: !predKill
77    
78    (* record an assignment to the IL variable dstVar (corresponding to the Simple AST variable    (* record an assignment to the IL variable dstVar (corresponding to the Simple AST variable
79     * srcVar) in the current pending-join node.  The predIndex specifies which path into the     * srcVar) in the current pending-join node.  The predIndex specifies which path into the
80     * JOIN node this assignment occurs on.     * JOIN node this assignment occurs on.
81     *)     *)
82      fun recordAssign (env, JOIN{arity, phiMap, ...}, srcVar, dstVar, predIndex) = let      fun recordAssign (_, [], _, _, _) = ()
83          | recordAssign (env, JOIN{arity, phiMap, ...}::_, srcVar, dstVar, predIndex) = let
84            val m = !phiMap            val m = !phiMap
85            val m'= (case VMap.find (m, srcVar)            val m'= (case VMap.find (m, srcVar)
86                   of NONE => let                   of NONE => let
# Line 95  Line 106 
106    (* complete a pending join operation by filling in the phi nodes from the phi map and    (* complete a pending join operation by filling in the phi nodes from the phi map and
107     * updating the environment.     * updating the environment.
108     *)     *)
109      fun completeJoin (env, JOIN{nd, phiMap, ...}) = let      fun commitJoin (env, JOIN{nd, phiMap, ...}::r) = let
110            val IL.ND{kind=IL.JOIN{phis, ...}, ...} = nd            val IL.ND{kind=IL.JOIN{phis, ...}, ...} = nd
111            fun doVar (srcVar, phi as (dstVar, _), (env, phis)) =            fun doVar (srcVar, phi as (dstVar, _), (env, phis)) =
112                  (VMap.insert (env, srcVar, dstVar), phi::phis)                  (VMap.insert (env, srcVar, dstVar), phi::phis)
# Line 104  Line 115 
115              phis := phis';              phis := phis';
116              env              env
117            end            end
118          | commitJoin _ = raise Fail "commitJoin: unexpected empty join stack"
119    
120    (* expression translation *)    (* expression translation *)
121      fun cvtExp (env, lhs, exp) = (case exp      fun cvtExp (env, lhs, exp) = (case exp

Legend:
Removed from v.495  
changed lines
  Added in v.496

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