Debian Codegraph @

lib/mlrisc-lib/MLRISC/alpha/emit/alphaMC.sml

raw
1 (*
2 * WARNING: This file was automatically generated by MDLGen (v3.1)
3 * from the machine description file "alpha/alpha.mdl".
4 * DO NOT EDIT this file directly
5 *)
6
7
8 functor AlphaMCEmitter(structure Instr : ALPHAINSTR
9 structure MLTreeEval : MLTREE_EVAL (* where T = Instr.T *)
10 where type T.Basis.cond = Instr.T.Basis.cond
11 and type T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode
12 and type T.Basis.ext = Instr.T.Basis.ext
13 and type T.Basis.fcond = Instr.T.Basis.fcond
14 and type T.Basis.rounding_mode = Instr.T.Basis.rounding_mode
15 and type T.Constant.const = Instr.T.Constant.const
16 and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx
17 and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx
18 and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx
19 and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx
20 and type T.I.div_rounding_mode = Instr.T.I.div_rounding_mode
21 and type T.Region.region = Instr.T.Region.region
22 and type T.ccexp = Instr.T.ccexp
23 and type T.fexp = Instr.T.fexp
24 (* and type T.labexp = Instr.T.labexp *)
25 and type T.mlrisc = Instr.T.mlrisc
26 and type T.oper = Instr.T.oper
27 and type T.rep = Instr.T.rep
28 and type T.rexp = Instr.T.rexp
29 and type T.stm = Instr.T.stm
30 structure Stream : INSTRUCTION_STREAM
31 structure CodeString : CODE_STRING
32 ) : INSTRUCTION_EMITTER =
33 struct
34 structure I = Instr
35 structure C = I.C
36 structure Constant = I.Constant
37 structure T = I.T
38 structure S = Stream
39 structure P = S.P
40 structure W = Word32
41
42 (* Alpha is little endian *)
43
44 fun error msg = MLRiscErrorMsg.error("AlphaMC",msg)
45 fun makeStream _ =
46 let infix && || << >> ~>>
47 val op << = W.<<
48 val op >> = W.>>
49 val op ~>> = W.~>>
50 val op || = W.orb
51 val op && = W.andb
52 val itow = W.fromInt
53 fun emit_bool false = 0w0 : W.word
54 | emit_bool true = 0w1 : W.word
55 val emit_int = itow
56 fun emit_word w = w
57 fun emit_label l = itow(Label.addrOf l)
58 fun emit_labexp le = itow(MLTreeEval.valueOf le)
59 fun emit_const c = itow(Constant.valueOf c)
60 val w32ToByte = Word8.fromLarge o Word32.toLarge
61 val loc = ref 0
62
63 (* emit a byte *)
64 fun eByte b =
65 let val i = !loc in loc := i + 1; CodeString.update(i,b) end
66
67 (* emit the low order byte of a word *)
68 (* note: fromLargeWord strips the high order bits! *)
69 fun eByteW w =
70 let val i = !loc
71 in loc := i + 1; CodeString.update(i, w32ToByte w) end
72
73 fun doNothing _ = ()
74 fun fail _ = raise Fail "MCEmitter"
75 fun getAnnotations () = error "getAnnotations"
76
77 fun pseudoOp pOp = P.emitValue{pOp=pOp, loc= !loc,emit=eByte}
78
79 fun init n = (CodeString.init n; loc := 0)
80
81
82 fun eWord32 w =
83 let val b8 = w
84 val w = w >> 0wx8
85 val b16 = w
86 val w = w >> 0wx8
87 val b24 = w
88 val w = w >> 0wx8
89 val b32 = w
90 in
91 ( eByteW b8;
92 eByteW b16;
93 eByteW b24;
94 eByteW b32 )
95 end
96 fun emit_GP r = itow (CellsBasis.physicalRegisterNum r)
97 and emit_FP r = itow (CellsBasis.physicalRegisterNum r)
98 and emit_CC r = itow (CellsBasis.physicalRegisterNum r)
99 and emit_MEM r = itow (CellsBasis.physicalRegisterNum r)
100 and emit_CTRL r = itow (CellsBasis.physicalRegisterNum r)
101 and emit_CELLSET r = itow (CellsBasis.physicalRegisterNum r)
102 fun emit_branch (I.BR) = (0wx30 : Word32.word)
103 | emit_branch (I.BLBC) = (0wx38 : Word32.word)
104 | emit_branch (I.BEQ) = (0wx39 : Word32.word)
105 | emit_branch (I.BLT) = (0wx3A : Word32.word)
106 | emit_branch (I.BLE) = (0wx3B : Word32.word)
107 | emit_branch (I.BLBS) = (0wx3C : Word32.word)
108 | emit_branch (I.BNE) = (0wx3D : Word32.word)
109 | emit_branch (I.BGE) = (0wx3E : Word32.word)
110 | emit_branch (I.BGT) = (0wx3F : Word32.word)
111 and emit_fbranch (I.FBEQ) = (0wx31 : Word32.word)
112 | emit_fbranch (I.FBLT) = (0wx32 : Word32.word)
113 | emit_fbranch (I.FBLE) = (0wx33 : Word32.word)
114 | emit_fbranch (I.FBNE) = (0wx35 : Word32.word)
115 | emit_fbranch (I.FBGE) = (0wx36 : Word32.word)
116 | emit_fbranch (I.FBGT) = (0wx37 : Word32.word)
117 and emit_load (I.LDB) = error "LDB"
118 | emit_load (I.LDW) = error "LDW"
119 | emit_load (I.LDBU) = (0wx2 : Word32.word)
120 | emit_load (I.LDWU) = (0wx4 : Word32.word)
121 | emit_load (I.LDL) = (0wx28 : Word32.word)
122 | emit_load (I.LDL_L) = (0wx2A : Word32.word)
123 | emit_load (I.LDQ) = (0wx29 : Word32.word)
124 | emit_load (I.LDQ_L) = (0wx2B : Word32.word)
125 | emit_load (I.LDQ_U) = (0wxB : Word32.word)
126 and emit_store (I.STB) = (0wxE : Word32.word)
127 | emit_store (I.STW) = (0wxD : Word32.word)
128 | emit_store (I.STL) = (0wx2C : Word32.word)
129 | emit_store (I.STQ) = (0wx2D : Word32.word)
130 | emit_store (I.STQ_U) = (0wxF : Word32.word)
131 and emit_fload (I.LDF) = (0wx20 : Word32.word)
132 | emit_fload (I.LDG) = (0wx21 : Word32.word)
133 | emit_fload (I.LDS) = (0wx22 : Word32.word)
134 | emit_fload (I.LDT) = (0wx23 : Word32.word)
135 and emit_fstore (I.STF) = (0wx24 : Word32.word)
136 | emit_fstore (I.STG) = (0wx25 : Word32.word)
137 | emit_fstore (I.STS) = (0wx26 : Word32.word)
138 | emit_fstore (I.STT) = (0wx27 : Word32.word)
139 and emit_operate (I.ADDL) = (0wx10, 0wx0)
140 | emit_operate (I.ADDQ) = (0wx10, 0wx20)
141 | emit_operate (I.CMPBGE) = (0wx10, 0wxF)
142 | emit_operate (I.CMPEQ) = (0wx10, 0wx2D)
143 | emit_operate (I.CMPLE) = (0wx10, 0wx6D)
144 | emit_operate (I.CMPLT) = (0wx10, 0wx4D)
145 | emit_operate (I.CMPULE) = (0wx10, 0wx3D)
146 | emit_operate (I.CMPULT) = (0wx10, 0wx1D)
147 | emit_operate (I.SUBL) = (0wx10, 0wx9)
148 | emit_operate (I.SUBQ) = (0wx10, 0wx29)
149 | emit_operate (I.S4ADDL) = (0wx10, 0wx2)
150 | emit_operate (I.S4ADDQ) = (0wx10, 0wx22)
151 | emit_operate (I.S4SUBL) = (0wx10, 0wxB)
152 | emit_operate (I.S4SUBQ) = (0wx10, 0wx2B)
153 | emit_operate (I.S8ADDL) = (0wx10, 0wx12)
154 | emit_operate (I.S8ADDQ) = (0wx10, 0wx32)
155 | emit_operate (I.S8SUBL) = (0wx10, 0wx1B)
156 | emit_operate (I.S8SUBQ) = (0wx10, 0wx3B)
157 | emit_operate (I.AND) = (0wx11, 0wx0)
158 | emit_operate (I.BIC) = (0wx11, 0wx8)
159 | emit_operate (I.BIS) = (0wx11, 0wx20)
160 | emit_operate (I.EQV) = (0wx11, 0wx48)
161 | emit_operate (I.ORNOT) = (0wx11, 0wx28)
162 | emit_operate (I.XOR) = (0wx11, 0wx40)
163 | emit_operate (I.EXTBL) = (0wx12, 0wx6)
164 | emit_operate (I.EXTLH) = (0wx12, 0wx6A)
165 | emit_operate (I.EXTLL) = (0wx12, 0wx26)
166 | emit_operate (I.EXTQH) = (0wx12, 0wx7A)
167 | emit_operate (I.EXTQL) = (0wx12, 0wx36)
168 | emit_operate (I.EXTWH) = (0wx12, 0wx5A)
169 | emit_operate (I.EXTWL) = (0wx12, 0wx16)
170 | emit_operate (I.INSBL) = (0wx12, 0wxB)
171 | emit_operate (I.INSLH) = (0wx12, 0wx67)
172 | emit_operate (I.INSLL) = (0wx12, 0wx2B)
173 | emit_operate (I.INSQH) = (0wx12, 0wx77)
174 | emit_operate (I.INSQL) = (0wx12, 0wx3B)
175 | emit_operate (I.INSWH) = (0wx12, 0wx57)
176 | emit_operate (I.INSWL) = (0wx12, 0wx1B)
177 | emit_operate (I.MSKBL) = (0wx12, 0wx2)
178 | emit_operate (I.MSKLH) = (0wx12, 0wx62)
179 | emit_operate (I.MSKLL) = (0wx12, 0wx22)
180 | emit_operate (I.MSKQH) = (0wx12, 0wx72)
181 | emit_operate (I.MSKQL) = (0wx12, 0wx32)
182 | emit_operate (I.MSKWH) = (0wx12, 0wx52)
183 | emit_operate (I.MSKWL) = (0wx12, 0wx12)
184 | emit_operate (I.SLL) = (0wx12, 0wx39)
185 | emit_operate (I.SRA) = (0wx12, 0wx3C)
186 | emit_operate (I.SRL) = (0wx12, 0wx34)
187 | emit_operate (I.ZAP) = (0wx12, 0wx30)
188 | emit_operate (I.ZAPNOT) = (0wx12, 0wx31)
189 | emit_operate (I.MULL) = (0wx13, 0wx0)
190 | emit_operate (I.MULQ) = (0wx13, 0wx20)
191 | emit_operate (I.UMULH) = (0wx13, 0wx30)
192 and emit_cmove (I.CMOVEQ) = (0wx24 : Word32.word)
193 | emit_cmove (I.CMOVLBC) = (0wx16 : Word32.word)
194 | emit_cmove (I.CMOVLBS) = (0wx14 : Word32.word)
195 | emit_cmove (I.CMOVGE) = (0wx46 : Word32.word)
196 | emit_cmove (I.CMOVGT) = (0wx66 : Word32.word)
197 | emit_cmove (I.CMOVLE) = (0wx64 : Word32.word)
198 | emit_cmove (I.CMOVLT) = (0wx44 : Word32.word)
199 | emit_cmove (I.CMOVNE) = (0wx26 : Word32.word)
200 and emit_operateV (I.ADDLV) = (0wx10, 0wx40)
201 | emit_operateV (I.ADDQV) = (0wx10, 0wx60)
202 | emit_operateV (I.SUBLV) = (0wx10, 0wx49)
203 | emit_operateV (I.SUBQV) = (0wx10, 0wx69)
204 | emit_operateV (I.MULLV) = (0wx13, 0wx40)
205 | emit_operateV (I.MULQV) = (0wx13, 0wx60)
206 and emit_funary (I.CVTLQ) = (0wx17, 0wx10)
207 | emit_funary (I.CVTQL) = (0wx17, 0wx30)
208 | emit_funary (I.CVTQLSV) = (0wx17, 0wx530)
209 | emit_funary (I.CVTQLV) = (0wx17, 0wx130)
210 | emit_funary (I.CVTQS) = (0wx16, 0wxBC)
211 | emit_funary (I.CVTQSC) = (0wx16, 0wx3C)
212 | emit_funary (I.CVTQT) = (0wx16, 0wxBE)
213 | emit_funary (I.CVTQTC) = (0wx16, 0wx3E)
214 | emit_funary (I.CVTTS) = (0wx16, 0wxAC)
215 | emit_funary (I.CVTTSC) = (0wx16, 0wx2C)
216 | emit_funary (I.CVTST) = (0wx16, 0wx2AC)
217 | emit_funary (I.CVTSTS) = (0wx16, 0wx6AC)
218 | emit_funary (I.CVTTQ) = (0wx16, 0wxAF)
219 | emit_funary (I.CVTTQC) = (0wx16, 0wx2F)
220 and emit_foperate (I.CPYS) = (0wx17, 0wx20)
221 | emit_foperate (I.CPYSE) = (0wx17, 0wx22)
222 | emit_foperate (I.CPYSN) = (0wx17, 0wx21)
223 | emit_foperate (I.MF_FPCR) = (0wx17, 0wx25)
224 | emit_foperate (I.MT_FPCR) = (0wx17, 0wx24)
225 | emit_foperate (I.CMPTEQ) = (0wx16, 0wxA5)
226 | emit_foperate (I.CMPTLT) = (0wx16, 0wxA6)
227 | emit_foperate (I.CMPTLE) = (0wx16, 0wxA7)
228 | emit_foperate (I.CMPTUN) = (0wx16, 0wxA4)
229 | emit_foperate (I.CMPTEQSU) = (0wx16, 0wx5A5)
230 | emit_foperate (I.CMPTLTSU) = (0wx16, 0wx5A6)
231 | emit_foperate (I.CMPTLESU) = (0wx16, 0wx5A7)
232 | emit_foperate (I.CMPTUNSU) = (0wx16, 0wx5A4)
233 | emit_foperate (I.ADDS) = (0wx16, 0wx80)
234 | emit_foperate (I.ADDT) = (0wx16, 0wxA0)
235 | emit_foperate (I.DIVS) = (0wx16, 0wx83)
236 | emit_foperate (I.DIVT) = (0wx16, 0wxA3)
237 | emit_foperate (I.MULS) = (0wx16, 0wx82)
238 | emit_foperate (I.MULT) = (0wx16, 0wxA2)
239 | emit_foperate (I.SUBS) = (0wx16, 0wx81)
240 | emit_foperate (I.SUBT) = (0wx16, 0wxA1)
241 and emit_fcmove (I.FCMOVEQ) = (0wx2A : Word32.word)
242 | emit_fcmove (I.FCMOVGE) = (0wx2D : Word32.word)
243 | emit_fcmove (I.FCMOVGT) = (0wx2F : Word32.word)
244 | emit_fcmove (I.FCMOVLE) = (0wx2E : Word32.word)
245 | emit_fcmove (I.FCMOVLT) = (0wx2C : Word32.word)
246 | emit_fcmove (I.FCMOVNE) = (0wx2B : Word32.word)
247 and emit_foperateV (I.ADDSSUD) = (0wx5C0 : Word32.word)
248 | emit_foperateV (I.ADDSSU) = (0wx580 : Word32.word)
249 | emit_foperateV (I.ADDTSUD) = (0wx5E0 : Word32.word)
250 | emit_foperateV (I.ADDTSU) = (0wx5A0 : Word32.word)
251 | emit_foperateV (I.DIVSSUD) = (0wx5C3 : Word32.word)
252 | emit_foperateV (I.DIVSSU) = (0wx583 : Word32.word)
253 | emit_foperateV (I.DIVTSUD) = (0wx5E3 : Word32.word)
254 | emit_foperateV (I.DIVTSU) = (0wx5A3 : Word32.word)
255 | emit_foperateV (I.MULSSUD) = (0wx5C2 : Word32.word)
256 | emit_foperateV (I.MULSSU) = (0wx582 : Word32.word)
257 | emit_foperateV (I.MULTSUD) = (0wx5E2 : Word32.word)
258 | emit_foperateV (I.MULTSU) = (0wx5A2 : Word32.word)
259 | emit_foperateV (I.SUBSSUD) = (0wx5C1 : Word32.word)
260 | emit_foperateV (I.SUBSSU) = (0wx581 : Word32.word)
261 | emit_foperateV (I.SUBTSUD) = (0wx5E1 : Word32.word)
262 | emit_foperateV (I.SUBTSU) = (0wx5A1 : Word32.word)
263 and emit_osf_user_palcode (I.BPT) = (0wx80 : Word32.word)
264 | emit_osf_user_palcode (I.BUGCHK) = (0wx81 : Word32.word)
265 | emit_osf_user_palcode (I.CALLSYS) = (0wx83 : Word32.word)
266 | emit_osf_user_palcode (I.GENTRAP) = (0wxAA : Word32.word)
267 | emit_osf_user_palcode (I.IMB) = (0wx86 : Word32.word)
268 | emit_osf_user_palcode (I.RDUNIQUE) = (0wx9E : Word32.word)
269 | emit_osf_user_palcode (I.WRUNIQUE) = (0wx9F : Word32.word)
270 fun Memory {opc, ra, rb, disp} =
271 let val rb = emit_GP rb
272 in eWord32 ((opc << 0wx1A) + ((ra << 0wx15) + ((rb << 0wx10) + (disp && 0wxFFFF))))
273 end
274 and Split {le} =
275 let
276 (*#line 428.22 "alpha/alpha.mdl"*)
277 val i = MLTreeEval.valueOf le
278
279 (*#line 429.22 "alpha/alpha.mdl"*)
280 val w = itow i
281
282 (*#line 430.22 "alpha/alpha.mdl"*)
283 val hi = w ~>> 0wx10
284
285 (*#line 431.22 "alpha/alpha.mdl"*)
286 val lo = w && 0wxFFFF
287 in (if (lo < 0wx8000)
288 then (hi, lo)
289 else (hi + 0wx1, lo - 0wx10000))
290 end
291 and High {le} =
292 let
293 (*#line 434.21 "alpha/alpha.mdl"*)
294 val (hi, _) = Split {le=le}
295 in hi
296 end
297 and Low {le} =
298 let
299 (*#line 435.21 "alpha/alpha.mdl"*)
300 val (_, lo) = Split {le=le}
301 in lo
302 end
303 and LoadStore {opc, ra, rb, disp} =
304 let
305 (*#line 437.12 "alpha/alpha.mdl"*)
306 val disp =
307 (case disp of
308 I.REGop rb => emit_GP rb
309 | I.IMMop i => itow i
310 | I.HILABop le => High {le=le}
311 | I.LOLABop le => Low {le=le}
312 | I.LABop le => itow (MLTreeEval.valueOf le)
313 )
314 in Memory {opc=opc, ra=ra, rb=rb, disp=disp}
315 end
316 and ILoadStore {opc, r, b, d} =
317 let val r = emit_GP r
318 in LoadStore {opc=opc, ra=r, rb=b, disp=d}
319 end
320 and FLoadStore {opc, r, b, d} =
321 let val r = emit_FP r
322 in LoadStore {opc=opc, ra=r, rb=b, disp=d}
323 end
324 and Jump {ra, rb, h, disp} =
325 let val ra = emit_GP ra
326 val rb = emit_GP rb
327 val disp = emit_int disp
328 in eWord32 ((ra << 0wx15) + ((rb << 0wx10) + ((h << 0wxE) + ((disp && 0wx3FFF) + 0wx68000000))))
329 end
330 and Memory_fun {opc, ra, rb, func} =
331 let val ra = emit_GP ra
332 val rb = emit_GP rb
333 in eWord32 ((opc << 0wx1A) + ((ra << 0wx15) + ((rb << 0wx10) + func)))
334 end
335 and Branch {opc, ra, disp} =
336 let val opc = emit_branch opc
337 val ra = emit_GP ra
338 in eWord32 ((opc << 0wx1A) + ((ra << 0wx15) + (disp && 0wx1FFFFF)))
339 end
340 and Bsr {ra, disp} =
341 let val ra = emit_GP ra
342 in eWord32 ((ra << 0wx15) + ((disp && 0wx1FFFFF) + 0wxD0000000))
343 end
344 and Fbranch {opc, ra, disp} =
345 let val opc = emit_fbranch opc
346 val ra = emit_FP ra
347 in eWord32 ((opc << 0wx1A) + ((ra << 0wx15) + (disp && 0wx1FFFFF)))
348 end
349 and Operate0 {opc, ra, rb, func, rc} =
350 let val ra = emit_GP ra
351 val rb = emit_GP rb
352 val rc = emit_GP rc
353 in eWord32 ((opc << 0wx1A) + ((ra << 0wx15) + ((rb << 0wx10) + ((func << 0wx5) + rc))))
354 end
355 and Operate1 {opc, ra, lit, func, rc} =
356 let val ra = emit_GP ra
357 val rc = emit_GP rc
358 in eWord32 ((opc << 0wx1A) + ((ra << 0wx15) + (((lit && 0wxFF) << 0wxD) + ((func << 0wx5) + (rc + 0wx1000)))))
359 end
360 and Operate {opc, ra, rb, func, rc} =
361 (case rb of
362 I.REGop rb => Operate0 {opc=opc, ra=ra, rb=rb, func=func, rc=rc}
363 | I.IMMop i => Operate1 {opc=opc, ra=ra, lit=itow i, func=func, rc=rc}
364 | I.HILABop le => Operate1 {opc=opc, ra=ra, lit=High {le=le}, func=func,
365 rc=rc}
366 | I.LOLABop le => Operate1 {opc=opc, ra=ra, lit=Low {le=le}, func=func,
367 rc=rc}
368 | I.LABop le => Operate1 {opc=opc, ra=ra, lit=itow (MLTreeEval.valueOf le),
369 func=func, rc=rc}
370 )
371 and Foperate {opc, fa, fb, func, fc} =
372 let val fa = emit_FP fa
373 val fb = emit_FP fb
374 val fc = emit_FP fc
375 in eWord32 ((opc << 0wx1A) + ((fa << 0wx15) + ((fb << 0wx10) + ((func << 0wx5) + fc))))
376 end
377 and Funary {opc, fb, func, fc} =
378 let val fb = emit_FP fb
379 val fc = emit_FP fc
380 in eWord32 ((opc << 0wx1A) + ((fb << 0wx10) + ((func << 0wx5) + (fc + 0wx3E00000))))
381 end
382 and Pal {func} = eWord32 func
383
384 (*#line 473.7 "alpha/alpha.mdl"*)
385 fun disp lab = (itow (((Label.addrOf lab) - ( ! loc)) - 4)) ~>> 0wx2
386
387 (*#line 474.7 "alpha/alpha.mdl"*)
388 val zeroR = Option.valOf (C.zeroReg CellsBasis.GP)
389 fun emitter instr =
390 let
391 fun emitInstr (I.LDA{r, b, d}) = ILoadStore {opc=0wx8, r=r, b=b, d=d}
392 | emitInstr (I.LDAH{r, b, d}) = ILoadStore {opc=0wx9, r=r, b=b, d=d}
393 | emitInstr (I.LOAD{ldOp, r, b, d, mem}) = ILoadStore {opc=emit_load ldOp,
394 r=r, b=b, d=d}
395 | emitInstr (I.STORE{stOp, r, b, d, mem}) = ILoadStore {opc=emit_store stOp,
396 r=r, b=b, d=d}
397 | emitInstr (I.FLOAD{ldOp, r, b, d, mem}) = FLoadStore {opc=emit_fload ldOp,
398 r=r, b=b, d=d}
399 | emitInstr (I.FSTORE{stOp, r, b, d, mem}) = FLoadStore {opc=emit_fstore stOp,
400 r=r, b=b, d=d}
401 | emitInstr (I.JMPL({r, b, d}, list)) = Jump {h=0wx0, ra=r, rb=b, disp=d}
402 | emitInstr (I.JSR{r, b, d, defs, uses, cutsTo, mem}) = Jump {h=0wx1,
403 ra=r, rb=b, disp=d}
404 | emitInstr (I.BSR{r, lab, defs, uses, cutsTo, mem}) = Bsr {ra=r, disp=disp lab}
405 | emitInstr (I.RET{r, b, d}) = Jump {h=0wx2, ra=r, rb=b, disp=d}
406 | emitInstr (I.BRANCH{b, r, lab}) = Branch {opc=b, ra=r, disp=disp lab}
407 | emitInstr (I.FBRANCH{b, f, lab}) = Fbranch {opc=b, ra=f, disp=disp lab}
408 | emitInstr (I.OPERATE{oper, ra, rb, rc}) =
409 let
410 (*#line 578.15 "alpha/alpha.mdl"*)
411 val (opc, func) = emit_operate oper
412 in Operate {opc=opc, func=func, ra=ra, rb=rb, rc=rc}
413 end
414 | emitInstr (I.OPERATEV{oper, ra, rb, rc}) =
415 let
416 (*#line 585.15 "alpha/alpha.mdl"*)
417 val (opc, func) = emit_operateV oper
418 in Operate {opc=opc, func=func, ra=ra, rb=rb, rc=rc}
419 end
420 | emitInstr (I.CMOVE{oper, ra, rb, rc}) = Operate {opc=0wx11, func=emit_cmove oper,
421 ra=ra, rb=rb, rc=rc}
422 | emitInstr (I.PSEUDOARITH{oper, ra, rb, rc, tmps}) = error "PSEUDOARITH"
423 | emitInstr (I.FUNARY{oper, fb, fc}) =
424 let
425 (*#line 603.15 "alpha/alpha.mdl"*)
426 val (opc, func) = emit_funary oper
427 in Funary {opc=opc, func=func, fb=fb, fc=fc}
428 end
429 | emitInstr (I.FOPERATE{oper, fa, fb, fc}) =
430 let
431 (*#line 611.15 "alpha/alpha.mdl"*)
432 val (opc, func) = emit_foperate oper
433 in Foperate {opc=opc, func=func, fa=fa, fb=fb, fc=fc}
434 end
435 | emitInstr (I.FOPERATEV{oper, fa, fb, fc}) = Foperate {opc=0wx16, func=emit_foperateV oper,
436 fa=fa, fb=fb, fc=fc}
437 | emitInstr (I.FCMOVE{oper, fa, fb, fc}) = Foperate {opc=0wx17, func=emit_fcmove oper,
438 fa=fa, fb=fb, fc=fc}
439 | emitInstr (I.TRAPB) = Memory_fun {opc=0wx18, ra=zeroR, rb=zeroR, func=0wx0}
440 | emitInstr (I.CALL_PAL{code, def, use}) = Pal {func=emit_osf_user_palcode code}
441 | emitInstr (I.SOURCE{}) = ()
442 | emitInstr (I.SINK{}) = ()
443 | emitInstr (I.PHI{}) = ()
444 in
445 emitInstr instr
446 end
447
448 fun emitInstruction(I.ANNOTATION{i, ...}) = emitInstruction(i)
449 | emitInstruction(I.INSTR(i)) = emitter(i)
450 | emitInstruction(I.LIVE _) = ()
451 | emitInstruction(I.KILL _) = ()
452 | emitInstruction _ = error "emitInstruction"
453
454 in S.STREAM{beginCluster=init,
455 pseudoOp=pseudoOp,
456 emit=emitInstruction,
457 endCluster=fail,
458 defineLabel=doNothing,
459 entryLabel=doNothing,
460 comment=doNothing,
461 exitBlock=doNothing,
462 annotation=doNothing,
463 getAnnotations=getAnnotations
464 }
465 end
466 end
467