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

SCM Repository

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

Diff of /branches/pure-cfg/src/compiler/IL/census-fn.sml

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

revision 612, Sat Mar 12 17:56:24 2011 UTC revision 613, Sat Mar 12 19:29:23 2011 UTC
# Line 21  Line 21 
21      fun inc (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)      fun inc (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)
22      fun setBinding (IL.V{bind, ...}, vb) = bind := vb      fun setBinding (IL.V{bind, ...}, vb) = bind := vb
23    
24      fun init (IL.Program{globals, globalInit, strands}) = let      fun init (IL.Program{globals, globalInit, initially, strands}) = let
25            fun clearVar (IL.V{useCnt, ...}) = useCnt := 0            fun clearVar (IL.V{useCnt, ...}) = useCnt := 0
26          (* clear the counts of the variables defined in a node *)          (* clear the counts of the variables defined in a node *)
27            fun clearNode (IL.ND{kind, ...}) = (case kind            fun clearNode (IL.ND{kind, ...}) = (case kind
# Line 29  Line 29 
29                    | IL.ASSIGN{stm=(x, _), ...} => clearVar x                    | IL.ASSIGN{stm=(x, _), ...} => clearVar x
30                    | _ => ()                    | _ => ()
31                  (* end case *))                  (* end case *))
32            (* clear the counts of the initially code *)
33              fun clearInitially (IL.Initially{create, iters, ...}) = let
34                    fun clearIter (cfg, param, lo, hi) = (
35                          IL.CFG.apply clearNode cfg;
36                          clearVar param)
37                    in
38                      List.app clearIter iters;
39                      IL.CFG.apply clearNode (#1 create)
40                    end
41          (* clear the counts of the variables defined in an strand *)          (* clear the counts of the variables defined in an strand *)
42            fun clearStrand (IL.Strand{params, state, stateInit, methods, ...}) = let            fun clearStrand (IL.Strand{params, state, stateInit, methods, ...}) = let
43                  fun clearMethod (IL.Method{stateIn, body, ...}) = (                  fun clearMethod (IL.Method{stateIn, body, ...}) = (
# Line 64  Line 73 
73                    | IL.EXIT{live, ...} => incList live                    | IL.EXIT{live, ...} => incList live
74                    | _ => ()                    | _ => ()
75                  (* end case *))                  (* end case *))
76            (* increment the counts of variables used in the initially code *)
77              fun incInitially (IL.Initially{create, iters, ...}) = let
78                    fun incIter (cfg, param, lo, hi) = (
79                          IL.CFG.apply incNode cfg;
80                          setBinding (param, IL.VB_PARAM);  (* QUESTION: should there be a special kind for this? *)
81                          inc lo; inc hi)
82                    in
83                      List.app incIter iters;
84                      IL.CFG.apply incNode (#1 create);
85                      List.app inc (#3 create)
86                    end
87          (* increment the counts of the variables used in a strand *)          (* increment the counts of the variables used in a strand *)
88            fun incStrand (IL.Strand{params, state, stateInit, methods, ...}) = let            fun incStrand (IL.Strand{params, state, stateInit, methods, ...}) = let
89                  fun incMethod (IL.Method{stateIn, stateOut, body, ...}) = (                  fun incMethod (IL.Method{stateIn, stateOut, body, ...}) = (
# Line 83  Line 103 
103            (* first clear the counts of all variables *)            (* first clear the counts of all variables *)
104              List.app clearVar globals;              List.app clearVar globals;
105              IL.CFG.apply clearNode globalInit;              IL.CFG.apply clearNode globalInit;
106                clearInitially initially;
107              List.app clearStrand strands;              List.app clearStrand strands;
108            (* then count uses *)            (* then count uses *)
109              IL.CFG.apply incNode globalInit;              IL.CFG.apply incNode globalInit;
110                incInitially initially;
111              List.app incStrand strands              List.app incStrand strands
112            end            end
113    

Legend:
Removed from v.612  
changed lines
  Added in v.613

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