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/flowgraph/printFlowgraph.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/flowgraph/printFlowgraph.sml

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

revision 983, Wed Nov 21 18:44:55 2001 UTC revision 984, Wed Nov 21 19:00:08 2001 UTC
# Line 4  Line 4 
4   *)   *)
5  signature PRINT_FLOWGRAPH =  signature PRINT_FLOWGRAPH =
6  sig  sig
    structure CFG : CONTROL_FLOW_GRAPH  
7     structure Asm : INSTRUCTION_EMITTER     structure Asm : INSTRUCTION_EMITTER
8        where I = CFG.I and P = CFG.P     structure CFG : CONTROL_FLOW_GRAPH
9                          where I = Asm.I
10                            and P = Asm.S.P
11    
12     val printCFG : TextIO.outstream -> string -> CFG.cfg -> unit     val printCFG : TextIO.outstream -> string -> CFG.cfg -> unit
13  end  end
14    
15    
16  functor PrintFlowgraph  functor PrintFlowgraph
17     (structure CFG : CONTROL_FLOW_GRAPH     (structure Asm : INSTRUCTION_EMITTER
18      structure Asm : INSTRUCTION_EMITTER      structure CFG : CONTROL_FLOW_GRAPH
19         where P=CFG.P and I=CFG.I                      where I = Asm.I
20                          and P = Asm.S.P
21     ) : PRINT_FLOWGRAPH =     ) : PRINT_FLOWGRAPH =
22  struct  struct
23     structure Asm = Asm     structure Asm = Asm
24     structure CFG = CFG     structure CFG = CFG
25     structure C   = CFG.I.C     structure C   = CFG.I.C
26     structure W   = CFG.W     structure W   = CFG.W
27       structure Fmt = Format
28    
29     val i2s = Int.toString     val i2s = Int.toString
30    
# Line 40  Line 43 
43         val Asm.S.STREAM{emit,pseudoOp,defineLabel,annotation,...} =         val Asm.S.STREAM{emit,pseudoOp,defineLabel,annotation,...} =
44               AsmStream.withStream stream Asm.makeStream annotations               AsmStream.withStream stream Asm.makeStream annotations
45    
46         fun showFreq(ref w) = "["^W.toString w^"]"         fun showFreq(ref w) = Fmt.format "[%s]" [Fmt.STR(W.toString w)]
47         fun showEdge(blknum,e) = i2s blknum^":"^CFG.show_edge e         fun showEdge(blknum,e) =
48               Fmt.format "%d:%s" [Fmt.INT blknum, Fmt.STR(CFG.show_edge e)]
49         fun showSucc(_, x, e) = showEdge(x,e)         fun showSucc(_, x, e) = showEdge(x,e)
50         fun showPred(x, _, e) = showEdge(x,e)         fun showPred(x, _, e) = showEdge(x,e)
51         fun showSuccs b =         fun showSuccs b =
# Line 54  Line 58 
58               pr "\n")               pr "\n")
59    
60         fun printBlock(_, CFG.BLOCK{kind=CFG.START, id, freq, ...}) =         fun printBlock(_, CFG.BLOCK{kind=CFG.START, id, freq, ...}) =
61             (pr ("ENTRY " ^ i2s id ^ showFreq freq^"\n");             (pr (Fmt.format "ENTRY %d %s\n" [Fmt.INT id, Fmt.STR(showFreq freq)]);
62              showSuccs id)              showSuccs id)
63           | printBlock(_, CFG.BLOCK{kind=CFG.STOP, id, freq, ...}) =           | printBlock(_, CFG.BLOCK{kind=CFG.STOP, id, freq, ...}) =
64             (pr ("EXIT " ^ i2s id ^ showFreq freq ^"\n");             (pr (Fmt.format "EXIT %d %s\n" [Fmt.INT id, Fmt.STR(showFreq freq)]);
65              showPreds id)              showPreds id)
66           | printBlock(_, CFG.BLOCK{id, freq, insns, annotations, data,           | printBlock(_, CFG.BLOCK{id, align, freq, insns, annotations,
67                                 labels, ...}) =                                 labels, ...}) =
68             (pr ("BLOCK " ^ i2s id ^ showFreq freq ^ "\n");             (pr (Fmt.format "BLOCK %d %s\n" [Fmt.INT id, Fmt.STR(showFreq freq)]);
69                case !align of NONE => () | SOME p => (pr (CFG.P.toString p ^ "\n"));
70              app annotation (!annotations);              app annotation (!annotations);
             app (fn CFG.PSEUDO pOp => pseudoOp pOp  
                   | CFG.LABEL l    => defineLabel l  
                 ) (!data);  
71              app defineLabel (!labels);              app defineLabel (!labels);
72              (*pr ("\tlive in:  " ^ CellsBasis.CellSet.toString (!liveIn) ^ "\n");              (*
73              pr ("\tlive out: " ^ CellsBasis.CellSet.toString (!liveOut) ^ "\n");*)                 pr ("\tlive in:  " ^ CellsBasis.CellSet.toString (!liveIn) ^ "\n");
74                   pr ("\tlive out: " ^ CellsBasis.CellSet.toString (!liveOut) ^ "\n");
75                 *)
76              showSuccs id;              showSuccs id;
77              showPreds id;              showPreds id;
78              app emit (rev (!insns)))              app emit (rev (!insns)))
79    
80           fun printData() = let
81             val CFG.INFO{data, ...} = #graph_info cfg
82           in List.app (pr o CFG.P.toString) (rev(!data))
83           end
84     in     in
85         pr("[ "^ title ^" ]\n");         pr(Fmt.format "[ %s ]\n" [Fmt.STR title]);
86         app annotation annotations;         app annotation annotations;
87         (* printBlock entry; *)         (* printBlock entry; *)
88         AsmStream.withStream stream (#forall_nodes cfg) printBlock;         AsmStream.withStream stream (#forall_nodes cfg) printBlock;
89         (* printBlock exit; *)         (* printBlock exit; *)
90           AsmStream.withStream stream printData ();
91         TextIO.flushOut stream         TextIO.flushOut stream
92     end     end
93  end  end

Legend:
Removed from v.983  
changed lines
  Added in v.984

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