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

SCM Repository

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

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

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

revision 1639, Wed Nov 16 01:48:07 2011 UTC revision 1640, Wed Nov 16 02:19:51 2011 UTC
# Line 41  Line 41 
41    
42      fun assignToString (y, rhs) = let      fun assignToString (y, rhs) = let
43            val rhs = (case rhs            val rhs = (case rhs
44                   of IL.VAR x => [Var.toString x, ";"]                   of IL.STATE x => [IL.StateVar.toString x, ";"]
45                      | IL.VAR x => [Var.toString x, ";"]
46                    | IL.LIT lit => [Literal.toString lit, ";"]                    | IL.LIT lit => [Literal.toString lit, ";"]
47                    | IL.OP(rator, []) => [Op.toString rator, ";"]                    | IL.OP(rator, []) => [Op.toString rator, ";"]
48                    | IL.OP(rator, args) => [                    | IL.OP(rator, args) => [
# Line 61  Line 62 
62              String.concat(typedVar y :: " = " :: rhs)              String.concat(typedVar y :: " = " :: rhs)
63            end            end
64    
65        fun massignToString ([], rator, xs) = String.concat [
66                Op.toString rator, "(", String.concatWith "," (List.map Var.toString xs), ");"
67              ]
68          | massignToString (ys, rator, xs) = String.concat [
69                "(", String.concatWith "," (List.map typedVar ys), ") = ",
70                Op.toString rator, "(", String.concatWith "," (List.map Var.toString xs), ");"
71              ]
72    
73      fun labelOf (IL.ND{id, ...}) = "L"^Stamp.toString id      fun labelOf (IL.ND{id, ...}) = "L"^Stamp.toString id
74    
75      fun ppCFG (out, cfg as IL.CFG{entry, exit}) = let      fun ppCFG (out, cfg as IL.CFG{entry, exit}) = let
# Line 108  Line 117 
117                          | IL.ASSIGN{stm, succ, ...} => (                          | IL.ASSIGN{stm, succ, ...} => (
118                              prln (out1, [assignToString stm, "\n"]);                              prln (out1, [assignToString stm, "\n"]);
119                              goto (out, !succ))                              goto (out, !succ))
120                            | IL.MASSIGN{stm, succ, ...} => (
121                                prln (out1, [massignToString stm, "\n"]);
122                                goto (out, !succ))
123                          | IL.NEW{strand, args, succ, ...} => (                          | IL.NEW{strand, args, succ, ...} => (
124                              prln (out1, [                              prln (out1, [
125                                  "new ", Atom.toString strand, "(",                                  "new ", Atom.toString strand, "(",
126                                  String.concatWith "," (List.map Var.toString args), ");\n"                                  String.concatWith "," (List.map Var.toString args), ");\n"
127                                ]);                                ]);
128                              goto (out, !succ))                              goto (out, !succ))
129                            | IL.SAVE{lhs, rhs, succ, ...} => (
130                                prln (out1, [
131                                    IL.StateVar.toString lhs, " = ", Var.toString rhs, ";\n"
132                                  ]);
133                                goto (out, !succ))
134                          | IL.EXIT{kind, live, ...} => let                          | IL.EXIT{kind, live, ...} => let
135                              val live = (case live                              val live = (case live
136                                     of [] => "()"                                     of [] => "()"
# Line 167  Line 184 
184              ppIters (incIndent out, iters)              ppIters (incIndent out, iters)
185            end            end
186    
187      fun ppMethod (out, IL.Method{name, stateIn, body}) = let      fun ppMethod (out, IL.Method{name, body}) = let
188            val out1 = incIndent out            val out1 = incIndent out
189            fun prVars xs = List.app (fn x => prl(out, [" ", typedVar x, ";"])) xs            fun prVars xs = List.app (fn x => prl(out, [" ", typedVar x, ";"])) xs
190            in            in
191              indent out; prl(out, ["method ", MethodName.toString name, "\n"]);              indent out; prl(out, ["method ", StrandUtil.nameToString name, "\n"]);
             indent out1; pr(out1, "state in: "); prVars stateIn; pr(out1, "\n");  
192              ppCFG (incIndent out1, body);              ppCFG (incIndent out1, body);
193              indent out1; pr(out1, "state out:"); prVars(IL.CFG.liveAtExit body); pr(out1, "\n");              indent out; prl(out, ["end ", StrandUtil.nameToString name, "\n"])
             indent out; prl(out, ["end ", MethodName.toString name, "\n"])  
194            end            end
195    
196      and ppStrand (out, IL.Strand{name, params, state, stateInit, methods}) = let      and ppStrand (out, IL.Strand{name, params, state, stateInit, methods}) = let
197            val out1 = incIndent out            val out1 = incIndent out
198            fun prVars xs = List.app            fun stateVar x = let
199                  (fn (true, x) => prl(out, [" output ", typedVar x, ";"])                  val l = [Ty.toString(IL.StateVar.ty x), " ", IL.StateVar.toString x, ";"]
200                    | (_, x) => prl(out, [" ", typedVar x, ";"]))                  val l = if IL.StateVar.isOutput x then "output " :: l else l
201                  xs                  in
202                      prl (out1, l)
203                    end
204            in            in
205              indent out;              indent out;
206              prl(out, [              prl(out, [
207                  "strand ", Atom.toString name, " (",                  "strand ", Atom.toString name, " (",
208                  String.concatWith ", " (List.map typedVar params), ")\n"                  String.concatWith ", " (List.map typedVar params), ")\n"
209                ]);                ]);
210              indent out1; pr(out1, "state: "); prVars state; pr(out1, "\n");              indent out1; pr(out1, "state: "); List.app stateVar state; pr(out1, "\n");
211              ppCFG (incIndent out1, stateInit);              ppCFG (incIndent out1, stateInit);
212              List.app (fn m => ppMethod(out1, m)) methods;              List.app (fn m => ppMethod(out1, m)) methods;
213              indent out; prl(out, ["end ", Atom.toString name, "\n"])              indent out; prl(out, ["end ", Atom.toString name, "\n"])
214            end            end
215    
216      fun output (outS, msg, IL.Program{globalInit, initially, strands}) = let      fun output (outS, msg, IL.Program{props, globalInit, initially, strands}) = let
217            val out = (outS, 0)            val out = (outS, 0)
218            val out1 = incIndent out            val out1 = incIndent out
219            in            in
220              pr (out, concat["##### ", msg, " ####\n"]);              pr (out, concat["##### ", msg, " ####\n"]);
221                pr(out, "## properties\n");
222                case props
223                 of [] => prln(out1, ["none\n"])
224                  | _ => prln(out1, [String.concatWith " " (List.map StrandUtil.propToString props), "\n"])
225                (* end case *);
226              pr (out, "## globals\n");              pr (out, "## globals\n");
227              List.app              List.app
228                (fn x => (indent out1; prl(out1, ["global ", typedVar x, "\n"])))                (fn x => (indent out1; prl(out1, ["global ", typedVar x, "\n"])))

Legend:
Removed from v.1639  
changed lines
  Added in v.1640

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