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/branches/idlbasis-devel/src/MLRISC/ppc/emit/ppcMC.sml
ViewVC logotype

Diff of /sml/branches/idlbasis-devel/src/MLRISC/ppc/emit/ppcMC.sml

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

revision 411, Fri Sep 3 00:25:03 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 19  Line 19 
19     (* PPC is a big endian architecture *)     (* PPC is a big endian architecture *)
20    
21     fun error msg = MLRiscErrorMsg.error("PPCMC",msg)     fun error msg = MLRiscErrorMsg.error("PPCMC",msg)
22     fun makeStream() =     fun makeStream _ =
23     let infix && || << >> ~>>     let infix && || << >> ~>>
24         val op << = W.<<         val op << = W.<<
25         val op >> = W.>>         val op >> = W.>>
# Line 74  Line 74 
74    
75     fun emit_SPR r = (itow ((regmap r) - 72))     fun emit_SPR r = (itow ((regmap r) - 72))
76     and emit_CC r = (itow ((regmap r) - 64))     and emit_CC r = (itow ((regmap r) - 64))
    and emit_GP r = (itow (regmap r))  
77     and emit_FP r = (itow ((regmap r) - 32))     and emit_FP r = (itow ((regmap r) - 32))
78       and emit_GP r = (itow (regmap r))
79    
80     fun emit_bo (I.TRUE) = (0wxc : Word32.word)     fun emit_unary (I.NEG) = (0wx68 : Word32.word)
81         | emit_unary (I.EXTSB) = (0wx3ba : Word32.word)
82         | emit_unary (I.EXTSH) = (0wx39a : Word32.word)
83         | emit_unary (I.EXTSW) = (0wx3da : Word32.word)
84         | emit_unary (I.CNTLZW) = (0wx1a : Word32.word)
85         | emit_unary (I.CNTLZD) = (0wx3a : Word32.word)
86       and emit_farith (I.FADD) = (0wx3f, 0wx15)
87         | emit_farith (I.FSUB) = (0wx3f, 0wx14)
88         | emit_farith (I.FMUL) = (0wx3f, 0wx19)
89         | emit_farith (I.FDIV) = (0wx3f, 0wx12)
90         | emit_farith (I.FADDS) = (0wx3b, 0wx15)
91         | emit_farith (I.FSUBS) = (0wx3b, 0wx14)
92         | emit_farith (I.FMULS) = (0wx3b, 0wx19)
93         | emit_farith (I.FDIVS) = (0wx3b, 0wx12)
94       and emit_operand (I.RegOp GP) = (emit_GP GP)
95         | emit_operand (I.ImmedOp int) = (itow int)
96         | emit_operand (I.LabelOp labexp) = (itow (LabelExp.valueOf labexp))
97         | emit_operand (I.ConstOp const) = (itow (Constant.valueOf const))
98       and emit_funary (I.FMR) = (0wx3f, 0wx48)
99         | emit_funary (I.FNEG) = (0wx3f, 0wx28)
100         | emit_funary (I.FABS) = (0wx3f, 0wx108)
101         | emit_funary (I.FNABS) = (0wx3f, 0wx88)
102         | emit_funary (I.FSQRT) = (0wx3f, 0wx16)
103         | emit_funary (I.FSQRTS) = (0wx3b, 0wx16)
104         | emit_funary (I.FRSP) = (0wx3f, 0wxc)
105         | emit_funary (I.FCTIW) = (0wx3f, 0wxe)
106         | emit_funary (I.FCTIWZ) = (0wx3f, 0wxf)
107         | emit_funary (I.FCTID) = (0wx3f, 0wx32e)
108         | emit_funary (I.FCTIDZ) = (0wx3f, 0wx32f)
109         | emit_funary (I.FCFID) = (0wx3f, 0wx34e)
110       and emit_bo (I.TRUE) = (0wxc : Word32.word)
111       | emit_bo (I.FALSE) = (0wx4 : Word32.word)       | emit_bo (I.FALSE) = (0wx4 : Word32.word)
112       | emit_bo (I.ALWAYS) = (0wx14 : Word32.word)       | emit_bo (I.ALWAYS) = (0wx14 : Word32.word)
113       | emit_bo (I.COUNTER{eqZero, cond}) =       | emit_bo (I.COUNTER{eqZero, cond}) =
# Line 95  Line 125 
125         | (true, true) => 0wxa         | (true, true) => 0wxa
126          )          )
127         )         )
128     and emit_arithi (I.ADDI) = (0wxe : Word32.word)     and emit_ccarith (I.CRAND) = (0wx101 : Word32.word)
129       | emit_arithi (I.ADDIS) = (0wxf : Word32.word)       | emit_ccarith (I.CROR) = (0wx1c1 : Word32.word)
130       | emit_arithi (I.SUBFIC) = (0wx8 : Word32.word)       | emit_ccarith (I.CRXOR) = (0wxc1 : Word32.word)
131       | emit_arithi (I.MULLI) = (0wx7 : Word32.word)       | emit_ccarith (I.CRNAND) = (0wxe1 : Word32.word)
132       | emit_arithi (I.ANDI_Rc) = (0wx1c : Word32.word)       | emit_ccarith (I.CRNOR) = (0wx21 : Word32.word)
133       | emit_arithi (I.ANDIS_Rc) = (0wx1d : Word32.word)       | emit_ccarith (I.CREQV) = (0wx121 : Word32.word)
134       | emit_arithi (I.ORI) = (0wx18 : Word32.word)       | emit_ccarith (I.CRANDC) = (0wx81 : Word32.word)
135       | emit_arithi (I.ORIS) = (0wx19 : Word32.word)       | emit_ccarith (I.CRORC) = (0wx1a1 : Word32.word)
      | emit_arithi (I.XORI) = (0wx1a : Word32.word)  
      | emit_arithi (I.XORIS) = (0wx1b : Word32.word)  
      | emit_arithi (I.SRAWI) = (error "SRAWI")  
      | emit_arithi (I.SRADI) = (error "SRADI")  
    and emit_farith3 (I.FMADD) = (0wx3f, 0wx1d)  
      | emit_farith3 (I.FMADDS) = (0wx3b, 0wx1d)  
      | emit_farith3 (I.FMSUB) = (0wx3f, 0wx1c)  
      | emit_farith3 (I.FMSUBS) = (0wx3b, 0wx1c)  
      | emit_farith3 (I.FNMADD) = (0wx3f, 0wx1f)  
      | emit_farith3 (I.FNMADDS) = (0wx3b, 0wx1f)  
      | emit_farith3 (I.FNMSUB) = (0wx3f, 0wx1e)  
      | emit_farith3 (I.FNMSUBS) = (0wx3b, 0wx1e)  
      | emit_farith3 (I.FSEL) = (0wx3f, 0wx17)  
    and emit_farith (I.FADD) = (0wx3f, 0wx15)  
      | emit_farith (I.FSUB) = (0wx3f, 0wx14)  
      | emit_farith (I.FMUL) = (0wx3f, 0wx19)  
      | emit_farith (I.FDIV) = (0wx3f, 0wx12)  
      | emit_farith (I.FADDS) = (0wx3b, 0wx15)  
      | emit_farith (I.FSUBS) = (0wx3b, 0wx14)  
      | emit_farith (I.FMULS) = (0wx3b, 0wx19)  
      | emit_farith (I.FDIVS) = (0wx3b, 0wx12)  
