Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/cluster/printCluster.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/cluster/printCluster.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 744 - (download) (annotate)
Fri Dec 8 04:11:42 2000 UTC (18 years, 9 months ago) by leunga
File size: 2757 byte(s)

   A CVS update record!

   Changed type cell from int to datatype, and numerous other changes.
   Affect every client of MLRISC.  Lal says this can be bootstrapped on all
   machines.  See smlnj/HISTORY for details.

   Tag:  leunga-20001207-cell-monster-hack
(* printFlowgraph.sml -- print flowgraph of target machine instructions. 
 *
 * Copyright (c) 1997 Bell Laboratories.
 *)
signature PRINT_CLUSTER = 
sig
   structure F : FLOWGRAPH
   structure E : INSTRUCTION_EMITTER
      where I = F.I and P = F.P

   val printCluster : TextIO.outstream -> string -> F.cluster -> unit
end


functor PrintCluster 
   (structure Flowgraph : FLOWGRAPH
    structure Asm       : INSTRUCTION_EMITTER 
       where P=Flowgraph.P and I=Flowgraph.I
   ) : PRINT_CLUSTER =
struct
   structure E = Asm
   structure F = Flowgraph
   structure C = Flowgraph.C
   structure W = F.W

   fun printList stream list = let
     fun pr str = TextIO.output(stream, str)
     fun iter [] = ()
       | iter [i] = pr i
       | iter (h::t) = (pr (h ^ ", "); iter t)
   in iter list
   end

   fun showFreq(ref w) = "["^W.toString w^"]"
   fun showEdge'(blknum,w) = Int.toString blknum^showFreq w
   fun showEdge(F.BBLOCK{blknum, ...},w) = showEdge'(blknum,w)
     | showEdge(F.ENTRY{blknum, ...},w) = showEdge'(blknum,w)
     | showEdge(F.EXIT{blknum, ...},w) = showEdge'(blknum,w)
     | showEdge(_, w) = "???"

   fun printCluster stream title 
        (F.CLUSTER {blocks, entry, exit, annotations, ...}) = 
   let fun pr str = TextIO.output(stream, str)
       val prList = printList stream
       val E.S.STREAM{emit,pseudoOp,defineLabel,annotation,...} = 
             AsmStream.withStream stream E.makeStream (!annotations)

       fun printBlock(F.ENTRY{blknum, succ, freq, ...}) = 
           (pr ("ENTRY " ^ Int.toString blknum ^ showFreq freq^"\n");
            pr "\tsucc:     "; prList (map showEdge (!succ));        pr "\n")
         | printBlock(F.PSEUDO pOp) = pseudoOp pOp
         | printBlock(F.LABEL l)    = defineLabel l
         | printBlock(F.BBLOCK{blknum, freq, succ, pred, liveOut, liveIn, 
                               insns, annotations, ...}) = 
           (pr ("BLOCK " ^ Int.toString blknum ^ showFreq freq ^ "\n");
            app annotation (!annotations);
            pr ("\tlive in:  " ^ C.CellSet.toString (!liveIn) ^ "\n");
            pr ("\tlive out: " ^ C.CellSet.toString (!liveOut) ^ "\n");
            pr ("\tsucc:     "); prList (map showEdge (!succ)); pr "\n";
            pr ("\tpred:     "); prList (map showEdge (!pred)); pr "\n";
            app emit (rev (!insns)))
         | printBlock(F.EXIT{blknum, pred, freq, ...}) = 
           (pr ("EXIT " ^ Int.toString blknum ^ showFreq freq ^"\n");
            pr "\tpred:     "; prList (map showEdge (!pred));  pr "\n")
   in
       pr("[ "^ title ^" ]\n");
       app annotation (!annotations);
       printBlock entry;
       AsmStream.withStream stream (app printBlock) blocks;
       printBlock exit;
       TextIO.flushOut stream
   end
end


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