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/hppa/hppaRewrite.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/hppa/hppaRewrite.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 113 - (view) (download)
Original Path: sml/branches/SMLNJ/src/MLRISC/hppa/hppaRewrite.sml

1 : monnier 16 (* hppaRewrite.sml -- rewrite an hppa instruction
2 :     *
3 :     * COPYRIGHT (c) 1997 Bell Labs
4 :     *)
5 :    
6 :     functor HppaRewrite(Instr:HPPAINSTR) = struct
7 :     structure I = Instr
8 :    
9 :     fun rewriteUse(mapr, instr, rs, rt) = let
10 :     fun replc r = if mapr r=rs then rt else r
11 :     in
12 :     case instr
13 :     of I.STORE{st, b, d, r, mem} =>
14 :     I.STORE{st=st, b=replc b, d=d, r=replc r, mem=mem}
15 :     | I.LOAD{l, r1, r2, t, mem} =>
16 :     I.LOAD{l=l, r1=replc r1, r2=replc r2, t=t, mem=mem}
17 :     | I.LOADI{li, r, i, t, mem=mem} =>
18 :     I.LOADI{li=li, r=replc r, i=i, t=t, mem=mem}
19 :     | I.ARITH{a, r1, r2, t} => I.ARITH{a=a, r1=replc r1, r2=replc r2, t=t}
20 :     | I.ARITHI{ai, r, i, t} => I.ARITHI{ai=ai, r=replc r, i=i, t=t}
21 :     | I.COMCLR{cc, r1, r2, t} => I.COMCLR{cc=cc, r1=replc r1, r2=replc r2, t=t}
22 :     | I.SHIFTV{sv, r, len, t} => I.SHIFTV{sv=sv, r=replc r, len=len, t=t}
23 :     | I.SHIFT{s, r, p, len, t} => I.SHIFT{s=s, r=replc r, p=p, len=len, t=t}
24 :     | I.BCOND{cmp, bc, r1, r2, t, f, n} =>
25 :     I.BCOND{cmp=cmp, bc=bc, r1=replc r1, r2=replc r2, t=t, f=f,n=n}
26 :     | I.BCONDI{cmpi, bc, i, r2, t, f, n} =>
27 :     I.BCONDI{cmpi=cmpi, bc=bc, i=i, r2=replc r2, t=t, f=f,n=n}
28 :     | I.BV{x, b, labs, n} => I.BV{x=replc x, b=replc b, labs=labs,n=n}
29 : monnier 106 | I.BLE{b, d, sr, t, defs, uses=(i,f)} =>
30 :     I.BLE{b=replc b, d=d, sr=sr, t=t, defs=defs, uses=(map replc i, f)}
31 : monnier 16 | I.LDO{b, t, i} => I.LDO{b=replc b, t=t, i=i}
32 :     | I.COPY{dst, src, tmp, impl} =>
33 :     I.COPY{dst=dst, src=map replc src, impl=impl, tmp=tmp}
34 :     | I.MTCTL{r, t} => I.MTCTL{r=replc r, t=t}
35 :     | I.FSTORE{fst, b, d, r, mem} =>
36 :     I.FSTORE{fst=fst, b=replc b, d=d, r=r, mem=mem}
37 :     | I.FSTOREX{fstx, b, x, r, mem} =>
38 :     I.FSTOREX{fstx=fstx, b=replc b, x=replc x, r=r, mem=mem}
39 :     | I.FLOAD{fl, b, d, t, mem} =>
40 :     I.FLOAD{fl=fl, b=replc b, d=d, t=t, mem=mem}
41 :     | I.FLOADX{flx, b, x, t, mem} =>
42 :     I.FLOADX{flx=flx, b=replc b, x=replc x, t=t, mem=mem}
43 :     | _ => instr
44 :     end
45 :    
46 :     fun rewriteDef(mapr, instr, rs, rt) = let
47 :     fun replc r = if mapr r=rs then rt else r
48 :     fun ea (SOME(I.Direct r)) = SOME(I.Direct (replc r))
49 :     | ea x = x
50 :     in
51 :     case instr
52 :     of I.ARITH{a, r1, r2, t} => I.ARITH{a=a, r1=r1, r2=r2, t=replc t}
53 :     | I.ARITHI{ai, i, r, t} => I.ARITHI{ai=ai, i=i, r=r, t=replc t}
54 :     | I.LOAD{l, r1, r2, t, mem} => I.LOAD{l=l,r1=r1,r2=r2,t=replc t,mem=mem}
55 :     | I.LOADI{li, i, r, t, mem} => I.LOADI{li=li,i=i,r=r,t=replc t,mem=mem}
56 :     | I.COMCLR{cc, r1, r2, t} => I.COMCLR{cc=cc, r1=r1, r2=r2, t=replc t}
57 :     | I.SHIFTV{sv, r, len, t} => I.SHIFTV{sv=sv, r=r, len=len, t=replc t}
58 :     | I.SHIFT{s, r, p, len, t} => I.SHIFT{s=s, r=r, p=p, len=len, t=replc t}
59 : monnier 106 | I.BLE{d, b, sr, t, defs=(i,f), uses} =>
60 :     I.BLE{d=d, b=b, sr=sr, t=replc t, defs=(map replc i, f), uses=uses}
61 : monnier 16 | I.LDIL{i, t} => I.LDIL{i=i, t=replc t}
62 :     | I.LDO{i, b, t} => I.LDO{i=i, b=b, t=replc t}
63 :     | I.COPY{dst, src, impl, tmp} =>
64 :     I.COPY{dst=map replc dst, src=src, impl=impl, tmp=ea tmp}
65 :     | _ => instr
66 :     end
67 :    
68 :     fun frewriteUse(mapr, instr, fs, ft) = let
69 :     fun replc r = if mapr r=fs then ft else r
70 :     in
71 :     case instr
72 :     of I.FSTORE{fst, b, d, r, mem} =>
73 :     I.FSTORE{fst=fst, b=b, d=d, r=replc r, mem=mem}
74 :     | I.FSTOREX{fstx, b, x, r, mem} =>
75 :     I.FSTOREX{fstx=fstx, b=b, x=x, r=replc r, mem=mem}
76 :     | I.FARITH{fa, r1, r2, t} =>
77 :     I.FARITH{fa=fa, r1=replc r1, r2=replc r2, t=t}
78 :     | I.FUNARY{fu, f, t} => I.FUNARY{fu=fu, f=replc f, t=t}
79 :     | I.FCMP(fcc, f1, f2) => I.FCMP(fcc, replc f1, replc f2)
80 :     | I.FCOPY{dst, src, tmp, impl} =>
81 :     I.FCOPY{dst=dst, src=map replc src, impl=impl, tmp=tmp}
82 : monnier 106 | I.BLE{d, b, sr, t, defs=defs, uses=(i,f)} =>
83 :     I.BLE{d=d, b=b, sr=sr, t=replc t, defs=defs, uses=(i, map replc f)}
84 : monnier 16 | _ => instr
85 :     (*esac*)
86 :     end
87 :    
88 :     fun frewriteDef(mapr, instr, fs, ft) = let
89 :     fun replc r = if mapr r=fs then ft else r
90 :     fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(replc f))
91 :     | ea x = x
92 :     in
93 :     case instr
94 :     of I.FLOAD{fl, b, d, t, mem} =>
95 :     I.FLOAD{fl=fl, b=b, d=d, t=replc t,mem=mem}
96 :     | I.FLOADX{flx, b, x, t, mem} =>
97 :     I.FLOADX{flx=flx, b=b, x=x, t=replc t, mem=mem}
98 :     | I.FARITH {fa, r1, r2, t} => I.FARITH{fa=fa, r1=r1, r2=r2, t=replc t}
99 :     | I.FUNARY{fu, f, t} => I.FUNARY{fu=fu, f=f, t=replc t}
100 :     | I.FCOPY{dst, src, impl, tmp} =>
101 :     I.FCOPY{dst=map replc dst, src=src, impl=impl, tmp=ea tmp}
102 : monnier 106 | I.BLE{d, b, sr, t, defs=(i,f), uses} =>
103 :     I.BLE{d=d, b=b, sr=sr, t=replc t, defs=(i, map replc f), uses=uses}
104 : monnier 16 | _ => instr
105 :     (*esac*)
106 :     end
107 :     end
108 : monnier 93
109 :     (*
110 : monnier 113 * $Log$
111 : monnier 93 *)

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