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 3613, Fri Jan 22 22:37:54 2016 UTC revision 3754, Thu Apr 14 22:45:39 2016 UTC
# Line 67  Line 67 
67              bodyExit : node ref,        (* the loop body exit node *)              bodyExit : node ref,        (* the loop body exit node *)
68              succ : node ref             (* the loop-exit edge *)              succ : node ref             (* the loop-exit edge *)
69            }            }
70          | NEXT of {                       (* a loop-body exit node *)
71                pred : node ref,            (* the predecessor *)
72                succ : node ref             (* the FOREACH node *)
73              }
74        | COM of  {                       (* comment *)        | COM of  {                       (* comment *)
75              pred : node ref,              pred : node ref,
76              text : string list,              text : string list,
# Line 356  Line 360 
360                        | JOIN _ => "JOIN"                        | JOIN _ => "JOIN"
361                        | COND _ => "COND"                        | COND _ => "COND"
362                        | FOREACH _ => "FOREACH"                        | FOREACH _ => "FOREACH"
363                          | NEXT _ => "NEXT"
364                        | COM _ => "COM"                        | COM _ => "COM"
365                        | ASSIGN _ => "ASSIGN"                        | ASSIGN _ => "ASSIGN"
366                        | MASSIGN _ => "MASSIGN"                        | MASSIGN _ => "MASSIGN"
# Line 385  Line 390 
390                      in                      in
391                        List.foldr (fn ((_, xs), ys) => add(xs, ys)) [!src] (!phis)                        List.foldr (fn ((_, xs), ys) => add(xs, ys)) [!src] (!phis)
392                      end                      end
393                    | NEXT _ => []
394                  | ASSIGN{stm=(y, rhs), ...} => (case rhs                  | ASSIGN{stm=(y, rhs), ...} => (case rhs
395                       of GLOBAL _ => []                       of GLOBAL _ => []
396                        | STATE _ => []                        | STATE _ => []
# Line 425  Line 431 
431                    bodyExit = ref dummy,                    bodyExit = ref dummy,
432                    succ = ref dummy                    succ = ref dummy
433                  }))                  }))
434            fun mkNEXT () = new(NEXT{pred = ref dummy, succ = ref dummy})
435          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})
436          fun mkASSIGN (lhs, rhs) = (          fun mkASSIGN (lhs, rhs) = (
437                Var.setBinding (lhs, VB_RHS rhs);                Var.setBinding (lhs, VB_RHS rhs);
# Line 472  Line 479 
479                  | ENTRY _ => raise Fail("setPred on ENTRY node " ^ toString nd0)                  | ENTRY _ => raise Fail("setPred on ENTRY node " ^ toString nd0)
480                  | JOIN{preds, ...} => preds := !preds @ [nd]  (* assume preds are added in order *)                  | JOIN{preds, ...} => preds := !preds @ [nd]  (* assume preds are added in order *)
481                  | FOREACH{pred, ...} => pred := nd                  | FOREACH{pred, ...} => pred := nd
482                    | NEXT{pred, ...} => pred := nd
483                  | COND{pred, ...} => pred := nd                  | COND{pred, ...} => pred := nd
484                  | COM{pred, ...} => pred := nd                  | COM{pred, ...} => pred := nd
485                  | ASSIGN{pred, ...} => pred := nd                  | ASSIGN{pred, ...} => pred := nd
# Line 487  Line 495 
495                  | JOIN{preds, ...} => !preds                  | JOIN{preds, ...} => !preds
496                  | COND{pred, ...} => [!pred]                  | COND{pred, ...} => [!pred]
497                  | FOREACH{pred, bodyExit, ...} => [!pred, !bodyExit]                  | FOREACH{pred, bodyExit, ...} => [!pred, !bodyExit]
498                    | NEXT{pred, ...} => [!pred]
499                  | COM{pred, ...} => [!pred]                  | COM{pred, ...} => [!pred]
500                  | ASSIGN{pred, ...} => [!pred]                  | ASSIGN{pred, ...} => [!pred]
501                  | MASSIGN{pred, ...} => [!pred]                  | MASSIGN{pred, ...} => [!pred]
# Line 502  Line 511 
511                  | COND _ => true                  | COND _ => true
512                  | COM _ => true                  | COM _ => true
513                  | FOREACH _ => true                  | FOREACH _ => true
514                    | NEXT _ => true
515                  | ASSIGN _ => true                  | ASSIGN _ => true
516                  | MASSIGN _ => true                  | MASSIGN _ => true
517                  | GASSIGN _ => true                  | GASSIGN _ => true
# Line 516  Line 526 
526                  | JOIN{succ, ...} => succ := nd                  | JOIN{succ, ...} => succ := nd
527                  | COND _ => raise Fail("setSucc on COND node "^toString nd0)                  | COND _ => raise Fail("setSucc on COND node "^toString nd0)
528                  | FOREACH{succ, ...} => succ := nd                  | FOREACH{succ, ...} => succ := nd
529                    | NEXT{succ, ...} => succ := nd
530                  | COM{succ, ...} => succ := nd                  | COM{succ, ...} => succ := nd
531                  | ASSIGN{succ, ...} => succ := nd                  | ASSIGN{succ, ...} => succ := nd
532                  | MASSIGN{succ, ...} => succ := nd                  | MASSIGN{succ, ...} => succ := nd
# Line 530  Line 541 
541                  | JOIN{succ, ...} => [!succ]                  | JOIN{succ, ...} => [!succ]
542                  | COND{trueBranch, falseBranch, ...} => [!trueBranch, !falseBranch]                  | COND{trueBranch, falseBranch, ...} => [!trueBranch, !falseBranch]
543                  | FOREACH{bodyEntry, succ, ...} => [!bodyEntry, !succ]                  | FOREACH{bodyEntry, succ, ...} => [!bodyEntry, !succ]
544                    | NEXT{succ, ...} => [!succ]
545                  | COM{succ, ...} => [!succ]                  | COM{succ, ...} => [!succ]
546                  | ASSIGN{succ, ...} => [!succ]                  | ASSIGN{succ, ...} => [!succ]
547                  | MASSIGN{succ, ...} => [!succ]                  | MASSIGN{succ, ...} => [!succ]
# Line 709  Line 721 
721                        if Node.same(!pred', nd)                        if Node.same(!pred', nd)
722                          then pred' := pred                          then pred' := pred
723                          else bodyExit := pred                          else bodyExit := pred
724                      | NEXT _ => raise Fail "deleteNode(NEXT)"
725                    | _ => Node.setPred (succ, pred)                    | _ => Node.setPred (succ, pred)
726                  (* end case *);                  (* end case *);
727                (* replace the successor edge from pred to nd with an edge from pred to succ *)                (* replace the successor edge from pred to nd with an edge from pred to succ *)
# Line 832  Line 845 
845         * node, then the block is inserted immediatly before the exit.         * node, then the block is inserted immediatly before the exit.
846         *)         *)
847          fun appendBlock (cfg, []) = cfg          fun appendBlock (cfg, []) = cfg
848            | appendBlock (cfg as CFG{entry, exit}, stms) = (case exit            | appendBlock (cfg as CFG{entry, exit}, stms) = let
                of ND{kind=EXIT{pred, ...}, ...} => let  
849                      fun mkNode (ASSGN stm) = Node.mkASSIGN stm                      fun mkNode (ASSGN stm) = Node.mkASSIGN stm
850                        | mkNode (MASSGN stm) = Node.mkMASSIGN stm                        | mkNode (MASSGN stm) = Node.mkMASSIGN stm
851                        | mkNode (GASSGN stm) = Node.mkGASSIGN stm                        | mkNode (GASSGN stm) = Node.mkGASSIGN stm
# Line 844  Line 856 
856                              Node.addEdge (prev, nd);                              Node.addEdge (prev, nd);
857                              nd                              nd
858                            end                            end
859                  in
860                    case exit
861                     of ND{kind=EXIT{pred, ...}, ...} => let
862                          val last = List.foldl f (!pred) stms
863                          in
864                            pred := last;
865                            Node.setSucc(last, exit);
866                            cfg
867                          end
868                      | ND{kind=NEXT{pred, ...}, ...} => let
869                      val last = List.foldl f (!pred) stms                      val last = List.foldl f (!pred) stms
870                      in                      in
871                        pred := last;                        pred := last;
# Line 851  Line 873 
873                        cfg                        cfg
874                      end                      end
875                  | _ => concat(cfg, mkBlock stms)                  | _ => concat(cfg, mkBlock stms)
876                (* end case *))                  (* end case *)
877                  end
878        end        end
879    
880      structure RHS =      structure RHS =

Legend:
Removed from v.3613  
changed lines
  Added in v.3754

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