Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/ir-archive/test3.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/ir-archive/test3.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 912 - (view) (download)

1 : george 912 (*
2 :     * This example is from the paper
3 :     * ``A New Frameowrk for Elimination Based Data Flow Analysis using DJ Graphs''
4 :     * By Sreedhar et. al.
5 :     * This is the irreducible example.
6 :     *)
7 :     structure TestDJDataflow2 =
8 :     struct
9 :     structure Graph = Graph;
10 :     val CFG as Graph.GRAPH cfg = DirectedGraph.graph("cfg",(),10) :
11 :     (string,unit,unit) Graph.graph
12 :     structure Viewer = GraphViewer(AllDisplays)
13 :     structure L = GraphLayout
14 :     structure Dom = DominatorTree(DirectedGraph)
15 :     structure DJ = DJGraph(Dom)
16 :     structure Dataflow = DJDataflow(Dom)
17 :    
18 :     val _ = app (#add_node cfg)
19 :     [(0,"0"),
20 :     (1,"1"),
21 :     (2,"2"),
22 :     (3,"3"),
23 :     (4,"4"),
24 :     (5,"5"),
25 :     (6,"6"),
26 :     (7,"7"),
27 :     (8,"8")
28 :     ]
29 :     val _ = #set_entries cfg [0]
30 :     val _ = #set_exits cfg [9]
31 :     val _ = app (#add_edge cfg)
32 :     [(0,1,()),
33 :     (1,2,()),
34 :     (1,3,()),
35 :     (2,4,()),
36 :     (3,4,()),
37 :     (4,5,()),
38 :     (4,6,()),
39 :     (5,7,()),
40 :     (6,7,()),
41 :     (7,4,()),
42 :     (7,8,()),
43 :     (8,3,())
44 :     ]
45 :    
46 :     val Dom = Dom.makeDominator CFG
47 :    
48 :     fun viewCFG _ =
49 :     Viewer.view(L.makeLayout
50 :     {graph = fn _ => [],
51 :     node = fn (i,_) => [L.LABEL(Int.toString i)],
52 :     edge = fn (i,j,_) => [L.COLOR "red"]
53 :     } CFG)
54 :     fun viewDom _ =
55 :     Viewer.view(L.makeLayout
56 :     {graph = fn _ => [],
57 :     node = fn (i,_) => [L.LABEL(Int.toString i)],
58 :     edge = fn (i,j,_) => [L.COLOR "red"]
59 :     } Dom)
60 :     fun viewDJ _ =
61 :     let fun iso kind G =
62 :     IsomorphicGraphView.map (fn x => x) (fn x => kind) (fn g => ()) G
63 :     val idom = Dom.immediately_dominates Dom
64 :     val Dom = iso [L.COLOR "red"] Dom
65 :     val CFG = iso [L.COLOR "green"] CFG
66 :     val CFG' = SubgraphView.subgraph_view
67 :     (map #1 (#nodes cfg ()))
68 :     (fn (i,j,_) => not(idom(i,j))) CFG
69 :     val DJ = UnionGraphView.union_view (fn _ => ()) (Dom,CFG')
70 :     in Viewer.view(L.makeLayout
71 :     {graph = fn _ => [],
72 :     node = fn (i,_) => [L.LABEL(Int.toString i)],
73 :     edge = fn (i,j,e) => e
74 :     } DJ)
75 :     end
76 :    
77 :     fun testDataflow() =
78 :     let fun closure{y} = print("Closure "^Int.toString y^"\n")
79 :     fun var_elim{y,z} = print("Variable elim "^Int.toString y^
80 :     "->"^Int.toString z^"\n")
81 :     fun fixpoint{scc} = ()
82 :     fun compute{y,z} = ()
83 :     in Dataflow.analyze{closure=closure, var_elim=var_elim,
84 :     fixpoint=fixpoint, compute=compute} Dom
85 :     end
86 :    
87 :     end
88 :    

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