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/scheduling/globalScheduler.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/scheduling/globalScheduler.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 744 - (view) (download)

1 : leunga 695 (*
2 :     * A top level functor and ties all the modules for global scheduling
3 :     * together.
4 :     *)
5 :    
6 :     functor GlobalScheduler
7 :     (structure IR : MLRISC_IR
8 :     structure DDG : SCHEDULER_DDG
9 :     structure InsnProps : INSN_PROPERTIES
10 :     structure RTLProps : RTL_PROPERTIES
11 :     structure Viewer : GLOBAL_SCHEDULER_DDG_VIEWER
12 :     structure FormatInsn : FORMAT_INSTRUCTION
13 :     (* structure Rewrite : REWRITE_INSTRUCTIONS *)
14 :     sharing InsnProps.I = IR.I = DDG.I = (* = Rewrite.I *)
15 :     FormatInsn.I = RTLProps.I
16 :     sharing Viewer.IR = IR
17 :     sharing Viewer.DDG = DDG
18 :     ) : MLRISC_IR_OPTIMIZATION =
19 :     struct
20 :     structure IR = IR
21 :     structure CFG = IR.CFG
22 :     structure I = IR.I
23 :     structure SchedProps = DDG.SchedProps
24 :     structure SL = SortedList
25 :     structure G = Graph
26 :     structure A = Array
27 :    
28 :     structure RegionBuilder = RegionBuilder(IR)
29 :    
30 :     structure DDGBuilder =
31 :     SchedulerDDGBuilder
32 :     (structure DDG = DDG
33 :     structure CFG = CFG
34 :     structure InsnProps = InsnProps
35 :     structure RTLProps = RTLProps
36 :     )
37 :    
38 :     structure ListScheduler =
39 :     ListScheduler
40 :     (structure IR = IR
41 :     structure DDG = DDG
42 :     structure InsnProps = InsnProps
43 :     structure FormatInsn = FormatInsn
44 :     (* structure Rewrite = Rewrite *)
45 :     )
46 :    
47 :     structure GlobalCP = GlobalCriticalPath(DDG)
48 :    
49 :     structure DAGScheduling =
50 :     DAGScheduling
51 :     (structure ListScheduler = ListScheduler
52 :     structure DDGBuilder = DDGBuilder
53 :     structure Viewer = Viewer
54 :     structure Ranks = GlobalCP
55 :     )
56 :    
57 :     structure Liveness = LivenessAnalysis(CFG)
58 :    
59 :     type flowgraph = IR.IR
60 :    
61 :     val name = "global scheduling"
62 :    
63 :     val cpu = MLRiscControl.getString "cpu"
64 :     val _ = cpu := "default"
65 :    
66 :     fun computeLiveness(cpu_info,CFG as G.GRAPH cfg) =
67 :     let val SchedProps.CPU_INFO{defUse=insnDefUse, ...} = cpu_info
68 :     val regmap = I.C.lookup(CFG.regmap CFG)
69 :     fun defUse(_,CFG.BLOCK{insns, ...}) =
70 :     let fun scan([], def, use) = (def, use)
71 :     | scan(i::is, def, use) =
72 :     let val (d,u) = insnDefUse i
73 :     val u = SL.uniq(map regmap u)
74 :     val u' = SL.difference(u, def)
75 :     val use' = SL.merge(u', use)
76 :     val d = SL.uniq(map (fn (r,l) => regmap r) d)
77 :     val d' = SL.difference(d, use')
78 :     val def' = SL.merge(d', def)
79 :     in scan(is, def', use')
80 :     end
81 :     in scan(rev(!insns), [], [])
82 :     end
83 :    
84 :     fun liveOut(_, block) =
85 : leunga 744 map regmap (I.C.CellSet.toCellList (CFG.liveOut block))
86 : leunga 695
87 :     fun result{block=(_,CFG.BLOCK{annotations, ...}), liveIn, liveOut} =
88 :     annotations :=
89 :     #set DDG.LIVENESS ({liveIn=liveIn, liveOut=liveOut}, !annotations)
90 :    
91 :     in Liveness.liveness{cfg=CFG,defUse=defUse,liveOut=liveOut, result=result}
92 :     end
93 :    
94 :     fun run IR =
95 :     let val maxBlocks=100
96 :     val maxInstrs=1000
97 :     val minFreqRatio=0.01
98 :     val traceOnly=false
99 :     val sideEntries=true
100 :     val internalBackEdges=false
101 :     val insertDummyBlocks=false
102 :     val params = {maxBlocks = maxBlocks,
103 :     maxInstrs = maxInstrs,
104 :     traceOnly = traceOnly,
105 :     minFreqRatio = minFreqRatio,
106 :     sideEntries = sideEntries,
107 :     internalBackEdges = internalBackEdges,
108 :     insertDummyBlocks = insertDummyBlocks
109 :     }
110 :     val cpu_info = SchedProps.info{backward=false,cpu=SchedProps.cpu(!cpu)}
111 :     in computeLiveness(cpu_info,IR);
112 :     RegionBuilder.regionBuilder params IR (DAGScheduling.schedule cpu_info);
113 :     IR
114 :     end
115 :    
116 :     end

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