Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/x86/emit/x86Asm.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/x86/emit/x86Asm.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

1 : monnier 411 (*
2 : george 545 * This file was automatically generated by MDGen (v2.0)
3 : monnier 411 * from the machine description file "x86/x86.md".
4 : monnier 247 *)
5 :    
6 :    
7 : monnier 411 functor X86AsmEmitter(structure Instr : X86INSTR
8 :     structure Stream : INSTRUCTION_STREAM
9 :     structure Shuffle : X86SHUFFLE
10 :     where I = Instr
11 :    
12 : leunga 646 (*#line 242.7 "x86/x86.md"*)
13 : monnier 411 structure MemRegs : MEMORY_REGISTERS where I=Instr
14 :     ) : INSTRUCTION_EMITTER =
15 : monnier 247 struct
16 : monnier 411 structure I = Instr
17 :     structure C = I.C
18 :     structure S = Stream
19 :     structure P = S.P
20 : george 545 structure LabelExp = I.LabelExp
21 : monnier 411 structure Constant = I.Constant
22 :    
23 : monnier 498 val show_cellset = MLRiscControl.getFlag "asm-show-cellset"
24 : george 545 val show_region = MLRiscControl.getFlag "asm-show-region"
25 : leunga 594 val indent_copies = MLRiscControl.getFlag "asm-indent-copies"
26 : monnier 498
27 : george 545 fun error msg = MLRiscErrorMsg.error("X86AsmEmitter",msg)
28 : monnier 411
29 : monnier 429 fun makeStream formatAnnotations =
30 : monnier 411 let val stream = !AsmStream.asmOutStream
31 : monnier 429 fun emit' s = TextIO.output(stream,s)
32 :     val newline = ref true
33 :     val tabs = ref 0
34 :     fun tabbing 0 = ()
35 :     | tabbing n = (emit' "\t"; tabbing(n-1))
36 :     fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s)
37 :     fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n"))
38 : monnier 411 fun comma() = emit ","
39 : leunga 594 fun tab() = tabs := 1
40 :     fun indent() = tabs := 2
41 : monnier 429 fun ms n = let val s = Int.toString n
42 :     in if n<0 then "-"^String.substring(s,1,size s-1)
43 :     else s
44 :     end
45 : monnier 411 fun emit_label lab = emit(Label.nameOf lab)
46 :     fun emit_labexp le = emit(LabelExp.toString le)
47 :     fun emit_const c = emit(Constant.toString c)
48 :     fun emit_int i = emit(ms i)
49 :     fun paren f = (emit "("; f(); emit ")")
50 :     fun defineLabel lab = emit(Label.nameOf lab^":\n")
51 :     fun entryLabel lab = defineLabel lab
52 : leunga 624 fun comment msg = (tab(); emit("/* " ^ msg ^ " */"))
53 : monnier 411 fun annotation a = (comment(Annotations.toString a); nl())
54 : george 545 fun doNothing _ = ()
55 : monnier 411 fun emit_region mem = comment(I.Region.toString mem)
56 : george 545 val emit_region =
57 :     if !show_region then emit_region else doNothing
58 : monnier 411 fun pseudoOp pOp = emit(P.toString pOp)
59 :     fun init size = (comment("Code Size = " ^ ms size); nl())
60 :     fun emitter regmap =
61 :     let
62 : george 545 val emitRegInfo = AsmFormatUtil.reginfo
63 :     (emit,regmap,formatAnnotations)
64 :     fun emit_GP r =
65 :     ( emit (C.showGP (regmap r));
66 :     emitRegInfo r )
67 : monnier 429 and emit_FP r =
68 : george 545 ( emit (C.showFP (regmap r));
69 :     emitRegInfo r )
70 :     and emit_CC r =
71 :     ( emit (C.showCC (regmap r));
72 :     emitRegInfo r )
73 :     and emit_MEM r =
74 :     ( emit (C.showMEM (regmap r));
75 :     emitRegInfo r )
76 :     and emit_CTRL r =
77 :     ( emit (C.showCTRL (regmap r));
78 :     emitRegInfo r )
79 : monnier 498
80 :     fun emit_cellset(title,cellset) =
81 :     (nl(); comment(title^C.cellsetToString' regmap cellset))
82 : george 545 val emit_cellset =
83 :     if !show_cellset then emit_cellset else doNothing
84 : monnier 498 fun emit_defs cellset = emit_cellset("defs: ",cellset)
85 :     fun emit_uses cellset = emit_cellset("uses: ",cellset)
86 : george 545 fun asm_cond (I.EQ) = "e"
87 :     | asm_cond (I.NE) = "ne"
88 :     | asm_cond (I.LT) = "l"
89 :     | asm_cond (I.LE) = "le"
90 :     | asm_cond (I.GT) = "g"
91 :     | asm_cond (I.GE) = "ge"
92 :     | asm_cond (I.B) = "b"
93 :     | asm_cond (I.BE) = "be"
94 :     | asm_cond (I.A) = "a"
95 :     | asm_cond (I.AE) = "ae"
96 :     | asm_cond (I.C) = "c"
97 :     | asm_cond (I.NC) = "nc"
98 :     | asm_cond (I.P) = "p"
99 :     | asm_cond (I.NP) = "np"
100 :     | asm_cond (I.O) = "o"
101 :     | asm_cond (I.NO) = "no"
102 :     and emit_cond x = emit (asm_cond x)
103 :     and asm_binaryOp (I.ADDL) = "addl"
104 :     | asm_binaryOp (I.SUBL) = "subl"
105 :     | asm_binaryOp (I.ANDL) = "andl"
106 :     | asm_binaryOp (I.ORL) = "orl"
107 :     | asm_binaryOp (I.XORL) = "xorl"
108 :     | asm_binaryOp (I.SHLL) = "shll"
109 :     | asm_binaryOp (I.SARL) = "sarl"
110 :     | asm_binaryOp (I.SHRL) = "shrl"
111 :     | asm_binaryOp (I.ADCL) = "adcl"
112 :     | asm_binaryOp (I.SBBL) = "sbbl"
113 :     | asm_binaryOp (I.ADDW) = "addw"
114 :     | asm_binaryOp (I.SUBW) = "subw"
115 :     | asm_binaryOp (I.ANDW) = "andw"
116 :     | asm_binaryOp (I.ORW) = "orw"
117 :     | asm_binaryOp (I.XORW) = "xorw"
118 :     | asm_binaryOp (I.SHLW) = "shlw"
119 :     | asm_binaryOp (I.SARW) = "sarw"
120 :     | asm_binaryOp (I.SHRW) = "shrw"
121 :     | asm_binaryOp (I.ADDB) = "addb"
122 :     | asm_binaryOp (I.SUBB) = "subb"
123 :     | asm_binaryOp (I.ANDB) = "andb"
124 :     | asm_binaryOp (I.ORB) = "orb"
125 :     | asm_binaryOp (I.XORB) = "xorb"
126 :     | asm_binaryOp (I.SHLB) = "shlb"
127 :     | asm_binaryOp (I.SARB) = "sarb"
128 :     | asm_binaryOp (I.SHRB) = "shrb"
129 : leunga 646 | asm_binaryOp (I.BTSW) = "btsw"
130 :     | asm_binaryOp (I.BTCW) = "btcw"
131 :     | asm_binaryOp (I.BTRW) = "btrw"
132 :     | asm_binaryOp (I.BTSL) = "btsl"
133 :     | asm_binaryOp (I.BTCL) = "btcl"
134 :     | asm_binaryOp (I.BTRL) = "btrl"
135 :     | asm_binaryOp (I.ROLW) = "rolw"
136 :     | asm_binaryOp (I.RORW) = "rorw"
137 :     | asm_binaryOp (I.ROLL) = "roll"
138 :     | asm_binaryOp (I.RORL) = "rorl"
139 :     | asm_binaryOp (I.XCHGB) = "xchgb"
140 :     | asm_binaryOp (I.XCHGW) = "xchgw"
141 :     | asm_binaryOp (I.XCHGL) = "xchgl"
142 :     | asm_binaryOp (I.LOCK_ADCW) = "lock\n\tadcw"
143 :     | asm_binaryOp (I.LOCK_ADCL) = "lock\n\tadcl"
144 :     | asm_binaryOp (I.LOCK_ADDW) = "lock\n\taddw"
145 :     | asm_binaryOp (I.LOCK_ADDL) = "lock\n\taddl"
146 :     | asm_binaryOp (I.LOCK_ANBW) = "lock\n\tanbw"
147 :     | asm_binaryOp (I.LOCK_ANBL) = "lock\n\tanbl"
148 :     | asm_binaryOp (I.LOCK_ANDW) = "lock\n\tandw"
149 :     | asm_binaryOp (I.LOCK_ANDL) = "lock\n\tandl"
150 :     | asm_binaryOp (I.LOCK_BTSW) = "lock\n\tbtsw"
151 :     | asm_binaryOp (I.LOCK_BTSL) = "lock\n\tbtsl"
152 :     | asm_binaryOp (I.LOCK_BTRW) = "lock\n\tbtrw"
153 :     | asm_binaryOp (I.LOCK_BTRL) = "lock\n\tbtrl"
154 :     | asm_binaryOp (I.LOCK_BTCW) = "lock\n\tbtcw"
155 :     | asm_binaryOp (I.LOCK_BTCL) = "lock\n\tbtcl"
156 :     | asm_binaryOp (I.LOCK_ORW) = "lock\n\torw"
157 :     | asm_binaryOp (I.LOCK_ORL) = "lock\n\torl"
158 :     | asm_binaryOp (I.LOCK_SBBW) = "lock\n\tsbbw"
159 :     | asm_binaryOp (I.LOCK_SBBL) = "lock\n\tsbbl"
160 :     | asm_binaryOp (I.LOCK_SUBW) = "lock\n\tsubw"
161 :     | asm_binaryOp (I.LOCK_SUBL) = "lock\n\tsubl"
162 :     | asm_binaryOp (I.LOCK_XORW) = "lock\n\txorw"
163 :     | asm_binaryOp (I.LOCK_XORL) = "lock\n\txorl"
164 :     | asm_binaryOp (I.LOCK_XCHGB) = "lock\n\txchgb"
165 :     | asm_binaryOp (I.LOCK_XCHGW) = "lock\n\txchgw"
166 :     | asm_binaryOp (I.LOCK_XCHGL) = "lock\n\txchgl"
167 : george 545 and emit_binaryOp x = emit (asm_binaryOp x)
168 : leunga 606 and asm_multDivOp (I.MULL) = "mull"
169 :     | asm_multDivOp (I.IDIVL) = "idivl"
170 :     | asm_multDivOp (I.DIVL) = "divl"
171 : george 545 and emit_multDivOp x = emit (asm_multDivOp x)
172 :     and asm_unaryOp (I.DECL) = "decl"
173 :     | asm_unaryOp (I.INCL) = "incl"
174 :     | asm_unaryOp (I.NEGL) = "negl"
175 :     | asm_unaryOp (I.NOTL) = "notl"
176 :     | asm_unaryOp (I.NOTW) = "notw"
177 :     | asm_unaryOp (I.NOTB) = "notb"
178 : leunga 646 | asm_unaryOp (I.LOCK_DECL) = "lock\n\tdecl"
179 :     | asm_unaryOp (I.LOCK_INCL) = "lock\n\tincl"
180 :     | asm_unaryOp (I.LOCK_NEGL) = "lock\n\tnegl"
181 :     | asm_unaryOp (I.LOCK_NOTL) = "lock\n\tnotl"
182 : george 545 and emit_unaryOp x = emit (asm_unaryOp x)
183 : leunga 646 and asm_bitOp (I.BTW) = "btw"
184 :     | asm_bitOp (I.BTL) = "btl"
185 :     | asm_bitOp (I.LOCK_BTW) = "lock\n\tbtw"
186 :     | asm_bitOp (I.LOCK_BTL) = "lock\n\tbtl"
187 :     and emit_bitOp x = emit (asm_bitOp x)
188 : george 545 and asm_move (I.MOVL) = "movl"
189 :     | asm_move (I.MOVB) = "movb"
190 :     | asm_move (I.MOVW) = "movw"
191 :     | asm_move (I.MOVSWL) = "movswl"
192 :     | asm_move (I.MOVZWL) = "movzwl"
193 :     | asm_move (I.MOVSBL) = "movsbl"
194 :     | asm_move (I.MOVZBL) = "movzbl"
195 :     and emit_move x = emit (asm_move x)
196 : monnier 429 and asm_fbinOp (I.FADDP) = "faddp"
197 : george 555 | asm_fbinOp (I.FADDS) = "fadds"
198 : monnier 411 | asm_fbinOp (I.FMULP) = "fmulp"
199 : george 555 | asm_fbinOp (I.FMULS) = "fmuls"
200 : leunga 565 | asm_fbinOp (I.FCOMS) = "fcoms"
201 :     | asm_fbinOp (I.FCOMPS) = "fcomps"
202 : monnier 411 | asm_fbinOp (I.FSUBP) = "fsubp"
203 : george 555 | asm_fbinOp (I.FSUBS) = "fsubs"
204 : monnier 411 | asm_fbinOp (I.FSUBRP) = "fsubrp"
205 : george 555 | asm_fbinOp (I.FSUBRS) = "fsubrs"
206 : monnier 411 | asm_fbinOp (I.FDIVP) = "fdivp"
207 : george 555 | asm_fbinOp (I.FDIVS) = "fdivs"
208 : monnier 411 | asm_fbinOp (I.FDIVRP) = "fdivrp"
209 : george 555 | asm_fbinOp (I.FDIVRS) = "fdivrs"
210 :     | asm_fbinOp (I.FADDL) = "faddl"
211 :     | asm_fbinOp (I.FMULL) = "fmull"
212 : leunga 565 | asm_fbinOp (I.FCOML) = "fcoml"
213 :     | asm_fbinOp (I.FCOMPL) = "fcompl"
214 : george 555 | asm_fbinOp (I.FSUBL) = "fsubl"
215 :     | asm_fbinOp (I.FSUBRL) = "fsubrl"
216 :     | asm_fbinOp (I.FDIVL) = "fdivl"
217 :     | asm_fbinOp (I.FDIVRL) = "fdivrl"
218 : george 545 and emit_fbinOp x = emit (asm_fbinOp x)
219 : leunga 565 and asm_fibinOp (I.FIADDS) = "fiadds"
220 :     | asm_fibinOp (I.FIMULS) = "fimuls"
221 :     | asm_fibinOp (I.FICOMS) = "ficoms"
222 :     | asm_fibinOp (I.FICOMPS) = "ficomps"
223 :     | asm_fibinOp (I.FISUBS) = "fisubs"
224 :     | asm_fibinOp (I.FISUBRS) = "fisubrs"
225 :     | asm_fibinOp (I.FIDIVS) = "fidivs"
226 :     | asm_fibinOp (I.FIDIVRS) = "fidivrs"
227 :     | asm_fibinOp (I.FIADDL) = "fiaddl"
228 :     | asm_fibinOp (I.FIMULL) = "fimull"
229 :     | asm_fibinOp (I.FICOML) = "ficoml"
230 :     | asm_fibinOp (I.FICOMPL) = "ficompl"
231 :     | asm_fibinOp (I.FISUBL) = "fisubl"
232 :     | asm_fibinOp (I.FISUBRL) = "fisubrl"
233 :     | asm_fibinOp (I.FIDIVL) = "fidivl"
234 :     | asm_fibinOp (I.FIDIVRL) = "fidivrl"
235 :     and emit_fibinOp x = emit (asm_fibinOp x)
236 : monnier 429 and asm_funOp (I.FABS) = "fabs"
237 :     | asm_funOp (I.FCHS) = "fchs"
238 : george 545 | asm_funOp (I.FSIN) = "fsin"
239 :     | asm_funOp (I.FCOS) = "fcos"
240 :     | asm_funOp (I.FTAN) = "ftan"
241 :     | asm_funOp (I.FSCALE) = "fscale"
242 :     | asm_funOp (I.FRNDINT) = "frndint"
243 :     | asm_funOp (I.FSQRT) = "fsqrt"
244 :     | asm_funOp (I.FTST) = "ftst"
245 :     | asm_funOp (I.FXAM) = "fxam"
246 :     | asm_funOp (I.FINCSTP) = "fincstp"
247 :     | asm_funOp (I.FDECSTP) = "fdecstp"
248 :     and emit_funOp x = emit (asm_funOp x)
249 :     and asm_fenvOp (I.FLDENV) = "fldenv"
250 :     | asm_fenvOp (I.FNLDENV) = "fnldenv"
251 :     | asm_fenvOp (I.FSTENV) = "fstenv"
252 :     | asm_fenvOp (I.FNSTENV) = "fnstenv"
253 :     and emit_fenvOp x = emit (asm_fenvOp x)
254 : monnier 247
255 : leunga 646 (*#line 244.6 "x86/x86.md"*)
256 : george 545 val memReg = MemRegs.memReg regmap
257 :    
258 : leunga 646 (*#line 245.6 "x86/x86.md"*)
259 : monnier 429 fun emitInt32 i = let
260 : monnier 247
261 : leunga 646 (*#line 246.10 "x86/x86.md"*)
262 : george 545 val s = Int32.toString i
263 : monnier 429
264 : leunga 646 (*#line 247.10 "x86/x86.md"*)
265 : monnier 429 val s = (if (i >= 0)
266 : george 545 then s
267 :     else ("-" ^ (String.substring (s, 1, (size s) - 1))))
268 :     in emit s
269 : monnier 429 end
270 :    
271 :    
272 : leunga 646 (*#line 250.6 "x86/x86.md"*)
273 : george 545 fun emitScale 0 = emit "1"
274 :     | emitScale 1 = emit "2"
275 :     | emitScale 2 = emit "4"
276 :     | emitScale 3 = emit "8"
277 :     | emitScale _ = error "emitScale"
278 :     and eImmed (I.Immed i) = emitInt32 i
279 :     | eImmed (I.ImmedLabel lexp) = emit_labexp lexp
280 :     | eImmed _ = error "eImmed"
281 : monnier 411 and emit_operand opn =
282 :     (
283 :     case opn of
284 :     I.Immed i =>
285 : george 545 ( emit "$";
286 :     emitInt32 i )
287 : monnier 411 | I.ImmedLabel lexp =>
288 : george 545 ( emit "$";
289 :     emit_labexp lexp )
290 :     | I.LabelEA le => emit_labexp le
291 :     | I.Relative _ => error "emit_operand"
292 :     | I.Direct r => emit_GP r
293 :     | I.MemReg r => emit_operand (memReg opn)
294 : george 555 | I.ST f => emit_FP f
295 :     | I.FDirect f => emit_operand (memReg opn)
296 : monnier 411 | I.Displace{base, disp, mem, ...} =>
297 : george 545 ( emit_disp disp;
298 :     emit "(";
299 :     emit_GP base;
300 :     emit ")";
301 :     emit_region mem )
302 : leunga 576 | I.Indexed{base, index, scale, disp, mem, ...} =>
303 : george 545 ( emit_disp disp;
304 :     emit "(";
305 : leunga 576
306 :     (
307 :     case base of
308 :     NONE => ()
309 :     | SOME base => emit_GP base
310 :     );
311 : george 545 comma ();
312 :     emit_GP index;
313 :     comma ();
314 :     emitScale scale;
315 :     emit ")";
316 :     emit_region mem )
317 : monnier 411 )
318 : george 545 and emit_disp (I.Immed 0) = ()
319 :     | emit_disp (I.Immed i) = emitInt32 i
320 :     | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp
321 :     | emit_disp _ = error "emit_disp"
322 : monnier 247
323 : leunga 646 (*#line 290.7 "x86/x86.md"*)
324 : george 545 fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp
325 : leunga 594 | stupidGas opnd =
326 :     ( emit "*";
327 :     emit_operand opnd )
328 : george 545
329 : leunga 646 (*#line 294.7 "x86/x86.md"*)
330 : george 555 fun isMemOpnd (I.MemReg _) = true
331 :     | isMemOpnd (I.FDirect f) = true
332 :     | isMemOpnd (I.LabelEA _) = true
333 :     | isMemOpnd (I.Displace _) = true
334 :     | isMemOpnd (I.Indexed _) = true
335 :     | isMemOpnd _ = false
336 :    
337 : leunga 646 (*#line 300.7 "x86/x86.md"*)
338 : leunga 565 fun chop fbinOp = let
339 : george 555
340 : leunga 646 (*#line 301.15 "x86/x86.md"*)
341 : leunga 565 val n = size fbinOp
342 :     in
343 :     (
344 :     case Char.toLower (String.sub (fbinOp, n - 1)) of
345 :     (#"s" | #"l") => String.substring (fbinOp, 0, n - 1)
346 :     | _ => fbinOp
347 :     )
348 :     end
349 : george 555
350 : leunga 565
351 : leunga 646 (*#line 307.7 "x86/x86.md"*)
352 : monnier 411 val emit_dst = emit_operand
353 : george 545
354 : leunga 646 (*#line 308.7 "x86/x86.md"*)
355 : monnier 411 val emit_src = emit_operand
356 : george 545
357 : leunga 646 (*#line 309.7 "x86/x86.md"*)
358 : monnier 411 val emit_opnd = emit_operand
359 : george 545
360 : leunga 646 (*#line 310.7 "x86/x86.md"*)
361 : monnier 411 val emit_rsrc = emit_operand
362 : george 545
363 : leunga 646 (*#line 311.7 "x86/x86.md"*)
364 : monnier 411 val emit_lsrc = emit_operand
365 : george 545
366 : leunga 646 (*#line 312.7 "x86/x86.md"*)
367 : monnier 411 val emit_addr = emit_operand
368 : monnier 247
369 : leunga 646 (*#line 313.7 "x86/x86.md"*)
370 : george 545 val emit_src1 = emit_operand
371 : leunga 594 fun emitInstr' instr =
372 : monnier 411 (
373 :     case instr of
374 : george 545 I.NOP => emit "nop"
375 : monnier 411 | I.JMP(operand, label) =>
376 : george 545 ( emit "jmp\t";
377 :     stupidGas operand )
378 : monnier 247 | I.JCC{cond, opnd} =>
379 : george 545 ( emit "j";
380 :     emit_cond cond;
381 :     emit "\t";
382 :     stupidGas opnd )
383 : monnier 411 | I.CALL(operand, cellset1, cellset2, region) =>
384 : george 545 ( emit "call\t";
385 :     stupidGas operand;
386 :     emit_region region;
387 :     emit_defs cellset1;
388 :     emit_uses cellset2 )
389 : leunga 594 | I.ENTER{src1, src2} =>
390 :     ( emit "enter\t";
391 :     emit_operand src1;
392 :     emit ", ";
393 :     emit_operand src2 )
394 : george 545 | I.LEAVE => emit "leave"
395 : monnier 429 | I.RET operand =>
396 : george 545 ( emit "ret";
397 : monnier 429
398 :     (
399 :     case operand of
400 :     NONE => ()
401 :     | SOME e =>
402 : george 545 ( emit "\t";
403 :     emit_operand e )
404 : monnier 429 ))
405 : monnier 247 | I.MOVE{mvOp, src, dst} =>
406 : george 545 ( emit_move mvOp;
407 :     emit "\t";
408 :     emit_src src;
409 :     emit ", ";
410 :     emit_dst dst )
411 : monnier 247 | I.LEA{r32, addr} =>
412 : george 545 ( emit "leal\t";
413 :     emit_addr addr;
414 :     emit ", ";
415 :     emit_GP r32 )
416 :     | I.CMPL{lsrc, rsrc} =>
417 :     ( emit "cmpl\t";
418 :     emit_rsrc rsrc;
419 :     emit ", ";
420 :     emit_lsrc lsrc )
421 :     | I.CMPW{lsrc, rsrc} =>
422 :     ( emit "cmpb\t";
423 :     emit_rsrc rsrc;
424 :     emit ", ";
425 :     emit_lsrc lsrc )
426 :     | I.CMPB{lsrc, rsrc} =>
427 :     ( emit "cmpb\t";
428 :     emit_rsrc rsrc;
429 :     emit ", ";
430 :     emit_lsrc lsrc )
431 :     | I.TESTL{lsrc, rsrc} =>
432 :     ( emit "testl\t";
433 :     emit_rsrc rsrc;
434 :     emit ", ";
435 :     emit_lsrc lsrc )
436 :     | I.TESTW{lsrc, rsrc} =>
437 :     ( emit "testw\t";
438 :     emit_rsrc rsrc;
439 :     emit ", ";
440 :     emit_lsrc lsrc )
441 :     | I.TESTB{lsrc, rsrc} =>
442 :     ( emit "testb\t";
443 :     emit_rsrc rsrc;
444 :     emit ", ";
445 :     emit_lsrc lsrc )
446 : leunga 646 | I.BITOP{bitOp, lsrc, rsrc} =>
447 :     ( emit_bitOp bitOp;
448 :     emit "\t";
449 :     emit_rsrc rsrc;
450 :     emit ", ";
451 :     emit_lsrc lsrc )
452 : monnier 411 | I.BINARY{binOp, src, dst} =>
453 : george 545 (
454 :     case (src, binOp) of
455 :     (I.Direct _, (I.SARL | I.SHRL | I.SHLL | I.SARW | I.SHRW | I.SHLW | I.SARB | I.SHRB | I.SHLB)) =>
456 :     ( emit_binaryOp binOp;
457 :     emit "\t%cl, ";
458 :     emit_dst dst )
459 :     | _ =>
460 :     ( emit_binaryOp binOp;
461 :     emit "\t";
462 :     emit_src src;
463 :     emit ", ";
464 :     emit_dst dst )
465 :     )
466 : monnier 411 | I.MULTDIV{multDivOp, src} =>
467 : george 545 ( emit_multDivOp multDivOp;
468 : leunga 606 emit "\t";
469 : george 545 emit_src src )
470 :     | I.MUL3{dst, src2, src1} =>
471 :     (
472 :     case src2 of
473 :     NONE =>
474 :     ( emit "imul\t";
475 :     emit_src1 src1;
476 :     emit ", ";
477 :     emit_GP dst )
478 :     | SOME i =>
479 :     ( emit "imul\t$";
480 :     emitInt32 i;
481 :     emit ", ";
482 :     emit_src1 src1;
483 :     emit ", ";
484 :     emit_GP dst )
485 :     )
486 : monnier 247 | I.UNARY{unOp, opnd} =>
487 : george 545 ( emit_unaryOp unOp;
488 :     emit "\t";
489 :     emit_opnd opnd )
490 :     | I.SET{cond, opnd} =>
491 :     ( emit "set";
492 :     emit_cond cond;
493 :     emit "\t";
494 :     emit_opnd opnd )
495 :     | I.CMOV{cond, src, dst} =>
496 :     ( emit "cmov";
497 :     emit_cond cond;
498 :     emit "\t";
499 :     emit_src src;
500 :     emit ", ";
501 :     emit_GP dst )
502 :     | I.PUSHL operand =>
503 :     ( emit "pushl\t";
504 :     emit_operand operand )
505 :     | I.PUSHW operand =>
506 :     ( emit "pushw\t";
507 :     emit_operand operand )
508 :     | I.PUSHB operand =>
509 :     ( emit "pushb\t";
510 :     emit_operand operand )
511 : monnier 411 | I.POP operand =>
512 : george 545 ( emit "popl\t";
513 :     emit_operand operand )
514 :     | I.CDQ => emit "cdq"
515 :     | I.INTO => emit "into"
516 :     | I.COPY{dst, src, tmp} => emitInstrs (Shuffle.shuffle {regmap=regmap, tmp=tmp, dst=dst, src=src})
517 :     | I.FCOPY{dst, src, tmp} => emitInstrs (Shuffle.shufflefp {regmap=regmap, tmp=tmp, dst=dst, src=src})
518 : leunga 565 | I.FBINARY{binOp, src, dst} => (if (isMemOpnd src)
519 :     then
520 :     ( emit_fbinOp binOp;
521 :     emit "\t";
522 :     emit_src src )
523 :     else
524 :     ( emit (chop (asm_fbinOp binOp));
525 :     emit "\t";
526 :     emit_src src;
527 :     emit ", ";
528 :     emit_dst dst ))
529 :     | I.FIBINARY{binOp, src} =>
530 :     ( emit_fibinOp binOp;
531 : george 545 emit "\t";
532 : leunga 565 emit_src src )
533 : george 545 | I.FUNARY funOp => emit_funOp funOp
534 :     | I.FUCOMPP => emit "fucompp"
535 :     | I.FCOMPP => emit "fcompp"
536 :     | I.FXCH{opnd} =>
537 :     ( emit "fxch\t";
538 :     (if (opnd = (C.ST 1))
539 :     then ()
540 :     else (emit_FP opnd)))
541 :     | I.FSTPL operand =>
542 :     ( emit "fstpl\t";
543 :     emit_operand operand )
544 :     | I.FSTPS operand =>
545 :     ( emit "fstps\t";
546 :     emit_operand operand )
547 : george 555 | I.FSTPT operand =>
548 :     ( emit "fstps\t";
549 :     emit_operand operand )
550 : leunga 579 | I.FSTL operand =>
551 :     ( emit "fstl\t";
552 :     emit_operand operand )
553 :     | I.FSTS operand =>
554 :     ( emit "fsts\t";
555 :     emit_operand operand )
556 : leunga 565 | I.FLD1 => emit "fld1"
557 :     | I.FLDL2E => emit "fldl2e"
558 :     | I.FLDL2T => emit "fldl2t"
559 :     | I.FLDLG2 => emit "fldlg2"
560 :     | I.FLDLN2 => emit "fldln2"
561 :     | I.FLDPI => emit "fldpi"
562 :     | I.FLDZ => emit "fldz"
563 : george 545 | I.FLDL operand =>
564 :     ( emit "fldl\t";
565 :     emit_operand operand )
566 :     | I.FLDS operand =>
567 :     ( emit "flds\t";
568 :     emit_operand operand )
569 : george 555 | I.FLDT operand =>
570 :     ( emit "fldt\t";
571 :     emit_operand operand )
572 : monnier 411 | I.FILD operand =>
573 : george 545 ( emit "fild\t";
574 :     emit_operand operand )
575 : leunga 565 | I.FILDL operand =>
576 :     ( emit "fildl\t";
577 :     emit_operand operand )
578 :     | I.FILDLL operand =>
579 :     ( emit "fildll\t";
580 :     emit_operand operand )
581 : george 545 | I.FNSTSW => emit "fnstsw"
582 :     | I.FENV{fenvOp, opnd} =>
583 :     ( emit_fenvOp fenvOp;
584 :     emit "\t";
585 :     emit_opnd opnd )
586 :     | I.SAHF => emit "sahf"
587 : monnier 411 | I.ANNOTATION{i, a} =>
588 : leunga 624 ( comment (Annotations.toString a);
589 :     nl ();
590 :     emitInstr i )
591 :     | I.SOURCE{} => emit "source"
592 :     | I.SINK{} => emit "sink"
593 :     | I.PHI{} => emit "phi"
594 : leunga 594 )
595 :     and emitInstr i = (tab(); emitInstr' i; nl())
596 :     and emitInstrIndented i = (indent(); emitInstr' i; nl())
597 :     and emitInstrs instrs =
598 :     app (if !indent_copies then emitInstrIndented
599 :     else emitInstr) instrs
600 : monnier 411 in emitInstr end
601 :    
602 : monnier 429 in S.STREAM{beginCluster=init,
603 : monnier 411 pseudoOp=pseudoOp,
604 :     emit=emitter,
605 : monnier 429 endCluster=doNothing,
606 : monnier 411 defineLabel=defineLabel,
607 :     entryLabel=entryLabel,
608 :     comment=comment,
609 :     exitBlock=doNothing,
610 : monnier 429 annotation=annotation,
611 :     phi=doNothing,
612 :     alias=doNothing
613 : monnier 411 }
614 :     end
615 : monnier 247 end
616 :    

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