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/instructions/cells.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/instructions/cells.sml

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

revision 428, Wed Sep 8 09:47:00 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 1  Line 1 
1  (*  (*
2   * Description of registers and other updatable cells.   * Description of cell and other updatable cells.
3   *   *
4   * -- Allen.   * -- Allen.
5   *)   *)
# Line 15  Line 15 
15      val physical    : {kind:cellkind,from:int,to:int} list      val physical    : {kind:cellkind,from:int,to:int} list
16     ) : CELLS_BASIS =     ) : CELLS_BASIS =
17  struct  struct
    structure DA = DynamicArray  
18     type cellkind = cellkind     type cellkind = cellkind
19     type register = int     type cell = int
20     type regmap   = register Intmap.intmap     type regmap = cell Intmap.intmap
21     exception Cells = Cells     exception Cells = Cells
22    
23     val cellkinds = kinds     val cellkinds = kinds
24     val cellkindToString = cellkindToString     val cellkindToString = cellkindToString
25    
26     val initSize = firstPseudo * 4     val initSize = firstPseudo * 4
27     val cellKindTable = DA.array(initSize,unknown)     val cellKindTable = Intmap.new(initSize,Cells) : cellkind Intmap.intmap
28       val lookupCellKind = Intmap.map cellKindTable
29       val cellKind = Intmap.mapWithDefault (cellKindTable,INT)
30       val updateCellKind = Intmap.add  cellKindTable
31    
32       val cellKindOn = MLRiscControl.getFlag "register-cellkind";
33    
34     fun init() =     fun init() =
35        (DA.clear(cellKindTable,initSize);        if !cellKindOn then
36          (Intmap.clear(cellKindTable);
37         app (fn {kind,from,to} =>         app (fn {kind,from,to} =>
38                 let fun loop r =                 let fun loop r =
39                         if r > to then () else                         if r > to then () else
40                         (DA.update(cellKindTable,r,kind); loop(r+1))                         (Intmap.add cellKindTable (r,kind); loop(r+1))
41                 in  loop from end                 in  loop from end
42             ) physical             ) physical
43        )        ) else ()
44    
45     val firstPseudo = firstPseudo     val firstPseudo = firstPseudo
46    
# Line 66  Line 71 
71    
72     fun newCell c =     fun newCell c =
73         let val cnt = lookupCnt c         let val cnt = lookupCnt c
74         in  fn () =>         in  fn _ =>
75             let val r = !name             let val r = !name
76             in  name := r + 1;             in  name := r + 1;
77                 cnt := !cnt + 1;                 cnt := !cnt + 1;
78                 DA.update(cellKindTable,r,c);                 if !cellKindOn andalso c <> INT
79                   then updateCellKind (r,c) else ();
80                 r                 r
81             end             end
82         end         end
83    
84     val newReg  = newCell INT     local val cnt = lookupCnt INT
85     val newFreg = newCell FLOAT     in fun newReg _ =
86          let val r = !name
87          in  name := r + 1;
88              cnt := !cnt + 1;
89              r
90          end
91       end
92    
93       local val cnt = lookupCnt FLOAT
94       in fun newFreg _ =
95          let val r = !name
96          in  name := r + 1;
97              cnt := !cnt + 1;
98              if !cellKindOn then updateCellKind (r,FLOAT) else ();
99              r
100          end
101       end
102    
103     fun newVar r' =     fun newVar r' =
104     let val r = !name     let val r = !name
105     in  name := r + 1;     in  name := r + 1;
106         DA.update(cellKindTable,r,DA.sub(cellKindTable,r'));         if !cellKindOn then
107             (updateCellKind(r,lookupCellKind r') handle _ => ())
108           else ();
109         r         r
110     end     end
111    
112     fun numCell c = let val cnt = lookupCnt c in fn () => !cnt end     fun numCell c = let val cnt = lookupCnt c in fn () => !cnt end
113    
    fun cellKind r = DA.sub(cellKindTable,r)  
    fun updateCellKind(r,k) = DA.update(cellKindTable,r,k)  
   
114     fun maxCell() = !name     fun maxCell() = !name
115    
116     fun regmap() =     fun regmap() =
# Line 103  Line 124 
124         map         map
125     end     end
126    
127     fun lookup regmap = let val look = Intmap.map regmap     val lookup = Intmap.mapInt
                        in  fn r => look r handle _ => r end  
128    
129     fun reset() = (init();     fun reset() = (init();
130                    app (fn r => r := 0) counters;                    app (fn r => r := 0) counters;

Legend:
Removed from v.428  
changed lines
  Added in v.429

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