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 /MLRISC/trunk/gc-safety/gc-liveness.sml
ViewVC logotype

Diff of /MLRISC/trunk/gc-safety/gc-liveness.sml

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

revision 744, Fri Dec 8 04:11:42 2000 UTC revision 775, Fri Jan 12 01:17:51 2001 UTC
# Line 3  Line 3 
3   *)   *)
4  functor GCLiveness  functor GCLiveness
5    (structure IR : MLRISC_IR    (structure IR : MLRISC_IR
6     structure GCMap : GC_MAP     structure GC : GC_TYPE
7     structure InsnProps : INSN_PROPERTIES     structure InsnProps : INSN_PROPERTIES
8        sharing InsnProps.I = IR.I        sharing InsnProps.I = IR.I
9    ) : GC_LIVENESS =    ) : GC_LIVENESS =
# Line 12  Line 12 
12    structure IR  = IR    structure IR  = IR
13    structure C   = IR.I.C    structure C   = IR.I.C
14    structure CFG = IR.CFG    structure CFG = IR.CFG
15    structure GC  = GCMap.GC    structure GC  = GC
16    structure G   = Graph    structure G   = Graph
17    structure GCTypeMap =    structure GCTypeMap = GCTypeMap(GC)
      GCTypeMap(structure C = C  
                structure GC = GC)  
18    structure R = GCTypeMap    structure R = GCTypeMap
19    structure A = Array    structure A = Array
20    
# Line 30  Line 28 
28            val join     = R.joins            val join     = R.joins
29            type dataflow_info =            type dataflow_info =
30                  (C.cell -> GC.gctype) *                  (C.cell -> GC.gctype) *
                 (C.cell -> C.cell) *  
31                  { liveIn : R.typemap, liveOut : R.typemap } A.array                  { liveIn : R.typemap, liveOut : R.typemap } A.array
32            fun mk(gcmap,regmap,regs) =            fun mk(gcmap,regs) =
33                R.fromList(map (fn r => (regmap r,gcmap r)) regs)                R.fromList(map (fn r => (r,gcmap r)) regs)
34    
35            fun liveOut(gcmap,regmap,b as CFG.BLOCK{id,...}) =            fun liveOut(gcmap,b as CFG.BLOCK{id,...}) =
36            let val cellset = CFG.liveOut(b)            let val cellset = CFG.liveOut(b)
37                val regs    = C.CellSet.toCellList cellset                val regs    = C.CellSet.toCellList cellset
38            in  mk(gcmap,regmap,regs)            in  mk(gcmap,regs)
39            end            end
40    
41            val defUseR = InsnProps.defUse C.GP            val defUseR = InsnProps.defUse C.GP
42            val defUseF = InsnProps.defUse C.FP            val defUseF = InsnProps.defUse C.FP
43    
44            fun scan(gcmap,regmap,CFG.BLOCK{insns,...}) =            fun scan(gcmap,CFG.BLOCK{insns,...}) =
45            let fun loop([],def,use) = (def,use)            let fun loop([],def,use) = (def,use)
46                  | loop(i::is,def,use) =                  | loop(i::is,def,use) =
47                    let val (d1,u1) = defUseR i                    let val (d1,u1) = defUseR i
48                        val (d2,u2) = defUseF i                        val (d2,u2) = defUseF i
49                        val d = mk(gcmap,regmap,d1 @ d2)                        val d = mk(gcmap,d1 @ d2)
50                        val u = mk(gcmap,regmap,u1 @ u2)                        val u = mk(gcmap,u1 @ u2)
51                        (* val _ = print("d="^R.toString d^" ")                        (* val _ = print("d="^R.toString d^" ")
52                        val _ = print("u="^R.toString u^"\n")                        val _ = print("u="^R.toString u^"\n")
53                        val _ = print("use-d="^R.toString(R.kill(use,d))^"\n")*)                        val _ = print("use-d="^R.toString(R.kill(use,d))^"\n")*)
# Line 62  Line 59 
59                    end                    end
60            in  loop(!insns,R.empty,R.empty) end            in  loop(!insns,R.empty,R.empty) end
61    
62            fun prologue (_,(gcmap,regmap,_)) (b,b') =            fun prologue (_,(gcmap,_)) (b,b') =
63            let val (def,use) = scan(gcmap,regmap,b')            let val (def,use) = scan(gcmap,b')
64                val liveOut   = liveOut(gcmap,regmap,b')                val liveOut   = liveOut(gcmap,b')
65            in  (* print("Liveout("^Int.toString b^")="^R.toString liveOut^"\n");            in  (* print("Liveout("^Int.toString b^")="^R.toString liveOut^"\n");
66                print("def("^Int.toString b^")="^R.toString def^"\n");                print("def("^Int.toString b^")="^R.toString def^"\n");
67                print("use("^Int.toString b^")="^R.toString use^"\n"); *)                print("use("^Int.toString b^")="^R.toString use^"\n"); *)
# Line 73  Line 70 
70                  transfer = fn liveOut => R.gen(R.kill(liveOut,def),use)                  transfer = fn liveOut => R.gen(R.kill(liveOut,def),use)
71                }                }
72            end            end
73            fun epilogue (_,(_,_,table))            fun epilogue (_,(_,table))
74                {node=(b,_), input=liveOut, output=liveIn } =                {node=(b,_), input=liveOut, output=liveIn } =
75                 ((* print("Livein("^Int.toString b^")="^R.toString liveIn^"\n");                 ((* print("Livein("^Int.toString b^")="^R.toString liveIn^"\n");
76                  print("Liveout("^Int.toString b^")="^R.toString liveOut^"\n");*)                  print("Liveout("^Int.toString b^")="^R.toString liveOut^"\n");*)
# Line 83  Line 80 
80    
81    fun liveness (IR as G.GRAPH cfg) =    fun liveness (IR as G.GRAPH cfg) =
82    let val an = !(CFG.annotations IR)    let val an = !(CFG.annotations IR)
       val gcmap = #lookup GCMap.GCMAP an  
       val regmap = CFG.regmap IR  
83        val table = A.array(#capacity cfg (),{liveIn=R.empty,liveOut=R.empty})        val table = A.array(#capacity cfg (),{liveIn=R.empty,liveOut=R.empty})
84        val gclookup = IntHashTable.find gcmap        fun gclookup(C.CELL{an, ...}) = #lookup GC.GC_TYPE (!an)
85        val gclookup = fn r => case gclookup r of SOME t => t | NONE => GC.TOP        val _ = Liveness.analyze(IR,(gclookup,table))
       val _ = Liveness.analyze(IR,(gclookup,C.lookup regmap,table))  
86    in  table    in  table
87    end    end
88    

Legend:
Removed from v.744  
changed lines
  Added in v.775

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