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

SCM Repository

[smlnj] Diff of /MLRISC/releases/release-110.64/IR/mlrisc-ir.sml
ViewVC logotype

Diff of /MLRISC/releases/release-110.64/IR/mlrisc-ir.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 245, Sat Apr 17 18:47:12 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 1  Line 1 
1    (*
2     * MLRISC IR
3     *
4     * This is for performing whole program analysis.
5     * All optimizations are based on this representation.
6     * It provides a few useful views: dominator tree, control dependence graph,
7     * loop nesting (interval) structure etc. Also there is a mechanism to
8     * incrementally attach additional views to the IR.  The SSA infrastructure
9     * is implemented in such a manner.
10     *
11     * -- Allen
12     *)
13    
14  functor MLRISC_IRFn  functor MLRISC_IRFn
15     (structure CFG         : CONTROL_FLOW_GRAPH     (structure CFG         : CONTROL_FLOW_GRAPH
16      structure CDG         : CONTROL_DEPENDENCE_GRAPH      structure CDG         : CONTROL_DEPENDENCE_GRAPH
# Line 6  Line 19 
19      structure Util        : CFG_UTIL      structure Util        : CFG_UTIL
20         sharing Loop.Dom = CDG.Dom         sharing Loop.Dom = CDG.Dom
21         sharing Util.CFG = CFG         sharing Util.CFG = CFG
22        structure Ctrl : MLRISC_CONTROL
23     ) : MLRISC_IR =     ) : MLRISC_IR =
24  struct  struct
25    
# Line 34  Line 48 
48           | f [] = [(name,layout)]           | f [] = [(name,layout)]
49     in  layouts := f(!layouts) end     in  layouts := f(!layouts) end
50    
51     fun view name IR =     exception NoLayout
52     let fun f [] = print ("[Can't find "^name^"]\n")  
53           | f((x,layout)::rest) =     fun findLayout name =
54             if x = name then GraphViewer.view (layout IR) else f rest     let fun f [] = (print ("[Can't find "^name^"]\n"); raise NoLayout)
55             | f((x,layout)::rest) = if x = name then layout else f rest
56     in  f(!layouts) end     in  f(!layouts) end
57    
58       fun view name IR = GraphViewer.view(findLayout name IR)
59               handle NoLayout => ()
60    
61       fun views names IR =
62           let val layouts = map (fn n => findLayout n IR) names
63           in  GraphViewer.view(GraphCombinations.sums layouts)
64           end handle NoLayout => ()
65    
66     fun viewSubgraph IR subgraph =     fun viewSubgraph IR subgraph =
67           GraphViewer.view (CFG.subgraphLayout{cfg=IR,subgraph=subgraph})           GraphViewer.view (CFG.subgraphLayout{cfg=IR,subgraph=subgraph})
68    
# Line 47  Line 70 
70      * This function defines how we compute a new view      * This function defines how we compute a new view
71      *)      *)
72    
73     fun memo compute =     val verbose = Ctrl.getFlag "verbose"
74    
75       fun memo name compute =
76     let val {get,put,rmv,...} = A.new()     let val {get,put,rmv,...} = A.new()
77         fun getView         fun getView(IR as G.GRAPH{graph_info=CFG.INFO{annotations,...},...}:IR)=
78             (IR as G.GRAPH{graph_info=CFG.INFO{annotations,...},...} : IR) =         let fun process(SOME(ref(SOME info))) =
79             case get (!annotations) of                   (if !verbose then print ("[reusing "^name^"]") else (); info)
80                SOME info => info               | process(SOME r) =
81             |  NONE => let val info = compute IR                   let val _    = if !verbose then print("[computing "^name)
82                            fun kill() = annotations := rmv(!annotations)                                  else ()
83                        in  annotations :=                       val info = compute IR
84                               CFG.CHANGEDONCE kill::put(info,!annotations);                       val _    = if !verbose then print "]" else ()
85                            info                   in  r := SOME info; info end
86               |  process NONE =
87                  let val r = ref NONE
88                      fun kill() = (r := NONE;
89                                    if !verbose then print("[uncaching "^name^"]")
90                                    else ())
91                  in  annotations := CFG.CHANGED kill :: put(r,!annotations);
92                      process(SOME r)
93                        end                        end
94           in  process(get (!annotations)) end
95     in  getView     in  getView
96     end     end
97    
# Line 66  Line 99 
99      *  Extract various views from an IR      *  Extract various views from an IR
100      *)      *)
101    
102     val doms = memo Dom.dominator_trees     val doms = memo "dom" Dom.dominator_trees
103     fun dom IR  = #1 (doms IR)     fun dom IR  = #1 (doms IR)
104     fun pdom IR = #2 (doms IR)     fun pdom IR = #2 (doms IR)
105     val cdg  = memo (fn IR => CDG.control_dependence_graph CFG.cdgEdge (doms IR))     val cdg  = memo "cdg"
106     val loop = memo (Loop.loop_structure o dom)               (fn IR => CDG.control_dependence_graph CFG.cdgEdge (doms IR))
107       val loop = memo "loop" (Loop.loop_structure o dom)
108     val changed = CFG.changed     val changed = CFG.changed
109    
110     (*     (*
# Line 125  Line 159 
159    
160  end  end
161    
 (*  
  * $Log$  
  *)  
   

Legend:
Removed from v.245  
changed lines
  Added in v.411

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