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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/sparc/sparcShuffle.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/sparc/sparcShuffle.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 129 - (view) (download)

1 : monnier 129 functor SparcShuffle(I:SPARCINSTR) = struct
2 :     structure I = I
3 :     structure W = Word32
4 :     structure Shuffle = Shuffle(I)
5 :     type t = {regMap:int->int, temp:I.ea option, dst:int list, src:int list}
6 :    
7 :     fun error msg = MLRiscErrorMsg.impossible ("SparcShuffle." ^ msg)
8 :     val mem = I.Region.memory
9 :    
10 :     fun immed13 n = ~4096 <= n andalso n < 4096
11 :     (* split into 22 high bits/10 low bits *)
12 :     fun split n =
13 :     let val w = W.fromInt n
14 :     in {hi=W.toInt(W.~>>(w,0w10)),lo=W.toInt(W.andb(w,0wx3ff))} end
15 :     fun offset disp =
16 :     if immed13 disp then ([],I.IMMED disp)
17 :     else let val {lo,hi} = split disp
18 :     val r = I.C.newReg()
19 :     in ([I.SETHI{i=hi,d=r},
20 :     I.ARITH{a=I.OR,r=r,i=I.IMMED lo,d=r,cc=false}],
21 :     I.REG r)
22 :     end
23 :    
24 :     fun move{src=I.Direct rs, dst=I.Direct rt} =
25 :     [I.ARITH{a=I.OR, cc=false, r=0, i=I.REG rs, d=rt}]
26 :     | move{src=I.Displace{base, disp}, dst=I.Direct rt} =
27 :     let val (insns,i) = offset disp
28 :     in insns@[I.LOAD{l=I.LD, r=base, i=i, d=rt, mem=mem}] end
29 :     | move{src=I.Direct rs, dst=I.Displace{base, disp}} =
30 :     let val (insns,i) = offset disp
31 :     in insns@[I.STORE{s=I.ST, r=base, i=i, d=rs, mem=mem}] end
32 :     | move _ = error "move"
33 :    
34 :     fun fmove{src=I.FDirect fs, dst=I.FDirect fd} =
35 :     [I.FPop1{a=I.FMOVd, r=fs, d=fd}]
36 :     | fmove{src=I.Displace{base, disp}, dst=I.FDirect ft} =
37 :     let val (insns,i) = offset disp
38 :     in insns@[I.FLOAD{l=I.LDDF, r=base, i=i, d=ft, mem=mem}] end
39 :     | fmove{src=I.FDirect fs, dst=I.Displace{base, disp}} =
40 :     let val (insns,i) = offset disp
41 :     in insns@[I.FSTORE{s=I.STDF, r=base, i=i, d=fs, mem=mem}] end
42 :     | fmove _ = error "fmove"
43 :    
44 :     val shuffle = Shuffle.shuffle{mvInstr = move, ea=I.Direct}
45 :    
46 :     val shufflefp = Shuffle.shuffle {mvInstr=fmove, ea=I.FDirect}
47 :     end
48 :    
49 :    
50 :     (*
51 :     * $Log$
52 :     *)

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