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