136     and emit_arith (I.ADD) = (0wx10a : Word32.word)     and emit_arith (I.ADD) = (0wx10a : Word32.word)
137       | emit_arith (I.SUBF) = (0wx28 : Word32.word)       | emit_arith (I.SUBF) = (0wx28 : Word32.word)
138       | emit_arith (I.MULLW) = (0wxeb : Word32.word)       | emit_arith (I.MULLW) = (0wxeb : Word32.word)
# Line 150  Line 159 
159       | emit_arith (I.SRAD) = (0wx31a : Word32.word)       | emit_arith (I.SRAD) = (0wx31a : Word32.word)
160     and emit_fcmp (I.FCMPO) = (0wx20 : Word32.word)     and emit_fcmp (I.FCMPO) = (0wx20 : Word32.word)
161       | emit_fcmp (I.FCMPU) = (0wx0 : Word32.word)       | emit_fcmp (I.FCMPU) = (0wx0 : Word32.word)
162     and emit_ccarith (I.CRAND) = (0wx101 : Word32.word)     and emit_farith3 (I.FMADD) = (0wx3f, 0wx1d)
163       | emit_ccarith (I.CROR) = (0wx1c1 : Word32.word)       | emit_farith3 (I.FMADDS) = (0wx3b, 0wx1d)
164       | emit_ccarith (I.CRXOR) = (0wxc1 : Word32.word)       | emit_farith3 (I.FMSUB) = (0wx3f, 0wx1c)
165       | emit_ccarith (I.CRNAND) = (0wxe1 : Word32.word)       | emit_farith3 (I.FMSUBS) = (0wx3b, 0wx1c)
166       | emit_ccarith (I.CRNOR) = (0wx21 : Word32.word)       | emit_farith3 (I.FNMADD) = (0wx3f, 0wx1f)
167       | emit_ccarith (I.CREQV) = (0wx121 : Word32.word)       | emit_farith3 (I.FNMADDS) = (0wx3b, 0wx1f)
168       | emit_ccarith (I.CRANDC) = (0wx81 : Word32.word)       | emit_farith3 (I.FNMSUB) = (0wx3f, 0wx1e)
169       | emit_ccarith (I.CRORC) = (0wx1a1 : Word32.word)       | emit_farith3 (I.FNMSUBS) = (0wx3b, 0wx1e)
170     and emit_funary (I.FMR) = (0wx3f, 0wx48)       | emit_farith3 (I.FSEL) = (0wx3f, 0wx17)
171       | emit_funary (I.FNEG) = (0wx3f, 0wx28)     and emit_arithi (I.ADDI) = (0wxe : Word32.word)
172       | emit_funary (I.FABS) = (0wx3f, 0wx108)       | emit_arithi (I.ADDIS) = (0wxf : Word32.word)
173       | emit_funary (I.FNABS) = (0wx3f, 0wx88)       | emit_arithi (I.SUBFIC) = (0wx8 : Word32.word)
174       | emit_funary (I.FSQRT) = (0wx3f, 0wx16)       | emit_arithi (I.MULLI) = (0wx7 : Word32.word)
175       | emit_funary (I.FSQRTS) = (0wx3b, 0wx16)       | emit_arithi (I.ANDI_Rc) = (0wx1c : Word32.word)
176       | emit_funary (I.FRSP) = (0wx3f, 0wxc)       | emit_arithi (I.ANDIS_Rc) = (0wx1d : Word32.word)
177       | emit_funary (I.FCTIW) = (0wx3f, 0wxe)       | emit_arithi (I.ORI) = (0wx18 : Word32.word)
178       | emit_funary (I.FCTIWZ) = (0wx3f, 0wxf)       | emit_arithi (I.ORIS) = (0wx19 : Word32.word)
179       | emit_funary (I.FCTID) = (0wx3f, 0wx32e)       | emit_arithi (I.XORI) = (0wx1a : Word32.word)
180       | emit_funary (I.FCTIDZ) = (0wx3f, 0wx32f)       | emit_arithi (I.XORIS) = (0wx1b : Word32.word)
181       | emit_funary (I.FCFID) = (0wx3f, 0wx34e)       | emit_arithi (I.SRAWI) = (error "SRAWI")
182     and emit_operand (I.RegOp GP) = (emit_GP GP)       | emit_arithi (I.SRADI) = (error "SRADI")
      | emit_operand (I.ImmedOp int) = (itow int)  
      | emit_operand (I.LabelOp labexp) = (itow (LabelExp.valueOf labexp))  
      | emit_operand (I.ConstOp const) = (itow (Constant.valueOf const))  
    and emit_unary (I.NEG) = (0wx68 : Word32.word)  
      | emit_unary (I.EXTSB) = (0wx3ba : Word32.word)  
      | emit_unary (I.EXTSH) = (0wx39a : Word32.word)  
      | emit_unary (I.EXTSW) = (0wx3da : Word32.word)  
      | emit_unary (I.CNTLZW) = (0wx1a : Word32.word)  
      | emit_unary (I.CNTLZD) = (0wx3a : Word32.word)  
   
    fun arithi' {oper, rt, ra, im} = let  
           val oper = (emit_arithi oper)  
           val rt = (emit_GP rt)  
           val ra = (emit_GP ra)  
           val im = (emit_operand im)  
        in (eWord32 ((im && 0wxffff) + ((ra << 0wx10) + ((rt << 0wx15) + (oper << 0wx1a)))))  
        end  
   
    and loadde {opcd, rt, ra, de, xop} = let  
           val rt = (emit_GP rt)  
           val ra = (emit_GP ra)  
           val de = (emit_operand de)  
        in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((rt << 0wx15) + (opcd << 0wx1a))))))  
        end  
183    
184     and tdi {to, ra, si} = let     fun rldimi {rs, ra, sh, mb, sh2} = let
185            val to = (emit_int to)            val rs = (emit_GP rs)
186            val ra = (emit_GP ra)            val ra = (emit_GP ra)
187            val si = (emit_operand si)            val mb = (emit_int mb)
188         in (eWord32 ((si && 0wxffff) + ((ra << 0wx10) + ((to << 0wx15) + 0wx8000000))))         in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7800000c))))))
189         end         end
190    
191     and stored {opcd, rs, ra, d} = let     and rldcl {rs, ra, sh, mb} = let
192            val rs = (emit_GP rs)            val rs = (emit_GP rs)
193            val ra = (emit_GP ra)            val ra = (emit_GP ra)
194            val d = (emit_operand d)            val sh = (emit_GP sh)
195         in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((rs << 0wx15) + (opcd << 0wx1a)))))            val mb = (emit_int mb)
196           in (eWord32 ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000010)))))
197         end         end
198    
199     and twi {to, ra, si} = let     and fcmp {bf, fa, fb, cmp} = let
200            val to = (emit_int to)            val bf = (emit_CC bf)
201            val ra = (emit_GP ra)            val fa = (emit_FP fa)
202            val si = (emit_operand si)            val fb = (emit_FP fb)
203         in (eWord32 ((si && 0wxffff) + ((ra << 0wx10) + ((to << 0wx15) + 0wxc000000))))            val cmp = (emit_fcmp cmp)
204           in (eWord32 ((cmp << 0wx1) + ((fb << 0wxb) + ((fa << 0wx10) + ((bf << 0wx17) + 0wxfc000000)))))
205         end         end
206    
207     and floadd {opcd, ft, ra, d} = let     and mtspr {rs, spr} = let
208            val ft = (emit_FP ft)            val spr = (emit_SPR spr)
209            val ra = (emit_GP ra)         in (mtspr' {rs=rs, spr=(((spr && 0wx1f) << 0wx5) + ((spr >> 0wx5)&& 0wx1f))})
           val d = (emit_operand d)  
        in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((ft << 0wx15) + (opcd << 0wx1a)))))  
