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-basis.sml
ViewVC logotype

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

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

revision 889, Thu Jul 19 20:35:20 2001 UTC revision 900, Tue Aug 14 15:10:12 2001 UTC
# Line 264  Line 264 
264                    val hashVal = hashColor                    val hashVal = hashColor
265                    val sameKey = sameColor)                    val sameKey = sameColor)
266    
267        structure CellSet =
268          struct
269           type cellset = (cellkindDesc * cell list) list
270           val empty = []
271    
272           fun same(DESC{counter=c1,...}, DESC{counter=c2,...}) = c1=c2
273    
274           fun descOf (CELL{desc, ...}) = desc
275    
276           fun add (r, cellset:cellset) =
277           let val k = descOf r
278               fun loop [] = [(k,[r])]
279                 | loop((x as (k',s))::cellset) =
280                    if same(k,k') then (k',r::s)::cellset
281                    else x::loop cellset
282           in  loop cellset end
283    
284           fun rmv (r, cellset:cellset) =
285           let val k = descOf r
286               val c = registerId r
287               fun filter [] = []
288                 | filter(r::rs) = if registerId r = c then filter rs
289                                   else r::filter rs
290               fun loop [] = []
291                 | loop((x as (k',s))::cellset) =
292                    if same(k,k') then (k',filter s)::cellset else x::loop cellset
293           in  loop cellset end
294    
295           fun get (k : cellkindDesc) = let
296                 fun loop ([] : cellset) = []
297                   | loop ((x as (k',s))::cellset) =
298                       if same(k, k') then s else loop cellset
299                 in
300                   loop
301                 end
302    
303           fun update (k : cellkindDesc) (cellset:cellset, s) = let
304                 fun loop [] = [(k,s)]
305                   | loop((x as (k',_))::cellset) =
306                       if same(k,k') then (k',s)::cellset else x::loop cellset
307                 in
308                   loop cellset
309                 end
310    
311           fun map {from,to} (cellset:cellset) =
312           let val CELL{desc=k,...} = from
313               val cf = registerId from
314               fun trans r = if registerId r = cf then to else r
315               fun loop [] = []
316                 | loop((x as (k',s))::cellset) =
317                    if same(k, k') then (k',List.map trans s)::cellset
318                    else x::loop cellset
319           in  loop cellset end
320    
321           val toCellList : cellset -> cell list =
322               List.foldr (fn ((_,S),S') => S @ S') []
323    
324           (* Pretty print cellset *)
325           fun printSet(f,set,S) =
326           let fun loop([], S) = "}"::S
327                 | loop([x], S) = f(chase x)::"}"::S
328                 | loop(x::xs, S) = f(chase x)::" "::loop(xs, S)
329           in  "{"::loop(set, S) end
330    
331           fun toString' cellset =
332           let fun pr cellset =
333               let fun loop((DESC{kind, toString, ...},s)::rest, S)=
334                       (case s of
335                          [] => loop(rest, S)
336                        | _  => cellkindToString kind::"="::
337                                printSet(toString o registerId,s," "::loop(rest,S))
338                       )
339                     | loop([],S) = S
340               in  String.concat(loop(cellset, []))
341               end
342           in  pr cellset end
343    
344           val toString = toString'
345         end (* CellSet *)
346    
347      (*      (*
348       * These annotations specifies definitions and uses       * These annotations specifies definitions and uses
349       * for a pseudo instruction.       * for a pseudo instruction.

Legend:
Removed from v.889  
changed lines
  Added in v.900

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