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 /sml/trunk/src/MLRISC/backpatch/backpatch.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/backpatch/backpatch.sml

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

revision 983, Wed Nov 21 18:44:55 2001 UTC revision 984, Wed Nov 21 19:00:08 2001 UTC
# Line 7  Line 7 
7  (** bbsched2.sml - invoke scheduling after span dependent resolution **)  (** bbsched2.sml - invoke scheduling after span dependent resolution **)
8    
9  functor BBSched2  functor BBSched2
10      (structure CFG     : CONTROL_FLOW_GRAPH      (structure Emitter : INSTRUCTION_EMITTER
11         structure CFG     : CONTROL_FLOW_GRAPH
12                             where I = Emitter.I
13                               and P = Emitter.S.P
14       structure Jumps   : SDI_JUMPS       structure Jumps   : SDI_JUMPS
15                          where I = CFG.I                          where I = CFG.I
      structure Emitter : INSTRUCTION_EMITTER  
                         where P = CFG.P  
                           and I = CFG.I  
16       structure Placement : BLOCK_PLACEMENT       structure Placement : BLOCK_PLACEMENT
17                          where CFG=CFG                          where CFG=CFG
18      ) =      ) =
# Line 41  Line 41 
41      | CLUSTER of {comp : compressed list}      | CLUSTER of {comp : compressed list}
42    
43    val clusterList : compressed list ref = ref []    val clusterList : compressed list ref = ref []
44    fun cleanUp() = clusterList := []    val dataList : P.pseudo_op list ref = ref []
45      fun cleanUp() = (clusterList := []; dataList := [])
46    
47    fun bbsched(cfg as G.GRAPH graph) = let    fun bbsched(cfg as G.GRAPH{graph_info=CFG.INFO{data, ...}, ...}) = let
48      val blocks = map #2 (Placement.blockPlacement cfg)      val blocks = map #2 (Placement.blockPlacement cfg)
49    
50      fun compress [] = []      fun compress [] = []
51        | compress(CFG.BLOCK{data, labels, insns, ...} :: rest) = let        | compress(CFG.BLOCK{align, labels, insns, ...} :: rest) = let
52            fun pseudo(CFG.LABEL lab) = LABEL lab            fun alignIt(chunks) =
53              | pseudo(CFG.PSEUDO pOp) = PSEUDO pOp              (case !align of NONE => chunks | SOME p => PSEUDO(p)::chunks)
54    
55            fun mkCode(0, [], [], code) = code            fun mkCode(0, [], [], code) = code
56              | mkCode(size, insns, [], code) = FIXED{size=size, insns=insns}:: code              | mkCode(size, insns, [], code) = FIXED{size=size, insns=insns}:: code
57              | mkCode(size, insns, instr::instrs, code) = let              | mkCode(size, insns, instr::instrs, code) = let
# Line 67  Line 69 
69                  else mkCode(size+s, instr::insns, instrs, code)                  else mkCode(size+s, instr::insns, instrs, code)
70                end                end
71          in          in
72            map pseudo (!data) @            alignIt
73              map LABEL (!labels) @              (map LABEL (!labels) @
74                 CODE(mkCode(0, [], !insns, [])) :: compress rest                 CODE(mkCode(0, [], !insns, [])) :: compress rest)
75          end          end
   
76    in    in
77      clusterList:=CLUSTER{comp = compress blocks}:: (!clusterList)      clusterList:=CLUSTER{comp = compress blocks}:: (!clusterList);
78        dataList := !data @ !dataList
79    end    end
80    
   
   
   
81    fun finish() = let    fun finish() = let
82      fun labels(PSEUDO pOp::rest, pos) =      fun labels(PSEUDO pOp::rest, pos) =
83            (P.adjustLabels(pOp, pos); labels(rest, pos+P.sizeOf(pOp,pos)))            (P.adjustLabels(pOp, pos); labels(rest, pos+P.sizeOf(pOp,pos)))
# Line 138  Line 137 
137      end      end
138        | emitCluster _ = error "emitCluster"        | emitCluster _ = error "emitCluster"
139    
140      val compressed = (rev (!clusterList)) before cleanUp()      (* The dataList is in reverse order, and the entries in each
141         * are also in reverse
142         *)
143        val compressed = rev (map PSEUDO (!dataList) @ !clusterList) before cleanUp()
144    in    in
145      beginCluster(fixpoint compressed);      beginCluster(fixpoint (compressed));
146      foldl emitCluster 0 compressed;      foldl emitCluster 0 compressed;
147      ()      ()
148    end (*finish*)    end (*finish*)

Legend:
Removed from v.983  
changed lines
  Added in v.984

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