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

Annotation of /sml/branches/SMLNJ/src/MLRISC/Glue/mlrisc-glue.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 498 - (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 : monnier 411 (structure Asm : INSTRUCTION_EMITTER
9 : monnier 245 structure F : FLOWGRAPH
10 :     structure P : INSN_PROPERTIES
11 : monnier 411 structure FreqProps : FREQUENCY_PROPERTIES
12 :     sharing P.I = Asm.I = F.I = FreqProps.I
13 :     sharing F.P = Asm.P
14 : monnier 245 ) : MLRISC_GLUE =
15 :     struct
16 :    
17 :     structure F = F
18 :     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 : monnier 498 structure GraphViewer = GraphViewerFn(AllDisplays)
28 : monnier 245
29 :     structure FormatInsn = FormatInstructionFn(Asm)
30 :    
31 :     structure CFG = ControlFlowGraphFn
32 :     (structure I = I
33 :     structure P = F.P
34 :     structure GraphImpl = DirectedGraph
35 :     structure Asm = Asm
36 :     )
37 :    
38 : monnier 429 structure Util = CFGUtilFn
39 : monnier 245 (structure CFG = CFG
40 : monnier 429 structure P = P
41 : monnier 245 )
42 :    
43 : monnier 429 structure CFG2Cluster = CFG2ClusterFn
44 :     (structure CFG = CFG
45 :     structure Util = Util
46 :     structure F = F
47 :     )
48 :    
49 : monnier 245 structure Cluster2CFG = Cluster2CFGFn
50 : monnier 429 (structure CFG = CFG
51 :     structure Util = Util
52 :     structure F = F
53 :     structure P = P
54 : monnier 245 )
55 :    
56 :     structure Dom = DominatorTreeFn(DirectedGraph)
57 :    
58 :     structure CDG = ControlDependenceGraphFn
59 :     (structure Dom = Dom
60 :     structure GraphImpl = DirectedGraph
61 :     )
62 :    
63 :     structure Loop = LoopStructureFn
64 :     (structure Dom = Dom
65 :     structure GraphImpl = DirectedGraph
66 :     )
67 :    
68 :     structure IR = MLRISC_IRFn
69 :     (structure CFG = CFG
70 :     structure CDG = CDG
71 :     structure Loop = Loop
72 :     structure GraphViewer = GraphViewer
73 :     structure Util = Util
74 :     )
75 :    
76 : monnier 411 structure Guess = StaticBranchPredictionFn
77 :     (structure IR = IR
78 :     structure Props = P
79 :     structure FreqProps = FreqProps
80 :     )
81 : monnier 245
82 :     structure Liveness = LivenessAnalysisFn(CFG)
83 :    
84 :     structure Reshape = ReshapeBranchesFn(structure IR = IR
85 :     structure P = P)
86 :    
87 :     fun view phase ir = if !view_IR then IR.view phase ir else ()
88 :    
89 :     val ssaParams = {copyPropagation=false,keepName=true,semiPruned=false}
90 :    
91 :     fun optimize cluster =
92 :     let datatype rep = IR of IR.IR
93 :     | CLUSTER of F.cluster
94 : monnier 498 fun doPhase "cluster->cfg" (CLUSTER c) = IR(Cluster2CFG.cluster2cfg c)
95 : monnier 245 | doPhase "cfg->cluster" (IR cfg) =
96 :     CLUSTER(CFG2Cluster.cfg2cluster{cfg=cfg,relayout=false})
97 :     | doPhase "guess" (r as IR ir) =
98 : monnier 411 (Guess.profile {loopMultiplier=10} ir; r)
99 : monnier 245 | doPhase "reshape" (r as IR ir) = (Reshape.reshapeBranches ir; r)
100 :     | doPhase "view-cfg" (r as IR ir) = (view "cfg" ir; r)
101 :     | doPhase "view-dom" (r as IR ir) = (view "dom" ir; r)
102 :     | doPhase "view-pdom" (r as IR ir) = (view "pdom" ir; r)
103 :     | doPhase "view-doms" (r as IR ir) = (view "doms" ir; r)
104 :     | doPhase "view-cdg" (r as IR ir) = (view "cdg" ir; r)
105 :     | doPhase "view-loop" (r as IR ir) = (view "loop" ir; r)
106 :     | doPhase phase _ = error(phase)
107 :     fun doPhases [] (CLUSTER c) = c
108 :     | doPhases [] _ = error "cluster needed"
109 :     | doPhases (phase::phases) ir =
110 :     (if !verbose then print("["^phase^"]\n") else ();
111 :     doPhases phases (doPhase phase ir))
112 :     in doPhases (!phases) (CLUSTER cluster)
113 :     end
114 :    
115 :     fun codegen cluster = if !mlrisc then optimize cluster else cluster
116 :    
117 :     end

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