Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/IL/dom-tree-fn.sml
 [diderot] / branches / pure-cfg / src / compiler / IL / dom-tree-fn.sml

# Diff of /branches/pure-cfg/src/compiler/IL/dom-tree-fn.sml

revision 740, Mon Apr 4 02:07:42 2011 UTC revision 741, Mon Apr 4 16:37:33 2011 UTC
# Line 12  Line 12
12    (* compute the dominance-tree information for a CFG *)    (* compute the dominance-tree information for a CFG *)
13      val computeTree : IL.cfg -> unit      val computeTree : IL.cfg -> unit
14
15    (* get the dominance-tree children associated with a given node *)    (* return the dominance-tree children associated with a given node.  Note that children,
16       * which are immediate successors of the node, will be listed first.
17       *)
18      val children : IL.node -> IL.node list      val children : IL.node -> IL.node list
19
20    (* cleanup the node properties used to store information about the tree *)    (* cleanup the node properties used to store information about the tree *)
# Line 48  Line 50
50            fun walk (ifStk : open_if list, nd) = (case Nd.kind nd            fun walk (ifStk : open_if list, nd) = (case Nd.kind nd
51                   of IL.NULL => raise Fail "unexpected NULL node"                   of IL.NULL => raise Fail "unexpected NULL node"
52                    | IL.ENTRY{succ} => walk (ifStk, !succ)                    | IL.ENTRY{succ} => walk (ifStk, !succ)
53                    | IL.JOIN{succ, ...} => (case ifStk                    | IL.JOIN{preds, succ, ...} =>
54                          if (List.length(!preds) > 1)
55                            then (case ifStk
56                         of [] => raise Fail "unmatched JOIN"                         of [] => raise Fail "unmatched JOIN"
57                          | THEN_BR{cond, elseBr}::r => (                          | THEN_BR{cond, elseBr}::r => (
58                              setJoin(cond, nd);                              setJoin(cond, nd);
59                              walk (ELSE_BR{cond=cond}::r, elseBr))                              walk (ELSE_BR{cond=cond}::r, elseBr))
60                          | ELSE_BR{cond}::r => (                          | ELSE_BR{cond}::r => (
setJoin(cond, nd);  (* may be redundant *)
61                              walk (r, !succ))                              walk (r, !succ))
62                        (* end case *))                        (* end case *))
63                            else walk(List.tl ifStk, !succ)
64                    | IL.COND{trueBranch, falseBranch, ...} =>                    | IL.COND{trueBranch, falseBranch, ...} =>
65                        walk (THEN_BR{cond=nd, elseBr = !falseBranch}::ifStk, !trueBranch)                        walk (THEN_BR{cond=nd, elseBr = !falseBranch}::ifStk, !trueBranch)
66                    | IL.COM{succ, ...} => walk (ifStk, !succ)                    | IL.COM{succ, ...} => walk (ifStk, !succ)

Legend:
 Removed from v.740 changed lines Added in v.741