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 578, Tue Mar 14 05:16:29 2000 UTC revision 579, Wed Mar 22 06:33:08 2000 UTC
# Line 458  Line 458 
458          * We'll just do it from scratch for now.          * We'll just do it from scratch for now.
459          *)          *)
460         fun rebuild(cellkind, G) =         fun rebuild(cellkind, G) =
461             (Core.clearGraph G; Core.clearNodes G;             (Core.clearNodes G;
462              buildIt(cellkind, Core.regmap G, G))              buildIt(cellkind, Core.regmap G, G)
463               )
464    
465         val regs = foldr(fn (r, "") => Int.toString r         val regs = foldr(fn (r, "") => Int.toString r
466                           | (r, l)  => Int.toString r^","^l) ""                           | (r, l)  => Int.toString r^","^l) ""
# Line 470  Line 471 
471         fun spill{copyInstr, spill, spillSrc, spillCopyTmp,         fun spill{copyInstr, spill, spillSrc, spillCopyTmp,
472                   reload, reloadDst, renameSrc, graph as G.GRAPH{regmap, ...},                   reload, reloadDst, renameSrc, graph as G.GRAPH{regmap, ...},
473                   cellkind, nodes=nodesToSpill} =                   cellkind, nodes=nodesToSpill} =
474         let         let (* Remove the interference graph now *)
475               val _ = Core.clearGraph graph
476    
477             (* maps program point to registers to be spilled *)             (* maps program point to registers to be spilled *)
478             val spillSet = Intmap.new(32, NotThere) : C.cell list Intmap.intmap             val spillSet = Intmap.new(32, NotThere) : C.cell list Intmap.intmap
479    
# Line 503  Line 506 
506             fun ins set =             fun ins set =
507             let val add  = Intmap.add set             let val add  = Intmap.add set
508                 val look = Intmap.mapWithDefault(set, [])                 val look = Intmap.mapWithDefault(set, [])
509             in  fn r => fn x =>                 fun enter(r, []) = ()
510                 (add (x, r::look x);                   | enter(r, pt::pts) =
511                  addAffectedBlocks (blockNum x, true)                     (add (pt, r::look pt);
512                        addAffectedBlocks (blockNum pt, true);
513                        enter(r, pts)
514                 )                 )
515               in  enter
516             end             end
517    
518             val insSpillSet  = ins spillSet             val insSpillSet  = ins spillSet
# Line 514  Line 520 
520             val insKillSet   =             val insKillSet   =
521             let val add  = Intmap.add killSet             let val add  = Intmap.add killSet
522                 val look = Intmap.mapWithDefault(killSet, [])                 val look = Intmap.mapWithDefault(killSet, [])
523             in  fn r => fn x => add (x, r::look x) end                 fun enter(r, []) = ()
524                     | enter(r, pt::pts) = (add(pt, r::look pt); enter(r, pts))
525               in  enter
526               end
527    
528             (* Mark all spill/reload locations *)             (* Mark all spill/reload locations *)
529             val markSpills = app             fun markSpills [] = ()
530                (fn G.NODE{color, number, defs=ref defs, uses=ref uses, ...} =>               | markSpills(
531                    G.NODE{color, number, defs as ref d, uses as ref u, ...}::ns) =
532                 let fun spillIt(defs, uses) =                 let fun spillIt(defs, uses) =
533                         (app (insSpillSet number) defs;                         (insSpillSet(number, defs);
534                          app (insReloadSet number) uses;                          insReloadSet(number, uses);
535                          (* Definitions but no use! *)                          (* Definitions but no use! *)
536                          case uses of                          case uses of
537                             [] => app (insKillSet number) defs                             [] => insKillSet(number, defs)
538                           | _ => ()                           | _ => ()
539                         )                         )
540                 in  case !color of                 in  case !color of
541                       G.SPILLED c => spillIt(defs, uses)                       G.SPILLED c => spillIt(d, u)
542                     | G.PSEUDO => spillIt(defs, uses)                     | G.PSEUDO => spillIt(d, u)
543                     | _ => ()                     | _ => ();
544                       markSpills ns
545                 end                 end
              )  
546             val _ = markSpills nodesToSpill             val _ = markSpills nodesToSpill
547    
548             (* Print all spill/reload locations *)             (* Print all spill/reload locations *)
# Line 582  Line 592 
592    
593         in  Intmap.app rewriteAll affectedBlocks;         in  Intmap.app rewriteAll affectedBlocks;
594             let val spilledMarker = SPILLED ~2             let val spilledMarker = SPILLED ~2
595             in  app (fn G.NODE{number, color as ref(SPILLED c), ...} =>                 fun mark [] = ()
596                          if number <> c then color := spilledMarker else ()                   | mark(G.NODE{number, color as ref(SPILLED c), ...}::rest)=
597                       | G.NODE{color as ref PSEUDO, ...} =>                       (if number <> c then color := spilledMarker else ();
598                          color := spilledMarker                        mark rest)
599                       | _ => ()                   | mark(G.NODE{color as ref PSEUDO, ...}::rest) =
600                     ) nodesToSpill                        (color := spilledMarker; mark rest)
601                     | mark(_::rest) = mark rest
602               in  mark nodesToSpill
603             end;             end;
604             rebuild(cellkind, graph)             rebuild(cellkind, graph)
605         end         end

Legend:
Removed from v.578  
changed lines
  Added in v.579

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