210         end         end
211    
212     and tdr {to, ra, rb} = let     and rldcr {rs, ra, sh, mb} = let
213            val to = (emit_int to)            val rs = (emit_GP rs)
214            val ra = (emit_GP ra)            val ra = (emit_GP ra)
215            val rb = (emit_GP rb)            val sh = (emit_GP sh)
216         in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((to << 0wx15) + 0wx7c000088))))            val mb = (emit_int mb)
217           in (eWord32 ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000012)))))
218         end         end
219    
220     and loadd {opcd, rt, ra, d} = let     and rotatei {oper, ra, rs, sh, mb, me} = let
221            val rt = (emit_GP rt)            val sh = (emit_operand sh)
222            val ra = (emit_GP ra)         in
223            val d = (emit_operand d)            (
224         in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((rt << 0wx15) + (opcd << 0wx1a)))))             case (oper, me) of
225               (I.RLWINM, SOME me) => (rlwinm {ra=ra, rs=rs, sh=sh, mb=mb, me=me})
226             | (I.RLWIMI, SOME me) => (rlwimi {ra=ra, rs=rs, sh=sh, mb=mb, me=me})
227             | (I.RLDICL, _) => (rldicl {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})
228             | (I.RLDICR, _) => (rldicr {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})
229             | (I.RLDIC, _) => (rldic {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})
230             | (I.RLDIMI, _) => (rldimi {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})
231              )
232         end         end
233    
234     and twr {to, ra, rb} = let     and loadx {rt, ra, rb, xop} = let
235            val to = (emit_int to)            val rt = (emit_GP rt)
236            val ra = (emit_GP ra)            val ra = (emit_GP ra)
237            val rb = (emit_GP rb)            val rb = (emit_GP rb)
238         in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((to << 0wx15) + 0wx7c000008))))         in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((rt << 0wx15) + 0wx7c000000)))))
        end  
   
    and Cmpli {bf, l, ra, ui} = let  
           val bf = (emit_CC bf)  
           val l = (emit_bool l)  
           val ra = (emit_GP ra)  
           val ui = (emit_operand ui)  
        in (eWord32 ((ui && 0wxffff) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx28000000)))))  
239         end         end
240    
241     and td {to, ra, si} =     and tw {to, ra, si} =
242         (         (
243          case si of          case si of
244          I.RegOp rb => (tdr {to=to, ra=ra, rb=rb})          I.RegOp rb => (twr {to=to, ra=ra, rb=rb})
245        | _ => (tdi {to=to, ra=ra, si=si})        | _ => (twi {to=to, ra=ra, si=si})
246         )         )
247     and rldcl {rs, ra, sh, mb} = let     and stored {opcd, rs, ra, d} = let
248            val rs = (emit_GP rs)            val rs = (emit_GP rs)
249            val ra = (emit_GP ra)            val ra = (emit_GP ra)
250            val sh = (emit_GP sh)            val d = (emit_operand d)
251            val mb = (emit_int mb)         in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((rs << 0wx15) + (opcd << 0wx1a)))))
        in (eWord32 ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000010)))))  
252         end         end
253    
254     and farith3 {oper, ft, fa, fc, fb, Rc} = let     and srawi {rs, ra, sh} = let
255            val oper = (emit_farith3 oper)            val rs = (emit_GP rs)
256              val ra = (emit_GP ra)
257              val sh = (emit_operand sh)
258           in (eWord32 (((sh && 0wx1f) << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7c000670))))
259           end
260    
261       and farith {oper, ft, fa, fb, Rc} = let
262            val ft = (emit_FP ft)            val ft = (emit_FP ft)
263            val fa = (emit_FP fa)            val fa = (emit_FP fa)
           val fc = (emit_FP fc)  
264            val fb = (emit_FP fb)            val fb = (emit_FP fb)
265         in let         in let
266    
267  (*#line 448.1 "ppc/ppc.md"*)  (*#line 439.1 "ppc/ppc.md"*)
268               val(opcd, xo) = oper               val(opcd, xo) = (emit_farith oper)
269            in (a_form {opcd=opcd, frt=ft, fra=fa, frb=fb, frc=fc, xo=xo, rc=Rc})            in
270                 (
271                  case oper of
272                  (I.FMUL|I.FMULS) => (a_form {opcd=opcd, frt=ft, fra=fa, frb=0wx0, frc=fb, xo=xo, rc=Rc})
273                | _ => (a_form {opcd=opcd, frt=ft, fra=fa, frb=fb, frc=0wx0, xo=xo, rc=Rc})
274                 )
275            end            end
276    
277         end         end
278    
279     and bce {bo, bi, bd, aa, lk} = let     and arith' {rt, ra, rb, OE, oper, Rc} = let
280            val bo = (emit_bo bo)            val rt = (emit_GP rt)
281            val aa = (emit_bool aa)            val ra = (emit_GP ra)
282            val lk = (emit_bool lk)            val rb = (emit_GP rb)
283         in (eWord32 (lk + ((aa << 0wx1) + (((bd && 0wx3fff) << 0wx2) + ((bi << 0wx10) + ((bo << 0wx15) + 0wx40000000))))))            val OE = (emit_bool OE)
284              val oper = (emit_arith oper)
285              val Rc = (emit_bool Rc)
286           in (eWord32 (Rc + ((oper << 0wx1) + ((OE << 0wxa) + ((rb << 0wxb) + ((ra << 0wx10) + ((rt << 0wx15) + 0wx7c000000)))))))
287         end         end
288    
289     and rlwimi {rs, ra, sh, mb, me} = let     and sradi {rs, ra, sh} = let
290            val rs = (emit_GP rs)            val sh = (emit_operand sh)
291            val ra = (emit_GP ra)         in (sradi' {rs=rs, ra=ra, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1)})
292            val mb = (emit_int mb)         end
293            val me = (emit_int me)  
294         in (eWord32 ((me << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx50000000))))))     and twi {to, ra, si} = let
295              val to = (emit_int to)
296              val ra = (emit_GP ra)
297              val si = (emit_operand si)
298           in (eWord32 ((si && 0wxffff) + ((ra << 0wx10) + ((to << 0wx15) + 0wxc000000))))
299         end         end
300    
301     and storex {rs, ra, rb, xop} = let     and storex {rs, ra, rb, xop} = let
# Line 304  Line 305 
305         in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7c000000)))))         in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7c000000)))))
306         end         end
307    
308     and ccarith {oper, bt, ba, bb} = let     and bc {bo, bi, bd, aa, lk} = let
309            val oper = (emit_ccarith oper)            val bo = (emit_bo bo)
310         in (xl_form {opcd=0wx13, bt=(cr_bit {cc=bt}), ba=(cr_bit {cc=ba}), bb=(cr_bit {cc=bb}), xo=oper, lk=false})            val aa = (emit_bool aa)
311              val lk = (emit_bool lk)
312           in (eWord32 (lk + ((aa << 0wx1) + (((bd && 0wx3fff) << 0wx2) + ((bi << 0wx10) + ((bo << 0wx15) + 0wx40000000))))))
313         end         end
314    
315     and rldcr {rs, ra, sh, mb} = let     and be {li, aa, lk} = let
316            val rs = (emit_GP rs)            val aa = (emit_bool aa)
317            val ra = (emit_GP ra)            val lk = (emit_bool lk)
318            val sh = (emit_GP sh)         in (eWord32 (lk + ((aa << 0wx1) + (((li && 0wxffffff) << 0wx2) + 0wx58000000))))
           val mb = (emit_int mb)  
        in (eWord32 ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000012)))))  
