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 /MLRISC/trunk/Glue/mlrisc-glue.sml
ViewVC logotype

Annotation of /MLRISC/trunk/Glue/mlrisc-glue.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2126 - (view) (download)

1 : monnier 411 (*
2 :     * Simple module for building the IR etc. Doesn't do any real optimizations.
3 :     *
4 :     * -- Allen
5 :     *)
6 :    
7 : monnier 245 functor MLRISCGlue
8 : george 545 (structure Asm : INSTRUCTION_EMITTER
9 :     structure Flowgraph : FLOWGRAPH
10 :     structure InsnProps : INSN_PROPERTIES
11 : monnier 411 structure FreqProps : FREQUENCY_PROPERTIES
12 : george 545 sharing InsnProps.I = Asm.I = Flowgraph.I = FreqProps.I
13 :     sharing Flowgraph.P = Asm.P
14 : monnier 245 ) : MLRISC_GLUE =
15 :     struct
16 :    
17 : george 545 structure F = Flowgraph
18 : monnier 245 structure I = F.I
19 :    
20 : monnier 429 val mlrisc = MLRiscControl.getFlag "mlrisc"
21 :     val phases = MLRiscControl.getStringList "mlrisc-phases"
22 :     val view_IR = MLRiscControl.getFlag "view-IR"
23 :     val verbose = MLRiscControl.getFlag "verbose"
24 : monnier 245
25 : monnier 411 fun error msg = MLRiscErrorMsg.error("MLRISCGlue",msg)
26 : monnier 245
27 : george 545 structure GraphViewer = GraphViewer(AllDisplays)
28 : monnier 245
29 : george 545 structure FormatInsn = FormatInstruction(Asm)
30 : monnier 245
31 : george 545 structure CFG = ControlFlowGraph
32 :     (structure I = I
33 :     structure PseudoOps = F.P
34 : monnier 245 structure GraphImpl = DirectedGraph
35 : leunga 624 structure InsnProps = InsnProps
36 : monnier 245 structure Asm = Asm
37 :     )
38 :    
39 : george 545 structure Util = CFGUtil
40 :     (structure CFG = CFG
41 :     structure InsnProps = InsnProps
42 : monnier 245 )
43 :    
44 : george 545 structure CFG2Cluster = CFG2Cluster
45 :     (structure CFG = CFG
46 :     structure Util = Util
47 :     structure Flowgraph = Flowgraph
48 : monnier 429 )
49 :    
50 : george 545 structure Cluster2CFG = Cluster2CFG
51 :     (structure CFG = CFG
52 :     structure Util = Util
53 :     structure Flowgraph = Flowgraph
54 :     structure InsnProps = InsnProps
55 : monnier 245 )
56 :    
57 : george 545 structure Dom = DominatorTree(DirectedGraph)
58 : monnier 245
59 : george 545 structure CDG = ControlDependenceGraph
60 : monnier 245 (structure Dom = Dom
61 :     structure GraphImpl = DirectedGraph
62 :     )
63 :    
64 : george 545 structure Loop = LoopStructure
65 : monnier 245 (structure Dom = Dom
66 :     structure GraphImpl = DirectedGraph
67 :     )
68 :    
69 : george 545 structure IR = MLRISC_IR
70 : monnier 245 (structure CFG = CFG
71 :     structure CDG = CDG
72 :     structure Loop = Loop
73 :     structure GraphViewer = GraphViewer
74 :     structure Util = Util
75 :     )
76 :    
77 : george 545 structure Guess = StaticBranchPrediction
78 :     (structure IR = IR
79 :     structure InsnProps = InsnProps
80 :     structure FreqProps = FreqProps
81 :     val loopMultiplier=10
82 :     )
83 : monnier 245
84 : george 545 structure Liveness = LivenessAnalysis(CFG)
85 : monnier 245
86 : george 545 structure Reshape = ReshapeBranches
87 :     (structure IR = IR
88 :     structure InsnProps = InsnProps
89 :     )
90 : monnier 245
91 : george 545 structure BranchChaining = BranchChaining
92 :     (structure IR = IR
93 :     structure InsnProps = InsnProps
94 :     )
95 :    
96 : leunga 657 structure CPR = CriticalPathReduction
97 :     (structure IR = IR
98 :     structure InsnProps = InsnProps
99 :     )
100 :    
101 : george 545 structure ClusterGraph = ClusterGraph(Flowgraph)
102 :    
103 :     structure ClusterViewer = ClusterViewer
104 :     (structure GraphViewer = GraphViewer
105 :     structure ClusterGraph = ClusterGraph
106 :     structure Asm = Asm
107 :     )
108 :    
109 : monnier 245 fun view phase ir = if !view_IR then IR.view phase ir else ()
110 : george 545 fun view' cluster = if !view_IR then
111 :     ClusterViewer.view(ClusterGraph.clusterGraph cluster) else ()
112 : monnier 245
113 :     fun optimize cluster =
114 :     let datatype rep = IR of IR.IR
115 :     | CLUSTER of F.cluster
116 : monnier 498 fun doPhase "cluster->cfg" (CLUSTER c) = IR(Cluster2CFG.cluster2cfg c)
117 : monnier 245 | doPhase "cfg->cluster" (IR cfg) =
118 :     CLUSTER(CFG2Cluster.cfg2cluster{cfg=cfg,relayout=false})
119 : george 545 | doPhase "guess" (r as IR ir) = (Guess.run ir; r)
120 :     | doPhase "reshape" (r as IR ir) = (Reshape.run ir; r)
121 :     | doPhase "branch-chaining" (r as IR ir) = (BranchChaining.run ir; r)
122 : leunga 657 | doPhase "cpr" (r as IR ir) = (CPR.run ir; r)
123 : monnier 245 | doPhase "view-cfg" (r as IR ir) = (view "cfg" ir; r)
124 :     | doPhase "view-dom" (r as IR ir) = (view "dom" ir; r)
125 :     | doPhase "view-pdom" (r as IR ir) = (view "pdom" ir; r)
126 :     | doPhase "view-doms" (r as IR ir) = (view "doms" ir; r)
127 :     | doPhase "view-cdg" (r as IR ir) = (view "cdg" ir; r)
128 :     | doPhase "view-loop" (r as IR ir) = (view "loop" ir; r)
129 : george 545 | doPhase "view-cluster" (r as CLUSTER c) = (view' c; r)
130 : monnier 245 | doPhase phase _ = error(phase)
131 :     fun doPhases [] (CLUSTER c) = c
132 :     | doPhases [] _ = error "cluster needed"
133 :     | doPhases (phase::phases) ir =
134 :     (if !verbose then print("["^phase^"]\n") else ();
135 :     doPhases phases (doPhase phase ir))
136 :     in doPhases (!phases) (CLUSTER cluster)
137 :     end
138 :    
139 :     fun codegen cluster = if !mlrisc then optimize cluster else cluster
140 :    
141 :     end

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