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/IR/mlrisc-cfg-gen2.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/IR/mlrisc-cfg-gen2.sml

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

sml/branches/SMLNJ/src/MLRISC/IR/mlrisc-cfg-gen2.sml revision 468, Wed Nov 10 22:42:52 1999 UTC sml/trunk/src/MLRISC/IR/mlrisc-cfg-gen2.sml revision 545, Thu Feb 24 13:56:44 2000 UTC
# Line 10  Line 10 
10    (structure CFG : CONTROL_FLOW_GRAPH    (structure CFG : CONTROL_FLOW_GRAPH
11     structure InsnProps : INSN_PROPERTIES     structure InsnProps : INSN_PROPERTIES
12     structure MLTree : MLTREE     structure MLTree : MLTREE
   
    val codegen : CFG.cfg -> unit  
13       sharing CFG.I = InsnProps.I       sharing CFG.I = InsnProps.I
14       sharing MLTree.Constant = InsnProps.I.Constant       sharing MLTree.Constant = InsnProps.I.Constant
15       sharing MLTree.PseudoOp = CFG.P       sharing MLTree.PseudoOp = CFG.P
# Line 23  Line 21 
21     structure S = MLTree.Stream     structure S = MLTree.Stream
22     structure T = MLTree     structure T = MLTree
23     structure P = CFG.P     structure P = CFG.P
24     structure Builder = ControlFlowGraphGenFn     structure Builder = ControlFlowGraphGen
25       (structure CFG = CFG       (structure CFG = CFG
26        structure Stream = S        structure Stream = S
27        structure InsnProps = InsnProps        structure InsnProps = InsnProps
# Line 31  Line 29 
29    
30     type flowgraph = CFG.cfg     type flowgraph = CFG.cfg
31    
32     fun newStream() =     fun newStream{compile,flowgraph} =
33     let val cfg = ref(CFG.new(I.C.regmap()))     let val cfg = ref(case flowgraph of
34                           NONE => CFG.new(I.C.regmap())
35                         | SOME cfg => cfg
36                        )
37         val {stream,next} = Builder.builder(!cfg)         val {stream,next} = Builder.builder(!cfg)
38         val S.STREAM{beginCluster,endCluster,pseudoOp,emit,exitBlock,         val S.STREAM{beginCluster,endCluster,pseudoOp,emit,exitBlock,
39                      comment,annotation,defineLabel,entryLabel,alias,phi,...}                      comment,annotation,defineLabel,entryLabel,alias,phi,...}
40                        = stream                        = stream
        fun exit liveRegs =  
        let val addReg   = C.addCell C.GP  
            val addFreg  = C.addCell C.FP  
            val addCCreg = C.addCell C.CC  
            (* we don't care about memory locations that may be live. *)  
            fun live(T.GPR(T.REG(_,r))::rest, acc) = live(rest, addReg(r, acc))  
              | live(T.FPR(T.FREG(_,f))::rest, acc) = live(rest, addFreg(f, acc))  
              | live(T.CCR(T.CC c)::rest, acc) = live(rest, addCCreg(c, acc))  
              | live(_::rest, acc) = live(rest, acc)  
              | live([], acc) = acc  
   
            val lout = live(liveRegs, C.empty)  
        in  exitBlock(lout) end  
   
41         fun endCFG a =         fun endCFG a =
42         let val _      = endCluster a         let val _      = endCluster a
43             val oldCFG = !cfg             val oldCFG = !cfg
44             val newCFG = CFG.new(I.C.regmap())             val newCFG = CFG.new(I.C.regmap())
45         in  cfg := newCFG;         in  cfg := newCFG;
46             next newCFG;             next newCFG;
47             codegen oldCFG             compile oldCFG
48         end         end
49    
50     in  S.STREAM{beginCluster= beginCluster,     in  S.STREAM{beginCluster= beginCluster,
51                  endCluster  = endCFG,                  endCluster  = endCFG,
52                  pseudoOp    = pseudoOp,                  pseudoOp    = pseudoOp,
53                  emit        = emit,                  emit        = emit,
54                  exitBlock   = exit,                  exitBlock   = exitBlock,
55                  comment     = comment,                  comment     = comment,
56                  annotation  = annotation,                  annotation  = annotation,
57                  defineLabel = defineLabel,                  defineLabel = defineLabel,

Legend:
Removed from v.468  
changed lines
  Added in v.545

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