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 224 - (view) (download)

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 167 | I.BLR{x, t, labs, n} => I.BLR{x=replc x, t=t, labs=labs,n=n}
30 : monnier 106 | I.BLE{b, d, sr, t, defs, uses=(i,f)} =>
31 :     I.BLE{b=replc b, d=d, sr=sr, t=t, defs=defs, uses=(map replc i, f)}
32 : monnier 16 | I.LDO{b, t, i} => I.LDO{b=replc b, t=t, i=i}
33 :     | I.COPY{dst, src, tmp, impl} =>
34 :     I.COPY{dst=dst, src=map replc src, impl=impl, tmp=tmp}
35 :     | I.MTCTL{r, t} => I.MTCTL{r=replc r, t=t}
36 :     | I.FSTORE{fst, b, d, r, mem} =>
37 :     I.FSTORE{fst=fst, b=replc b, d=d, r=r, mem=mem}
38 :     | I.FSTOREX{fstx, b, x, r, mem} =>
39 :     I.FSTOREX{fstx=fstx, b=replc b, x=replc x, r=r, mem=mem}
40 :     | I.FLOAD{fl, b, d, t, mem} =>
41 :     I.FLOAD{fl=fl, b=replc b, d=d, t=t, mem=mem}
42 :     | I.FLOADX{flx, b, x, t, mem} =>
43 :     I.FLOADX{flx=flx, b=replc b, x=replc x, t=t, mem=mem}
44 :     | _ => instr
45 :     end
46 :    
47 :     fun rewriteDef(mapr, instr, rs, rt) = let
48 :     fun replc r = if mapr r=rs then rt else r
49 :     fun ea (SOME(I.Direct r)) = SOME(I.Direct (replc r))
50 :     | ea x = x
51 :     in
52 :     case instr
53 :     of I.ARITH{a, r1, r2, t} => I.ARITH{a=a, r1=r1, r2=r2, t=replc t}
54 :     | I.ARITHI{ai, i, r, t} => I.ARITHI{ai=ai, i=i, r=r, t=replc t}
55 :     | I.LOAD{l, r1, r2, t, mem} => I.LOAD{l=l,r1=r1,r2=r2,t=replc t,mem=mem}
56 :     | I.LOADI{li, i, r, t, mem} => I.LOADI{li=li,i=i,r=r,t=replc t,mem=mem}
57 :     | I.COMCLR{cc, r1, r2, t} => I.COMCLR{cc=cc, r1=r1, r2=r2, t=replc t}
58 :     | I.SHIFTV{sv, r, len, t} => I.SHIFTV{sv=sv, r=r, len=len, t=replc t}
59 :     | I.SHIFT{s, r, p, len, t} => I.SHIFT{s=s, r=r, p=p, len=len, t=replc t}
60 : monnier 167 | I.BLR{x, t, labs, n} => I.BLR{x=x, t=replc t, labs=labs,n=n}
61 : monnier 106 | I.BLE{d, b, sr, t, defs=(i,f), uses} =>
62 :     I.BLE{d=d, b=b, sr=sr, t=replc t, defs=(map replc i, f), uses=uses}
63 : monnier 16 | I.LDIL{i, t} => I.LDIL{i=i, t=replc t}
64 :     | I.LDO{i, b, t} => I.LDO{i=i, b=b, t=replc t}
65 :     | I.COPY{dst, src, impl, tmp} =>
66 :     I.COPY{dst=map replc dst, src=src, impl=impl, tmp=ea tmp}
67 :     | _ => instr
68 :     end
69 :    
70 :     fun frewriteUse(mapr, instr, fs, ft) = let
71 :     fun replc r = if mapr r=fs then ft else r
72 :     in
73 :     case instr
74 :     of I.FSTORE{fst, b, d, r, mem} =>
75 :     I.FSTORE{fst=fst, b=b, d=d, r=replc r, mem=mem}
76 :     | I.FSTOREX{fstx, b, x, r, mem} =>
77 :     I.FSTOREX{fstx=fstx, b=b, x=x, r=replc r, mem=mem}
78 :     | I.FARITH{fa, r1, r2, t} =>
79 :     I.FARITH{fa=fa, r1=replc r1, r2=replc r2, t=t}
80 :     | I.FUNARY{fu, f, t} => I.FUNARY{fu=fu, f=replc f, t=t}
81 : monnier 167 | I.FBRANCH{cc,f1,f2,t,f,n,long} =>
82 :     I.FBRANCH{cc=cc,f1=replc f1,f2=replc f2,t=t,f=f,n=n,long=long}
83 : monnier 16 | I.FCOPY{dst, src, tmp, impl} =>
84 :     I.FCOPY{dst=dst, src=map replc src, impl=impl, tmp=tmp}
85 : monnier 106 | I.BLE{d, b, sr, t, defs=defs, uses=(i,f)} =>
86 :     I.BLE{d=d, b=b, sr=sr, t=replc t, defs=defs, uses=(i, map replc f)}
87 : monnier 16 | _ => instr
88 :     (*esac*)
89 :     end
90 :    
91 :     fun frewriteDef(mapr, instr, fs, ft) = let
92 :     fun replc r = if mapr r=fs then ft else r
93 :     fun ea (SOME(I.FDirect f)) = SOME(I.FDirect(replc f))
94 :     | ea x = x
95 :     in
96 :     case instr
97 :     of I.FLOAD{fl, b, d, t, mem} =>
98 :     I.FLOAD{fl=fl, b=b, d=d, t=replc t,mem=mem}
99 :     | I.FLOADX{flx, b, x, t, mem} =>
100 :     I.FLOADX{flx=flx, b=b, x=x, t=replc t, mem=mem}
101 :     | I.FARITH {fa, r1, r2, t} => I.FARITH{fa=fa, r1=r1, r2=r2, t=replc t}
102 :     | I.FUNARY{fu, f, t} => I.FUNARY{fu=fu, f=f, t=replc t}
103 :     | I.FCOPY{dst, src, impl, tmp} =>
104 :     I.FCOPY{dst=map replc dst, src=src, impl=impl, tmp=ea tmp}
105 : monnier 106 | I.BLE{d, b, sr, t, defs=(i,f), uses} =>
106 :     I.BLE{d=d, b=b, sr=sr, t=replc t, defs=(i, map replc f), uses=uses}
107 : monnier 16 | _ => instr
108 :     (*esac*)
109 :     end
110 :     end
111 : monnier 93
112 :     (*
113 : monnier 167 * $Log: hppaRewrite.sml,v $
114 : monnier 223 * Revision 1.4 1998/10/06 14:04:37 george
115 :     * The instruction sequence FCMP, FTEST, FBCC is being replaced
116 :     * by the composite instruction FBRANCH. This makes scheduling and
117 :     * other tasks easier. Also, added BLR and BL in the instruction set.
118 :     * [leunga]
119 :     *
120 : monnier 167 * Revision 1.3 1998/05/25 15:11:00 george
121 :     * Fixed RCS keywords
122 :     *
123 : monnier 93 *)

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