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 3936, Mon Jun 6 10:34:23 2016 UTC revision 3937, Mon Jun 6 13:16:10 2016 UTC
# Line 577  Line 577 
577  (*DEBUG*)handle ex => (  (*DEBUG*)handle ex => (
578  print(concat["error in addEdge(", toString nd1, ",", toString nd2, ")\n"]);  print(concat["error in addEdge(", toString nd1, ",", toString nd2, ")\n"]);
579  raise ex)  raise ex)
 (* FIXME: the names replaceInEdge and replaceOutEdge are backwards! *)  
580        (* replace the edge src-->oldDst by the edge src-->dst *)        (* replace the edge src-->oldDst by the edge src-->dst *)
581          fun replaceInEdge {src, oldDst, dst} = (          fun replaceOutEdge {src, oldDst, dst} = (
582              (* first set the successor of src *)              (* first set the successor of src *)
583                case kind src                case kind src
584                 of COND{trueBranch, falseBranch, ...} =>                 of COND{trueBranch, falseBranch, ...} =>
# Line 601  Line 600 
600                  | _ => setPred (dst, src)                  | _ => setPred (dst, src)
601                (* end case *))                (* end case *))
602  (*DEBUG*)handle ex => (  (*DEBUG*)handle ex => (
603  print(concat["error in replaceInEdge(", toString src, ",", toString oldDst, ",", toString dst, ")\n"]);  print(concat["error in replaceOutEdge(", toString src, ",", toString oldDst, ",", toString dst, ")\n"]);
604  raise ex)  raise ex)
605        (* replace the edge oldSrc-->dst by the edge src-->dst *)        (* replace the edge oldSrc-->dst by the edge src-->dst *)
606          fun replaceOutEdge {oldSrc, src, dst} = (          fun replaceInEdge {oldSrc, src, dst} = (
607              (* first set the successor of src *)              (* first set the successor of src *)
608                case kind oldSrc                case kind oldSrc
609                 of COND{trueBranch, falseBranch, ...} =>                 of COND{trueBranch, falseBranch, ...} =>
# Line 620  Line 619 
619              (* then set the predecessor of dst *)              (* then set the predecessor of dst *)
620                case kind dst                case kind dst
621                 of JOIN{preds, ...} => let                 of JOIN{preds, ...} => let
622                      fun edit [] = raise Fail "replaceOutEdge: cannot find predecessor"                      fun edit [] = raise Fail "replaceInEdge: cannot find predecessor"
623                        | edit (nd::nds) = if same(nd, oldSrc) then src::nds else nd::edit nds                        | edit (nd::nds) = if same(nd, oldSrc) then src::nds else nd::edit nds
624                      in                      in
625                        preds := edit (!preds)                        preds := edit (!preds)
# Line 632  Line 631 
631                  | _ => setPred (dst, src)                  | _ => setPred (dst, src)
632                (* end case *))                (* end case *))
633  (*DEBUG*)handle ex => (  (*DEBUG*)handle ex => (
634  print(concat["error in replaceOutEdge(", toString oldSrc, ",", toString src, ",", toString dst, ")\n"]);  print(concat["error in replaceInEdge(", toString oldSrc, ",", toString src, ",", toString dst, ")\n"]);
635  raise ex)  raise ex)
636        (* properties *)        (* properties *)
637          fun newProp initFn =          fun newProp initFn =
# Line 756  Line 755 
755        (* replace a simple node in a cfg with a subgraph *)        (* replace a simple node in a cfg with a subgraph *)
756          fun replaceNode (oldNd as ND{kind, ...}, node) = (case kind          fun replaceNode (oldNd as ND{kind, ...}, node) = (case kind
757                 of ASSIGN{pred, succ, ...} => (                 of ASSIGN{pred, succ, ...} => (
758                      Node.replaceInEdge {src = !pred, oldDst = oldNd, dst = node};                      Node.replaceOutEdge {src = !pred, oldDst = oldNd, dst = node};
759                      Node.replaceOutEdge {oldSrc = oldNd, src = node, dst = !succ})                      Node.replaceInEdge {oldSrc = oldNd, src = node, dst = !succ})
760                  | MASSIGN{pred, succ, ...} => (                  | MASSIGN{pred, succ, ...} => (
761                      Node.replaceInEdge {src = !pred, oldDst = oldNd, dst = node};                      Node.replaceOutEdge {src = !pred, oldDst = oldNd, dst = node};
762                      Node.replaceOutEdge {oldSrc = oldNd, src = node, dst = !succ})                      Node.replaceInEdge {oldSrc = oldNd, src = node, dst = !succ})
763                  | GASSIGN{pred, succ, ...} => (                  | GASSIGN{pred, succ, ...} => (
764                      Node.replaceInEdge {src = !pred, oldDst = oldNd, dst = node};                      Node.replaceOutEdge {src = !pred, oldDst = oldNd, dst = node};
765                      Node.replaceOutEdge {oldSrc = oldNd, src = node, dst = !succ})                      Node.replaceInEdge {oldSrc = oldNd, src = node, dst = !succ})
766                  | NEW{pred, succ, ...} => (                  | NEW{pred, succ, ...} => (
767                      Node.replaceInEdge {src = !pred, oldDst = oldNd, dst = node};                      Node.replaceOutEdge {src = !pred, oldDst = oldNd, dst = node};
768                      Node.replaceOutEdge {oldSrc = oldNd, src = node, dst = !succ})                      Node.replaceInEdge {oldSrc = oldNd, src = node, dst = !succ})
769                  | SAVE{pred, succ, ...} => (                  | SAVE{pred, succ, ...} => (
770                      Node.replaceInEdge {src = !pred, oldDst = oldNd, dst = node};                      Node.replaceOutEdge {src = !pred, oldDst = oldNd, dst = node};
771                      Node.replaceOutEdge {oldSrc = oldNd, src = node, dst = !succ})                      Node.replaceInEdge {oldSrc = oldNd, src = node, dst = !succ})
772                  | EXIT{pred, succ=ref NONE, ...} =>                  | EXIT{pred, succ=ref NONE, ...} =>
773                      Node.replaceInEdge {src = !pred, oldDst = oldNd, dst = node}                      Node.replaceOutEdge {src = !pred, oldDst = oldNd, dst = node}
774                  | _ => raise Fail(concat[                  | _ => raise Fail(concat[
775                        "unsupported replaceNode(", Node.toString oldNd, ", ", Node.toString node, ")"                        "unsupported replaceNode(", Node.toString oldNd, ", ", Node.toString node, ")"
776                      ])                      ])
# Line 783  Line 782 
782                  then deleteNode nd                  then deleteNode nd
783                  else (case kind                  else (case kind
784                     of ASSIGN{pred, succ, ...} => (                     of ASSIGN{pred, succ, ...} => (
785                          Node.replaceInEdge {src = !pred, oldDst = nd, dst = entry};                          Node.replaceOutEdge {src = !pred, oldDst = nd, dst = entry};
786                          Node.replaceOutEdge {oldSrc = nd, src = exit, dst = !succ})                          Node.replaceInEdge {oldSrc = nd, src = exit, dst = !succ})
787                      | MASSIGN{pred, succ, ...} => (                      | MASSIGN{pred, succ, ...} => (
788                          Node.replaceInEdge {src = !pred, oldDst = nd, dst = entry};                          Node.replaceOutEdge {src = !pred, oldDst = nd, dst = entry};
789                          Node.replaceOutEdge {oldSrc = nd, src = exit, dst = !succ})                          Node.replaceInEdge {oldSrc = nd, src = exit, dst = !succ})
790                      | _ => raise Fail "unsupported replaceNodeWithCFG"                      | _ => raise Fail "unsupported replaceNodeWithCFG"
791                    (* end case *))                    (* end case *))
792    

Legend:
Removed from v.3936  
changed lines
  Added in v.3937

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