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

Diff of /sml/branches/SMLNJ/src/MLRISC/backpatch/backpatch.sml

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

revision 410, Fri Sep 3 00:25:03 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 9  Line 9 
9  functor BBSched2  functor BBSched2
10      (structure Flowgraph : FLOWGRAPH      (structure Flowgraph : FLOWGRAPH
11       structure Jumps : SDI_JUMPS       structure Jumps : SDI_JUMPS
12       structure Emitter : EMITTER_NEW       structure Emitter : INSTRUCTION_EMITTER
   
13         sharing Emitter.P = Flowgraph.P         sharing Emitter.P = Flowgraph.P
14         sharing Flowgraph.I = Jumps.I = Emitter.I): BBSCHED =         sharing Flowgraph.I = Jumps.I = Emitter.I): BBSCHED =
15    
# Line 23  Line 22 
22    structure J = Jumps    structure J = Jumps
23    structure P = Flowgraph.P    structure P = Flowgraph.P
24    
25    fun error msg = MLRiscErrorMsg.impossible ("BBSched."^msg)    fun error msg = MLRiscErrorMsg.error("BBSched",msg)
26    
27    datatype code =    datatype code =
28        SDI of {size : int ref,           (* variable sized *)        SDI of {size : int ref,           (* variable sized *)
# Line 35  Line 34 
34        PSEUDO of P.pseudo_op        PSEUDO of P.pseudo_op
35      | LABEL  of Label.label      | LABEL  of Label.label
36      | CODE of  code list      | CODE of  code list
37      | CLUSTER of {comp : compressed list, regmap : int Intmap.intmap}      | CLUSTER of {comp : compressed list, regmap : int -> int}
38    
39    val clusterList : compressed list ref = ref []    val clusterList : compressed list ref = ref []
40    fun cleanUp() = clusterList := []    fun cleanUp() = clusterList := []
41    
42    fun bbsched(cluster as F.CLUSTER{blocks, regmap, ...}) = let    fun bbsched(cluster as F.CLUSTER{blocks, regmap, ...}) = let
43        val regmap = C.lookup regmap
44      fun compress(F.PSEUDO pOp::rest) = PSEUDO pOp::compress rest      fun compress(F.PSEUDO pOp::rest) = PSEUDO pOp::compress rest
45        | compress(F.LABEL lab::rest) = LABEL lab:: compress rest        | compress(F.LABEL lab::rest) = LABEL lab:: compress rest
       | compress(F.ORDERED blks::rest) = compress(blks@rest)  
46        | compress(F.BBLOCK{insns, ...}::rest) = let        | compress(F.BBLOCK{insns, ...}::rest) = let
47            fun mkCode(0, [], [], code) = code            fun mkCode(0, [], [], code) = code
48              | mkCode(size, insns, [], code) = FIXED{size=size, insns=insns}:: code              | mkCode(size, insns, [], code) = FIXED{size=size, insns=insns}:: code
# Line 108  Line 107 
107      in if adjust(zl, 0, false) then fixpoint zl else size      in if adjust(zl, 0, false) then fixpoint zl else size
108      end      end
109    
110        val Emitter.S.STREAM{emit,defineLabel,init,pseudoOp,...} =
111                Emitter.makeStream()
112    
113      fun emitCluster(CLUSTER{comp, regmap}, loc) = let      fun emitCluster(CLUSTER{comp, regmap}, loc) = let
114        fun emit(PSEUDO pOp, loc) = (E.pseudoOp pOp; loc + P.sizeOf(pOp, loc))        val emit = emit regmap
115          | emit(LABEL lab, loc) = (E.defineLabel lab; loc)        fun process(PSEUDO pOp,loc) = (pseudoOp pOp; loc + P.sizeOf(pOp,loc))
116          | emit(CODE code, loc) = let          | process(LABEL lab,loc) = (defineLabel lab; loc)
117              val emitInstrs = app (fn i => E.emitInstr(i, regmap))          | process(CODE code,loc) = let
118                fun emitInstrs insns = app emit insns
119              fun e(FIXED{insns, size, ...}, loc) = (emitInstrs insns; loc+size)              fun e(FIXED{insns, size, ...}, loc) = (emitInstrs insns; loc+size)
120                | e(SDI{size, insn}, loc) =                | e(SDI{size, insn}, loc) =
121                   (emitInstrs (J.expand(insn, !size, loc)); loc + !size)                     (emitInstrs(J.expand(insn, !size, loc)); !size + loc)
122            in List.foldl e loc code            in foldl e loc code
123            end            end
124      in List.foldl emit loc comp      in foldl process loc comp
125      end      end
126    
127      val compressed = (rev (!clusterList)) before cleanUp()      val compressed = (rev (!clusterList)) before cleanUp()
128    in    in
129      E.init(fixpoint compressed);      init(fixpoint compressed);
130      List.foldl  emitCluster 0 compressed;      foldl emitCluster 0 compressed;
131      ()      ()
132    end (*finish*)    end (*finish*)
133    
134  end (* bbsched2 *)  end (* bbsched2 *)
135    
136    
 (*  
  * $Log: backpatch.sml,v $  
  * Revision 1.1.1.1  1998/11/16 21:47:14  george  
  *   Version 110.10  
  *  
  * Revision 1.2  1998/10/06 14:07:44  george  
  * Flowgraph has been removed from modules that do not need it.  
  * Changes to compiler/CodeGen/*/*{MLTree,CG}.sml necessary.  
  *                                              [leunga]  
  *  
  * Revision 1.1.1.1  1998/04/08 18:39:02  george  
  * Version 110.5  
  *  
  *)  

Legend:
Removed from v.410  
changed lines
  Added in v.411

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