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

Diff of /sml/trunk/src/MLRISC/ra/mem-ra.sml

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

revision 733, Fri Nov 17 05:13:45 2000 UTC revision 1125, Thu Mar 7 21:04:13 2002 UTC
# Line 20  Line 20 
20    
21    fun error msg = MLRiscErrorMsg.error("RACore", msg)    fun error msg = MLRiscErrorMsg.error("RACore", msg)
22    
   (* No overflow checking necessary here *)  
   fun x + y = W.toIntX(W.+(W.fromInt x, W.fromInt y))  
   fun x - y = W.toIntX(W.-(W.fromInt x, W.fromInt y))  
   
23    fun concat([], b) = b    fun concat([], b) = b
24      | concat(x::a, b) = concat(a, x::b)      | concat(x::a, b) = concat(a, x::b)
25    
# Line 38  Line 34 
34      | isMemLoc(SPILL_LOC _) = true      | isMemLoc(SPILL_LOC _) = true
35      | isMemLoc(MEMREG _) = true      | isMemLoc(MEMREG _) = true
36      | isMemLoc _ = false      | isMemLoc _ = false
37    
38    (*    (*
39     * Spill coalescing.     * Spill coalescing.
40     * Coalesce non-interfering moves between spilled nodes,     * Coalesce non-interfering moves between spilled nodes,
# Line 136  Line 133 
133    fun spillPropagation(G as GRAPH{bitMatrix, memRegs, ...}) nodesToSpill =    fun spillPropagation(G as GRAPH{bitMatrix, memRegs, ...}) nodesToSpill =
134    let val spillCoalescing = spillCoalescing G    let val spillCoalescing = spillCoalescing G
135        exception SpillProp        exception SpillProp
136        val visited =        val visited = IntHashTable.mkTable(32, SpillProp)
137            IntHashTable.mkTable(32, SpillProp) : bool IntHashTable.hash_table                       : bool IntHashTable.hash_table
138        fun hasBeenVisited i = getOpt (IntHashTable.find visited i, false)        val hasBeenVisited = IntHashTable.find visited
139          val hasBeenVisited = fn r => case hasBeenVisited r of NONE => false
140                                                              | SOME _ => true
141        val markAsVisited = IntHashTable.insert visited        val markAsVisited = IntHashTable.insert visited
142        val member = BM.member(!bitMatrix)        val member = BM.member(!bitMatrix)
143    
# Line 169  Line 168 
168                          (if debug then print "interfere\n" else ();                          (if debug then print "interfere\n" else ();
169                           moveSavings(mvs, pinned, total))                           moveSavings(mvs, pinned, total))
170                        else if x = ~1 then                        else if x = ~1 then
171                          (if debug then print (Int.toString cost^"\n") else ();                          (if debug then print (Real.toString cost^"\n") else ();
172                           moveSavings(mvs, pinned, total+cost))                           moveSavings(mvs, pinned, total+cost))
173                        else if pinned >= 0 andalso pinned <> x then                        else if pinned >= 0 andalso pinned <> x then
174                          (* already coalesced with another mem reg *)                          (* already coalesced with another mem reg *)
175                          (if debug then print "pinned\n" else ();                          (if debug then print "pinned\n" else ();
176                           moveSavings(mvs, pinned, total))                           moveSavings(mvs, pinned, total))
177                       else                       else
178                          (if debug then print (Int.toString cost^"\n") else ();                          (if debug then print (Real.toString cost^"\n") else ();
179                           moveSavings(mvs, x, total+cost))                           moveSavings(mvs, x, total+cost))
180    
181                   val _ = if debug then                   val _ = if debug then
# Line 190  Line 189 
189                   else                   else
190                      case (!dstCol, !srcCol) of                      case (!dstCol, !srcCol) of
191                        (SPILLED, PSEUDO) => savings(~1)                        (SPILLED, PSEUDO) => savings(~1)
192                      | (MEMREG m, PSEUDO) => savings(m)                      | (MEMREG(m, _), PSEUDO) => savings(m)
193                      | (SPILL_LOC s, PSEUDO) => savings(~s)                      | (SPILL_LOC s, PSEUDO) => savings(~s)
194                      | (PSEUDO, SPILLED) => savings(~1)                      | (PSEUDO, SPILLED) => savings(~1)
195                      | (PSEUDO, MEMREG m) => savings(m)                      | (PSEUDO, MEMREG(m, _)) => savings(m)
196                      | (PSEUDO, SPILL_LOC s) => savings(~s)                      | (PSEUDO, SPILL_LOC s) => savings(~s)
197                      | _ => (if debug then print "0 (other)\n" else ();                      | _ => (if debug then print "0 (other)\n" else ();
198                              moveSavings(mvs, pinned, total))                              moveSavings(mvs, pinned, total))
# Line 202  Line 201 
201            (* Find initial budget *)            (* Find initial budget *)
202            val _ = if debug then            val _ = if debug then
203                        print("Trying to propagate "^Int.toString me^                        print("Trying to propagate "^Int.toString me^
204                              " spill cost="^Int.toString spillcost^"\n")                              " spill cost="^Real.toString spillcost^"\n")
205                    else ()                    else ()
206    
207            val (pinned, savings) = moveSavings(!movelist, ~1, 0)            val (pinned, savings) = moveSavings(!movelist, ~1, 0.0)
208            val budget = spillcost - savings            val budget = spillcost - savings
209            val S      = [node]            val S      = [node]
210    
# Line 239  Line 238 
238                     else ();                     else ();
239                    improve(L, pinned, budget, S))                    improve(L, pinned, budget, S))
240                else                else
241                let val (pinned', savings) = moveSavings(!movelist, pinned, 0)                let val (pinned', savings) = moveSavings(!movelist, pinned, 0.0)
242                    val defUseSavings = cost+cost                    val defUseSavings = cost+cost
243                    val spillcost     = !pri                    val spillcost     = !pri
244                    val budget' = budget - savings - defUseSavings + spillcost                    val budget' = budget - savings - defUseSavings + spillcost
# Line 254  Line 253 
253                        improve(L, pinned, budget, S))                        improve(L, pinned, budget, S))
254                end                end
255    
256        in  if budget <= 0 then (budget, S)        in  if budget <= 0.0 then (budget, S)
257            else improve(lookaheads(!movelist, []), pinned, budget, S)            else improve(lookaheads(!movelist, []), pinned, budget, S)
258        end        end
259    
# Line 285  Line 284 
284                     spillNodes nodes                     spillNodes nodes
285                    )                    )
286    
287            in  if budget <= 0            in  if budget <= 0.0
288                then  (* propagate spill *)                then  (* propagate spill *)
289                   (if debug then                   (if debug then
290                      (print("Propagating ");                      (print("Propagating ");
# Line 428  Line 427 
427        fun spillIt{graph = G as GRAPH{mode, ...}, nodes,        fun spillIt{graph = G as GRAPH{mode, ...}, nodes,
428                    copyInstr, spill, spillSrc, spillCopyTmp,                    copyInstr, spill, spillSrc, spillCopyTmp,
429                    reload, reloadDst, renameSrc, cellkind} =                    reload, reloadDst, renameSrc, cellkind} =
430        let val nodes = if isOn(mode,SPILL_PROPAGATION) then        let
431              val nodes = if isOn(mode,SPILL_PROPAGATION) then
432                            spillPropagation G nodes else nodes                            spillPropagation G nodes else nodes
433            val _ = if isOn(mode,SPILL_COALESCING) then            val _ = if isOn(mode,SPILL_COALESCING) then
434                       spillCoalescing G nodes else ()                       spillCoalescing G nodes else ()

Legend:
Removed from v.733  
changed lines
  Added in v.1125

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