319         end         end
320    
321     and rotate {oper, ra, rs, sh, mb, me} =     and arith {oper, rt, ra, rb, OE, Rc} =
322         (         (
323          case (oper, me) of          case oper of
324          (I.RLWNM, SOME me) => (rlwnm {ra=ra, rs=rs, sh=sh, mb=mb, me=me})          (I.ADD|I.SUBF|I.MULLW|I.MULLD|I.MULHW|I.MULHWU|I.DIVW|I.DIVD|I.DIVWU|I.DIVDU) => (arith' {oper=oper, rt=rt, ra=ra, rb=rb, OE=OE, Rc=Rc})
325        | (I.RLDCL, _) => (rldcl {ra=ra, rs=rs, sh=sh, mb=mb})        | _ => (arith' {oper=oper, rt=ra, ra=rt, rb=rb, OE=OE, Rc=Rc})
       | (I.RLDCR, _) => (rldcr {ra=ra, rs=rs, sh=sh, mb=mb})  
326         )         )
327     and sradi' {rs, ra, sh, sh2} = let     and loadde {opcd, rt, ra, de, xop} = let
           val rs = (emit_GP rs)  
           val ra = (emit_GP ra)  
        in (eWord32 ((sh2 << 0wx1) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7c000674)))))  
        end  
   
    and floadx {ft, ra, rb, xop} = let  
           val ft = (emit_FP ft)  
           val ra = (emit_GP ra)  
           val rb = (emit_GP rb)  
        in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((ft << 0wx15) + 0wx7c000000)))))  
        end  
   
    and unary' {ra, rt, OE, oper, Rc} = let  
           val ra = (emit_GP ra)  
           val rt = (emit_GP rt)  
           val OE = (emit_bool OE)  
           val oper = (emit_unary oper)  
           val Rc = (emit_bool Rc)  
        in (eWord32 (Rc + ((oper << 0wx1) + ((OE << 0wxa) + ((rt << 0wx10) + ((ra << 0wx15) + 0wx7c000000))))))  
        end  
   
    and loadx {rt, ra, rb, xop} = let  
328            val rt = (emit_GP rt)            val rt = (emit_GP rt)
329            val ra = (emit_GP ra)            val ra = (emit_GP ra)
330            val rb = (emit_GP rb)            val de = (emit_operand de)
331         in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((rt << 0wx15) + 0wx7c000000)))))         in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((rt << 0wx15) + (opcd << 0wx1a))))))
332         end         end
333    
334     and bclre {bo, bi, lk} = let     and Cmpi {bf, l, ra, si} = let
335            val bo = (emit_bo bo)            val bf = (emit_CC bf)
336            val lk = (emit_bool lk)            val l = (emit_bool l)
337         in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000022))))            val ra = (emit_GP ra)
338              val si = (emit_operand si)
339           in (eWord32 ((si && 0wxffff) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx2c000000)))))
340         end         end
341    
    and arithi {oper, rt, ra, im} =  
        (  
         case oper of  
         (I.ADDI|I.ADDIS|I.SUBFIC|I.MULLI) => (arithi' {oper=oper, rt=rt, ra=ra, im=im})  
       | I.SRAWI => (srawi {rs=ra, ra=rt, sh=im})  
       | I.SRADI => (sradi {rs=ra, ra=rt, sh=im})  
       | _ => (arithi' {oper=oper, rt=ra, ra=rt, im=im})  
        )  
342     and x_form {opcd, rt, ra, rb, xo, rc} = let     and x_form {opcd, rt, ra, rb, xo, rc} = let
343            val rc = (emit_bool rc)            val rc = (emit_bool rc)
344         in (eWord32 (rc + ((xo << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((rt << 0wx15) + (opcd << 0wx1a)))))))         in (eWord32 (rc + ((xo << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((rt << 0wx15) + (opcd << 0wx1a)))))))
345         end         end
346    
347     and tw {to, ra, si} =     and Cmpl {bf, l, ra, rb} = let
        (  
         case si of  
         I.RegOp rb => (twr {to=to, ra=ra, rb=rb})  
       | _ => (twi {to=to, ra=ra, si=si})  
        )  
    and mtspr {rs, spr} = let  
           val spr = (emit_SPR spr)  
        in (mtspr' {rs=rs, spr=(((spr && 0wx1f) << 0wx5) + ((spr >> 0wx5)&& 0wx1f))})  
        end  
   
    and sradi {rs, ra, sh} = let  
           val sh = (emit_operand sh)  
        in (sradi' {rs=rs, ra=ra, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1)})  
        end  
   
    and bc {bo, bi, bd, aa, lk} = let  
           val bo = (emit_bo bo)  
           val aa = (emit_bool aa)  
           val lk = (emit_bool lk)  
        in (eWord32 (lk + ((aa << 0wx1) + (((bd && 0wx3fff) << 0wx2) + ((bi << 0wx10) + ((bo << 0wx15) + 0wx40000000))))))  
        end  
   
    and fcmp {bf, fa, fb, cmp} = let  
348            val bf = (emit_CC bf)            val bf = (emit_CC bf)
349            val fa = (emit_FP fa)            val l = (emit_bool l)
           val fb = (emit_FP fb)  
           val cmp = (emit_fcmp cmp)  
        in (eWord32 ((cmp << 0wx1) + ((fb << 0wxb) + ((fa << 0wx10) + ((bf << 0wx17) + 0wxfc000000)))))  
        end  
   
    and srawi {rs, ra, sh} = let  
           val rs = (emit_GP rs)  
350            val ra = (emit_GP ra)            val ra = (emit_GP ra)
351            val sh = (emit_operand sh)            val rb = (emit_GP rb)
352         in (eWord32 (((sh && 0wx1f) << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7c000670))))         in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx7c000040)))))
353         end         end
354    
355     and xl_form {opcd, bt, ba, bb, xo, lk} = let     and twr {to, ra, rb} = let
356            val lk = (emit_bool lk)            val to = (emit_int to)
357         in (eWord32 (lk + ((xo << 0wx1) + ((bb << 0wxb) + ((ba << 0wx10) + ((bt << 0wx15) + (opcd << 0wx1a)))))))            val ra = (emit_GP ra)
358              val rb = (emit_GP rb)
359           in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((to << 0wx15) + 0wx7c000008))))
360         end         end
361    
362     and be {li, aa, lk} = let     and ccarith {oper, bt, ba, bb} = let
363            val aa = (emit_bool aa)            val oper = (emit_ccarith oper)
364            val lk = (emit_bool lk)         in (xl_form {opcd=0wx13, bt=(cr_bit {cc=bt}), ba=(cr_bit {cc=ba}), bb=(cr_bit {cc=bb}), xo=oper, lk=false})
        in (eWord32 (lk + ((aa << 0wx1) + (((li && 0wxffffff) << 0wx2) + 0wx58000000))))  
