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

SCM Repository

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

Diff of /branches/vis15/src/compiler/translate/analyze-simple.sml

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

revision 3502, Thu Dec 17 23:13:35 2015 UTC revision 3538, Fri Dec 25 21:50:24 2015 UTC
# Line 15  Line 15 
15    
16      val analyze : Simple.block -> unit      val analyze : Simple.block -> unit
17    
18        val analyzeGlobalUpdate : Simple.block option -> unit
19    
20      val assignedVars : Simple.block -> SimpleVar.Set.set      val assignedVars : Simple.block -> SimpleVar.Set.set
21      val liveIn  : Simple.block -> SimpleVar.Set.set      val liveIn  : Simple.block -> SimpleVar.Set.set
22      val liveOut : Simple.block -> SimpleVar.Set.set      val liveOut : Simple.block -> SimpleVar.Set.set
23    
24      (* a property set on global variables that are modified during the global-update code *)
25        val updatedGlobal : SimpleVar.t -> bool
26    
27    end = struct    end = struct
28    
29      structure S = Simple      structure S = Simple
# Line 47  Line 52 
52      val setLiveOut = setFn      val setLiveOut = setFn
53      end      end
54    
55      (* track if a global variable is updated in the global-update code *)
56        local
57          val {setFn, getFn} = SV.newFlag()
58        in
59        val updatedGlobal = getFn
60        fun markUpdatedGlobal x = (case SV.kindOf x
61               of SV.ConstVar => raise Fail "update of ConstVar"
62                | SV.InputVar => setFn(x, true)
63                | SV.GlobalVar => setFn(x, true)
64                | _ => ()
65              (* end case *))
66        end (* local *)
67    
68    (* does a variable have local scope *)    (* does a variable have local scope *)
69      fun isLocal x = (case SV.kindOf x      fun isLocal x = (case SV.kindOf x
70             of SV.LocalVar => true             of SV.LocalVar => true
# Line 115  Line 133 
133              ()              ()
134            end            end
135    
136        fun analyzeGlobalUpdate NONE = ()
137          | analyzeGlobalUpdate (SOME blk) = let
138            (* identify and mark globals that are modified in the global-update code *)
139              fun doBlk (S.Block{code, ...}) = List.app doStm code
140              and doStm stm = (case stm
141                     of S.S_Assign(x, _) => markUpdatedGlobal x
142                      | S.S_IfThenElse(_, b1, b2) => (doBlk b1; doBlk b2)
143                      | S.S_Foreach(_, _, blk) => doBlk blk
144                      | S.S_MapReduce{results, ...} => List.app markUpdatedGlobal results
145                      | _ => ()
146                    (* end case *))
147              in
148                doBlk blk
149              end
150    
151    end    end

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

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