Debian Codegraph @

lib/mlrisc-lib/MLRISC/hppa/emit/hppaAsm.sml

raw
1 (*
2 * WARNING: This file was automatically generated by MDLGen (v3.1)
3 * from the machine description file "hppa/hppa.mdl".
4 * DO NOT EDIT this file directly
5 *)
6
7
8 functor HppaAsmEmitter(structure S : INSTRUCTION_STREAM
9 structure Instr : HPPAINSTR (* where T = S.P.T *)
10 where type T.Basis.cond = S.P.T.Basis.cond
11 and type T.Basis.div_rounding_mode = S.P.T.Basis.div_rounding_mode
12 and type T.Basis.ext = S.P.T.Basis.ext
13 and type T.Basis.fcond = S.P.T.Basis.fcond
14 and type T.Basis.rounding_mode = S.P.T.Basis.rounding_mode
15 and type T.Constant.const = S.P.T.Constant.const
16 and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) S.P.T.Extension.ccx
17 and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) S.P.T.Extension.fx
18 and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) S.P.T.Extension.rx
19 and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) S.P.T.Extension.sx
20 and type T.I.div_rounding_mode = S.P.T.I.div_rounding_mode
21 and type T.Region.region = S.P.T.Region.region
22 and type T.ccexp = S.P.T.ccexp
23 and type T.fexp = S.P.T.fexp
24 (* and type T.labexp = S.P.T.labexp *)
25 and type T.mlrisc = S.P.T.mlrisc
26 and type T.oper = S.P.T.oper
27 and type T.rep = S.P.T.rep
28 and type T.rexp = S.P.T.rexp
29 and type T.stm = S.P.T.stm
30 structure Shuffle : HPPASHUFFLE (* where I = Instr *)
31 where type I.Constant.const = Instr.Constant.const
32 and type I.Region.region = Instr.Region.region
33 and type I.T.Basis.cond = Instr.T.Basis.cond
34 and type I.T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode
35 and type I.T.Basis.ext = Instr.T.Basis.ext
36 and type I.T.Basis.fcond = Instr.T.Basis.fcond
37 and type I.T.Basis.rounding_mode = Instr.T.Basis.rounding_mode
38 and type ('s,'r,'f,'c) I.T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx
39 and type ('s,'r,'f,'c) I.T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx
40 and type ('s,'r,'f,'c) I.T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx
41 and type ('s,'r,'f,'c) I.T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx
42 and type I.T.I.div_rounding_mode = Instr.T.I.div_rounding_mode
43 and type I.T.ccexp = Instr.T.ccexp
44 and type I.T.fexp = Instr.T.fexp
45 (* and type I.T.labexp = Instr.T.labexp *)
46 and type I.T.mlrisc = Instr.T.mlrisc
47 and type I.T.oper = Instr.T.oper
48 and type I.T.rep = Instr.T.rep
49 and type I.T.rexp = Instr.T.rexp
50 and type I.T.stm = Instr.T.stm
51 and type I.addressing_mode = Instr.addressing_mode
52 and type I.arith = Instr.arith
53 and type I.arithi = Instr.arithi
54 and type I.bcond = Instr.bcond
55 and type I.bitcond = Instr.bitcond
56 and type I.cmp = Instr.cmp
57 and type I.cmpi = Instr.cmpi
58 and type I.ea = Instr.ea
59 and type I.farith = Instr.farith
60 and type I.fcnv = Instr.fcnv
61 and type I.fcond = Instr.fcond
62 and type I.field_selector = Instr.field_selector
63 and type I.fload = Instr.fload
64 and type I.floadx = Instr.floadx
65 and type I.fmt = Instr.fmt
66 and type I.fstore = Instr.fstore
67 and type I.fstorex = Instr.fstorex
68 and type I.funary = Instr.funary
69 and type I.instr = Instr.instr
70 and type I.instruction = Instr.instruction
71 and type I.load = Instr.load
72 and type I.loadi = Instr.loadi
73 and type I.operand = Instr.operand
74 and type I.scond = Instr.scond
75 and type I.shift = Instr.shift
76 and type I.shiftv = Instr.shiftv
77 and type I.store = Instr.store
78 structure MLTreeEval : MLTREE_EVAL (* where T = Instr.T *)
79 where type T.Basis.cond = Instr.T.Basis.cond
80 and type T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode
81 and type T.Basis.ext = Instr.T.Basis.ext
82 and type T.Basis.fcond = Instr.T.Basis.fcond
83 and type T.Basis.rounding_mode = Instr.T.Basis.rounding_mode
84 and type T.Constant.const = Instr.T.Constant.const
85 and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx
86 and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx
87 and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx
88 and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx
89 and type T.I.div_rounding_mode = Instr.T.I.div_rounding_mode
90 and type T.Region.region = Instr.T.Region.region
91 and type T.ccexp = Instr.T.ccexp
92 and type T.fexp = Instr.T.fexp
93 (* and type T.labexp = Instr.T.labexp *)
94 and type T.mlrisc = Instr.T.mlrisc
95 and type T.oper = Instr.T.oper
96 and type T.rep = Instr.T.rep
97 and type T.rexp = Instr.T.rexp
98 and type T.stm = Instr.T.stm
99 ) : INSTRUCTION_EMITTER =
100 struct
101 structure I = Instr
102 structure C = I.C
103 structure T = I.T
104 structure S = S
105 structure P = S.P
106 structure Constant = I.Constant
107
108 open AsmFlags
109
110 fun error msg = MLRiscErrorMsg.error("HppaAsmEmitter",msg)
111
112 fun makeStream formatAnnotations =
113 let val stream = !AsmStream.asmOutStream
114 fun emit' s = TextIO.output(stream,s)
115 val newline = ref true
116 val tabs = ref 0
117 fun tabbing 0 = ()
118 | tabbing n = (emit' "\t"; tabbing(n-1))
119 fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s)
120 fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n"))
121 fun comma() = emit ","
122 fun tab() = tabs := 1
123 fun indent() = tabs := 2
124 fun ms n = let val s = Int.toString n
125 in if n<0 then "-"^String.substring(s,1,size s-1)
126 else s
127 end
128 fun emit_label lab = emit(P.Client.AsmPseudoOps.lexpToString(T.LABEL lab))
129 fun emit_labexp le = emit(P.Client.AsmPseudoOps.lexpToString (T.LABEXP le))
130 fun emit_const c = emit(Constant.toString c)
131 fun emit_int i = emit(ms i)
132 fun paren f = (emit "("; f(); emit ")")
133 fun defineLabel lab = emit(P.Client.AsmPseudoOps.defineLabel lab^"\n")
134 fun entryLabel lab = defineLabel lab
135 fun comment msg = (tab(); emit("/* " ^ msg ^ " */"); nl())
136 fun annotation a = comment(Annotations.toString a)
137 fun getAnnotations() = error "getAnnotations"
138 fun doNothing _ = ()
139 fun fail _ = raise Fail "AsmEmitter"
140 fun emit_region mem = comment(I.Region.toString mem)
141 val emit_region =
142 if !show_region then emit_region else doNothing
143 fun pseudoOp pOp = (emit(P.toString pOp); emit "\n")
144 fun init size = (comment("Code Size = " ^ ms size); nl())
145 val emitCellInfo = AsmFormatUtil.reginfo
146 (emit,formatAnnotations)
147 fun emitCell r = (emit(CellsBasis.toString r); emitCellInfo r)
148 fun emit_cellset(title,cellset) =
149 (nl(); comment(title^CellsBasis.CellSet.toString cellset))
150 val emit_cellset =
151 if !show_cellset then emit_cellset else doNothing
152 fun emit_defs cellset = emit_cellset("defs: ",cellset)
153 fun emit_uses cellset = emit_cellset("uses: ",cellset)
154 val emit_cutsTo =
155 if !show_cutsTo then AsmFormatUtil.emit_cutsTo emit
156 else doNothing
157 fun emitter instr =
158 let
159 fun asm_fmt (I.SGL) = "sgl"
160 | asm_fmt (I.DBL) = "dbl"
161 | asm_fmt (I.QUAD) = "quad"
162 and emit_fmt x = emit (asm_fmt x)
163 and asm_loadi (I.LDW) = "ldw"
164 | asm_loadi (I.LDH) = "ldh"
165 | asm_loadi (I.LDB) = "ldb"
166 and emit_loadi x = emit (asm_loadi x)
167 and asm_store (I.STW) = "stw"
168 | asm_store (I.STH) = "sth"
169 | asm_store (I.STB) = "stb"
170 and emit_store x = emit (asm_store x)
171 and asm_load (I.LDWX) = "ldwx"
172 | asm_load (I.LDWX_S) = "ldwx,s"
173 | asm_load (I.LDWX_M) = "ldwx,m"
174 | asm_load (I.LDWX_SM) = "ldwx,sm"
175 | asm_load (I.LDHX) = "ldhx"
176 | asm_load (I.LDHX_S) = "ldhx,s"
177 | asm_load (I.LDHX_M) = "ldhx,m"
178 | asm_load (I.LDHX_SM) = "ldhx,sm"
179 | asm_load (I.LDBX) = "ldbx"
180 | asm_load (I.LDBX_M) = "ldbx,m"
181 and emit_load x = emit (asm_load x)
182 and asm_cmp (I.COMBT) = "combt"
183 | asm_cmp (I.COMBF) = "combf"
184 and emit_cmp x = emit (asm_cmp x)
185 and asm_cmpi (I.COMIBT) = "comibt"
186 | asm_cmpi (I.COMIBF) = "comibf"
187 and emit_cmpi x = emit (asm_cmpi x)
188 and asm_arith (I.ADD) = "add"
189 | asm_arith (I.ADDL) = "addl"
190 | asm_arith (I.ADDO) = "addo"
191 | asm_arith (I.SH1ADD) = "sh1add"
192 | asm_arith (I.SH1ADDL) = "sh1addl"
193 | asm_arith (I.SH1ADDO) = "sh1addo"
194 | asm_arith (I.SH2ADD) = "sh2add"
195 | asm_arith (I.SH2ADDL) = "sh2addl"
196 | asm_arith (I.SH2ADDO) = "sh2addo"
197 | asm_arith (I.SH3ADD) = "sh3add"
198 | asm_arith (I.SH3ADDL) = "sh3addl"
199 | asm_arith (I.SH3ADDO) = "sh3addo"
200 | asm_arith (I.SUB) = "sub"
201 | asm_arith (I.SUBO) = "subo"
202 | asm_arith (I.OR) = "or"
203 | asm_arith (I.XOR) = "xor"
204 | asm_arith (I.AND) = "and"
205 | asm_arith (I.ANDCM) = "andcm"
206 and emit_arith x = emit (asm_arith x)
207 and asm_arithi (I.ADDI) = "addi"
208 | asm_arithi (I.ADDIO) = "addio"
209 | asm_arithi (I.ADDIL) = "addil"
210 | asm_arithi (I.SUBI) = "subi"
211 | asm_arithi (I.SUBIO) = "subio"
212 and emit_arithi x = emit (asm_arithi x)
213 and asm_shiftv (I.VEXTRU) = "vextru"
214 | asm_shiftv (I.VEXTRS) = "vextrs"
215 | asm_shiftv (I.ZVDEP) = "zvdep"
216 and emit_shiftv x = emit (asm_shiftv x)
217 and asm_shift (I.EXTRU) = "extru"
218 | asm_shift (I.EXTRS) = "extrs"
219 | asm_shift (I.ZDEP) = "zdep"
220 and emit_shift x = emit (asm_shift x)
221 and asm_farith (I.FADD_S) = "fadd,sgl"
222 | asm_farith (I.FADD_D) = "fadd,dbl"
223 | asm_farith (I.FADD_Q) = "fadd,quad"
224 | asm_farith (I.FSUB_S) = "fsub,sgl"
225 | asm_farith (I.FSUB_D) = "fsub,dbl"
226 | asm_farith (I.FSUB_Q) = "fsub,quad"
227 | asm_farith (I.FMPY_S) = "fmpy,sgl"
228 | asm_farith (I.FMPY_D) = "fmpy,dbl"
229 | asm_farith (I.FMPY_Q) = "fmpy,quad"
230 | asm_farith (I.FDIV_S) = "fdiv,sgl"
231 | asm_farith (I.FDIV_D) = "fdiv,dbl"
232 | asm_farith (I.FDIV_Q) = "fdiv,quad"
233 | asm_farith (I.XMPYU) = "xmpyu"
234 and emit_farith x = emit (asm_farith x)
235 and asm_funary (I.FCPY_S) = "fcpy,sgl"
236 | asm_funary (I.FCPY_D) = "fcpy,dbl"
237 | asm_funary (I.FCPY_Q) = "fcpy,quad"
238 | asm_funary (I.FABS_S) = "fabs,sgl"
239 | asm_funary (I.FABS_D) = "fabs,dbl"
240 | asm_funary (I.FABS_Q) = "fabs,quad"
241 | asm_funary (I.FSQRT_S) = "fsqrt,sgl"
242 | asm_funary (I.FSQRT_D) = "fsqrt,dbl"
243 | asm_funary (I.FSQRT_Q) = "fsqrt,quad"
244 | asm_funary (I.FRND_S) = "frnd,sgl"
245 | asm_funary (I.FRND_D) = "frnd,dbl"
246 | asm_funary (I.FRND_Q) = "frnd,quad"
247 and emit_funary x = emit (asm_funary x)
248 and asm_fcnv (I.FCNVFF_SD) = "fcnvff,sgl,dbl"
249 | asm_fcnv (I.FCNVFF_SQ) = "fcnvff,sgl,quad"
250 | asm_fcnv (I.FCNVFF_DS) = "fcnvff,dbl,sgl"
251 | asm_fcnv (I.FCNVFF_DQ) = "fcnvff,dbl,quad"
252 | asm_fcnv (I.FCNVFF_QS) = "fcnvff,quad,sgl"
253 | asm_fcnv (I.FCNVFF_QD) = "fcnvff,quad,dbl"
254 | asm_fcnv (I.FCNVXF_S) = "fcnvxf,,sgl"
255 | asm_fcnv (I.FCNVXF_D) = "fcnvxf,,dbl"
256 | asm_fcnv (I.FCNVXF_Q) = "fcnvxf,,quad"
257 | asm_fcnv (I.FCNVFX_S) = "fcnvfx,sgl,"
258 | asm_fcnv (I.FCNVFX_D) = "fcnvfx,dbl,"
259 | asm_fcnv (I.FCNVFX_Q) = "fcnvfx,quad,"
260 | asm_fcnv (I.FCNVFXT_S) = "fcnvfxt,sgl,"
261 | asm_fcnv (I.FCNVFXT_D) = "fcnvfxt,dbl,"
262 | asm_fcnv (I.FCNVFXT_Q) = "fcnvfxt,quad,"
263 and emit_fcnv x = emit (asm_fcnv x)
264 and asm_fstore (I.FSTDS) = "fstds"
265 | asm_fstore (I.FSTWS) = "fstws"
266 and emit_fstore x = emit (asm_fstore x)
267 and asm_fstorex (I.FSTDX) = "fstdx"
268 | asm_fstorex (I.FSTDX_S) = "fstdx,s"
269 | asm_fstorex (I.FSTDX_M) = "fstdx,m"
270 | asm_fstorex (I.FSTDX_SM) = "fstdx,sm"
271 | asm_fstorex (I.FSTWX) = "fstwx"
272 | asm_fstorex (I.FSTWX_S) = "fstwx,s"
273 | asm_fstorex (I.FSTWX_M) = "fstwx,m"
274 | asm_fstorex (I.FSTWX_SM) = "fstwx,sm"
275 and emit_fstorex x = emit (asm_fstorex x)
276 and asm_floadx (I.FLDDX) = "flddx"
277 | asm_floadx (I.FLDDX_S) = "flddx,s"
278 | asm_floadx (I.FLDDX_M) = "flddx,m"
279 | asm_floadx (I.FLDDX_SM) = "flddx,sm"
280 | asm_floadx (I.FLDWX) = "fldwx"
281 | asm_floadx (I.FLDWX_S) = "fldwx,s"
282 | asm_floadx (I.FLDWX_M) = "fldwx,m"
283 | asm_floadx (I.FLDWX_SM) = "fldwx,sm"
284 and emit_floadx x = emit (asm_floadx x)
285 and asm_fload (I.FLDDS) = "fldds"
286 | asm_fload (I.FLDWS) = "fldws"
287 and emit_fload x = emit (asm_fload x)
288 and asm_bcond (I.EQ) = "="
289 | asm_bcond (I.LT) = "<"
290 | asm_bcond (I.LE) = "<="
291 | asm_bcond (I.LTU) = "<<"
292 | asm_bcond (I.LEU) = "<<="
293 | asm_bcond (I.NE) = "<>"
294 | asm_bcond (I.GE) = ">="
295 | asm_bcond (I.GT) = ">"
296 | asm_bcond (I.GTU) = ">>"
297 | asm_bcond (I.GEU) = ">>="
298 and emit_bcond x = emit (asm_bcond x)
299 and asm_bitcond (I.BSET) = "<"
300 | asm_bitcond (I.BCLR) = ">="
301 and emit_bitcond x = emit (asm_bitcond x)
302 and asm_fcond (I.False_) = "false?"
303 | asm_fcond (I.False) = "false"
304 | asm_fcond (I.?) = "?"
305 | asm_fcond (I.!<=>) = "!<=>"
306 | asm_fcond (I.==) = "=="
307 | asm_fcond (I.EQT) = "=t"
308 | asm_fcond (I.?=) = "?="
309 | asm_fcond (I.!<>) = "!<>"
310 | asm_fcond (I.!?>=) = "!?>="
311 | asm_fcond (I.<) = "<"
312 | asm_fcond (I.?<) = "?<"
313 | asm_fcond (I.!>=) = "!>="
314 | asm_fcond (I.!?>) = "!?>"
315 | asm_fcond (I.<=) = "<="
316 | asm_fcond (I.?<=) = "?<="
317 | asm_fcond (I.!>) = "!>"
318 | asm_fcond (I.!?<=) = "!?<="
319 | asm_fcond (I.>) = ">"
320 | asm_fcond (I.?>) = "?>"
321 | asm_fcond (I.!<=) = "!<="
322 | asm_fcond (I.!?<) = "!?<"
323 | asm_fcond (I.>=) = ">="
324 | asm_fcond (I.?>=) = "?>="
325 | asm_fcond (I.!<) = "!<"
326 | asm_fcond (I.!?=) = "!?="
327 | asm_fcond (I.<>) = "<>"
328 | asm_fcond (I.!=) = "!="
329 | asm_fcond (I.NET) = "!=t"
330 | asm_fcond (I.!?) = "!?"
331 | asm_fcond (I.<=>) = "<=>"
332 | asm_fcond (I.True_) = "true?"
333 | asm_fcond (I.True) = "true"
334 and emit_fcond x = emit (asm_fcond x)
335 and emit_operand (I.REG GP) = emit "reg"
336 | emit_operand (I.IMMED int) = emit_int int
337 | emit_operand (I.LabExp(labexp, field_selector)) = emit_labexp labexp
338 | emit_operand (I.HILabExp(labexp, field_selector)) = emit_labexp labexp
339 | emit_operand (I.LOLabExp(labexp, field_selector)) = emit_labexp labexp
340
341 (*#line 647.7 "hppa/hppa.mdl"*)
342 fun emit_n false = ()
343 | emit_n true = emit ",n"
344
345 (*#line 648.7 "hppa/hppa.mdl"*)
346 fun emit_nop false = ()
347 | emit_nop true = emit "\n\tnop"
348 fun emitInstr' instr =
349 (case instr of
350 I.LOADI{li, r, i, t, mem} =>
351 ( emit_loadi li;
352 emit "\t";
353 emit_operand i;
354 emit "(";
355 emitCell r;
356 emit "), ";
357 emitCell t;
358 emit_region mem )
359 | I.LOAD{l, r1, r2, t, mem} =>
360 ( emit_load l;
361 emit "\t";
362 emitCell r2;
363 emit "(";
364 emitCell r1;
365 emit "), ";
366 emitCell t;
367 emit_region mem )
368 | I.STORE{st, b, d, r, mem} =>
369 ( emit_store st;
370 emit "\t";
371 emitCell r;
372 emit ", ";
373 emit_operand d;
374 emit "(";
375 emitCell b;
376 emit ")";
377 emit_region mem )
378 | I.ARITH{a, r1, r2, t} =>
379 ( emit_arith a;
380 emit "\t";
381 emitCell r1;
382 emit ", ";
383 emitCell r2;
384 emit ", ";
385 emitCell t )
386 | I.ARITHI{ai, i, r, t} =>
387 ( emit_arithi ai;
388 emit "\t";
389 emit_operand i;
390 emit ", ";
391 emitCell r;
392 emit ", ";
393 emitCell t )
394 | I.COMCLR_LDO{cc, r1, r2, t1, i, b, t2} =>
395 (
396 ( emit "comclr,";
397 emit_bcond cc;
398 emit "\t";
399 emitCell r1;
400 emit ", ";
401 emitCell r2;
402 emit ", ";
403 emitCell t1;
404 emit "\n\t" );
405
406 ( emit "ldo\t";
407 emit_int i;
408 emit "(";
409 emitCell b;
410 emit "), ";
411 emitCell t2 ) )
412 | I.COMICLR_LDO{cc, i1, r2, t1, i2, b, t2} =>
413 (
414 ( emit "comiclr,";
415 emit_bcond cc;
416 emit "\t";
417 emitCell r2;
418 emit ", ";
419 emit_operand i1;
420 emit ", ";
421 emitCell t1;
422 emit "\n\t" );
423
424 ( emit "ldo\t";
425 emit_int i2;
426 emit "(";
427 emitCell b;
428 emit "), ";
429 emitCell t2 ) )
430 | I.SHIFTV{sv, r, len, t} =>
431 ( emit_shiftv sv;
432 emit "\t";
433 emitCell r;
434 emit ", ";
435 emit_int len;
436 emit ", ";
437 emitCell t )
438 | I.SHIFT{s, r, p, len, t} =>
439 ( emit_shift s;
440 emit "\t";
441 emitCell r;
442 emit ", ";
443 emit_int p;
444 emit ", ";
445 emit_int len;
446 emit ", ";
447 emitCell t )
448 | I.BCOND{cmp, bc, r1, r2, n, nop, t, f} =>
449 ( emit_cmp cmp;
450 emit ",";
451 emit_bcond bc;
452 emit_n n;
453 emit "\t";
454 emitCell r1;
455 emit ", ";
456 emitCell r2;
457 emit ", ";
458 emit_label t;
459 emit_nop nop )
460 | I.BCONDI{cmpi, bc, i, r2, n, nop, t, f} =>
461 ( emit_cmpi cmpi;
462 emit ",";
463 emit_bcond bc;
464 emit_n n;
465 emit "\t";
466 emit_int i;
467 emit ", ";
468 emitCell r2;
469 emit ", ";
470 emit_label t;
471 emit_nop nop )
472 | I.BB{bc, r, p, n, nop, t, f} =>
473 ( emit "bb,";
474 emit_bitcond bc;
475 emit_n n;
476 emit "\t";
477 emitCell r;
478 emit ", ";
479 emit_int p;
480 emit ", ";
481 emit_label t;
482 emit_nop nop )
483 | I.B{lab, n} =>
484 ( emit "b";
485 emit_n n;
486 emit "\t";
487 emit_label lab )
488 | I.LONGJUMP{lab, n, tmp, tmpLab} =>
489 (
490 ( emit "bl,n\t";
491 emit_label tmpLab;
492 emit ", ";
493 emitCell tmp;
494 emit "\n" );
495
496 ( emit_label tmpLab;
497 emit ":\n\t" );
498
499 ( emit "addil ";
500 emit_label lab;
501 emit "-(";
502 emit_label tmpLab;
503 emit "+4), ";
504 emitCell tmp;
505 emit "\n\t" );
506
507 ( emit "bv";
508 emit_n n;
509 emit "\t%r0(";
510 emitCell tmp;
511 emit ")" ) )
512 | I.BE{b, d, sr, n, labs} =>
513 ( emit "be";
514 emit_n n;
515 emit "\t";
516 emit_operand d;
517 emit "(";
518 emit_int sr;
519 emit ",";
520 emitCell b;
521 emit ")" )
522 | I.BV{x, b, labs, n} =>
523 ( emit "bv";
524 emit_n n;
525 emit "\t";
526 emitCell x;
527 emit "(";
528 emitCell b;
529 emit ")" )
530 | I.BLR{x, t, labs, n} =>
531 ( emit "blr";
532 emit_n n;
533 emit "\t";
534 emitCell x;
535 emit "(";
536 emitCell t;
537 emit ")" )
538 | I.BL{lab, t, defs, uses, cutsTo, mem, n} =>
539 ( emit "bl";
540 emit_n n;
541 emit "\t";
542 emit_label lab;
543 emit ", ";
544 emitCell t;
545 emit_region mem;
546 emit_defs defs;
547 emit_uses uses;
548 emit_cutsTo cutsTo )
549 | I.BLE{d, b, sr, t, defs, uses, cutsTo, mem} =>
550 ( emit "ble\t";
551 emit_operand d;
552 emit "(";
553 emit_int sr;
554 emit ",";
555 emitCell b;
556 emit ")";
557 emit_region mem;
558 emit_defs defs;
559 emit_uses uses;
560 emit_cutsTo cutsTo )
561 | I.LDIL{i, t} =>
562 ( emit "ldil\t";
563 emit_operand i;
564 emit ", ";
565 emitCell t )
566 | I.LDO{i, b, t} =>
567 ( emit "ldo\t";
568 emit_operand i;
569 emit "(";
570 emitCell b;
571 emit "), ";
572 emitCell t )
573 | I.MTCTL{r, t} =>
574 ( emit "mtctl\t";
575 emitCell r;
576 emit ", ";
577 emitCell t )
578 | I.FSTORE{fst, b, d, r, mem} =>
579 ( emit_fstore fst;
580 emit "\t";
581 emitCell r;
582 emit ", ";
583 emit_int d;
584 emit "(";
585 emitCell b;
586 emit ")";
587 emit_region mem )
588 | I.FSTOREX{fstx, b, x, r, mem} =>
589 ( emit_fstorex fstx;
590 emit "\t";
591 emitCell r;
592 emit ", ";
593 emitCell x;
594 emit "(";
595 emitCell b;
596 emit ")";
597 emit_region mem )
598 | I.FLOAD{fl, b, d, t, mem} =>
599 ( emit_fload fl;
600 emit "\t";
601 emit_int d;
602 emit "(";
603 emitCell b;
604 emit "), ";
605 emitCell t;
606 emit_region mem )
607 | I.FLOADX{flx, b, x, t, mem} =>
608 ( emit_floadx flx;
609 emit "\t";
610 emitCell x;
611 emit "(";
612 emitCell b;
613 emit "), ";
614 emitCell t;
615 emit_region mem )
616 | I.FARITH{fa, r1, r2, t} =>
617 ( emit_farith fa;
618 emit "\t";
619 emitCell r1;
620 emit ", ";
621 emitCell r2;
622 emit ", ";
623 emitCell t )
624 | I.FUNARY{fu, f, t} =>
625 ( emit_funary fu;
626 emit "\t";
627 emitCell f;
628 emit ", ";
629 emitCell t )
630 | I.FCNV{fcnv, f, t} =>
631 ( emit_fcnv fcnv;
632 emit "\t";
633 emitCell f;
634 emit ", ";
635 emitCell t )
636 | I.FBRANCH{cc, fmt, f1, f2, t, f, n, long} =>
637 (
638 ( emit "fcmp,";
639 emit_fmt fmt;
640 emit ",";
641 emit_fcond cc;
642 emit "\t";
643 emitCell f1;
644 emit ", ";
645 emitCell f2;
646 emit "\n\t" );
647 emit "ftest\n\t";
648
649 ( emit "b";
650 emit_n n;
651 emit "\t";
652 emit_label t ) )
653 | I.BREAK{code1, code2} =>
654 ( emit "break\t";
655 emit_int code1;
656 emit ", ";
657 emit_int code2 )
658 | I.NOP => emit "nop"
659 | I.SOURCE{} => emit "source"
660 | I.SINK{} => emit "sink"
661 | I.PHI{} => emit "phi"
662 )
663 in tab(); emitInstr' instr; nl()
664 end (* emitter *)
665 and emitInstrIndented i = (indent(); emitInstr i; nl())
666 and emitInstrs instrs =
667 app (if !indent_copies then emitInstrIndented
668 else emitInstr) instrs
669
670 and emitInstr(I.ANNOTATION{i,a}) =
671 ( comment(Annotations.toString a);
672 nl();
673 emitInstr i )
674 | emitInstr(I.LIVE{regs, spilled}) =
675 comment("live= " ^ CellsBasis.CellSet.toString regs ^
676 "spilled= " ^ CellsBasis.CellSet.toString spilled)
677 | emitInstr(I.KILL{regs, spilled}) =
678 comment("killed:: " ^ CellsBasis.CellSet.toString regs ^
679 "spilled:: " ^ CellsBasis.CellSet.toString spilled)
680 | emitInstr(I.INSTR i) = emitter i
681 | emitInstr(I.COPY{k=CellsBasis.GP, sz, src, dst, tmp}) =
682 emitInstrs(Shuffle.shuffle{tmp=tmp, src=src, dst=dst})
683 | emitInstr(I.COPY{k=CellsBasis.FP, sz, src, dst, tmp}) =
684 emitInstrs(Shuffle.shufflefp{tmp=tmp, src=src, dst=dst})
685 | emitInstr _ = error "emitInstr"
686
687 in S.STREAM{beginCluster=init,
688 pseudoOp=pseudoOp,
689 emit=emitInstr,
690 endCluster=fail,
691 defineLabel=defineLabel,
692 entryLabel=entryLabel,
693 comment=comment,
694 exitBlock=doNothing,
695 annotation=annotation,
696 getAnnotations=getAnnotations
697 }
698 end
699 end
700