365         end         end
366    
367     and mfspr' {rt, spr} = let     and mfspr' {rt, spr} = let
# Line 426  Line 369 
369         in (eWord32 ((spr << 0wxb) + ((rt << 0wx15) + 0wx7c0002a6)))         in (eWord32 ((spr << 0wxb) + ((rt << 0wx15) + 0wx7c0002a6)))
370         end         end
371    
372     and load {ld, rt, ra, d} =     and tdi {to, ra, si} = let
373         (            val to = (emit_int to)
374          case (d, ld) of            val ra = (emit_GP ra)
375          (I.RegOp rb, I.LBZ) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx57})            val si = (emit_operand si)
376        | (I.RegOp rb, I.LBZE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx5f})         in (eWord32 ((si && 0wxffff) + ((ra << 0wx10) + ((to << 0wx15) + 0wx8000000))))
377        | (I.RegOp rb, I.LHZ) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx117})         end
       | (I.RegOp rb, I.LHZE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx11f})  
       | (I.RegOp rb, I.LHA) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx157})  
       | (I.RegOp rb, I.LHAE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx15f})  
       | (I.RegOp rb, I.LWZ) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx17})  
       | (I.RegOp rb, I.LWZE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx1f})  
       | (I.RegOp rb, I.LDE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx31f})  
       | (d, I.LBZ) => (loadd {opcd=0wx22, rt=rt, ra=ra, d=d})  
       | (de, I.LBZE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx0})  
       | (d, I.LHZ) => (loadd {opcd=0wx28, rt=rt, ra=ra, d=d})  
       | (de, I.LHZE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx2})  
       | (d, I.LHA) => (loadd {opcd=0wx2a, rt=rt, ra=ra, d=d})  
       | (de, I.LHAE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx4})  
       | (d, I.LWZ) => (loadd {opcd=0wx20, rt=rt, ra=ra, d=d})  
       | (de, I.LWZE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx6})  
       | (de, I.LDE) => (loadde {opcd=0wx3e, rt=rt, ra=ra, de=de, xop=0wx0})  
        )  
    and cr_bit {cc} = let  
378    
379  (*#line 453.1 "ppc/ppc.md"*)     and b {li, aa, lk} = let
380            val(cr, bit) = cc            val aa = (emit_bool aa)
381         in (((emit_CC cr) << 0wx2) + (itow            val lk = (emit_bool lk)
382            (         in (eWord32 (lk + ((aa << 0wx1) + (((li && 0wxffffff) << 0wx2) + 0wx48000000))))
            case bit of  
            I.LT => 0  
          | I.GT => 1  
          | I.EQ => 2  
          | I.SO => 3  
          | I.FL => 0  
          | I.FG => 1  
          | I.FE => 2  
          | I.FU => 3  
          | I.FX => 0  
          | I.FEX => 1  
          | I.VX => 2  
          | I.OX => 3  
           )))  
383         end         end
384    
385     and fstore {st, fs, ra, d} =     and fstore {st, fs, ra, d} =
# Line 482  Line 394 
394        | (d, I.STFD) => (fstored {fs=fs, ra=ra, d=d, opcd=0wx36})        | (d, I.STFD) => (fstored {fs=fs, ra=ra, d=d, opcd=0wx36})
395        | (de, I.STFDE) => (fstorede {fs=fs, ra=ra, de=de, opcd=0wx3e, xop=0wxe})        | (de, I.STFDE) => (fstorede {fs=fs, ra=ra, de=de, opcd=0wx3e, xop=0wxe})
396         )         )
397       and rlwimi {rs, ra, sh, mb, me} = let
398              val rs = (emit_GP rs)
399              val ra = (emit_GP ra)
400              val mb = (emit_int mb)
401              val me = (emit_int me)
402           in (eWord32 ((me << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx50000000))))))
403           end
404    
405       and a_form {opcd, frt, fra, frb, frc, xo, rc} = let
406              val rc = (emit_bool rc)
407           in (eWord32 (rc + ((xo << 0wx1) + ((frc << 0wx6) + ((frb << 0wxb) + ((fra << 0wx10) + ((frt << 0wx15) + (opcd << 0wx1a))))))))
408           end
409    
410       and compare {cmp, bf, l, ra, rb} =
411           (
412            case (cmp, rb) of
413            (I.CMP, I.RegOp rb) => (Cmp {bf=bf, l=l, ra=ra, rb=rb})
414          | (I.CMPL, I.RegOp rb) => (Cmpl {bf=bf, l=l, ra=ra, rb=rb})
415          | (I.CMP, si) => (Cmpi {bf=bf, l=l, ra=ra, si=si})
416          | (I.CMPL, ui) => (Cmpli {bf=bf, l=l, ra=ra, ui=ui})
417           )
418       and mfspr {rt, spr} = let
419              val spr = (emit_SPR spr)
420           in (mfspr' {rt=rt, spr=(((spr && 0wx1f) << 0wx5) + ((spr >> 0wx5)&& 0wx1f))})
421           end
422    
423       and rldicl {rs, ra, sh, mb, sh2} = let
424              val rs = (emit_GP rs)
425              val ra = (emit_GP ra)
426              val mb = (emit_int mb)
427           in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000000))))))
428           end
429    
430       and tdr {to, ra, rb} = let
431              val to = (emit_int to)
432              val ra = (emit_GP ra)
433              val rb = (emit_GP rb)
434           in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((to << 0wx15) + 0wx7c000088))))
435           end
436    
437     and store {st, rs, ra, d} =     and store {st, rs, ra, d} =
438         (         (
439          case (d, st) of          case (d, st) of
# Line 500  Line 452 
452        | (de, I.STWE) => (storede {rs=rs, ra=ra, de=de, opcd=0wx3a, xop=0wxe})        | (de, I.STWE) => (storede {rs=rs, ra=ra, de=de, opcd=0wx3a, xop=0wxe})
453        | (de, I.STDE) => (storede {rs=rs, ra=ra, de=de, opcd=0wx3e, xop=0wx8})        | (de, I.STDE) => (storede {rs=rs, ra=ra, de=de, opcd=0wx3e, xop=0wx8})
454         )         )
455     and storede {opcd, rs, ra, de, xop} = let     and mtspr' {rs, spr} = let
456            val rs = (emit_GP rs)            val rs = (emit_GP rs)
457            val ra = (emit_GP ra)         in (eWord32 ((spr << 0wxb) + ((rs << 0wx15) + 0wx7c0003a6)))
           val de = (emit_operand de)  
        in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((rs << 0wx15) + (opcd << 0wx1a))))))  
458         end         end
459    
460     and rlwinm {rs, ra, sh, mb, me} = let     and rldic {rs, ra, sh, mb, sh2} = let
461            val rs = (emit_GP rs)            val rs = (emit_GP rs)
462            val ra = (emit_GP ra)            val ra = (emit_GP ra)
463            val mb = (emit_int mb)            val mb = (emit_int mb)
464            val me = (emit_int me)         in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000008))))))
        in (eWord32 ((me << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx54000000))))))  
