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