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 3470, Mon Nov 30 17:51:33 2015 UTC revision 3473, Wed Dec 2 17:57:53 2015 UTC
# Line 54  Line 54 
54              trueBranch : node ref,              trueBranch : node ref,
55              falseBranch : node ref              falseBranch : node ref
56            }            }
57          | FOREACH of {                    (* foreach-loop; this node combines aspects of the COND
58                                             * and JOIN nodes. *)
59                preds : node list ref,      (* the predecessors; the first item is the entry edge
60                                             * and the others are the loop back edges. *)
61                phis : phi list ref,        (* phi nodes (as in JOIN) *)
62                mask : bool list ref,       (* true for incoming fake edges *)
63                var : var,                  (* the loop variable *)
64                src : var,                  (* the source of values being iterated over *)
65                body : node ref,            (* the loop body *)
66                succ : node ref             (* the loop-exit edge *)
67              }
68        | COM of  {                       (* comment *)        | COM of  {                       (* comment *)
69              pred : node ref,              pred : node ref,
70              text : string list,              text : string list,
# Line 313  Line 324 
324                        | ENTRY _ => "ENTRY"                        | ENTRY _ => "ENTRY"
325                        | JOIN _ => "JOIN"                        | JOIN _ => "JOIN"
326                        | COND _ => "COND"                        | COND _ => "COND"
327                          | FOREACH _ => "FOREACH"
328                        | COM _ => "COM"                        | COM _ => "COM"
329                        | ASSIGN _ => "ASSIGN"                        | ASSIGN _ => "ASSIGN"
330                        | MASSIGN _ => "MASSIGN"                        | MASSIGN _ => "MASSIGN"
# Line 335  Line 347 
347                        List.foldr (fn ((_, xs), ys) => add(xs, ys)) [] (!phis)                        List.foldr (fn ((_, xs), ys) => add(xs, ys)) [] (!phis)
348                      end                      end
349                  | COND{cond, ...} => [cond]                  | COND{cond, ...} => [cond]
350                    | FOREACH{src, phis, ...} => let
351                        fun add ([], ys) = ys
352                          | add (SOME x :: xs, ys) = add(xs, x::ys)
353                          | add (NONE :: xs, ys) = add(xs, ys)
354                        in
355                          List.foldr (fn ((_, xs), ys) => add(xs, ys)) [src] (!phis)
356                        end
357                  | ASSIGN{stm=(y, rhs), ...} => (case rhs                  | ASSIGN{stm=(y, rhs), ...} => (case rhs
358                       of GLOBAL _ => []                       of GLOBAL _ => []
359                        | STATE _ => []                        | STATE _ => []
# Line 354  Line 373 
373                (* end case *))                (* end case *))
374          fun defs (ND{kind, ...}) = (case kind          fun defs (ND{kind, ...}) = (case kind
375                 of JOIN{phis, ...} => List.map #1 (!phis)                 of JOIN{phis, ...} => List.map #1 (!phis)
376                    | FOREACH{var, phis, ...} => var :: List.map #1 (!phis)
377                  | ASSIGN{stm=(y, _), ...} => [y]                  | ASSIGN{stm=(y, _), ...} => [y]
378                  | MASSIGN{stm=(ys, _, _), ...} => ys                  | MASSIGN{stm=(ys, _, _), ...} => ys
379                  | _ => []                  | _ => []
# Line 365  Line 385 
385                  pred = ref dummy, cond = cond,                  pred = ref dummy, cond = cond,
386                  trueBranch = ref dummy, falseBranch = ref dummy                  trueBranch = ref dummy, falseBranch = ref dummy
387                })                })
388            fun mkFOREACH (var, src) = new (FOREACH{
389                    preds = ref [],
390                    phis = ref [], mask = ref [],
391                    var = var, src = src,
392                    body = ref dummy, succ = ref dummy
393                  })
394          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})
395          fun mkASSIGN (lhs, rhs) = (          fun mkASSIGN (lhs, rhs) = (
396                Var.setBinding (lhs, VB_RHS rhs);                Var.setBinding (lhs, VB_RHS rhs);
# Line 413  Line 439 
439                 of NULL => raise Fail("setPred on NULL node " ^ toString nd0)                 of NULL => raise Fail("setPred on NULL node " ^ toString nd0)
440                  | ENTRY _ => raise Fail("setPred on ENTRY node " ^ toString nd0)                  | ENTRY _ => raise Fail("setPred on ENTRY node " ^ toString nd0)
441                  | JOIN{preds, ...} => preds := !preds @ [nd]  (* assume preds are added in order *)                  | JOIN{preds, ...} => preds := !preds @ [nd]  (* assume preds are added in order *)
442                    | FOREACH{preds, ...} => preds := !preds @ [nd]
443                  | COND{pred, ...} => pred := nd                  | COND{pred, ...} => pred := nd
444                  | COM{pred, ...} => pred := nd                  | COM{pred, ...} => pred := nd
445                  | ASSIGN{pred, ...} => pred := nd                  | ASSIGN{pred, ...} => pred := nd
# Line 427  Line 454 
454                  | ENTRY _ => []                  | ENTRY _ => []
455                  | JOIN{preds, ...} => !preds                  | JOIN{preds, ...} => !preds
456                  | COND{pred, ...} => [!pred]                  | COND{pred, ...} => [!pred]
457                    | FOREACH{preds, ...} => !preds
458                  | COM{pred, ...} => [!pred]                  | COM{pred, ...} => [!pred]
459                  | ASSIGN{pred, ...} => [!pred]                  | ASSIGN{pred, ...} => [!pred]
460                  | MASSIGN{pred, ...} => [!pred]                  | MASSIGN{pred, ...} => [!pred]
# Line 441  Line 469 
469                  | JOIN _ => true                  | JOIN _ => true
470                  | COND _ => true                  | COND _ => true
471                  | COM _ => true                  | COM _ => true
472                    | FOREACH _ => true
473                  | ASSIGN _ => true                  | ASSIGN _ => true
474                  | MASSIGN _ => true                  | MASSIGN _ => true
475                  | GASSIGN _ => true                  | GASSIGN _ => true
# Line 454  Line 483 
483                  | ENTRY{succ} => succ := nd                  | ENTRY{succ} => succ := nd
484                  | JOIN{succ, ...} => succ := nd                  | JOIN{succ, ...} => succ := nd
485                  | COND _ => raise Fail("setSucc on COND node "^toString nd0)                  | COND _ => raise Fail("setSucc on COND node "^toString nd0)
486                    | FOREACH _ => raise Fail("setSucc on FOREACH node "^toString nd0)
487                  | COM{succ, ...} => succ := nd                  | COM{succ, ...} => succ := nd
488                  | ASSIGN{succ, ...} => succ := nd                  | ASSIGN{succ, ...} => succ := nd
489                  | MASSIGN{succ, ...} => succ := nd                  | MASSIGN{succ, ...} => succ := nd
# Line 467  Line 497 
497                  | ENTRY{succ} => [!succ]                  | ENTRY{succ} => [!succ]
498                  | JOIN{succ, ...} => [!succ]                  | JOIN{succ, ...} => [!succ]
499                  | COND{trueBranch, falseBranch, ...} => [!trueBranch, !falseBranch]                  | COND{trueBranch, falseBranch, ...} => [!trueBranch, !falseBranch]
500                    | FOREACH{body, succ, ...} => [!body, !succ]
501                  | COM{succ, ...} => [!succ]                  | COM{succ, ...} => [!succ]
502                  | ASSIGN{succ, ...} => [!succ]                  | ASSIGN{succ, ...} => [!succ]
503                  | MASSIGN{succ, ...} => [!succ]                  | MASSIGN{succ, ...} => [!succ]
# Line 481  Line 512 
512            | setTrueBranch (nd, _) = raise Fail("setTrueBranch on " ^ toString nd)            | setTrueBranch (nd, _) = raise Fail("setTrueBranch on " ^ toString nd)
513          fun setFalseBranch (ND{kind=COND{falseBranch, ...}, ...}, nd) = falseBranch := nd          fun setFalseBranch (ND{kind=COND{falseBranch, ...}, ...}, nd) = falseBranch := nd
514            | setFalseBranch (nd, _) = raise Fail("setFalseBranch on " ^ toString nd)            | setFalseBranch (nd, _) = raise Fail("setFalseBranch on " ^ toString nd)
515            fun setBodyBranch (ND{kind=FOREACH{body, ...}, ...}, nd) = body := nd
516              | setBodyBranch (nd, _) = raise Fail("setBodyBranch on " ^ toString nd)
517            fun setExitBranch (ND{kind=FOREACH{succ, ...}, ...}, nd) = succ := nd
518              | setExitBranch (nd, _) = raise Fail("setExitBranch on " ^ toString nd)
519          fun setEdgeMask (ND{kind=JOIN{mask, ...}, ...}, mask') = mask := mask'          fun setEdgeMask (ND{kind=JOIN{mask, ...}, ...}, mask') = mask := mask'
520            | setEdgeMask (nd, _) = raise Fail("setEdgeMask on " ^ toString nd)            | setEdgeMask (nd, _) = raise Fail("setEdgeMask on " ^ toString nd)
521          fun addEdge (nd1, nd2) = (          fun addEdge (nd1, nd2) = (

Legend:
Removed from v.3470  
changed lines
  Added in v.3473

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