465         end         end
466    
467     and fload {ld, ft, ra, d} =     and load {ld, rt, ra, d} =
468         (         (
469          case (d, ld) of          case (d, ld) of
470          (I.RegOp rb, I.LFS) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx217})          (I.RegOp rb, I.LBZ) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx57})
471        | (I.RegOp rb, I.LFSE) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx21f})        | (I.RegOp rb, I.LBZE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx5f})
472        | (I.RegOp rb, I.LFD) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx257})        | (I.RegOp rb, I.LHZ) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx117})
473        | (I.RegOp rb, I.LFDE) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx25f})        | (I.RegOp rb, I.LHZE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx11f})
474        | (d, I.LFS) => (floadd {ft=ft, ra=ra, d=d, opcd=0wx30})        | (I.RegOp rb, I.LHA) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx157})
475        | (de, I.LFSE) => (floadde {ft=ft, ra=ra, de=de, opcd=0wx3e, xop=0wx4})        | (I.RegOp rb, I.LHAE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx15f})
476        | (d, I.LFD) => (floadd {ft=ft, ra=ra, d=d, opcd=0wx32})        | (I.RegOp rb, I.LWZ) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx17})
477        | (de, I.LFDE) => (floadde {ft=ft, ra=ra, de=de, opcd=0wx3e, xop=0wx6})        | (I.RegOp rb, I.LWZE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx1f})
478          | (I.RegOp rb, I.LDE) => (loadx {rt=rt, ra=ra, rb=rb, xop=0wx31f})
479          | (d, I.LBZ) => (loadd {opcd=0wx22, rt=rt, ra=ra, d=d})
480          | (de, I.LBZE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx0})
481          | (d, I.LHZ) => (loadd {opcd=0wx28, rt=rt, ra=ra, d=d})
482          | (de, I.LHZE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx2})
483          | (d, I.LHA) => (loadd {opcd=0wx2a, rt=rt, ra=ra, d=d})
484          | (de, I.LHAE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx4})
485          | (d, I.LWZ) => (loadd {opcd=0wx20, rt=rt, ra=ra, d=d})
486          | (de, I.LWZE) => (loadde {opcd=0wx3a, rt=rt, ra=ra, de=de, xop=0wx6})
487          | (de, I.LDE) => (loadde {opcd=0wx3e, rt=rt, ra=ra, de=de, xop=0wx0})
488         )         )
489     and floadde {opcd, ft, ra, de, xop} = let     and rldicr {rs, ra, sh, mb, sh2} = let
490            val ft = (emit_FP ft)            val rs = (emit_GP rs)
491            val ra = (emit_GP ra)            val ra = (emit_GP ra)
492            val de = (emit_operand de)            val mb = (emit_int mb)
493         in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((ft << 0wx15) + (opcd << 0wx1a))))))         in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000004))))))
494           end
495    
496       and rlwnm {rs, ra, sh, mb, me} = let
497              val rs = (emit_GP rs)
498              val ra = (emit_GP ra)
499              val sh = (emit_GP sh)
500              val mb = (emit_int mb)
501              val me = (emit_int me)
502           in (eWord32 ((me << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx5c000000))))))
503           end
504    
505       and m_form {opcd, rs, ra, rb, mb, me, rc} = let
506              val rc = (emit_bool rc)
507           in (eWord32 (rc + ((me << 0wx1) + ((mb << 0wx6) + ((rb << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + (opcd << 0wx1a))))))))
508         end         end
509    
510     and fstored {opcd, fs, ra, d} = let     and fstored {opcd, fs, ra, d} = let
511            val fs = (emit_FP fs)            val fs = (emit_FP fs)
512            val ra = (emit_GP ra)            val ra = (emit_GP ra)
513            val d = (emit_operand d)            val d = (emit_operand d)
514         in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((fs << 0wx15) + (opcd << 0wx1a)))))         in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((fs << 0wx15) + (opcd << 0wx1a)))))
515           end
516    
517       and mcrf {bf, bfa} = let
518              val bf = (emit_CC bf)
519              val bfa = (emit_CC bfa)
520           in (eWord32 ((bfa << 0wx12) + ((bf << 0wx17) + 0wx4c000000)))
521           end
522    
523       and unary' {ra, rt, OE, oper, Rc} = let
524              val ra = (emit_GP ra)
525              val rt = (emit_GP rt)
526              val OE = (emit_bool OE)
527              val oper = (emit_unary oper)
528              val Rc = (emit_bool Rc)
529           in (eWord32 (Rc + ((oper << 0wx1) + ((OE << 0wxa) + ((rt << 0wx10) + ((ra << 0wx15) + 0wx7c000000))))))
530         end         end
531    
532     and rlwnm {rs, ra, sh, mb, me} = let     and rlwinm {rs, ra, sh, mb, me} = let
533            val rs = (emit_GP rs)            val rs = (emit_GP rs)
534            val ra = (emit_GP ra)            val ra = (emit_GP ra)
           val sh = (emit_GP sh)  
535            val mb = (emit_int mb)            val mb = (emit_int mb)
536            val me = (emit_int me)            val me = (emit_int me)
537         in (eWord32 ((me << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx5c000000))))))         in (eWord32 ((me << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx54000000))))))
538         end         end
539    
540     and rldicl {rs, ra, sh, mb, sh2} = let     and fstorex {fs, ra, rb, xop} = let
541            val rs = (emit_GP rs)            val fs = (emit_FP fs)
542            val ra = (emit_GP ra)            val ra = (emit_GP ra)
543            val mb = (emit_int mb)            val rb = (emit_GP rb)
544         in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000000))))))         in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((fs << 0wx15) + 0wx7c000000)))))
545         end         end
546    
547     and fstorede {opcd, fs, ra, de, xop} = let     and fstorede {opcd, fs, ra, de, xop} = let
# Line 564  Line 551 
551         in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((fs << 0wx15) + (opcd << 0wx1a))))))         in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((fs << 0wx15) + (opcd << 0wx1a))))))
552         end         end
553    
554     and mtspr' {rs, spr} = let     and floadde {opcd, ft, ra, de, xop} = let
555            val rs = (emit_GP rs)            val ft = (emit_FP ft)
556         in (eWord32 ((spr << 0wxb) + ((rs << 0wx15) + 0wx7c0003a6)))            val ra = (emit_GP ra)
557              val de = (emit_operand de)
558           in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((ft << 0wx15) + (opcd << 0wx1a))))))
559         end         end
560    
561     and farith {oper, ft, fa, fb, Rc} = let     and arithi {oper, rt, ra, im} =
562           (
563            case oper of
564            (I.ADDI|I.ADDIS|I.SUBFIC|I.MULLI) => (arithi' {oper=oper, rt=rt, ra=ra, im=im})
565          | I.SRAWI => (srawi {rs=ra, ra=rt, sh=im})
566          | I.SRADI => (sradi {rs=ra, ra=rt, sh=im})
567          | _ => (arithi' {oper=oper, rt=ra, ra=rt, im=im})
568           )
569       and farith3 {oper, ft, fa, fc, fb, Rc} = let
570              val oper = (emit_farith3 oper)
571            val ft = (emit_FP ft)            val ft = (emit_FP ft)
572            val fa = (emit_FP fa)            val fa = (emit_FP fa)
573              val fc = (emit_FP fc)
574            val fb = (emit_FP fb)            val fb = (emit_FP fb)
575         in let         in let
576    
577  (*#line 439.1 "ppc/ppc.md"*)  (*#line 448.1 "ppc/ppc.md"*)
578               val(opcd, xo) = (emit_farith oper)               val(opcd, xo) = oper
579            in            in (a_form {opcd=opcd, frt=ft, fra=fa, frb=fb, frc=fc, xo=xo, rc=Rc})
              (  
               case oper of  
               (I.FMUL|I.FMULS) => (a_form {opcd=opcd, frt=ft, fra=fa, frb=0wx0, frc=fb, xo=xo, rc=Rc})  
             | _ => (a_form {opcd=opcd, frt=ft, fra=fa, frb=fb, frc=0wx0, xo=xo, rc=Rc})  
              )  
           end  
   
        end  
   
    and arith' {rt, ra, rb, OE, oper, Rc} = let  
           val rt = (emit_GP rt)  
           val ra = (emit_GP ra)  
           val rb = (emit_GP rb)  
           val OE = (emit_bool OE)  
           val oper = (emit_arith oper)  
           val Rc = (emit_bool Rc)  
        in (eWord32 (Rc + ((oper << 0wx1) + ((OE << 0wxa) + ((rb << 0wxb) + ((ra << 0wx10) + ((rt << 0wx15) + 0wx7c000000)))))))  
        end  
   
    and rldicr {rs, ra, sh, mb, sh2} = let  
           val rs = (emit_GP rs)  
           val ra = (emit_GP ra)  
           val mb = (emit_int mb)  
        in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000004))))))  
