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

Diff of /sml/trunk/src/MLRISC/cluster/clustergen.sml

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

revision 428, Wed Sep 8 09:47:00 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 8  Line 8 
8    (structure Flowgraph : FLOWGRAPH    (structure Flowgraph : FLOWGRAPH
9     structure InsnProps : INSN_PROPERTIES     structure InsnProps : INSN_PROPERTIES
10     structure MLTree : MLTREE     structure MLTree : MLTREE
    structure Stream : INSTRUCTION_STREAM  
11    
    val optimize : (Flowgraph.cluster -> Flowgraph.cluster) option ref  
12     val output : Flowgraph.cluster -> unit     val output : Flowgraph.cluster -> unit
13       sharing Flowgraph.I = InsnProps.I       sharing Flowgraph.I = InsnProps.I
14       sharing MLTree.Constant = InsnProps.I.Constant       sharing MLTree.Constant = InsnProps.I.Constant
15       sharing MLTree.PseudoOp = Flowgraph.P = Stream.P       sharing MLTree.PseudoOp = Flowgraph.P
16       sharing Flowgraph.B = MLTree.BNames = Stream.B       sharing Flowgraph.B = MLTree.BNames
17    ) : FLOWGRAPH_GEN =    ) : FLOWGRAPH_GEN =
18  struct  struct
19    
# Line 27  Line 25 
25    structure T = MLTree    structure T = MLTree
26    structure B = MLTree.BNames    structure B = MLTree.BNames
27    structure P = T.PseudoOp    structure P = T.PseudoOp
28    structure S = Stream    structure S = T.Stream
   structure Control = MLRISC_Control  
29    
30    type label = Label.label    type label = Label.label
31    
# Line 40  Line 37 
37    let val bblkCnt = ref 0    let val bblkCnt = ref 0
38        val entryLabels = ref ([] : Label.label list)        val entryLabels = ref ([] : Label.label list)
39        val blkName  = ref B.default        val blkName  = ref B.default
40          val regmap  = ref NONE
41          fun can'tUse _ = error "unimplemented"
42          val aliasF  = ref can'tUse : (T.alias -> unit) ref
43        val NOBLOCK = F.EXIT{blknum=0,freq=ref 0,pred=ref []}        val NOBLOCK = F.EXIT{blknum=0,freq=ref 0,pred=ref []}
44        val currBlock : F.block ref = ref NOBLOCK        val currBlock : F.block ref = ref NOBLOCK
45        val blockList : F.block list ref = ref []        val blockList : F.block list ref = ref []
# Line 78  Line 78 
78          fun defineLabel lab = blockListAdd(F.LABEL lab)          fun defineLabel lab = blockListAdd(F.LABEL lab)
79          fun entryLabel lab =          fun entryLabel lab =
80            (entryLabels := lab::(!entryLabels);  blockListAdd(F.LABEL lab))            (entryLabels := lab::(!entryLabels);  blockListAdd(F.LABEL lab))
         (*  
         fun ordered(mlts)        =  
           blockListAdd  
             (F.ORDERED(map (fn T.PSEUDO_OP pOp => F.PSEUDO pOp  
                              | T.DEFINELABEL lab => F.LABEL lab  
                              | T.ENTRYLABEL lab =>  
                                  (entryLabels := lab :: !entryLabels;  
                                   F.LABEL lab)  
                              | _ => error "ordered ")  
                        mlts)) *)  
81        end (*local*)        end (*local*)
82    
83        (** emitInstr - instructions are always added to currBlock. **)        (** emitInstr - instructions are always added to currBlock. **)
# Line 137  Line 127 
127         (*esac*)         (*esac*)
128        end        end
129    
130        fun endCluster(regmap,annotations) = let        fun endCluster(annotations) = let
131            exception LabTbl            exception LabTbl
132            val labTbl : F.block Intmap.intmap = Intmap.new(16, LabTbl)            val labTbl : F.block Intmap.intmap = Intmap.new(16, LabTbl)
133            val addLabTbl = Intmap.add labTbl            val addLabTbl = Intmap.add labTbl
# Line 214  Line 204 
204              of blk as F.BBLOCK _ => blockList := blk :: !blockList              of blk as F.BBLOCK _ => blockList := blk :: !blockList
205               | _ => ()               | _ => ()
206    
207            val blocks = rev(!blockList) before blockList := []            val blocks = rev(!blockList)
208              val _ = blockList := []
209            val _ = fillLabTbl(blocks)            val _ = fillLabTbl(blocks)
210            val _ = graphEdges(blocks)            val _ = graphEdges(blocks)
211            val cluster =            val cluster =
212             F.CLUSTER{blocks=blocks, entry=mkEntryBlock(), exit=exitBlk,             F.CLUSTER{blocks=blocks, entry=mkEntryBlock(), exit=exitBlk,
213                       blkCounter=ref(!bblkCnt), regmap=regmap,                       blkCounter=ref(!bblkCnt), regmap= Option.valOf(!regmap),
214                       annotations=ref(annotations)}                       annotations=ref(annotations)}
215            val codegen =            val _ = regmap := NONE
216               case !optimize of            val _ = aliasF := can'tUse
217                 NONE => output          in  output cluster
              | SOME optimizer => output o optimizer  
         in  codegen cluster  
218          end          end
219    
220        fun beginCluster _ =        fun beginCluster _ =
221          (entryLabels := [];        let val map = C.regmap()
222          in  entryLabels := [];
223           bblkCnt := 0;           bblkCnt := 0;
224           blkName := B.default;           blkName := B.default;
225           blockList := [];           blockList := [];
226           currBlock := NOBLOCK)            currBlock := NOBLOCK;
227              regmap := SOME map;
228              aliasF := Intmap.add map;
229              map
230          end
231    
232        fun comment _ = ()  (* unimplemented *)        fun comment msg = annotation(BasicAnnotations.COMMENT msg)
233          fun alias(v,r) = !aliasF(v,r)
234    
235     in S.STREAM     in S.STREAM
236        { init        = beginCluster,        { beginCluster= beginCluster,
237          finish      = endCluster,          endCluster  = endCluster,
238          emit        = fn _ => emitInstr,          emit        = emitInstr,
239          defineLabel = defineLabel,          defineLabel = defineLabel,
240          entryLabel  = entryLabel,          entryLabel  = entryLabel,
241          pseudoOp    = pseudoOp,          pseudoOp    = pseudoOp,
242          exitBlock   = exitBlock,          exitBlock   = exitBlock,
243          blockName   = blockName,          blockName   = blockName,
244          annotation  = annotation,          annotation  = annotation,
245          comment     = comment          comment     = comment,
246            alias       = alias,
247            phi         = can'tUse
248        }        }
249     end     end
250    

Legend:
Removed from v.428  
changed lines
  Added in v.429

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