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 /MLRISC/trunk/instructions/shuffle.sml
ViewVC logotype

Diff of /MLRISC/trunk/instructions/shuffle.sml

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

revision 247, Sat Apr 17 18:47:13 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 1  Line 1 
1  (* shuffle.sml -- implements the parallel copy instruction as a sequence  (* shuffle.sml -- implements the parallel copy instruction as a sequence
2   *              of moves. Makes use of asmTmpR from CELLS.   *              of moves.
3   *   *
4   * COPYRIGHT (c) 1996 Bell Laboratories.   * COPYRIGHT (c) 1996 Bell Laboratories.
5   *   *
# Line 12  Line 12 
12        {mvInstr : {dst:I.ea, src:I.ea} -> I.instruction list,        {mvInstr : {dst:I.ea, src:I.ea} -> I.instruction list,
13         ea : int -> I.ea}         ea : int -> I.ea}
14        ->        ->
15          {regMap: int -> int,          {regmap: int -> int,
16           temp : I.ea option,           tmp : I.ea option,
17           dst : int list,           dst : int list,
18           src : int list}           src : int list}
19          -> I.instruction list          -> I.instruction list
# Line 24  Line 24 
24      | equal (TEMP, TEMP) = true      | equal (TEMP, TEMP) = true
25      | equal _ = false      | equal _ = false
26    
27    fun shuffle{mvInstr, ea} {regMap, temp, dst, src} = let    fun shuffle{mvInstr, ea} {regmap, tmp, dst, src} = let
28      val mv = rev o mvInstr      val mv = rev o mvInstr
29      fun opnd (REG dst) = ea dst      fun opnd (REG dst) = ea dst
30        | opnd TEMP = Option.valOf temp        | opnd TEMP = Option.valOf tmp
31    
32      (* perform unconstrained moves *)      (* perform unconstrained moves *)
33      fun loop((p as (rd,rs))::rest, changed, used, done, instrs) =      fun loop((p as (rd,rs))::rest, changed, used, done, instrs) =
34          if List.exists (fn r => equal(r, rd)) used then          if List.exists (fn r => equal(r, rd)) used then
35             loop(rest, changed, used, p::done, instrs)             loop(rest, changed, used, p::done, instrs)
36          else loop(rest, true, used, done, mv{dst=opnd rd, src=opnd rs}@instrs)          else loop(rest, true, used, done,
37                      mv{dst=opnd rd, src=opnd rs}@instrs)
38        | loop([], changed, _, done, instrs) = (changed, done, instrs)        | loop([], changed, _, done, instrs) = (changed, done, instrs)
39    
40      fun cycle([], instrs) = instrs      fun cycle([], instrs) = instrs
# Line 44  Line 45 
45             | (false, (rd,rs)::acc, instrs) => let             | (false, (rd,rs)::acc, instrs) => let
46                 fun rename(p as (a,b)) = if equal(rd, b) then (a, TEMP) else p                 fun rename(p as (a,b)) = if equal(rd, b) then (a, TEMP) else p
47                 val acc' = (rd, rs) :: map rename acc                 val acc' = (rd, rs) :: map rename acc
48                 val instrs' = mv{dst=Option.valOf temp, src=opnd rd}@instrs                 val instrs' = mv{dst=Option.valOf tmp, src=opnd rd}@instrs
49                 val (_, acc'', instrs'') =                 val (_, acc'', instrs'') =
50                   loop(acc', false, map #2 acc', [], instrs')                   loop(acc', false, map #2 acc', [], instrs')
51               in cycle(acc'', instrs'')               in cycle(acc'', instrs'')
# Line 53  Line 54 
54    
55      (* remove moves that have been coalesced. *)      (* remove moves that have been coalesced. *)
56      fun rmvCoalesced(rd::rds, rs::rss) = let      fun rmvCoalesced(rd::rds, rs::rss) = let
57            val dst = regMap rd            val dst = regmap rd
58            val src = regMap rs            val src = regmap rs
59          in          in
60            if dst = src then rmvCoalesced(rds, rss)            if dst = src then rmvCoalesced(rds, rss)
61            else (REG dst, REG src)::rmvCoalesced(rds, rss)            else (REG dst, REG src)::rmvCoalesced(rds, rss)
# Line 64  Line 65 
65    end    end
66  end  end
67    
 (*  
  * $Log: shuffle.sml,v $  
  * Revision 1.1.1.1  1998/11/16 21:48:41  george  
  *   Version 110.10  
  *  
  * Revision 1.1.1.1  1998/04/08 18:39:02  george  
  * Version 110.5  
  *  
  *)  

Legend:
Removed from v.247  
changed lines
  Added in v.411

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