580         end         end
581    
    and mfspr {rt, spr} = let  
           val spr = (emit_SPR spr)  
        in (mfspr' {rt=rt, spr=(((spr && 0wx1f) << 0wx5) + ((spr >> 0wx5)&& 0wx1f))})  
582         end         end
583    
584     and arith {oper, rt, ra, rb, OE, Rc} =     and bclr {bo, bi, lk} = let
        (  
         case oper of  
         (I.ADD|I.SUBF|I.MULLW|I.MULLD|I.MULHW|I.MULHWU|I.DIVW|I.DIVD|I.DIVWU|I.DIVDU) => (arith' {oper=oper, rt=rt, ra=ra, rb=rb, OE=OE, Rc=Rc})  
       | _ => (arith' {oper=oper, rt=ra, ra=rt, rb=rb, OE=OE, Rc=Rc})  
        )  
    and bcctre {bo, bi, lk} = let  
585            val bo = (emit_bo bo)            val bo = (emit_bo bo)
586            val lk = (emit_bool lk)            val lk = (emit_bool lk)
587         in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000422))))         in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000020))))
588         end         end
589    
590     and mcrf {bf, bfa} = let     and Cmpli {bf, l, ra, ui} = let
591            val bf = (emit_CC bf)            val bf = (emit_CC bf)
592            val bfa = (emit_CC bfa)            val l = (emit_bool l)
593         in (eWord32 ((bfa << 0wx12) + ((bf << 0wx17) + 0wx4c000000)))            val ra = (emit_GP ra)
594         end            val ui = (emit_operand ui)
595           in (eWord32 ((ui && 0wxffff) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx28000000)))))
    and rotatei {oper, ra, rs, sh, mb, me} = let  
           val sh = (emit_operand sh)  
        in  
           (  
            case (oper, me) of  
            (I.RLWINM, SOME me) => (rlwinm {ra=ra, rs=rs, sh=sh, mb=mb, me=me})  
          | (I.RLWIMI, SOME me) => (rlwimi {ra=ra, rs=rs, sh=sh, mb=mb, me=me})  
          | (I.RLDICL, _) => (rldicl {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})  
          | (I.RLDICR, _) => (rldicr {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})  
          | (I.RLDIC, _) => (rldic {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})  
          | (I.RLDIMI, _) => (rldimi {ra=ra, rs=rs, sh=(sh && 0wx1f), sh2=((sh >> 0wx5)&& 0wx1), mb=mb})  
           )  
596         end         end
597    
598     and rldimi {rs, ra, sh, mb, sh2} = let     and storede {opcd, rs, ra, de, xop} = let
599            val rs = (emit_GP rs)            val rs = (emit_GP rs)
600            val ra = (emit_GP ra)            val ra = (emit_GP ra)
601            val mb = (emit_int mb)            val de = (emit_operand de)
602         in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7800000c))))))         in (eWord32 (xop + (((de && 0wxfff) << 0wx4) + ((ra << 0wx10) + ((rs << 0wx15) + (opcd << 0wx1a))))))
603         end         end
604    
605     and fstorex {fs, ra, rb, xop} = let     and xl_form {opcd, bt, ba, bb, xo, lk} = let
606            val fs = (emit_FP fs)            val lk = (emit_bool lk)
607            val ra = (emit_GP ra)         in (eWord32 (lk + ((xo << 0wx1) + ((bb << 0wxb) + ((ba << 0wx10) + ((bt << 0wx15) + (opcd << 0wx1a)))))))
           val rb = (emit_GP rb)  
        in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((fs << 0wx15) + 0wx7c000000)))))  
608         end         end
609    
610     and bcctr {bo, bi, lk} = let     and floadd {opcd, ft, ra, d} = let
611            val bo = (emit_bo bo)            val ft = (emit_FP ft)
612            val lk = (emit_bool lk)            val ra = (emit_GP ra)
613         in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000420))))            val d = (emit_operand d)
614           in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((ft << 0wx15) + (opcd << 0wx1a)))))
615         end         end
616    
617       and rotate {oper, ra, rs, sh, mb, me} =
618           (
619            case (oper, me) of
620            (I.RLWNM, SOME me) => (rlwnm {ra=ra, rs=rs, sh=sh, mb=mb, me=me})
621          | (I.RLDCL, _) => (rldcl {ra=ra, rs=rs, sh=sh, mb=mb})
622          | (I.RLDCR, _) => (rldcr {ra=ra, rs=rs, sh=sh, mb=mb})
623           )
624     and Cmp {bf, l, ra, rb} = let     and Cmp {bf, l, ra, rb} = let
625            val bf = (emit_CC bf)            val bf = (emit_CC bf)
626            val l = (emit_bool l)            val l = (emit_bool l)
# Line 669  Line 629 
629         in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx7c000000)))))         in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx7c000000)))))
630         end         end
631    
632     and Cmpi {bf, l, ra, si} = let     and bcctre {bo, bi, lk} = let
633            val bf = (emit_CC bf)            val bo = (emit_bo bo)
           val l = (emit_bool l)  
           val ra = (emit_GP ra)  
           val si = (emit_operand si)  
        in (eWord32 ((si && 0wxffff) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx2c000000)))))  
        end  
   
    and b {li, aa, lk} = let  
           val aa = (emit_bool aa)  
634            val lk = (emit_bool lk)            val lk = (emit_bool lk)
635         in (eWord32 (lk + ((aa << 0wx1) + (((li && 0wxffffff) << 0wx2) + 0wx48000000))))         in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000422))))
        end  
   
    and a_form {opcd, frt, fra, frb, frc, xo, rc} = let  
           val rc = (emit_bool rc)  
        in (eWord32 (rc + ((xo << 0wx1) + ((frc << 0wx6) + ((frb << 0wxb) + ((fra << 0wx10) + ((frt << 0wx15) + (opcd << 0wx1a))))))))  
