a02cd3101430817fda7014890ad05a7fc896eb60
[libfirm] / ir / be / ia32 / ia32_spec.pl
1 # Creation: 2005/10/19
2 # $Id$
3 # This is the specification for the ia32 assembler Firm-operations
4
5 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
6 $arch = "ia32";
7
8 # this string marks the beginning of a comment in emit
9 $comment_string = "/*";
10
11 # the number of additional opcodes you want to register
12 #$additional_opcodes = 0;
13
14 # The node description is done as a perl hash initializer with the
15 # following structure:
16 #
17 # %nodes = (
18 #
19 # <op-name> => {
20 #   "op_flags"  => "N|L|C|X|I|F|Y|H|c|K",
21 #   "irn_flags" => "R|N|I|S"
22 #   "arity"     => "0|1|2|3 ... |variable|dynamic|any",
23 #   "state"     => "floats|pinned|mem_pinned|exc_pinned",
24 #   "args"      => [
25 #                    { "type" => "type 1", "name" => "name 1" },
26 #                    { "type" => "type 2", "name" => "name 2" },
27 #                    ...
28 #                  ],
29 #   "comment"   => "any comment for constructor",
30 #   "reg_req"   => { "in" => [ "reg_class|register" ], "out" => [ "reg_class|register|in_rX" ] },
31 #   "cmp_attr"  => "c source code for comparing node attributes",
32 #   "emit"      => "emit code with templates",
33 #   "attr"      => "attitional attribute arguments for constructor"
34 #   "init_attr" => "emit attribute initialization template"
35 #   "rd_constructor" => "c source code which constructs an ir_node"
36 #   "latency"   => "latency of this operation (can be float)"
37 # },
38 #
39 # ... # (all nodes you need to describe)
40 #
41 # ); # close the %nodes initializer
42
43 # op_flags: flags for the operation, OPTIONAL (default is "N")
44 # the op_flags correspond to the firm irop_flags:
45 #   N   irop_flag_none
46 #   L   irop_flag_labeled
47 #   C   irop_flag_commutative
48 #   X   irop_flag_cfopcode
49 #   I   irop_flag_ip_cfopcode
50 #   F   irop_flag_fragile
51 #   Y   irop_flag_forking
52 #   H   irop_flag_highlevel
53 #   c   irop_flag_constlike
54 #   K   irop_flag_keep
55 #
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
58 #   R   rematerializeable
59 #   N   not spillable
60 #   I   ignore for register allocation
61 #   S   modifies stack pointer
62 #
63 # state: state of the operation, OPTIONAL (default is "floats")
64 #
65 # arity: arity of the operation, MUST NOT BE OMITTED
66 #
67 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
68 #        are always the first 3 arguments and are always autmatically
69 #        created)
70 #        If this key is missing the following arguments will be created:
71 #        for i = 1 .. arity: ir_node *op_i
72 #        ir_mode *mode
73 #
74 # outs:  if a node defines more than one output, the names of the projections
75 #        nodes having outs having automatically the mode mode_T
76 #        One can also annotate some flags for each out, additional to irn_flags.
77 #        They are separated from name with a colon ':', and concatenated by pipe '|'
78 #        Only I and S are available at the moment (same meaning as in irn_flags).
79 #        example: [ "frame:I", "stack:I|S", "M" ]
80 #
81 # comment: OPTIONAL comment for the node constructor
82 #
83 # rd_constructor: for every operation there will be a
84 #      new_rd_<arch>_<op-name> function with the arguments from above
85 #      which creates the ir_node corresponding to the defined operation
86 #      you can either put the complete source code of this function here
87 #
88 #      This key is OPTIONAL. If omitted, the following constructor will
89 #      be created:
90 #      if (!op_<arch>_<op-name>) assert(0);
91 #      for i = 1 to arity
92 #         set in[i] = op_i
93 #      done
94 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
95 #      return res
96 #
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
98 #
99 # latency: the latency of the operation, default is 1
100 #
101
102 # register types:
103 #   0 - no special type
104 #   1 - caller save (register must be saved by the caller of a function)
105 #   2 - callee save (register must be saved by the called function)
106 #   4 - ignore (do not assign this register)
107 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
108 %reg_classes = (
109   "gp" => [
110             { "name" => "eax", "type" => 1 },
111             { "name" => "edx", "type" => 1 },
112             { "name" => "ebx", "type" => 2 },
113             { "name" => "ecx", "type" => 1 },
114             { "name" => "esi", "type" => 2 },
115             { "name" => "edi", "type" => 2 },
116 #            { "name" => "r11", "type" => 1 },
117 #            { "name" => "r12", "type" => 1 },
118 #            { "name" => "r13", "type" => 1 },
119 #            { "name" => "r14", "type" => 1 },
120 #            { "name" => "r15", "type" => 1 },
121 #            { "name" => "r16", "type" => 1 },
122 #            { "name" => "r17", "type" => 1 },
123 #            { "name" => "r18", "type" => 1 },
124 #            { "name" => "r19", "type" => 1 },
125 #            { "name" => "r20", "type" => 1 },
126 #            { "name" => "r21", "type" => 1 },
127 #            { "name" => "r22", "type" => 1 },
128 #            { "name" => "r23", "type" => 1 },
129 #            { "name" => "r24", "type" => 1 },
130 #            { "name" => "r25", "type" => 1 },
131 #            { "name" => "r26", "type" => 1 },
132 #            { "name" => "r27", "type" => 1 },
133 #            { "name" => "r28", "type" => 1 },
134 #            { "name" => "r29", "type" => 1 },
135 #            { "name" => "r30", "type" => 1 },
136 #            { "name" => "r31", "type" => 1 },
137 #            { "name" => "r32", "type" => 1 },
138             { "name" => "ebp", "type" => 2 },
139             { "name" => "esp", "type" => 4 },
140             { "name" => "gp_NOREG", "type" => 2 | 4 },      # we need a dummy register for NoReg nodes
141             { "name" => "gp_UKNWN", "type" => 2 | 4 | 8 },  # we need a dummy register for Unknown nodes
142                         { "mode" => "mode_P" }
143           ],
144   "xmm" => [
145             { "name" => "xmm0", "type" => 1 },
146             { "name" => "xmm1", "type" => 1 },
147             { "name" => "xmm2", "type" => 1 },
148             { "name" => "xmm3", "type" => 1 },
149             { "name" => "xmm4", "type" => 1 },
150             { "name" => "xmm5", "type" => 1 },
151             { "name" => "xmm6", "type" => 1 },
152             { "name" => "xmm7", "type" => 1 },
153             { "name" => "xmm_NOREG", "type" => 2 | 4 },      # we need a dummy register for NoReg nodes
154             { "name" => "xmm_UKNWN", "type" => 2 | 4 | 8 },  # we need a dummy register for Unknown nodes
155                         { "mode" => "mode_D" }
156           ],
157   "vfp" => [
158             { "name" => "vf0", "type" => 1 },
159             { "name" => "vf1", "type" => 1 },
160             { "name" => "vf2", "type" => 1 },
161             { "name" => "vf3", "type" => 1 },
162             { "name" => "vf4", "type" => 1 },
163             { "name" => "vf5", "type" => 1 },
164             { "name" => "vf6", "type" => 1 },
165             { "name" => "vf7", "type" => 1 },
166             { "name" => "vfp_NOREG", "type" => 2 | 4 },      # we need a dummy register for NoReg nodes
167             { "name" => "vfp_UKNWN", "type" => 2 | 4 | 8 },  # we need a dummy register for Unknown nodes
168                         { "mode" => "mode_E" }
169           ],
170   "st" => [
171             { "name" => "st0", "type" => 1 },
172             { "name" => "st1", "type" => 1 },
173             { "name" => "st2", "type" => 1 },
174             { "name" => "st3", "type" => 1 },
175             { "name" => "st4", "type" => 1 },
176             { "name" => "st5", "type" => 1 },
177             { "name" => "st6", "type" => 1 },
178             { "name" => "st7", "type" => 1 },
179                         { "mode" => "mode_E" }
180           ]
181 ); # %reg_classes
182
183 #--------------------------------------------------#
184 #                        _                         #
185 #                       (_)                        #
186 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
187 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
188 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
189 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
190 #                                      | |         #
191 #                                      |_|         #
192 #--------------------------------------------------#
193
194 %operands = (
195 );
196
197 %nodes = (
198
199 #-----------------------------------------------------------------#
200 #  _       _                                         _            #
201 # (_)     | |                                       | |           #
202 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
203 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
204 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
205 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
206 #                   __/ |                                         #
207 #                  |___/                                          #
208 #-----------------------------------------------------------------#
209
210 # commutative operations
211
212 # NOTE:
213 # All nodes supporting Addressmode have 5 INs:
214 # 1 - base    r1 == NoReg in case of no AM or no base
215 # 2 - index   r2 == NoReg in case of no AM or no index
216 # 3 - op1     r3 == always present
217 # 4 - op2     r4 == NoReg in case of immediate operation
218 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
219
220 "Add" => {
221   "irn_flags" => "R",
222   "comment"   => "construct Add: Add(a, b) = Add(b, a) = a + b",
223   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
224   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
225   "emit"      => '. add %ia32_emit_binop /* Add(%A3, %A4) -> %D1 */',
226   "outs"      => [ "res", "M" ],
227 },
228
229 "AddC" => {
230   "comment"   => "construct Add with Carry: AddC(a, b) = Add(b, a) = a + b + carry",
231   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
232   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
233   "emit"      => '. adc %ia32_emit_binop /* AddC(%A3, %A4) -> %D1 */',
234   "outs"      => [ "res", "M" ],
235 },
236
237 "l_Add" => {
238   "op_flags"  => "C",
239   "irn_flags" => "R",
240   "cmp_attr"  => "  return 1;\n",
241   "comment"   => "construct lowered Add: Add(a, b) = Add(b, a) = a + b",
242   "arity"     => 2,
243 },
244
245 "l_AddC" => {
246   "op_flags"  => "C",
247   "cmp_attr"  => "  return 1;\n",
248   "comment"   => "construct lowered Add with Carry: AddC(a, b) = Add(b, a) = a + b + carry",
249   "arity"     => 2,
250 },
251
252 "MulS" => {
253   # we should not rematrialize this node. It produces 2 results and has
254   # very strict constrains
255   "comment"   => "construct MulS: MulS(a, b) = MulS(b, a) = a * b",
256   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
257   "reg_req"   => { "in" => [ "gp", "gp", "eax", "gp", "none" ], "out" => [ "eax", "edx" ] },
258   "emit"      => '. mul %ia32_emit_unop /* Mul(%A1, %A2) -> %D1 */',
259   "outs"      => [ "EAX", "EDX", "M" ],
260   "latency"   => 10,
261 },
262
263 "l_MulS" => {
264   # we should not rematrialize this node. It produces 2 results and has
265   # very strict constrains
266   "op_flags"  => "C",
267   "cmp_attr"  => "  return 1;\n",
268   "comment"   => "construct lowered MulS: MulS(a, b) = MulS(b, a) = a * b",
269   "outs"      => [ "EAX", "EDX", "M" ],
270   "arity"     => 2
271 },
272
273 "Mul" => {
274   "irn_flags" => "R",
275   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
276   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
277   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
278   "emit"      => '. imul %ia32_emit_binop /* Mul(%A1, %A2) -> %D1 */',
279   "outs"      => [ "res", "M" ],
280   "latency"   => 5,
281 },
282
283 "l_Mul" => {
284   "op_flags"  => "C",
285   "cmp_attr"  => "  return 1;\n",
286   "comment"   => "construct lowered Mul: Mul(a, b) = Mul(b, a) = a * b",
287   "arity"     => 2
288 },
289
290 # Mulh is an exception from the 4 INs with AM because the target is always EAX:EDX
291 "Mulh" => {
292   # we should not rematrialize this node. It produces 2 results and has
293   # very strict constrains
294   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
295   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
296   "reg_req"   => { "in" => [ "gp", "gp", "eax", "gp", "none" ], "out" => [ "eax", "edx" ] },
297   "emit"      => '. imul %ia32_emit_unop /* Mulh(%A1, %A2) -> %D1 */',
298   "outs"      => [ "EAX", "EDX", "M" ],
299   "latency"   => 5,
300 },
301
302 "And" => {
303   "irn_flags" => "R",
304   "comment"   => "construct And: And(a, b) = And(b, a) = a AND b",
305   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
306   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
307   "emit"      => '. and %ia32_emit_binop /* And(%A1, %A2) -> %D1 */',
308   "outs"      => [ "res", "M" ],
309 },
310
311 "Or" => {
312   "irn_flags" => "R",
313   "comment"   => "construct Or: Or(a, b) = Or(b, a) = a OR b",
314   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
315   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
316   "emit"      => '. or %ia32_emit_binop /* Or(%A1, %A2) -> %D1 */',
317   "outs"      => [ "res", "M" ],
318 },
319
320 "Eor" => {
321   "irn_flags" => "R",
322   "comment"   => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
323   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
324   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
325   "emit"      => '. xor %ia32_emit_binop /* Xor(%A1, %A2) -> %D1 */',
326   "outs"      => [ "res", "M" ],
327 },
328
329 "l_Eor" => {
330   "op_flags"  => "C",
331   "cmp_attr"  => "  return 1;\n",
332   "comment"   => "construct lowered Eor: Eor(a, b) = Eor(b, a) = a EOR b",
333   "arity"     => 2
334 },
335
336 "Max" => {
337   "irn_flags" => "R",
338   "comment"   => "construct Max: Max(a, b) = Max(b, a) = a > b ? a : b",
339   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
340   "emit"      =>
341 '2. cmp %S1, %S2 /* prepare Max (%S1 - %S2), (%A1, %A2) */
342   if (mode_is_signed(get_irn_mode(n))) {
343 4.  cmovl %D1, %S2 /* %S1 is less %S2 */
344   }
345   else {
346 4.  cmovb %D1, %S2 /* %S1 is below %S2 */
347   }
348 ',
349   "latency"   => 2,
350 },
351
352 "Min" => {
353   "irn_flags" => "R",
354   "comment"   => "construct Min: Min(a, b) = Min(b, a) = a < b ? a : b",
355   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
356   "emit"      =>
357 '2. cmp %S1, %S2 /* prepare Min (%S1 - %S2), (%A1, %A2) */
358   if (mode_is_signed(get_irn_mode(n))) {
359 2.  cmovg %D1, %S2 /* %S1 is greater %S2 */
360   }
361   else {
362 2.  cmova %D1, %S2, %D1 /* %S1 is above %S2 */
363   }
364 ',
365   "latency"   => 2,
366 },
367
368 # not commutative operations
369
370 "Sub" => {
371   "irn_flags" => "R",
372   "comment"   => "construct Sub: Sub(a, b) = a - b",
373   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
374   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
375   "emit"      => '. sub %ia32_emit_binop /* Sub(%A3, %A4) -> %D1 */',
376   "outs"      => [ "res", "M" ],
377 },
378
379 "SubC" => {
380   "comment"   => "construct Sub with Carry: SubC(a, b) = a - b - carry",
381   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
382   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3 !in_r4" ] },
383   "emit"      => '. sbb %ia32_emit_binop /* SubC(%A3, %A4) -> %D1 */',
384   "outs"      => [ "res", "M" ],
385 },
386
387 "l_Sub" => {
388   "irn_flags" => "R",
389   "cmp_attr"  => "  return 1;\n",
390   "comment"   => "construct lowered Sub: Sub(a, b) = a - b",
391   "arity"     => 2,
392 },
393
394 "l_SubC" => {
395   "cmp_attr"  => "  return 1;\n",
396   "comment"   => "construct lowered Sub with Carry: SubC(a, b) = a - b - carry",
397   "arity"     => 2,
398 },
399
400 "DivMod" => {
401   "op_flags"  => "F|L",
402   "state"     => "exc_pinned",
403   "reg_req"   => { "in" => [ "eax", "gp", "edx", "none" ], "out" => [ "eax", "edx" ] },
404   "attr"      => "ia32_op_flavour_t dm_flav",
405   "init_attr" => "  attr->data.op_flav = dm_flav;",
406   "cmp_attr"  => "  return attr_a->data.op_flav != attr_b->data.op_flav;\n",
407   "emit"      =>
408 '  if (mode_is_signed(get_ia32_res_mode(n))) {
409 4.  idiv %S2 /* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
410   }
411   else {
412 4.  div %S2 /* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
413   }
414 ',
415   "outs"      => [ "div_res", "mod_res", "M" ],
416   "latency"   => 25,
417 },
418
419 "Shl" => {
420   "irn_flags" => "R",
421   "comment"   => "construct Shl: Shl(a, b) = a << b",
422   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
423   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx gp_NOREG", "none" ], "out" => [ "in_r3 !in_r4" ] },
424   "emit"      => '. shl %ia32_emit_binop /* Shl(%A1, %A2) -> %D1 */',
425   "outs"      => [ "res", "M" ],
426 },
427
428 "l_Shl" => {
429   "cmp_attr"  => "  return 1;\n",
430   "comment"   => "construct lowered Shl: Shl(a, b) = a << b",
431   "arity"     => 2
432 },
433
434 "ShlD" => {
435   "irn_flags" => "R",
436   "comment"   => "construct ShlD: ShlD(a, b, c) = a, b << count (shift left count bits from b into a)",
437   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
438   # Out requirements is: different from all in
439   # This is because, out must be different from LowPart and ShiftCount.
440   # We could say "!ecx !in_r4" but it can occur, that all values live through
441   # this Shift and the only value dying is the ShiftCount. Then there would be a
442   # register missing, as result must not be ecx and all other registers are
443   # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
444   # (and probably never will). So we create artificial interferences of the result
445   # with all inputs, so the spiller can always assure a free register.
446   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "ecx", "none" ], "out" => [ "!in" ] },
447   "emit"      =>
448 '
449 if (get_ia32_immop_type(n) == ia32_ImmNone) {
450   if (get_ia32_op_type(n) == ia32_AddrModeD) {
451 4. shld %ia32_emit_am, %S4, %%cl /* ShlD(%A3, %A4, %A5) -> %D1 */
452   }
453   else {
454 4. shld %S3, %S4, %%cl /* ShlD(%A3, %A4, %A5) -> %D1 */
455   }
456 }
457 else {
458   if (get_ia32_op_type(n) == ia32_AddrModeD) {
459 4. shld %ia32_emit_am, %S4, %C /* ShlD(%A3, %A4, %A5) -> %D1 */
460   }
461   else {
462 4. shld %S3, %S4, %C /* ShlD(%A3, %A4, %A5) -> %D1 */
463   }
464 }
465 ',
466   "outs"      => [ "res", "M" ],
467   "latency"   => 6,
468 },
469
470 "l_ShlD" => {
471   "cmp_attr"  => "  return 1;\n",
472   "comment"   => "construct lowered ShlD: ShlD(a, b, c) = a, b << count (shift left count bits from b into a)",
473   "arity"     => 3
474 },
475
476 "Shr" => {
477   "irn_flags" => "R",
478   "comment"   => "construct Shr: Shr(a, b) = a >> b",
479   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
480   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx gp_NOREG", "none" ], "out" => [ "in_r3 !in_r4" ] },
481   "emit"      => '. shr %ia32_emit_binop /* Shr(%A1, %A2) -> %D1 */',
482   "outs"      => [ "res", "M" ],
483 },
484
485 "l_Shr" => {
486   "cmp_attr"  => "  return 1;\n",
487   "comment"   => "construct lowered Shr: Shr(a, b) = a << b",
488   "arity"     => 2
489 },
490
491 "ShrD" => {
492   "irn_flags" => "R",
493   "comment"   => "construct ShrD: ShrD(a, b, c) = a, b >> count (shift rigth count bits from a into b)",
494   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
495   # Out requirements is: different from all in
496   # This is because, out must be different from LowPart and ShiftCount.
497   # We could say "!ecx !in_r4" but it can occur, that all values live through
498   # this Shift and the only value dying is the ShiftCount. Then there would be a
499   # register missing, as result must not be ecx and all other registers are
500   # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
501   # (and probably never will). So we create artificial interferences of the result
502   # with all inputs, so the spiller can always assure a free register.
503   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "ecx", "none" ], "out" => [ "!in" ] },
504   "emit"      =>
505 '
506 if (get_ia32_immop_type(n) == ia32_ImmNone) {
507   if (get_ia32_op_type(n) == ia32_AddrModeD) {
508 4. shrd %ia32_emit_am, %S4, %%cl /* ShrD(%A3, %A4, %A5) -> %D1 */
509   }
510   else {
511 4. shrd %S3, %S4, %%cl /* ShrD(%A3, %A4, %A5) -> %D1 */
512   }
513 }
514 else {
515   if (get_ia32_op_type(n) == ia32_AddrModeD) {
516 4. shrd %ia32_emit_am, %S4, %C /* ShrD(%A3, %A4, %A5) -> %D1 */
517   }
518   else {
519 4. shrd %S3, %S4, %C /* ShrD(%A3, %A4, %A5) -> %D1 */
520   }
521 }
522 ',
523   "outs"      => [ "res", "M" ],
524   "latency"   => 6,
525 },
526
527 "l_ShrD" => {
528   "cmp_attr"  => "  return 1;\n",
529   "comment"   => "construct lowered ShrD: ShrD(a, b, c) = a, b >> count (shift rigth count bits from a into b)",
530   "arity"     => 3
531 },
532
533 "Shrs" => {
534   "irn_flags" => "R",
535   "comment"   => "construct Shrs: Shrs(a, b) = a >> b",
536   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
537   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx gp_NOREG", "none" ], "out" => [ "in_r3 !in_r4" ] },
538   "emit"      => '. sar %ia32_emit_binop /* Shrs(%A1, %A2) -> %D1 */',
539   "outs"      => [ "res", "M" ],
540 },
541
542 "l_Shrs" => {
543   "cmp_attr"  => "  return 1;\n",
544   "comment"   => "construct lowered Shrs: Shrs(a, b) = a << b",
545   "arity"     => 2
546 },
547
548 "RotR" => {
549   "irn_flags" => "R",
550   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
551   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
552   "reg_req"     => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
553   "emit"        => '. ror %ia32_emit_binop /* RotR(%A1, %A2) -> %D1 */',
554   "outs"      => [ "res", "M" ],
555 },
556
557 "RotL" => {
558   "irn_flags" => "R",
559   "comment"   => "construct RotL: RotL(a, b) = a ROTL b",
560   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
561   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
562   "emit"      => '. rol %ia32_emit_binop /* RotL(%A1, %A2) -> %D1 */',
563   "outs"      => [ "res", "M" ],
564 },
565
566 # unary operations
567
568 "Minus" => {
569   "irn_flags" => "R",
570   "comment"   => "construct Minus: Minus(a) = -a",
571   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
572   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
573   "emit"      => '. neg %ia32_emit_unop /* Neg(%A1) -> %D1, (%A1) */',
574   "outs"      => [ "res", "M" ],
575 },
576
577 "l_Minus" => {
578   "cmp_attr"  => "  return 1;\n",
579   "comment"   => "construct lowered Minus: Minus(a) = -a",
580   "arity"     => 1,
581 },
582
583 "Inc" => {
584   "irn_flags" => "R",
585   "comment"   => "construct Increment: Inc(a) = a++",
586   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
587   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
588   "emit"      => '. inc %ia32_emit_unop /* Inc(%S1) -> %D1, (%A1) */',
589   "outs"      => [ "res", "M" ],
590 },
591
592 "Dec" => {
593   "irn_flags" => "R",
594   "comment"   => "construct Decrement: Dec(a) = a--",
595   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
596   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
597   "emit"      => '. dec %ia32_emit_unop /* Dec(%S1) -> %D1, (%A1) */',
598   "outs"      => [ "res", "M" ],
599 },
600
601 "Not" => {
602   "irn_flags" => "R",
603   "comment"   => "construct Not: Not(a) = !a",
604   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
605   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
606   "emit"      => '. not %ia32_emit_unop /* Not(%S1) -> %D1, (%A1) */',
607   "outs"      => [ "res", "M" ],
608 },
609
610 # other operations
611
612 "CondJmp" => {
613   "op_flags"  => "L|X|Y",
614   "comment"   => "construct conditional jump: CMP A, B && JMPxx LABEL",
615   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
616   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ] },
617   "outs"      => [ "false", "true" ],
618   "latency"   => 3,
619 },
620
621 "TestJmp" => {
622   "op_flags"  => "L|X|Y",
623   "comment"   => "construct conditional jump: TEST A, B && JMPxx LABEL",
624   "reg_req"  => { "in" => [ "gp", "gp" ] },
625   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
626   "outs"      => [ "false", "true" ],
627   "latency"   => 3,
628 },
629
630 "CJmpAM" => {
631   "op_flags"  => "L|X|Y",
632   "comment"   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
633   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
634   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "none", "none" ] },
635   "outs"      => [ "false", "true" ],
636 },
637
638 "CJmp" => {
639   "op_flags"  => "L|X|Y",
640   "comment"   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
641   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
642   "reg_req"   => { "in" => [ "gp", "gp" ] },
643 },
644
645 "SwitchJmp" => {
646   "op_flags"  => "L|X|Y",
647   "comment"   => "construct switch",
648   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
649   "reg_req"   => { "in" => [ "gp" ], "out" => [ "none" ] },
650   "latency"   => 3,
651 },
652
653 "Const" => {
654   "op_flags"  => "c",
655   "irn_flags" => "R",
656   "comment"   => "represents an integer constant",
657   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
658   "reg_req"   => { "in" => [ "none" ], "out" => [ "gp" ] },
659 },
660
661 "Cdq" => {
662   # we should not rematrialize this node. It produces 2 results and has
663   # very strict constrains
664   "comment"   => "construct CDQ: sign extend EAX -> EDX:EAX",
665   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax in_r1", "edx" ] },
666   "emit"      => '. cdq /* sign extend EAX -> EDX:EAX, (%A1) */',
667   "outs"      => [ "EAX", "EDX" ],
668 },
669
670 # Load / Store
671
672 "Load" => {
673   "op_flags"  => "L|F",
674   "state"     => "exc_pinned",
675   "comment"   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
676   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
677   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
678   "latency"   => 3,
679   "emit"      =>
680 '  if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
681 4.   mov%Mx %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
682   }
683   else {
684 4.   mov %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
685   }
686 ',
687   "outs"      => [ "res", "M" ],
688 },
689
690 "l_Load" => {
691   "op_flags"  => "L|F",
692   "cmp_attr"  => "  return 1;\n",
693   "comment"   => "construct lowered Load: Load(ptr, mem) = LD ptr -> reg",
694   "outs"      => [ "res", "M" ],
695   "arity"     => 2,
696 },
697
698 "l_Store" => {
699   "op_flags"  => "L|F",
700   "cmp_attr"  => "  return 1;\n",
701   "state"     => "exc_pinned",
702   "comment"   => "construct lowered Store: Store(ptr, val, mem) = ST ptr,val",
703   "arity"     => 3,
704   "outs"      => [ "M" ],
705 },
706
707 "Store" => {
708   "op_flags"  => "L|F",
709   "state"     => "exc_pinned",
710   "comment"   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
711   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
712   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ] },
713   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
714   "outs"      => [ "M" ],
715   "latency"   => 3,
716 },
717
718 "Store8Bit" => {
719   "op_flags"  => "L|F",
720   "state"     => "exc_pinned",
721   "comment"   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
722   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
723   "reg_req"   => { "in" => [ "gp", "gp", "eax ebx ecx edx gp_NOREG", "none" ] },
724   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
725   "outs"      => [ "M" ],
726   "latency"   => 3,
727 },
728
729 "Lea" => {
730   "irn_flags" => "R",
731   "comment"   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
732   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
733   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
734   "emit"      => '. lea %D1, %ia32_emit_am /* LEA(%A1, %A2) */',
735   "latency"   => 2,
736 },
737
738 "Push" => {
739   "comment"   => "push on the stack",
740   "reg_req"   => { "in" => [ "gp", "gp", "gp", "esp", "none" ], "out" => [ "esp" ] },
741   "emit"      => '. push %ia32_emit_unop /* PUSH(%A1) */',
742   "outs"      => [ "stack:I|S", "M" ],
743   "latency"   => 3,
744 },
745
746 "Pop" => {
747   # We don't set class modify stack here (but we will do this on proj 1)
748   "comment"   => "pop a gp register from the stack",
749   "reg_req"   => { "in" => [ "gp", "gp", "esp", "none" ], "out" => [ "gp", "esp" ] },
750   "emit"      => '. pop %ia32_emit_unop /* POP(%A1) */',
751   "outs"      => [ "res", "stack:I|S", "M" ],
752   "latency"   => 4,
753 },
754
755 "Enter" => {
756   "comment"   => "create stack frame",
757   "reg_req"   => { "in" => [ "esp" ], "out" => [ "ebp", "esp" ] },
758   "emit"      => '. enter /* Enter */',
759   "outs"      => [ "frame:I", "stack:I|S", "M" ],
760   "latency"   => 15,
761 },
762
763 "Leave" => {
764   "comment"   => "destroy stack frame",
765   "reg_req"   => { "in" => [ "esp", "ebp" ], "out" => [ "ebp", "esp" ] },
766   "emit"      => '. leave /* Leave */',
767   "outs"      => [ "frame:I", "stack:I|S", "M" ],
768   "latency"   => 3,
769 },
770
771 "AddSP" => {
772   "irn_flags" => "I",
773   "comment"   => "allocate space on stack",
774   "reg_req"   => { "in" => [ "esp", "gp" ], "out" => [ "esp", "none" ] },
775   "outs"      => [ "stack:S", "M" ],
776 },
777
778 "SubSP" => {
779   "irn_flags" => "I",
780   "comment"   => "free space on stack",
781   "reg_req"   => { "in" => [ "esp", "gp" ], "out" => [ "esp", "none" ] },
782   "outs"      => [ "stack:S", "M" ],
783 },
784
785 "LdTls" => {
786   "irn_flags" => "R",
787   "comment"   => "get the TLS base address",
788   "reg_req"   => { "out" => [ "gp" ] },
789 },
790
791
792
793 #-----------------------------------------------------------------------------#
794 #   _____ _____ ______    __ _             _                     _            #
795 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
796 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
797 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
798 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
799 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
800 #-----------------------------------------------------------------------------#
801
802 # commutative operations
803
804 "xAdd" => {
805   "irn_flags" => "R",
806   "comment"   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
807   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
808   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
809   "emit"      => '. adds%M %ia32_emit_binop /* SSE Add(%A3, %A4) -> %D1 */',
810   "outs"      => [ "res", "M" ],
811   "latency"   => 4,
812 },
813
814 "xMul" => {
815   "irn_flags" => "R",
816   "comment"   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
817   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
818   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
819   "emit"      => '. muls%M %ia32_emit_binop /* SSE Mul(%A3, %A4) -> %D1 */',
820   "outs"      => [ "res", "M" ],
821   "latency"   => 4,
822 },
823
824 "xMax" => {
825   "irn_flags" => "R",
826   "comment"   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
827   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
828   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
829   "emit"      => '. maxs%M %ia32_emit_binop /* SSE Max(%A3, %A4) -> %D1 */',
830   "outs"      => [ "res", "M" ],
831   "latency"   => 2,
832 },
833
834 "xMin" => {
835   "irn_flags" => "R",
836   "comment"   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
837   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
838   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
839   "emit"      => '. mins%M %ia32_emit_binop /* SSE Min(%A3, %A4) -> %D1 */',
840   "outs"      => [ "res", "M" ],
841   "latency"   => 2,
842 },
843
844 "xAnd" => {
845   "irn_flags" => "R",
846   "comment"   => "construct SSE And: And(a, b) = a AND b",
847   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
848   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
849   "emit"      => '. andp%M %ia32_emit_binop /* SSE And(%A3, %A4) -> %D1 */',
850   "outs"      => [ "res", "M" ],
851   "latency"   => 3,
852 },
853
854 "xOr" => {
855   "irn_flags" => "R",
856   "comment"   => "construct SSE Or: Or(a, b) = a OR b",
857   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
858   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
859   "emit"      => '. orp%M %ia32_emit_binop /* SSE Or(%A3, %A4) -> %D1 */',
860   "outs"      => [ "res", "M" ],
861 },
862
863 "xEor" => {
864   "irn_flags" => "R",
865   "comment"   => "construct SSE Eor: Eor(a, b) = a XOR b",
866   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
867   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
868   "emit"      => '. xorp%M %ia32_emit_binop /* SSE Xor(%A3, %A4) -> %D1 */',
869   "outs"      => [ "res", "M" ],
870   "latency"   => 3,
871 },
872
873 # not commutative operations
874
875 "xAndNot" => {
876   "irn_flags" => "R",
877   "comment"   => "construct SSE AndNot: AndNot(a, b) = a AND NOT b",
878   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
879   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
880   "emit"      => '. andnp%M %ia32_emit_binop /* SSE AndNot(%A3, %A4) -> %D1 */',
881   "outs"      => [ "res", "M" ],
882   "latency"   => 3,
883 },
884
885 "xSub" => {
886   "irn_flags" => "R",
887   "comment"   => "construct SSE Sub: Sub(a, b) = a - b",
888   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
889   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
890   "emit"      => '. subs%M %ia32_emit_binop /* SSE Sub(%A1, %A2) -> %D1 */',
891   "outs"      => [ "res", "M" ],
892   "latency"   => 4,
893 },
894
895 "xDiv" => {
896   "irn_flags" => "R",
897   "comment"   => "construct SSE Div: Div(a, b) = a / b",
898   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
899   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
900   "emit"      => '. divs%M %ia32_emit_binop /* SSE Div(%A1, %A2) -> %D1 */',
901   "outs"      => [ "res", "M" ],
902   "latency"   => 16,
903 },
904
905 # other operations
906
907 "xCmp" => {
908   "irn_flags" => "R",
909   "comment"   => "construct SSE Compare: Cmp(a, b) == a = a cmp b",
910   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
911   "outs"      => [ "res", "M" ],
912   "latency"   => 3,
913 },
914
915 "xCondJmp" => {
916   "op_flags"  => "L|X|Y",
917   "comment"   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
918   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
919   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "none", "none" ] },
920   "outs"      => [ "false", "true" ],
921   "latency"   => 5,
922 },
923
924 "xConst" => {
925   "op_flags"  => "c",
926   "irn_flags" => "R",
927   "comment"   => "represents a SSE constant",
928   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
929   "reg_req"   => { "in" => [ "none" ], "out" => [ "xmm" ] },
930   "emit"      => '. movs%M %D1, %C /* Load fConst into register */',
931   "latency"   => 2,
932 },
933
934 # Load / Store
935
936 "xLoad" => {
937   "op_flags"  => "L|F",
938   "state"     => "exc_pinned",
939   "comment"   => "construct SSE Load: Load(ptr, mem) = LD ptr",
940   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
941   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "xmm" ] },
942   "emit"      => '. movs%M %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */',
943   "outs"      => [ "res", "M" ],
944   "latency"   => 2,
945 },
946
947 "xStore" => {
948   "op_flags" => "L|F",
949   "state"    => "exc_pinned",
950   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
951   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
952   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ] },
953   "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */',
954   "outs"      => [ "M" ],
955   "latency"   => 2,
956 },
957
958 "xStoreSimple" => {
959   "op_flags" => "L|F",
960   "state"    => "exc_pinned",
961   "comment"  => "construct Store without index: Store(ptr, val, mem) = ST ptr,val",
962   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
963   "reg_req"  => { "in" => [ "gp", "xmm", "none" ] },
964   "emit"     => '. movs%M %ia32_emit_am, %S2 /* store XMM0 onto stack */',
965   "outs"      => [ "M" ],
966   "latency"   => 2,
967 },
968
969 "l_X87toSSE" => {
970   "op_flags" => "L|F",
971   "comment"  => "construct: transfer a value from x87 FPU into a SSE register",
972   "cmp_attr" => "  return 1;\n",
973   "arity"    => 3,
974 },
975
976 "l_SSEtoX87" => {
977   "op_flags" => "L|F",
978   "comment"  => "construct: transfer a value from SSE register to x87 FPU",
979   "cmp_attr" => "  return 1;\n",
980   "arity"    => 3,
981 },
982
983 "GetST0" => {
984   "op_flags" => "L|F",
985   "irn_flags" => "I",
986   "state"    => "exc_pinned",
987   "comment"  => "store ST0 onto stack",
988   "cmp_attr" => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
989   "reg_req"  => { "in" => [ "gp", "none" ] },
990   "emit"     => '. fstp %ia32_emit_am /* store ST0 onto stack */',
991   "outs"     => [ "M" ],
992   "latency"  => 4,
993 },
994
995 "SetST0" => {
996   "op_flags" => "L|F",
997   "irn_flags" => "I",
998   "state"    => "exc_pinned",
999   "comment"  => "load ST0 from stack",
1000   "cmp_attr" => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1001   "reg_req"  => { "in" => [ "gp", "none" ], "out" => [ "vf0", "none" ] },
1002   "emit"     => '. fld %ia32_emit_am /* load ST0 from stack */',
1003   "outs"     => [ "res", "M" ],
1004   "latency"  => 2,
1005 },
1006
1007 # CopyB
1008
1009 "CopyB" => {
1010   "op_flags" => "F|H",
1011   "state"    => "pinned",
1012   "comment"  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
1013   "reg_req"  => { "in" => [ "edi", "esi", "ecx", "none" ], "out" => [ "edi", "esi", "ecx", "none" ] },
1014   "outs"     => [ "DST", "SRC", "CNT", "M" ],
1015 },
1016
1017 "CopyB_i" => {
1018   "op_flags" => "F|H",
1019   "state"    => "pinned",
1020   "comment"  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
1021   "cmp_attr" => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1022   "reg_req"  => { "in" => [ "edi", "esi", "none" ], "out" => [  "edi", "esi", "none" ] },
1023   "outs"     => [ "DST", "SRC", "M" ],
1024 },
1025
1026 # Conversions
1027
1028 "Conv_I2I" => {
1029   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3", "none" ] },
1030   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1031   "comment"  => "construct Conv Int -> Int",
1032   "outs"     => [ "res", "M" ],
1033 },
1034
1035 "Conv_I2I8Bit" => {
1036   "reg_req"  => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ], "out" => [ "in_r3", "none" ] },
1037   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1038   "comment"  => "construct Conv Int -> Int",
1039   "outs"     => [ "res", "M" ],
1040 },
1041
1042 "Conv_I2FP" => {
1043   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "xmm", "none" ] },
1044   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1045   "comment"  => "construct Conv Int -> Floating Point",
1046   "outs"     => [ "res", "M" ],
1047   "latency"  => 10,
1048 },
1049
1050 "Conv_FP2I" => {
1051   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "gp", "none" ] },
1052   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1053   "comment"  => "construct Conv Floating Point -> Int",
1054   "outs"     => [ "res", "M" ],
1055   "latency"  => 10,
1056 },
1057
1058 "Conv_FP2FP" => {
1059   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "xmm", "none" ] },
1060   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1061   "comment"  => "construct Conv Floating Point -> Floating Point",
1062   "outs"     => [ "res", "M" ],
1063   "latency"  => 8,
1064 },
1065
1066 "CmpCMov" => {
1067   "irn_flags" => "R",
1068   "comment"   => "construct Conditional Move: CMov(sel, a, b) == sel ? a : b",
1069   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp" ], "out" => [ "in_r4" ] },
1070   "latency"   => 2,
1071 },
1072
1073 "PsiCondCMov" => {
1074   "irn_flags" => "R",
1075   "comment"   => "check if Psi condition tree evaluates to true and move result accordingly",
1076   "reg_req"   => { "in" => [ "gp", "gp", "gp" ], "out" => [ "in_r3" ] },
1077   "latency"   => 2,
1078 },
1079
1080 "xCmpCMov" => {
1081   "irn_flags" => "R",
1082   "comment"   => "construct Conditional Move: SSE Compare + int CMov ",
1083   "reg_req"   => { "in" => [ "xmm", "xmm", "gp", "gp" ], "out" => [ "in_r4" ] },
1084   "latency"   => 5,
1085 },
1086
1087 "vfCmpCMov" => {
1088   "irn_flags" => "R",
1089   "comment"   => "construct Conditional Move: x87 Compare + int CMov",
1090   "reg_req"   => { "in" => [ "vfp", "vfp", "gp", "gp" ], "out" => [ "in_r4" ] },
1091   "latency"   => 10,
1092 },
1093
1094 "CmpSet" => {
1095   "irn_flags" => "R",
1096   "comment"   => "construct Set: Set(sel) == sel ? 1 : 0",
1097   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1098   "outs"      => [ "res", "M" ],
1099   "latency"   => 2,
1100 },
1101
1102 "PsiCondSet" => {
1103   "irn_flags" => "R",
1104   "comment"   => "check if Psi condition tree evaluates to true and set result accordingly",
1105   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax ebx ecx edx" ] },
1106   "latency"   => 2,
1107 },
1108
1109 "xCmpSet" => {
1110   "irn_flags" => "R",
1111   "comment"   => "construct Set: SSE Compare + int Set",
1112   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1113   "outs"      => [ "res", "M" ],
1114   "latency"   => 5,
1115 },
1116
1117 "vfCmpSet" => {
1118   "irn_flags" => "R",
1119   "comment"   => "construct Set: x87 Compare + int Set",
1120   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1121   "outs"      => [ "res", "M" ],
1122   "latency"   => 10,
1123 },
1124
1125 "vfCMov" => {
1126   "irn_flags" => "R",
1127   "comment"   => "construct x87 Conditional Move: vfCMov(sel, a, b) = sel ? a : b",
1128   "reg_req"   => { "in" => [ "vfp", "vfp", "vfp", "vfp" ], "out" => [ "vfp" ] },
1129   "latency"   => 10,
1130 },
1131
1132 #----------------------------------------------------------#
1133 #        _      _               _    __ _             _    #
1134 #       (_)    | |             | |  / _| |           | |   #
1135 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1136 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1137 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1138 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1139 #                 | |                                      #
1140 #  _ __   ___   __| | ___  ___                             #
1141 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1142 # | | | | (_) | (_| |  __/\__ \                            #
1143 # |_| |_|\___/ \__,_|\___||___/                            #
1144 #----------------------------------------------------------#
1145
1146 "vfadd" => {
1147   "irn_flags" => "R",
1148   "comment"   => "virtual fp Add: Add(a, b) = Add(b, a) = a + b",
1149   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1150   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1151   "outs"      => [ "res", "M" ],
1152   "latency"   => 4,
1153 },
1154
1155 "vfmul" => {
1156   "irn_flags" => "R",
1157   "comment"   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1158   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1159   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1160   "outs"      => [ "res", "M" ],
1161   "latency"   => 4,
1162 },
1163
1164 "l_vfmul" => {
1165   "op_flags"  => "C",
1166   "cmp_attr"  => "  return 1;\n",
1167   "comment"   => "lowered virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1168   "arity"     => 2,
1169 },
1170
1171 "vfsub" => {
1172   "irn_flags" => "R",
1173   "comment"   => "virtual fp Sub: Sub(a, b) = a - b",
1174   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1175   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1176   "outs"      => [ "res", "M" ],
1177   "latency"   => 4,
1178 },
1179
1180 "l_vfsub" => {
1181   "cmp_attr"  => "  return 1;\n",
1182   "comment"   => "lowered virtual fp Sub: Sub(a, b) = a - b",
1183   "arity"     => 2,
1184 },
1185
1186 "vfdiv" => {
1187   "comment"   => "virtual fp Div: Div(a, b) = a / b",
1188   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1189   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1190   "outs"      => [ "res", "M" ],
1191   "latency"   => 20,
1192 },
1193
1194 "l_vfdiv" => {
1195   "cmp_attr"  => "  return 1;\n",
1196   "comment"   => "lowered virtual fp Div: Div(a, b) = a / b",
1197   "arity"     => 2,
1198 },
1199
1200 "vfabs" => {
1201   "irn_flags" => "R",
1202   "comment"   => "virtual fp Abs: Abs(a) = |a|",
1203   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1204   "latency"   => 2,
1205 },
1206
1207 "vfchs" => {
1208   "irn_flags" => "R",
1209   "comment"   => "virtual fp Chs: Chs(a) = -a",
1210   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1211   "latency"   => 2,
1212 },
1213
1214 "vfsin" => {
1215   "irn_flags" => "R",
1216   "comment"   => "virtual fp Sin: Sin(a) = sin(a)",
1217   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1218   "latency"   => 150,
1219 },
1220
1221 "vfcos" => {
1222   "irn_flags" => "R",
1223   "comment"   => "virtual fp Cos: Cos(a) = cos(a)",
1224   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1225   "latency"   => 150,
1226 },
1227
1228 "vfsqrt" => {
1229   "irn_flags" => "R",
1230   "comment"   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
1231   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1232   "latency"   => 30,
1233 },
1234
1235 # virtual Load and Store
1236
1237 "vfld" => {
1238   "op_flags"  => "L|F",
1239   "state"     => "exc_pinned",
1240   "comment"   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
1241   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1242   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
1243   "outs"      => [ "res", "M" ],
1244   "latency"   => 2,
1245 },
1246
1247 "vfst" => {
1248   "op_flags"  => "L|F",
1249   "state"     => "exc_pinned",
1250   "comment"   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
1251   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1252   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
1253   "outs"      => [ "M" ],
1254   "latency"   => 2,
1255 },
1256
1257 # Conversions
1258
1259 "vfild" => {
1260   "comment"   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1261   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1262   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
1263   "outs"      => [ "res", "M" ],
1264   "latency"   => 4,
1265 },
1266
1267 "l_vfild" => {
1268   "cmp_attr"  => "  return 1;\n",
1269   "comment"   => "lowered virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1270   "outs"      => [ "res", "M" ],
1271   "arity"     => 2,
1272 },
1273
1274 "vfist" => {
1275   "comment"   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1276   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1277   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
1278   "outs"      => [ "M" ],
1279   "latency"   => 4,
1280 },
1281
1282 "l_vfist" => {
1283   "cmp_attr"  => "  return 1;\n",
1284   "comment"   => "lowered virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1285   "outs"      => [ "M" ],
1286   "arity"     => 3,
1287 },
1288
1289
1290 # constants
1291
1292 "vfldz" => {
1293   "irn_flags" => "R",
1294   "comment"   => "virtual fp Load 0.0: Ld 0.0 -> reg",
1295   "reg_req"   => { "out" => [ "vfp" ] },
1296   "latency"   => 4,
1297 },
1298
1299 "vfld1" => {
1300   "irn_flags" => "R",
1301   "comment"   => "virtual fp Load 1.0: Ld 1.0 -> reg",
1302   "reg_req"   => { "out" => [ "vfp" ] },
1303   "latency"   => 4,
1304 },
1305
1306 "vfldpi" => {
1307   "irn_flags" => "R",
1308   "comment"   => "virtual fp Load pi: Ld pi -> reg",
1309   "reg_req"   => { "out" => [ "vfp" ] },
1310   "latency"   => 4,
1311 },
1312
1313 "vfldln2" => {
1314   "irn_flags" => "R",
1315   "comment"   => "virtual fp Load ln 2: Ld ln 2 -> reg",
1316   "reg_req"   => { "out" => [ "vfp" ] },
1317   "latency"   => 4,
1318 },
1319
1320 "vfldlg2" => {
1321   "irn_flags" => "R",
1322   "comment"   => "virtual fp Load lg 2: Ld lg 2 -> reg",
1323   "reg_req"   => { "out" => [ "vfp" ] },
1324   "latency"   => 4,
1325 },
1326
1327 "vfldl2t" => {
1328   "irn_flags" => "R",
1329   "comment"   => "virtual fp Load ld 10: Ld ld 10 -> reg",
1330   "reg_req"   => { "out" => [ "vfp" ] },
1331   "latency"   => 4,
1332 },
1333
1334 "vfldl2e" => {
1335   "irn_flags" => "R",
1336   "comment"   => "virtual fp Load ld e: Ld ld e -> reg",
1337   "reg_req"   => { "out" => [ "vfp" ] },
1338   "latency"   => 4,
1339 },
1340
1341 "vfConst" => {
1342   "op_flags"  => "c",
1343   "irn_flags" => "R",
1344   "init_attr" => "  set_ia32_ls_mode(res, mode);",
1345   "comment"   => "represents a virtual floating point constant",
1346   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1347   "reg_req"   => { "in" => [ "none" ], "out" => [ "vfp" ] },
1348   "latency"   => 3,
1349 },
1350
1351 # other
1352
1353 "vfCondJmp" => {
1354   "op_flags"  => "L|X|Y",
1355   "comment"   => "represents a virtual floating point compare",
1356   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1357   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "none", "none", "eax" ] },
1358   "outs"      => [ "false", "true", "temp_reg_eax" ],
1359   "latency"   => 10,
1360 },
1361
1362 #------------------------------------------------------------------------#
1363 #       ___ _____    __ _             _                     _            #
1364 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1365 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1366 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1367 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1368 #------------------------------------------------------------------------#
1369
1370 "fadd" => {
1371   "op_flags"  => "R",
1372   "rd_constructor" => "NONE",
1373   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1374   "reg_req"   => { },
1375   "emit"      => '. fadd %ia32_emit_x87_binop /* x87 fadd(%A3, %A4) -> %D1 */',
1376 },
1377
1378 "faddp" => {
1379   "op_flags"  => "R",
1380   "rd_constructor" => "NONE",
1381   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1382   "reg_req"   => { },
1383   "emit"      => '. faddp %ia32_emit_x87_binop /* x87 fadd(%A3, %A4) -> %D1 */',
1384 },
1385
1386 "fmul" => {
1387   "op_flags"  => "R",
1388   "rd_constructor" => "NONE",
1389   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1390   "reg_req"   => { },
1391   "emit"      => '. fmul %ia32_emit_x87_binop /* x87 fmul(%A3, %A4) -> %D1 */',
1392 },
1393
1394 "fmulp" => {
1395   "op_flags"  => "R",
1396   "rd_constructor" => "NONE",
1397   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1398   "reg_req"   => { },
1399   "emit"      => '. fmulp %ia32_emit_x87_binop /* x87 fmul(%A3, %A4) -> %D1 */',,
1400 },
1401
1402 "fsub" => {
1403   "op_flags"  => "R",
1404   "rd_constructor" => "NONE",
1405   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1406   "reg_req"   => { },
1407   "emit"      => '. fsub %ia32_emit_x87_binop /* x87 fsub(%A3, %A4) -> %D1 */',
1408 },
1409
1410 "fsubp" => {
1411   "op_flags"  => "R",
1412   "rd_constructor" => "NONE",
1413   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1414   "reg_req"   => { },
1415   "emit"      => '. fsubp %ia32_emit_x87_binop /* x87 fsub(%A3, %A4) -> %D1 */',
1416 },
1417
1418 "fsubr" => {
1419   "op_flags"  => "R",
1420   "rd_constructor" => "NONE",
1421   "irn_flags" => "R",
1422   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1423   "reg_req"   => { },
1424   "emit"      => '. fsubr %ia32_emit_x87_binop /* x87 fsubr(%A3, %A4) -> %D1 */',
1425 },
1426
1427 "fsubrp" => {
1428   "op_flags"  => "R",
1429   "rd_constructor" => "NONE",
1430   "irn_flags" => "R",
1431   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1432   "reg_req"   => { },
1433   "emit"      => '. fsubrp %ia32_emit_x87_binop /* x87 fsubr(%A3, %A4) -> %D1 */',
1434 },
1435
1436 "fdiv" => {
1437   "op_flags"  => "R",
1438   "rd_constructor" => "NONE",
1439   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1440   "reg_req"   => { },
1441   "emit"      => '. fdiv %ia32_emit_x87_binop /* x87 fdiv(%A3, %A4) -> %D1 */',
1442 },
1443
1444 "fdivp" => {
1445   "op_flags"  => "R",
1446   "rd_constructor" => "NONE",
1447   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1448   "reg_req"   => { },
1449   "emit"      => '. fdivp %ia32_emit_x87_binop /* x87 fdiv(%A3, %A4) -> %D1 */',
1450 },
1451
1452 "fdivr" => {
1453   "op_flags"  => "R",
1454   "rd_constructor" => "NONE",
1455   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1456   "reg_req"   => { },
1457   "emit"      => '. fdivr %ia32_emit_x87_binop /* x87 fdivr(%A3, %A4) -> %D1 */',
1458 },
1459
1460 "fdivrp" => {
1461   "op_flags"  => "R",
1462   "rd_constructor" => "NONE",
1463   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1464   "reg_req"   => { },
1465   "emit"      => '. fdivrp %ia32_emit_x87_binop /* x87 fdivr(%A3, %A4) -> %D1 */',
1466 },
1467
1468 "fabs" => {
1469   "op_flags"  => "R",
1470   "rd_constructor" => "NONE",
1471   "comment"   => "x87 fp Abs: Abs(a) = |a|",
1472   "reg_req"   => { },
1473   "emit"      => '. fabs /* x87 fabs(%A1) -> %D1 */',
1474 },
1475
1476 "fchs" => {
1477   "op_flags"  => "R",
1478   "rd_constructor" => "NONE",
1479   "comment"   => "x87 fp Chs: Chs(a) = -a",
1480   "reg_req"   => { },
1481   "emit"      => '. fchs /* x87 fchs(%A1) -> %D1 */',
1482 },
1483
1484 "fsin" => {
1485   "op_flags"  => "R",
1486   "rd_constructor" => "NONE",
1487   "comment"   => "x87 fp Sin: Sin(a) = sin(a)",
1488   "reg_req"   => { },
1489   "emit"      => '. fsin /* x87 sin(%A1) -> %D1 */',
1490 },
1491
1492 "fcos" => {
1493   "op_flags"  => "R",
1494   "rd_constructor" => "NONE",
1495   "comment"   => "x87 fp Cos: Cos(a) = cos(a)",
1496   "reg_req"   => { },
1497   "emit"      => '. fcos /* x87 cos(%A1) -> %D1 */',
1498 },
1499
1500 "fsqrt" => {
1501   "op_flags"  => "R",
1502   "rd_constructor" => "NONE",
1503   "comment"   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1504   "reg_req"   => { },
1505   "emit"      => '. fsqrt $ /* x87 sqrt(%A1) -> %D1 */',
1506 },
1507
1508 # x87 Load and Store
1509
1510 "fld" => {
1511   "rd_constructor" => "NONE",
1512   "op_flags"  => "R|L|F",
1513   "state"     => "exc_pinned",
1514   "comment"   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1515   "reg_req"   => { },
1516   "emit"      => '. fld %ia32_emit_am /* Load((%A1)) -> %D1 */',
1517 },
1518
1519 "fst" => {
1520   "rd_constructor" => "NONE",
1521   "op_flags"  => "R|L|F",
1522   "state"     => "exc_pinned",
1523   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1524   "reg_req"   => { },
1525   "emit"      => '. fst %ia32_emit_am /* Store(%A3) -> (%A1) */',
1526 },
1527
1528 "fstp" => {
1529   "rd_constructor" => "NONE",
1530   "op_flags"  => "R|L|F",
1531   "state"     => "exc_pinned",
1532   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1533   "reg_req"   => { },
1534   "emit"      => '. fstp %ia32_emit_am /* Store(%A3) -> (%A1) and pop */',
1535 },
1536
1537 # Conversions
1538
1539 "fild" => {
1540   "op_flags"  => "R",
1541   "rd_constructor" => "NONE",
1542   "comment"   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1543   "reg_req"   => { },
1544   "emit"      => '. fild %ia32_emit_am /* integer Load((%A1)) -> %D1 */',
1545 },
1546
1547 "fist" => {
1548   "op_flags"  => "R",
1549   "rd_constructor" => "NONE",
1550   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1551   "reg_req"   => { },
1552   "emit"      => '. fist %ia32_emit_am /* integer Store(%A3) -> (%A1) */',
1553 },
1554
1555 "fistp" => {
1556   "op_flags"  => "R",
1557   "rd_constructor" => "NONE",
1558   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1559   "reg_req"   => { },
1560   "emit"      => '. fistp %ia32_emit_am /* integer Store(%A3) -> (%A1) and pop */',
1561 },
1562
1563 # constants
1564
1565 "fldz" => {
1566   "op_flags"  => "R|c",
1567   "irn_flags"  => "R",
1568   "comment"   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1569   "reg_req"   => { },
1570   "emit"      => '. fldz /* x87 0.0 -> %D1 */',
1571 },
1572
1573 "fld1" => {
1574   "op_flags"  => "R|c",
1575   "irn_flags"  => "R",
1576   "comment"   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1577   "reg_req"   => { },
1578   "emit"      => '. fld1 /* x87 1.0 -> %D1 */',
1579 },
1580
1581 "fldpi" => {
1582   "op_flags"  => "R|c",
1583   "irn_flags"  => "R",
1584   "comment"   => "x87 fp Load pi: Ld pi -> reg",
1585   "reg_req"   => { },
1586   "emit"      => '. fldpi /* x87 pi -> %D1 */',
1587 },
1588
1589 "fldln2" => {
1590   "op_flags"  => "R|c",
1591   "irn_flags"  => "R",
1592   "comment"   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1593   "reg_req"   => { },
1594   "emit"      => '. fldln2 /* x87 ln(2) -> %D1 */',
1595 },
1596
1597 "fldlg2" => {
1598   "op_flags"  => "R|c",
1599   "irn_flags"  => "R",
1600   "comment"   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1601   "reg_req"   => { },
1602   "emit"      => '. fldlg2 /* x87 log(2) -> %D1 */',
1603 },
1604
1605 "fldl2t" => {
1606   "op_flags"  => "R|c",
1607   "irn_flags"  => "R",
1608   "comment"   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1609   "reg_req"   => { },
1610   "emit"      => '. fldll2t /* x87 ld(10) -> %D1 */',
1611 },
1612
1613 "fldl2e" => {
1614   "op_flags"  => "R|c",
1615   "irn_flags"  => "R",
1616   "comment"   => "x87 fp Load ld e: Ld ld e -> reg",
1617   "reg_req"   => { },
1618   "emit"      => '. fldl2e /* x87 ld(e) -> %D1 */',
1619 },
1620
1621 "fldConst" => {
1622   "op_flags"  => "R|c",
1623   "irn_flags" => "R",
1624   "rd_constructor" => "NONE",
1625   "comment"   => "represents a x87 constant",
1626   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1627   "reg_req"   => { "out" => [ "st" ] },
1628   "emit"      => '. fld %ia32_emit_adr /* Load fConst into register -> %D1 */',
1629 },
1630
1631 # fxch, fpush, fpop
1632 # Note that it is NEVER allowed to do CSE on these nodes
1633
1634 "fxch" => {
1635   "op_flags"  => "R|K",
1636   "comment"   => "x87 stack exchange",
1637   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1638   "cmp_attr"  => "  return 1;\n",
1639   "emit"      => '. fxch %X1 /* x87 swap %X1, %X3 */',
1640 },
1641
1642 "fpush" => {
1643   "op_flags"  => "R",
1644   "comment"   => "x87 stack push",
1645   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1646   "cmp_attr"  => "  return 1;\n",
1647   "emit"      => '. fld %X1 /* x87 push %X1 */',
1648 },
1649
1650 "fpop" => {
1651   "op_flags"  => "R|K",
1652   "comment"   => "x87 stack pop",
1653   "reg_req"   => { "out" => [ "st" ] },
1654   "cmp_attr"  => "  return 1;\n",
1655   "emit"      => '. fstp %X1 /* x87 pop %X1 */',
1656 },
1657
1658 # compare
1659
1660 "fcomJmp" => {
1661   "op_flags"  => "L|X|Y",
1662   "comment"   => "floating point compare",
1663   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1664   "reg_req"   => { },
1665 },
1666
1667 "fcompJmp" => {
1668   "op_flags"  => "L|X|Y",
1669   "comment"   => "floating point compare and pop",
1670   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1671   "reg_req"   => { },
1672 },
1673
1674 "fcomppJmp" => {
1675   "op_flags"  => "L|X|Y",
1676   "comment"   => "floating point compare and pop twice",
1677   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1678   "reg_req"   => { },
1679 },
1680
1681 "fcomrJmp" => {
1682   "op_flags"  => "L|X|Y",
1683   "comment"   => "floating point compare reverse",
1684   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1685   "reg_req"   => { },
1686 },
1687
1688 "fcomrpJmp" => {
1689   "op_flags"  => "L|X|Y",
1690   "comment"   => "floating point compare reverse and pop",
1691   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1692   "reg_req"   => { },
1693 },
1694
1695 "fcomrppJmp" => {
1696   "op_flags"  => "L|X|Y",
1697   "comment"   => "floating point compare reverse and pop twice",
1698   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1699   "reg_req"   => { },
1700 },
1701
1702 ); # end of %nodes