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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/cfg-ir/ssa-fn.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/cfg-ir/ssa-fn.sml

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

revision 3505, Fri Dec 18 02:47:03 2015 UTC revision 3527, Tue Dec 22 16:44:18 2015 UTC
# Line 12  Line 12 
12    
13  functor SSAFn (  functor SSAFn (
14    
15      val ilName : string      val irName : string
16    
17      structure Ty : SSA_TYPES      structure Ty : SSA_TYPES
18      structure Op : OPERATORS where type ty = Ty.ty      structure Op : OPERATORS where type ty = Ty.ty
# Line 22  Line 22 
22      structure Ty = Ty      structure Ty = Ty
23      structure Op = Op      structure Op = Op
24    
25      val ilName = ilName      val irName = irName
26    
27    (***** CFG *****)    (***** CFG *****)
28    
29        datatype global_kind = datatype GlobalVarKind.t
30    
31      datatype cfg = CFG of {      datatype cfg = CFG of {
32          entry : node,   (* the entry node of a graph; not necessarily an ENTRY node *)          entry : node,   (* the entry node of a graph; not necessarily an ENTRY node *)
33          exit : node     (* the exit node of a graph; not necessarily an EXIT node. *)          exit : node     (* the exit node of a graph; not necessarily an EXIT node. *)
# Line 131  Line 133 
133                                          (* n'th result of operator in multi-assignment *)                                          (* n'th result of operator in multi-assignment *)
134        | VB_PHI of var option list       (* defined by a phi node *)        | VB_PHI of var option list       (* defined by a phi node *)
135        | VB_PARAM                        (* parameter to a strand *)        | VB_PARAM                        (* parameter to a strand *)
136          | VB_ITER                         (* bound in a foreach loop *)
137    
138    (***** global variables *****)    (***** global variables *****)
139      and global_var = GV of {      and global_var = GV of {
140          id : Stamp.stamp,               (* variable's unique ID *)          id : Stamp.stamp,               (* variable's unique ID *)
141          name : string,                  (* variable's name *)          name : string,                  (* variable's name *)
142          ty : Ty.ty,                     (* variable's type *)          ty : Ty.ty,                     (* variable's type *)
143          input : bool,                   (* true for input variables *)          kind : global_kind,             (* the variable kind *)
144            useCnt : int ref,               (* count of uses *)
145          props : PropList.holder          props : PropList.holder
146        }        }
147    
# Line 193  Line 197 
197    
198      structure GlobalVar =      structure GlobalVar =
199        struct        struct
200          fun new (isIn, name, ty) = GV{          fun new (kind, name, ty) = GV{
201                  id = Stamp.new(),                  id = Stamp.new(),
202                  name = name,                  name = name,
203                  ty = ty,                  ty = ty,
204                  input = isIn,                  kind = kind,
205                    useCnt = ref 0,
206                  props = PropList.newHolder()                  props = PropList.newHolder()
207                }                }
208          fun name (GV{name, ...}) = name          fun name (GV{name, ...}) = name
209          fun uniqueName (GV{id, name, ...}) = name ^ Stamp.toString id          fun uniqueName (GV{id, name, ...}) = name ^ Stamp.toString id
210            fun kind (GV{kind, ...}) = kind
211          fun ty (GV{ty, ...}) = ty          fun ty (GV{ty, ...}) = ty
212          fun isInput (GV{input, ...}) = input          fun isInput (GV{kind=InputVar, ...}) = true
213              | isInput _ = false
214            fun useCount (GV{useCnt, ...}) = !useCnt
215          fun same (GV{id=a, ...}, GV{id=b, ...}) = Stamp.same(a, b)          fun same (GV{id=a, ...}, GV{id=b, ...}) = Stamp.same(a, b)
216          fun compare (GV{id=a, ...}, GV{id=b, ...}) = Stamp.compare(a, b)          fun compare (GV{id=a, ...}, GV{id=b, ...}) = Stamp.compare(a, b)
217          fun hash (GV{id, ...}) = Stamp.hash id          fun hash (GV{id, ...}) = Stamp.hash id
# Line 383  Line 391 
391                  pred = ref dummy, cond = cond,                  pred = ref dummy, cond = cond,
392                  trueBranch = ref dummy, falseBranch = ref dummy                  trueBranch = ref dummy, falseBranch = ref dummy
393                })                })
394          fun mkFOREACH (var, src) = new (FOREACH{          fun mkFOREACH (var, src) = (
395                  Var.setBinding (var, VB_ITER);
396                  new (FOREACH{
397                  pred = ref dummy,                  pred = ref dummy,
398                  phis = ref [], mask = ref [],                  phis = ref [], mask = ref [],
399                  var = var, src = src,                  var = var, src = src,
400                  bodyEntry = ref dummy,                  bodyEntry = ref dummy,
401                  bodyExit = ref dummy,                  bodyExit = ref dummy,
402                  succ = ref dummy                  succ = ref dummy
403                })                  }))
404          fun mkCOM text = new (COM{pred = ref dummy, text = text, succ = ref dummy})          fun mkCOM text = new (COM{pred = ref dummy, text = text, succ = ref dummy})
405          fun mkASSIGN (lhs, rhs) = (          fun mkASSIGN (lhs, rhs) = (
406                Var.setBinding (lhs, VB_RHS rhs);                Var.setBinding (lhs, VB_RHS rhs);
# Line 885  Line 895 
895              String.concatWithMap "," (fn NONE => "_" | SOME x => Var.toString x) xs, ")"              String.concatWithMap "," (fn NONE => "_" | SOME x => Var.toString x) xs, ")"
896            ]            ]
897        | vbToString VB_PARAM = "PARAM"        | vbToString VB_PARAM = "PARAM"
898          | vbToString VB_ITER = "ITER"
899    
900    (* return a string representation of a PHI node *)    (* return a string representation of a PHI node *)
901      fun phiToString (y, xs) = String.concat [      fun phiToString (y, xs) = String.concat [

Legend:
Removed from v.3505  
changed lines
  Added in v.3527

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