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

SCM Repository

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

Diff of /trunk/src/compiler/IL/census-fn.sml

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

revision 2355, Sun Apr 7 11:35:08 2013 UTC revision 2356, Sun Apr 7 14:45:25 2013 UTC
# Line 21  Line 21 
21    
22      fun inc (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)      fun inc (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)
23      fun dec (IL.V{useCnt, ...}) = (useCnt := !useCnt - 1)      fun dec (IL.V{useCnt, ...}) = (useCnt := !useCnt - 1)
     fun setBinding (IL.V{bind, ...}, vb) = bind := vb  
24    
25      fun init (IL.Program{globalInit, initially, strands, ...}) = let      fun init (IL.Program{globalInit, initially, strands, ...}) = let
26            fun clearVar (IL.V{useCnt, ...}) = useCnt := 0            fun clearVar (IL.V{useCnt, ...}) = useCnt := 0
# Line 54  Line 53 
53           * is used to count the live variables at exits, since the context affects the           * is used to count the live variables at exits, since the context affects the
54           * treatment of these.           * treatment of these.
55           *)           *)
 (* FIXME: setting the binding here is probably redundant, since the mk functions do it too! *)  
56            fun incNode exitCount (IL.ND{kind, ...}) = (case kind            fun incNode exitCount (IL.ND{kind, ...}) = (case kind
57                   of IL.JOIN{phis, ...} => let                   of IL.JOIN{phis, ...} => let
58                        fun f (y, xs) = (                        fun f (y, xs) = incList xs
                             setBinding (y, IL.VB_PHI xs);  
                             incList xs)  
59                        in                        in
60                          List.app f (!phis)                          List.app f (!phis)
61                        end                        end
62                    | IL.COND{cond, ...} => inc cond                    | IL.COND{cond, ...} => inc cond
63                    | IL.ASSIGN{stm = (y, rhs), ...} => (                    | IL.ASSIGN{stm = (y, rhs), ...} => IL.RHS.app inc rhs
64                        setBinding (y, IL.VB_RHS rhs);                    | IL.MASSIGN{stm = (ys, rator, xs), ...} => List.app inc xs
                       IL.RHS.app inc rhs)  
                   | IL.MASSIGN{stm = (ys, rator, xs), ...} => let  
                       fun setB (_, []) = ()  
                         | setB (i, x::xs) = (  
                             setBinding (x, IL.VB_MULTIOP(i, rator, xs));  
                             setB (i+1, xs))  
                       in  
                         setB (0, ys);  
                         List.app inc xs  
                       end  
65                    | IL.NEW{args, ...} => incList args                    | IL.NEW{args, ...} => incList args
66                    | IL.SAVE{rhs, ...} => inc rhs                    | IL.SAVE{rhs, ...} => inc rhs
67                    | IL.EXIT{live, ...} => exitCount live                    | IL.EXIT{live, ...} => exitCount live
# Line 83  Line 69 
69                  (* end case *))                  (* end case *))
70          (* increment the counts of variables used in the initially code *)          (* increment the counts of variables used in the initially code *)
71            fun incInitially (IL.Initially{create, rangeInit, iters, ...}) = let            fun incInitially (IL.Initially{create, rangeInit, iters, ...}) = let
72                  fun incIter (param, lo, hi) = (                  fun incIter (param, lo, hi) = (inc lo; inc hi)
                       setBinding (param, IL.VB_PARAM);  (* QUESTION: should there be a special kind for this? *)  
                       inc lo; inc hi)  
73                  in                  in
74                    IL.CFG.apply (incNode (fn live => incList live)) rangeInit;                    IL.CFG.apply (incNode (fn live => incList live)) rangeInit;
75                    List.app incIter iters;                    List.app incIter iters;
# Line 97  Line 81 
81                  fun incMethod (IL.Method{body, ...}) =                  fun incMethod (IL.Method{body, ...}) =
82                        IL.CFG.apply (incNode (fn live => incList live)) body                        IL.CFG.apply (incNode (fn live => incList live)) body
83                  in                  in
                   List.app (fn x => setBinding(x, IL.VB_PARAM)) params;  
84                    IL.CFG.apply (incNode (fn live => incList live)) stateInit;                    IL.CFG.apply (incNode (fn live => incList live)) stateInit;
85                    List.app incMethod methods                    List.app incMethod methods
86                  end                  end

Legend:
Removed from v.2355  
changed lines
  Added in v.2356

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