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

SCM Repository

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

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

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

revision 392, Thu Oct 14 15:34:28 2010 UTC revision 412, Sat Oct 16 15:19:19 2010 UTC
# Line 89  Line 89 
89      and var = V of {      and var = V of {
90          name : string,                  (* name *)          name : string,                  (* name *)
91          id : Stamp.stamp,               (* unique ID *)          id : Stamp.stamp,               (* unique ID *)
92            ty : Ty.ty,                     (* type *)
93          bind : var_bind ref,            (* binding *)          bind : var_bind ref,            (* binding *)
94          useCnt : int ref,               (* count of uses *)          useCnt : int ref,               (* count of uses *)
95          props : PropList.holder          props : PropList.holder
# Line 196  Line 197 
197        end        end
198    
199      structure Var : sig      structure Var : sig
200          val new : string -> var          val new : string * Ty.ty -> var
201          val name : var -> string          val name : var -> string
202            val ty : var -> Ty.ty
203          val binding : var -> var_bind          val binding : var -> var_bind
204          val setBinding : var * var_bind -> unit          val setBinding : var * var_bind -> unit
205          val same : var * var -> bool          val same : var * var -> bool
# Line 221  Line 223 
223          structure Tbl : MONO_HASH_TABLE where type Key.hash_key = var          structure Tbl : MONO_HASH_TABLE where type Key.hash_key = var
224        end        end
225    
226      (* return a string representation of a PHI node *)
227        val phiToString : (var * var list) -> string
228    
229      (* return a string representation of an assignment *)
230        val assignToString : assign -> string
231    
232    (* DFS sorting of the graph rooted at the entry to a statement; the resulting list will    (* DFS sorting of the graph rooted at the entry to a statement; the resulting list will
233     * be in preorder with parents before children.     * be in preorder with parents before children.
234     *)     *)
# Line 314  Line 322 
322    
323      and var = V of {      and var = V of {
324          name : string,                  (* name *)          name : string,                  (* name *)
325            ty : Ty.ty,                     (* type *)
326          bind : var_bind ref,            (* binding *)          bind : var_bind ref,            (* binding *)
327          id : Stamp.stamp,               (* unique ID *)          id : Stamp.stamp,               (* unique ID *)
328          useCnt : int ref,               (* count of uses *)          useCnt : int ref,               (* count of uses *)
# Line 535  Line 544 
544    
545      structure Var =      structure Var =
546        struct        struct
547          fun new name = V{          fun new (name, ty) = V{
548                  name = name,                  name = name,
549                  id = Stamp.new(),                  id = Stamp.new(),
550                    ty = ty,
551                  bind = ref VB_NONE,                  bind = ref VB_NONE,
552                  useCnt = ref 0,                  useCnt = ref 0,
553                  props = PropList.newHolder()                  props = PropList.newHolder()
554                }                }
555          fun name (V{name, ...}) = name          fun name (V{name, ...}) = name
556            fun ty (V{ty, ...}) = ty
557          fun binding (V{bind, ...}) = !bind          fun binding (V{bind, ...}) = !bind
558          fun setBinding (V{bind, ...}, vb) = bind := vb          fun setBinding (V{bind, ...}, vb) = bind := vb
559          fun same (V{id=a, ...}, V{id=b, ...}) = Stamp.same(a, b)          fun same (V{id=a, ...}, V{id=b, ...}) = Stamp.same(a, b)
# Line 572  Line 583 
583            end)            end)
584        end        end
585    
586      (* return a string representation of a PHI node *)
587        fun phiToString (y, xs) = String.concat [
588                Ty.toString(Var.ty y), " ", Var.toString y, " = PHI(",
589                String.concatWith "," (List.map Var.toString xs), ")"
590              ]
591    
592      (* return a string representation of an assignment *)
593        fun assignToString (y, rhs) = let
594              val rhs = (case rhs
595                     of VAR x => Var.toString x
596                      | LIT lit => Literal.toString lit
597                      | OP(rator, xs) => String.concat [
598                            Op.toString rator,
599                            "(", String.concatWith "," (List.map Var.toString xs), ")"
600                          ]
601                      | CONS xs => String.concat [
602                            "[", String.concatWith "," (List.map Var.toString xs), "]"
603                          ]
604                    (* end case *))
605              in
606                String.concat [Ty.toString(Var.ty y), " ", Var.toString y, " = ", rhs]
607              end
608    
609    (* DFS sorting of the graph rooted at the entry to a statement; the resulting list will    (* DFS sorting of the graph rooted at the entry to a statement; the resulting list will
610     * be in preorder with parents before children.     * be in preorder with parents before children.
611     *)     *)

Legend:
Removed from v.392  
changed lines
  Added in v.412

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