636         end         end
637    
638     and Cmpl {bf, l, ra, rb} = let     and cr_bit {cc} = let
           val bf = (emit_CC bf)  
           val l = (emit_bool l)  
           val ra = (emit_GP ra)  
           val rb = (emit_GP rb)  
        in (eWord32 ((rb << 0wxb) + ((ra << 0wx10) + ((l << 0wx15) + ((bf << 0wx17) + 0wx7c000040)))))  
        end  
639    
640     and m_form {opcd, rs, ra, rb, mb, me, rc} = let  (*#line 453.1 "ppc/ppc.md"*)
641            val rc = (emit_bool rc)            val(cr, bit) = cc
642         in (eWord32 (rc + ((me << 0wx1) + ((mb << 0wx6) + ((rb << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + (opcd << 0wx1a))))))))         in (((emit_CC cr) << 0wx2) + (itow
643              (
644               case bit of
645               I.LT => 0
646             | I.GT => 1
647             | I.EQ => 2
648             | I.SO => 3
649             | I.FL => 0
650             | I.FG => 1
651             | I.FE => 2
652             | I.FU => 3
653             | I.FX => 0
654             | I.FEX => 1
655             | I.VX => 2
656             | I.OX => 3
657              )))
658         end         end
659    
660     and bclr {bo, bi, lk} = let     and loadd {opcd, rt, ra, d} = let
661            val bo = (emit_bo bo)            val rt = (emit_GP rt)
662            val lk = (emit_bool lk)            val ra = (emit_GP ra)
663         in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000020))))            val d = (emit_operand d)
664           in (eWord32 ((d && 0wxffff) + ((ra << 0wx10) + ((rt << 0wx15) + (opcd << 0wx1a)))))
665         end         end
666    
667     and funary {oper, ft, fb, Rc} = let     and funary {oper, ft, fb, Rc} = let
# Line 720  Line 677 
677    
678         end         end
679    
680     and rldic {rs, ra, sh, mb, sh2} = let     and fload {ld, ft, ra, d} =
681           (
682            case (d, ld) of
683            (I.RegOp rb, I.LFS) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx217})
684          | (I.RegOp rb, I.LFSE) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx21f})
685          | (I.RegOp rb, I.LFD) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx257})
686          | (I.RegOp rb, I.LFDE) => (floadx {ft=ft, ra=ra, rb=rb, xop=0wx25f})
687          | (d, I.LFS) => (floadd {ft=ft, ra=ra, d=d, opcd=0wx30})
688          | (de, I.LFSE) => (floadde {ft=ft, ra=ra, de=de, opcd=0wx3e, xop=0wx4})
689          | (d, I.LFD) => (floadd {ft=ft, ra=ra, d=d, opcd=0wx32})
690          | (de, I.LFDE) => (floadde {ft=ft, ra=ra, de=de, opcd=0wx3e, xop=0wx6})
691           )
692       and arithi' {oper, rt, ra, im} = let
693              val oper = (emit_arithi oper)
694              val rt = (emit_GP rt)
695              val ra = (emit_GP ra)
696              val im = (emit_operand im)
697           in (eWord32 ((im && 0wxffff) + ((ra << 0wx10) + ((rt << 0wx15) + (oper << 0wx1a)))))
698           end
699    
700       and bclre {bo, bi, lk} = let
701              val bo = (emit_bo bo)
702              val lk = (emit_bool lk)
703           in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000022))))
704           end
705    
706       and td {to, ra, si} =
707           (
708            case si of
709            I.RegOp rb => (tdr {to=to, ra=ra, rb=rb})
710          | _ => (tdi {to=to, ra=ra, si=si})
711           )
712       and sradi' {rs, ra, sh, sh2} = let
713            val rs = (emit_GP rs)            val rs = (emit_GP rs)
714            val ra = (emit_GP ra)            val ra = (emit_GP ra)
715            val mb = (emit_int mb)         in (eWord32 ((sh2 << 0wx1) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx7c000674)))))
716         in (eWord32 ((sh2 << 0wx1) + ((mb << 0wx6) + ((sh << 0wxb) + ((ra << 0wx10) + ((rs << 0wx15) + 0wx78000008))))))         end
717    
718       and bce {bo, bi, bd, aa, lk} = let
719              val bo = (emit_bo bo)
720              val aa = (emit_bool aa)
721              val lk = (emit_bool lk)
722           in (eWord32 (lk + ((aa << 0wx1) + (((bd && 0wx3fff) << 0wx2) + ((bi << 0wx10) + ((bo << 0wx15) + 0wx40000000))))))
723           end
724    
725       and floadx {ft, ra, rb, xop} = let
726              val ft = (emit_FP ft)
727              val ra = (emit_GP ra)
728              val rb = (emit_GP rb)
729           in (eWord32 ((xop << 0wx1) + ((rb << 0wxb) + ((ra << 0wx10) + ((ft << 0wx15) + 0wx7c000000)))))
730           end
731    
732       and bcctr {bo, bi, lk} = let
733              val bo = (emit_bo bo)
734              val lk = (emit_bool lk)
735           in (eWord32 (lk + ((bi << 0wx10) + ((bo << 0wx15) + 0wx4c000420))))
736         end         end
737    
738     and unary {ra, rt, oper, OE, Rc} =     and unary {ra, rt, oper, OE, Rc} =
# Line 733  Line 741 
741          I.NEG => (unary' {ra=rt, rt=ra, oper=oper, OE=OE, Rc=Rc})          I.NEG => (unary' {ra=rt, rt=ra, oper=oper, OE=OE, Rc=Rc})
742        | _ => (unary' {ra=ra, rt=rt, oper=oper, OE=OE, Rc=Rc})        | _ => (unary' {ra=ra, rt=rt, oper=oper, OE=OE, Rc=Rc})
743         )         )
    and compare {cmp, bf, l, ra, rb} =  
        (  
         case (cmp, rb) of  
         (I.CMP, I.RegOp rb) => (Cmp {bf=bf, l=l, ra=ra, rb=rb})  
       | (I.CMPL, I.RegOp rb) => (Cmpl {bf=bf, l=l, ra=ra, rb=rb})  
       | (I.CMP, si) => (Cmpi {bf=bf, l=l, ra=ra, si=si})  
       | (I.CMPL, ui) => (Cmpli {bf=bf, l=l, ra=ra, ui=ui})  
        )  
744    
745     fun relative (I.LabelOp lexp) = ((itow ((LabelExp.valueOf lexp) - (! loc))) ~>> 0wx2)     fun relative (I.LabelOp lexp) = ((itow ((LabelExp.valueOf lexp) - (! loc))) ~>> 0wx2)
746       | relative _ = (error "relative")       | relative _ = (error "relative")
# Line 777  Line 777 
777             emitInstr             emitInstr
778         end         end
779    
780     in  S.STREAM{init=init,     in  S.STREAM{beginCluster=init,
781                  pseudoOp=pseudoOp,                  pseudoOp=pseudoOp,
782                  emit=emitter,                  emit=emitter,
783                  finish=doNothing,                  endCluster=doNothing,
784                  defineLabel=doNothing,                  defineLabel=doNothing,
785                  entryLabel=doNothing,                  entryLabel=doNothing,
786                  comment=doNothing,                  comment=doNothing,
787                  exitBlock=doNothing,                  exitBlock=doNothing,
788                  blockName=doNothing,                  blockName=doNothing,
789                  annotation=doNothing                  annotation=doNothing,
790                    phi=doNothing,
791                    alias=doNothing
792                 }                 }
793     end     end
794  end  end

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

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