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

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

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

revision 957, Thu Oct 11 15:47:53 2001 UTC revision 958, Fri Oct 12 03:54:43 2001 UTC
# Line 76  Line 76 
76     in app dump (#nodes graph ())     in app dump (#nodes graph ())
77     end     end
78    
79       val annotations = CFG.annotations
80    
81     val dummyBlock =   CFG.newBlock(~1, ref 0)     val dummyBlock =   CFG.newBlock(~1, ref 0)
82    
83     fun x + y = Word.toIntX(Word.+(Word.fromInt x, Word.fromInt y))     fun x + y = Word.toIntX(Word.+(Word.fromInt x, Word.fromInt y))
84    
85       val uniq = ListMergeSort.uniqueSort
86                    (fn ({block=b1,insn=i1},{block=b2,insn=i2}) =>
87                        case Int.compare(b1,b2) of
88                          EQUAL => Int.compare(i1,i2)
89                        | ord   => ord)
90    
91     fun services(cfg as Graph.GRAPH graph) = let     fun services(cfg as Graph.GRAPH graph) = let
92         val CFG.INFO{annotations=clAnns, ...} = #graph_info graph         val CFG.INFO{annotations=clAnns, ...} = #graph_info graph
93         val blocks = #nodes graph ()         val blocks = #nodes graph ()
# Line 89  Line 97 
97    
98         val N = maxBlockId(blocks, #capacity graph ())         val N = maxBlockId(blocks, #capacity graph ())
99    
        fun computeShift(0w0, max) = 0w31-max  
          | computeShift(N, max) = computeShift(Word.>>(N, 0w1), Word.+(max,0w1))  
        val shift = computeShift(Word.>>(Word.fromInt N, 0w15), 0w15)  
        val mask  = Word.<<(0w1, shift) - 0w1  
   
100         (*         (*
101          * Construct program point          * Construct program point
102          *)          *)
103         fun progPt(blknum, instrId) =         fun progPt(blknum, instrId) = {block=blknum, insn=instrId}
104             Word.toIntX(Word.+(Word.<<(Word.fromInt blknum, shift),         fun blockNum{block,insn} = block
105                                        Word.fromInt instrId))         fun instrNum{block,insn} = insn
        fun blockNum pt = Word.toIntX(Word.>>(Word.fromInt pt, shift))  
        fun instrNum pt = Word.toIntX(Word.andb(Word.fromInt pt, mask))  
106    
107             (* blocks indexed by block id *)             (* blocks indexed by block id *)
108         val blockTable   = A.array(N, (#new_id graph (), dummyBlock))         val blockTable   = A.array(N, (#new_id graph (), dummyBlock))
# Line 129  Line 130 
130              * v is a source of a copy.              * v is a source of a copy.
131              *)              *)
132             val copyTable    = IntHashTable.mkTable(N, NotThere)             val copyTable    = IntHashTable.mkTable(N, NotThere)
133                  : {dst:CB.cell,pt:int} list IntHashTable.hash_table                  : {dst:CB.cell,pt:G.programPoint} list IntHashTable.hash_table
134             val lookupCopy   = IntHashTable.find copyTable             val lookupCopy   = IntHashTable.find copyTable
135             val lookupCopy   = fn r => case lookupCopy r of SOME c => c             val lookupCopy   = fn r => case lookupCopy r of SOME c => c
136                                                           | NONE => []                                                           | NONE => []
# Line 259  Line 260 
260                         liveOutAtStmt(block, A.length defs, defs, 1, !freq, span)                         liveOutAtStmt(block, A.length defs, defs, 1, !freq, span)
261                       end                       end
262    
263                 val useSites = SortedList.uniq(!uses)                 val useSites = uniq(!uses)
264                 val trail    = initialize(v, v', useSites)                 val trail    = initialize(v, v', useSites)
265                 val span     = foreachUseSite (useSites, 0)                 val span     = foreachUseSite (useSites, 0)
266                 val _        = cleanup trail                 val _        = cleanup trail
# Line 300  Line 301 
301                             (* Add a pseudo use for tmpR *)                             (* Add a pseudo use for tmpR *)
302                            (case chase(getnode(colorOf r)) of                            (case chase(getnode(colorOf r)) of
303                               tmp as NODE{uses,defs=ref [d],...} =>                               tmp as NODE{uses,defs=ref [d],...} =>
304                                 (uses := [d-1]; (dst, tmp::tmps))                               let fun prev{block,insn}={block=block,insn=insn-1}
305                                 in  (uses := [prev d]; (dst, tmp::tmps))
306                                 end
307                            | _ => error "mkMoves"                            | _ => error "mkMoves"
308                            )                            )
309                         | (_, dst) => (dst, tmps)                         | (_, dst) => (dst, tmps)
# Line 347  Line 350 
350                           val _    = UA.update(dtab, i, defs)                           val _    = UA.update(dtab, i, defs)
351                           val (mv, tmps) =                           val (mv, tmps) =
352                                 mkMoves(insn, pt, d, u, w, mv, tmps)                                 mkMoves(insn, pt, d, u, w, mv, tmps)
353                       in  scan(rest, pt+1, i+1, mv, tmps)                           fun next{block,insn} = {block=block,insn=insn+1}
354                         in  scan(rest,next pt, i+1, mv, tmps)
355                       end                       end
356                   val (pt, i, mv, tmps) =                   val (pt, i, mv, tmps) =
357                     scan(!insns, progPt(nid,1), 1, mv, tmps)                     scan(!insns, progPt(nid,1), 1, mv, tmps)
                  val _ =  
                    if pt >= progPt(nid+1, 0) then  
                       error("mkNodes: too many instructions")  
                    else ()  
358                 in                 in
359                   (* If the block is escaping, then all liveout                   (* If the block is escaping, then all liveout
360                    * registers are considered used here.                    * registers are considered used here.
# Line 445  Line 445 
445             val _ = Core.clearGraph graph             val _ = Core.clearGraph graph
446    
447             (* maps program point to registers to be spilled *)             (* maps program point to registers to be spilled *)
448             val spillSet = IntHashTable.mkTable(32, NotThere)             val spillSet = G.PPtHashTable.mkTable(32, NotThere)
449    
450             (* maps program point to registers to be reloaded *)             (* maps program point to registers to be reloaded *)
451             val reloadSet = IntHashTable.mkTable(32, NotThere)             val reloadSet = G.PPtHashTable.mkTable(32, NotThere)
452    
453             (* maps program point to registers to be killed *)             (* maps program point to registers to be killed *)
454             val killSet = IntHashTable.mkTable(32, NotThere)             val killSet = G.PPtHashTable.mkTable(32, NotThere)
455    
456             val spillRewrite = Spill.spillRewrite             val spillRewrite = Spill.spillRewrite
457                                { graph=graph,                                { graph=graph,
# Line 474  Line 474 
474             val addAffectedBlocks = IntHashTable.insert affectedBlocks             val addAffectedBlocks = IntHashTable.insert affectedBlocks
475    
476             fun ins set = let             fun ins set = let
477                 val add  = IntHashTable.insert set                 val add  = G.PPtHashTable.insert set
478                 val look = IntHashTable.find set                 val look = G.PPtHashTable.find set
479                 val look = fn r => case look r of SOME s => s | NONE => []                 val look = fn r => case look r of SOME s => s | NONE => []
480                 fun enter(r, []) = ()                 fun enter(r, []) = ()
481                   | enter(r, pt::pts) =                   | enter(r, pt::pts) =
# Line 490  Line 490 
490             val insReloadSet = ins reloadSet             val insReloadSet = ins reloadSet
491             val insKillSet   =             val insKillSet   =
492               let               let
493                 val add  = IntHashTable.insert killSet                 val add  = G.PPtHashTable.insert killSet
494                 val look = IntHashTable.find killSet                 val look = G.PPtHashTable.find killSet
495                 val look = fn r => case look r of SOME s => s | NONE => []                 val look = fn r => case look r of SOME s => s | NONE => []
496                 fun enter(r, []) = ()                 fun enter(r, []) = ()
497                   | enter(r, pt::pts) = (add(pt, r::look pt); enter(r, pts))                   | enter(r, pt::pts) = (add(pt, r::look pt); enter(r, pts))

Legend:
Removed from v.957  
changed lines
  Added in v.958

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