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

Diff of /sml/trunk/src/MLRISC/backpatch/vlBackPatch.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 65  Line 65 
65    
66    fun error msg = MLRiscErrorMsg.error("vlBackPatch",msg)    fun error msg = MLRiscErrorMsg.error("vlBackPatch",msg)
67    
68    val clusters = ref ([] : cluster list)    val clusterList : cluster list ref = ref []
69      val dataList : P.pseudo_op list ref = ref []
70    fun cleanUp() = clusters := []    fun cleanUp() = (clusterList := []; dataList := [])
71    
72    val Asm.S.STREAM{emit,...} = Asm.makeStream []    val Asm.S.STREAM{emit,...} = Asm.makeStream []
73    
74    fun bbsched(cfg as G.GRAPH graph) = let    fun bbsched(cfg as G.GRAPH{graph_info=CFG.INFO{data, ...}, ...}) = let
75      val blocks = map #2 (Placement.blockPlacement cfg)      val blocks = map #2 (Placement.blockPlacement cfg)
76      fun bytes([], p) = p      fun bytes([], p) = p
77        | bytes([s], p) = BYTES(s, p)        | bytes([s], p) = BYTES(s, p)
78        | bytes(s, p) = BYTES(W8V.concat s, p)        | bytes(s, p) = BYTES(W8V.concat s, p)
79    
80      fun f(CFG.BLOCK{data, labels, insns, ...}::rest) = let      fun f(CFG.BLOCK{align, labels, insns, ...}::rest) = let
81           fun instrs([], b) = bytes(rev b, f rest)           fun instrs([], b) = bytes(rev b, f rest)
82             | instrs(i::rest, b) =             | instrs(i::rest, b) =
83               if Jumps.isSdi i then               if Jumps.isSdi i then
# Line 86  Line 86 
86                 instrs(rest, Emitter.emitInstr(i)::b)                 instrs(rest, Emitter.emitInstr(i)::b)
87           fun doLabels(lab::rest) = LABEL(lab, doLabels rest)           fun doLabels(lab::rest) = LABEL(lab, doLabels rest)
88             | doLabels [] = instrs(rev(!insns), [])             | doLabels [] = instrs(rev(!insns), [])
89           fun pseudo(CFG.PSEUDO pOp :: rest) = PSEUDO(pOp, pseudo rest)           fun alignIt(NONE) = doLabels(!labels)
90             | pseudo(CFG.LABEL lab :: rest) =  LABEL(lab, pseudo rest)             | alignIt(SOME p) = PSEUDO(p, alignIt(NONE))
91             | pseudo [] = doLabels(!labels)          in
92              alignIt(!align)
         in pseudo(!data)  
93          end          end
94        | f [] = NIL        | f [] = NIL
95    in    in
96      clusters :=      clusterList :=
97        CLUSTER{cluster=f blocks}:: !clusters        CLUSTER{cluster=f blocks}:: !clusterList;
98        dataList := !data @ !dataList
99    end    end
100    
101    
# Line 196  Line 196 
196          (fn (CLUSTER{cluster, ...}, loc) => init(cluster, loc)) 0 clusters          (fn (CLUSTER{cluster, ...}, loc) => init(cluster, loc)) 0 clusters
197      end      end
198    
199      val clusters = rev(!clusters) before clusters := []      (* The dataList is in reverse order, and the entries in each
200    in       * are also in reverse
201      initLabels(clusters);       *)
202      CodeString.init(fix clusters);      fun compUnit(d::dl, cl, acc) = compUnit(dl, cl, PSEUDO(d, acc))
203      loc := 0; chunk(0, clusters)        | compUnit([], cl, acc) = let
204              fun revCl(c::cl, acc) = revCl(cl, c::acc)
205                | revCl([], acc) = acc
206            in revCl(cl, [CLUSTER{cluster=acc}])
207            end
208    
209        val compressed =  compUnit(!dataList, !clusterList, NIL) before cleanUp()
210      in
211        initLabels(compressed);
212        CodeString.init(fix compressed);
213        loc := 0; chunk(0, compressed)
214    end (* finish *)    end (* finish *)
215    
216  end (* functor BackPatch *)  end (* functor BackPatch *)

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