added xCmp node (SSE compare with result in register)
[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"
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 # },
37 #
38 # ... # (all nodes you need to describe)
39 #
40 # ); # close the %nodes initializer
41
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
44 #   N   irop_flag_none
45 #   L   irop_flag_labeled
46 #   C   irop_flag_commutative
47 #   X   irop_flag_cfopcode
48 #   I   irop_flag_ip_cfopcode
49 #   F   irop_flag_fragile
50 #   Y   irop_flag_forking
51 #   H   irop_flag_highlevel
52 #   c   irop_flag_constlike
53 #   K   irop_flag_keep
54 #
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
57 #   R   rematerializeable
58 #   N   not spillable
59 #   I   ignore for register allocation
60 #
61 # state: state of the operation, OPTIONAL (default is "floats")
62 #
63 # arity: arity of the operation, MUST NOT BE OMITTED
64 #
65 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
66 #        are always the first 3 arguments and are always autmatically
67 #        created)
68 #        If this key is missing the following arguments will be created:
69 #        for i = 1 .. arity: ir_node *op_i
70 #        ir_mode *mode
71 #
72 # outs:  if a node defines more than one output, the names of the projections
73 #        nodes having outs having automatically the mode mode_T
74 #
75 # comment: OPTIONAL comment for the node constructor
76 #
77 # rd_constructor: for every operation there will be a
78 #      new_rd_<arch>_<op-name> function with the arguments from above
79 #      which creates the ir_node corresponding to the defined operation
80 #      you can either put the complete source code of this function here
81 #
82 #      This key is OPTIONAL. If omitted, the following constructor will
83 #      be created:
84 #      if (!op_<arch>_<op-name>) assert(0);
85 #      for i = 1 to arity
86 #         set in[i] = op_i
87 #      done
88 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
89 #      return res
90 #
91 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
92
93 # register types:
94 #   0 - no special type
95 #   1 - caller save (register must be saved by the caller of a function)
96 #   2 - callee save (register must be saved by the called function)
97 #   4 - ignore (do not assign this register)
98 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
99 %reg_classes = (
100   "gp" => [
101             { "name" => "eax", "type" => 1 },
102             { "name" => "edx", "type" => 1 },
103             { "name" => "ebx", "type" => 2 },
104             { "name" => "ecx", "type" => 1 },
105             { "name" => "esi", "type" => 2 },
106             { "name" => "edi", "type" => 2 },
107 #            { "name" => "r11", "type" => 1 },
108 #            { "name" => "r12", "type" => 1 },
109 #            { "name" => "r13", "type" => 1 },
110 #            { "name" => "r14", "type" => 1 },
111 #            { "name" => "r15", "type" => 1 },
112 #            { "name" => "r16", "type" => 1 },
113 #            { "name" => "r17", "type" => 1 },
114 #            { "name" => "r18", "type" => 1 },
115 #            { "name" => "r19", "type" => 1 },
116 #            { "name" => "r20", "type" => 1 },
117 #            { "name" => "r21", "type" => 1 },
118 #            { "name" => "r22", "type" => 1 },
119 #            { "name" => "r23", "type" => 1 },
120 #            { "name" => "r24", "type" => 1 },
121 #            { "name" => "r25", "type" => 1 },
122 #            { "name" => "r26", "type" => 1 },
123 #            { "name" => "r27", "type" => 1 },
124 #            { "name" => "r28", "type" => 1 },
125 #            { "name" => "r29", "type" => 1 },
126 #            { "name" => "r30", "type" => 1 },
127 #            { "name" => "r31", "type" => 1 },
128 #            { "name" => "r32", "type" => 1 },
129             { "name" => "ebp", "type" => 2 },
130             { "name" => "esp", "type" => 4 },
131             { "name" => "gp_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
132             { "name" => "gp_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
133                         { "mode" => "mode_P" }
134           ],
135   "xmm" => [
136             { "name" => "xmm0", "type" => 1 },
137             { "name" => "xmm1", "type" => 1 },
138             { "name" => "xmm2", "type" => 1 },
139             { "name" => "xmm3", "type" => 1 },
140             { "name" => "xmm4", "type" => 1 },
141             { "name" => "xmm5", "type" => 1 },
142             { "name" => "xmm6", "type" => 1 },
143             { "name" => "xmm7", "type" => 1 },
144             { "name" => "xmm_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
145             { "name" => "xmm_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
146                         { "mode" => "mode_D" }
147           ],
148   "vfp" => [
149             { "name" => "vf0", "type" => 1 },
150             { "name" => "vf1", "type" => 1 },
151             { "name" => "vf2", "type" => 1 },
152             { "name" => "vf3", "type" => 1 },
153             { "name" => "vf4", "type" => 1 },
154             { "name" => "vf5", "type" => 1 },
155             { "name" => "vf6", "type" => 1 },
156             { "name" => "vf7", "type" => 1 },
157             { "name" => "vfp_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
158             { "name" => "vfp_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
159                         { "mode" => "mode_E" }
160           ],
161   "st" => [
162             { "name" => "st0", "type" => 1 },
163             { "name" => "st1", "type" => 1 },
164             { "name" => "st2", "type" => 1 },
165             { "name" => "st3", "type" => 1 },
166             { "name" => "st4", "type" => 1 },
167             { "name" => "st5", "type" => 1 },
168             { "name" => "st6", "type" => 1 },
169             { "name" => "st7", "type" => 1 },
170                         { "mode" => "mode_E" }
171           ]
172 ); # %reg_classes
173
174 #--------------------------------------------------#
175 #                        _                         #
176 #                       (_)                        #
177 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
178 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
179 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
180 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
181 #                                      | |         #
182 #                                      |_|         #
183 #--------------------------------------------------#
184
185 %operands = (
186 );
187
188 %nodes = (
189
190 #-----------------------------------------------------------------#
191 #  _       _                                         _            #
192 # (_)     | |                                       | |           #
193 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
194 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
195 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
196 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
197 #                   __/ |                                         #
198 #                  |___/                                          #
199 #-----------------------------------------------------------------#
200
201 # commutative operations
202
203 # NOTE:
204 # All nodes supporting Addressmode have 5 INs:
205 # 1 - base    r1 == NoReg in case of no AM or no base
206 # 2 - index   r2 == NoReg in case of no AM or no index
207 # 3 - op1     r3 == always present
208 # 4 - op2     r4 == NoReg in case of immediate operation
209 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
210
211 "Add" => {
212   "irn_flags" => "R",
213   "comment"   => "construct Add: Add(a, b) = Add(b, a) = a + b",
214   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
215   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
216   "emit"      => '. add %ia32_emit_binop /* Add(%A1, %A2) -> %D1 */',
217   "outs"      => [ "res", "M" ],
218 },
219
220 "Mul" => {
221   "irn_flags" => "R",
222   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
223   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
224   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
225   "emit"      => '. imul %ia32_emit_binop /* Mul(%A1, %A2) -> %D1 */',
226   "outs"      => [ "res", "M" ],
227 },
228
229 # Mulh is an exception from the 4 INs with AM because the target is always EAX:EDX
230 "Mulh" => {
231   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
232   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
233   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "eax in_r3", "edx in_r4" ] },
234   "emit"      => '. imul %ia32_emit_binop /* Mulh(%A1, %A2) -> %D1 */',
235   "outs"      => [ "EAX", "EDX", "M" ],
236 },
237
238 "And" => {
239   "irn_flags" => "R",
240   "comment"   => "construct And: And(a, b) = And(b, a) = a AND b",
241   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
242   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
243   "emit"      => '. and %ia32_emit_binop /* And(%A1, %A2) -> %D1 */',
244   "outs"      => [ "res", "M" ],
245 },
246
247 "Or" => {
248   "irn_flags" => "R",
249   "comment"   => "construct Or: Or(a, b) = Or(b, a) = a OR b",
250   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
251   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
252   "emit"      => '. or %ia32_emit_binop /* Or(%A1, %A2) -> %D1 */',
253   "outs"      => [ "res", "M" ],
254 },
255
256 "Eor" => {
257   "irn_flags" => "R",
258   "comment"   => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
259   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
260   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
261   "emit"      => '. xor %ia32_emit_binop /* Xor(%A1, %A2) -> %D1 */',
262   "outs"      => [ "res", "M" ],
263 },
264
265 "Max" => {
266   "irn_flags" => "R",
267   "comment"   => "construct Max: Max(a, b) = Max(b, a) = a > b ? a : b",
268   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
269   "emit"      =>
270 '2. cmp %S1, %S2 /* prepare Max (%S1 - %S2), (%A1, %A2) */
271   if (mode_is_signed(get_irn_mode(n))) {
272 4.  cmovl %D1, %S2 /* %S1 is less %S2 */
273   }
274   else {
275 4.  cmovb %D1, %S2 /* %S1 is below %S2 */
276   }
277 '
278 },
279
280 "Min" => {
281   "irn_flags" => "R",
282   "comment"   => "construct Min: Min(a, b) = Min(b, a) = a < b ? a : b",
283   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
284   "emit"      =>
285 '2. cmp %S1, %S2 /* prepare Min (%S1 - %S2), (%A1, %A2) */
286   if (mode_is_signed(get_irn_mode(n))) {
287 2.  cmovg %D1, %S2 /* %S1 is greater %S2 */
288   }
289   else {
290 2.  cmova %D1, %S2, %D1 /* %S1 is above %S2 */
291   }
292 '
293 },
294
295 "CMov" => {
296   "irn_flags" => "R",
297   "comment"   => "construct Conditional Move: CMov(sel, a, b) == sel ? a : b",
298   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp" ], "out" => [ "in_r4" ] }
299 },
300
301 "Set" => {
302   "irn_flags" => "R",
303   "comment"   => "construct Set: Set(sel) == sel ? 1 : 0",
304   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "eax ebx ecx edx" ] },
305 },
306
307 # not commutative operations
308
309 "Sub" => {
310   "irn_flags" => "R",
311   "comment"   => "construct Sub: Sub(a, b) = a - b",
312   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
313   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
314   "emit"      => '. sub %ia32_emit_binop /* Sub(%A1, %A2) -> %D1 */',
315   "outs"      => [ "res", "M" ],
316 },
317
318 "DivMod" => {
319   "op_flags"  => "F|L",
320   "state"     => "exc_pinned",
321   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "eax in_r1", "edx in_r3" ] },
322   "attr"      => "ia32_op_flavour_t dm_flav",
323   "init_attr" => "  attr->data.op_flav = dm_flav;",
324   "cmp_attr"  => "  return attr_a->data.op_flav != attr_b->data.op_flav;\n",
325   "emit"      =>
326 '  if (mode_is_signed(get_irn_mode(n))) {
327 4.  idiv %S2 /* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
328   }
329   else {
330 4.  div %S2 /* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
331   }
332 ',
333   "outs"      => [ "div_res", "mod_res", "M" ],
334 },
335
336 "Shl" => {
337   "irn_flags" => "R",
338   "comment"   => "construct Shl: Shl(a, b) = a << b",
339   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
340   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
341   "emit"      => '. shl %ia32_emit_binop /* Shl(%A1, %A2) -> %D1 */',
342   "outs"      => [ "res", "M" ],
343 },
344
345 "Shr" => {
346   "irn_flags" => "R",
347   "comment"   => "construct Shr: Shr(a, b) = a >> b",
348   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
349   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
350   "emit"      => '. shr %ia32_emit_binop /* Shr(%A1, %A2) -> %D1 */',
351   "outs"      => [ "res", "M" ],
352 },
353
354 "Shrs" => {
355   "irn_flags" => "R",
356   "comment"   => "construct Shrs: Shrs(a, b) = a >> b",
357   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
358   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
359   "emit"      => '. sar %ia32_emit_binop /* Shrs(%A1, %A2) -> %D1 */',
360   "outs"      => [ "res", "M" ],
361 },
362
363 "RotR" => {
364   "irn_flags" => "R",
365   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
366   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
367   "reg_req"     => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
368   "emit"        => '. ror %ia32_emit_binop /* RotR(%A1, %A2) -> %D1 */',
369   "outs"      => [ "res", "M" ],
370 },
371
372 "RotL" => {
373   "irn_flags" => "R",
374   "comment"   => "construct RotL: RotL(a, b) = a ROTL b",
375   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
376   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
377   "emit"      => '. rol %ia32_emit_binop /* RotL(%A1, %A2) -> %D1 */',
378   "outs"      => [ "res", "M" ],
379 },
380
381 # unary operations
382
383 "Minus" => {
384   "irn_flags" => "R",
385   "comment"   => "construct Minus: Minus(a) = -a",
386   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
387   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
388   "emit"      => '. neg %ia32_emit_unop /* Neg(%A1) -> %D1, (%A1) */',
389   "outs"      => [ "res", "M" ],
390 },
391
392 "Inc" => {
393   "irn_flags" => "R",
394   "comment"   => "construct Increment: Inc(a) = a++",
395   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
396   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
397   "emit"      => '. inc %ia32_emit_unop /* Inc(%S1) -> %D1, (%A1) */',
398   "outs"      => [ "res", "M" ],
399 },
400
401 "Dec" => {
402   "irn_flags" => "R",
403   "comment"   => "construct Decrement: Dec(a) = a--",
404   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
405   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
406   "emit"      => '. dec %ia32_emit_unop /* Dec(%S1) -> %D1, (%A1) */',
407   "outs"      => [ "res", "M" ],
408 },
409
410 "Not" => {
411   "irn_flags" => "R",
412   "comment"   => "construct Not: Not(a) = !a",
413   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
414   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
415   "emit"      => '. not %ia32_emit_unop /* Not(%S1) -> %D1, (%A1) */',
416   "outs"      => [ "res", "M" ],
417 },
418
419 # other operations
420
421 "CondJmp" => {
422   "op_flags"  => "L|X|Y",
423   "comment"   => "construct conditional jump: CMP A, B && JMPxx LABEL",
424   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
425   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ] },
426   "outs"      => [ "false", "true" ],
427 },
428
429 "TestJmp" => {
430   "op_flags"  => "L|X|Y",
431   "comment"   => "construct conditional jump: TEST A, B && JMPxx LABEL",
432   "reg_req"  => { "in" => [ "gp", "gp" ] },
433   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
434   "outs"      => [ "false", "true" ],
435 },
436
437 "CJmpAM" => {
438   "op_flags"  => "L|X|Y",
439   "comment"   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
440   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
441   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "none", "none" ] },
442   "outs"      => [ "false", "true" ],
443 },
444
445 "CJmp" => {
446   "op_flags"  => "L|X|Y",
447   "comment"   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
448   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
449   "reg_req"   => { "in" => [ "gp", "gp" ] },
450 },
451
452 "SwitchJmp" => {
453   "op_flags"  => "L|X|Y",
454   "comment"   => "construct switch",
455   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
456   "reg_req"   => { "in" => [ "gp" ], "out" => [ "none" ] },
457 },
458
459 "Const" => {
460   "op_flags"  => "c",
461   "irn_flags" => "R",
462   "comment"   => "represents an integer constant",
463   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
464   "reg_req"   => { "in" => [ "none" ], "out" => [ "gp" ] },
465 },
466
467 "Cdq" => {
468   "irn_flags" => "R",
469   "comment"   => "construct CDQ: sign extend EAX -> EDX:EAX",
470   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax in_r1", "edx" ] },
471   "emit"      => '. cdq /* sign extend EAX -> EDX:EAX, (%A1) */',
472   "outs"      => [ "EAX", "EDX" ],
473 },
474
475 # Load / Store
476
477 "Load" => {
478   "op_flags"  => "L|F",
479   "irn_flags" => "R",
480   "state"     => "exc_pinned",
481   "comment"   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
482   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
483   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
484   "emit"      =>
485 '  if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
486 4.   mov%Mx %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
487   }
488   else {
489 4.   mov %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
490   }
491 ',
492   "outs"      => [ "res", "M" ],
493 },
494
495 "Store" => {
496   "op_flags"  => "L|F",
497   "state"     => "exc_pinned",
498   "comment"   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
499   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
500   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ] },
501   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
502   "outs"      => [ "M" ],
503 },
504
505 "Store8Bit" => {
506   "op_flags"  => "L|F",
507   "state"     => "exc_pinned",
508   "comment"   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
509   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
510   "reg_req"   => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ] },
511   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
512   "outs"      => [ "M" ],
513 },
514
515 "Lea" => {
516   "irn_flags" => "R",
517   "comment"   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
518   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
519   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
520   "emit"      => '. lea %D1, %ia32_emit_am /* LEA(%A1, %A2) */'
521 },
522
523 "Push" => {
524   "comment"   => "push a gp register on the stack",
525   "reg_req"   => { "in" => [ "esp", "gp", "none" ], "out" => [ "esp" ] },
526   "emit"      => '
527 if (get_ia32_id_cnst(n)) {
528         if (get_ia32_immop_type(n) == ia32_ImmConst) {
529 . push %C /* Push(%A2) */
530         } else {
531 . push OFFSET FLAT:%C /* Push(%A2) */
532         }
533 }
534 else {
535 . push %S2 /* Push(%A2) */
536 }
537 ',
538   "outs"      => [ "stack", "M" ],
539 },
540
541 "Pop" => {
542   "comment"   => "pop a gp register from the stack",
543   "reg_req"   => { "in" => [ "esp", "none" ], "out" => [ "gp", "esp" ] },
544   "emit"      => '. pop %D1 /* Pop -> %D1 */',
545   "outs"      => [ "res", "stack", "M" ],
546 },
547
548 "Enter" => {
549   "comment"   => "create stack frame",
550   "reg_req"   => { "in" => [ "esp" ], "out" => [ "ebp", "esp" ] },
551   "emit"      => '. enter /* Enter */',
552   "outs"      => [ "frame", "stack", "M" ],
553 },
554
555 "Leave" => {
556   "comment"   => "destroy stack frame",
557   "reg_req"   => { "in" => [ "esp", "ebp" ], "out" => [ "ebp", "esp" ] },
558   "emit"      => '. leave /* Leave */',
559   "outs"      => [ "frame", "stack", "M" ],
560 },
561
562 #-----------------------------------------------------------------------------#
563 #   _____ _____ ______    __ _             _                     _            #
564 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
565 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
566 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
567 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
568 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
569 #-----------------------------------------------------------------------------#
570
571 # commutative operations
572
573 "xAdd" => {
574   "irn_flags" => "R",
575   "comment"   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
576   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
577   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
578   "emit"      => '. adds%M %ia32_emit_binop /* SSE Add(%A3, %A4) -> %D1 */',
579   "outs"      => [ "res", "M" ],
580 },
581
582 "xMul" => {
583   "irn_flags" => "R",
584   "comment"   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
585   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
586   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
587   "emit"      => '. muls%M %ia32_emit_binop /* SSE Mul(%A3, %A4) -> %D1 */',
588   "outs"      => [ "res", "M" ],
589 },
590
591 "xMax" => {
592   "irn_flags" => "R",
593   "comment"   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
594   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
595   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
596   "emit"      => '. maxs%M %ia32_emit_binop /* SSE Max(%A3, %A4) -> %D1 */',
597   "outs"      => [ "res", "M" ],
598 },
599
600 "xMin" => {
601   "irn_flags" => "R",
602   "comment"   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
603   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
604   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
605   "emit"      => '. mins%M %ia32_emit_binop /* SSE Min(%A3, %A4) -> %D1 */',
606   "outs"      => [ "res", "M" ],
607 },
608
609 "xAnd" => {
610   "irn_flags" => "R",
611   "comment"   => "construct SSE And: And(a, b) = a AND b",
612   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
613   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
614   "emit"      => '. andp%M %ia32_emit_binop /* SSE And(%A3, %A4) -> %D1 */',
615   "outs"      => [ "res", "M" ],
616 },
617
618 "xOr" => {
619   "irn_flags" => "R",
620   "comment"   => "construct SSE Or: Or(a, b) = a OR b",
621   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
622   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
623   "emit"      => '. orp%M %ia32_emit_binop /* SSE Or(%A3, %A4) -> %D1 */',
624   "outs"      => [ "res", "M" ],
625 },
626
627 "xEor" => {
628   "irn_flags" => "R",
629   "comment"   => "construct SSE Eor: Eor(a, b) = a XOR b",
630   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
631   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
632   "emit"      => '. xorp%M %ia32_emit_binop /* SSE Xor(%A3, %A4) -> %D1 */',
633   "outs"      => [ "res", "M" ],
634 },
635
636 # not commutative operations
637
638 "xAndNot" => {
639   "irn_flags" => "R",
640   "comment"   => "construct SSE AndNot: AndNot(a, b) = a AND NOT b",
641   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
642   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
643   "emit"      => '. andnp%M %ia32_emit_binop /* SSE AndNot(%A3, %A4) -> %D1 */',
644   "outs"      => [ "res", "M" ],
645 },
646
647 "xSub" => {
648   "irn_flags" => "R",
649   "comment"   => "construct SSE Sub: Sub(a, b) = a - b",
650   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
651   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
652   "emit"      => '. subs%M %ia32_emit_binop /* SSE Sub(%A1, %A2) -> %D1 */',
653   "outs"      => [ "res", "M" ],
654 },
655
656 "xDiv" => {
657   "irn_flags" => "R",
658   "comment"   => "construct SSE Div: Div(a, b) = a / b",
659   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
660   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
661   "emit"      => '. divs%M %ia32_emit_binop /* SSE Div(%A1, %A2) -> %D1 */',
662   "outs"      => [ "res", "M" ],
663 },
664
665 # other operations
666
667 "xCmp" => {
668   "irn_flags" => "R",
669   "comment"   => "construct SSE Compare: Cmp(a, b) == a = a cmp b",
670   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
671   "outs"      => [ "res", "M" ],
672 },
673
674 "xCondJmp" => {
675   "op_flags"  => "L|X|Y",
676   "comment"   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
677   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
678   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "none", "none" ] },
679   "outs"      => [ "false", "true" ],
680 },
681
682 "xConst" => {
683   "op_flags"  => "c",
684   "irn_flags" => "R",
685   "comment"   => "represents a SSE constant",
686   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
687   "reg_req"   => { "in" => [ "none" ], "out" => [ "xmm" ] },
688   "emit"      => '. movs%M %D1, %C /* Load fConst into register */',
689 },
690
691 # Load / Store
692
693 "xLoad" => {
694   "op_flags"  => "L|F",
695   "irn_flags" => "R",
696   "state"     => "exc_pinned",
697   "comment"   => "construct SSE Load: Load(ptr, mem) = LD ptr",
698   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
699   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "xmm" ] },
700   "emit"      => '. movs%M %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */',
701   "outs"      => [ "res", "M" ],
702 },
703
704 "xStore" => {
705   "op_flags" => "L|F",
706   "state"    => "exc_pinned",
707   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
708   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
709   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ] },
710   "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */',
711   "outs"      => [ "M" ],
712 },
713
714 # CopyB
715
716 "CopyB" => {
717   "op_flags" => "F|H",
718   "state"    => "pinned",
719   "comment"  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
720   "reg_req"  => { "in" => [ "edi", "esi", "ecx", "none" ], "out" => [ "none" ] },
721 },
722
723 "CopyB_i" => {
724   "op_flags" => "F|H",
725   "state"    => "pinned",
726   "comment"  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
727   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
728   "reg_req"  => { "in" => [ "edi", "esi", "none" ], "out" => [ "none" ] },
729 },
730
731 # Conversions
732
733 "Conv_I2I" => {
734   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3", "none" ] },
735   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
736   "comment"  => "construct Conv Int -> Int",
737   "outs"      => [ "res", "M" ],
738 },
739
740 "Conv_I2I8Bit" => {
741   "reg_req"  => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ], "out" => [ "in_r3", "none" ] },
742   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
743   "comment"  => "construct Conv Int -> Int",
744   "outs"      => [ "res", "M" ],
745 },
746
747 "Conv_I2FP" => {
748   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "xmm", "none" ] },
749   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
750   "comment"  => "construct Conv Int -> Floating Point",
751   "outs"      => [ "res", "M" ],
752 },
753
754 "Conv_FP2I" => {
755   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "gp", "none" ] },
756   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
757   "comment"  => "construct Conv Floating Point -> Int",
758   "outs"      => [ "res", "M" ],
759 },
760
761 "Conv_FP2FP" => {
762   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "xmm", "none" ] },
763   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
764   "comment"  => "construct Conv Floating Point -> Floating Point",
765   "outs"      => [ "res", "M" ],
766 },
767
768 #----------------------------------------------------------#
769 #        _      _               _    __ _             _    #
770 #       (_)    | |             | |  / _| |           | |   #
771 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
772 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
773 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
774 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
775 #                 | |                                      #
776 #  _ __   ___   __| | ___  ___                             #
777 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
778 # | | | | (_) | (_| |  __/\__ \                            #
779 # |_| |_|\___/ \__,_|\___||___/                            #
780 #----------------------------------------------------------#
781
782 "vfadd" => {
783   "irn_flags" => "R",
784   "comment"   => "virtual fp Add: Add(a, b) = Add(b, a) = a + b",
785   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
786   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
787   "outs"      => [ "res", "M" ],
788 },
789
790 "vfmul" => {
791   "irn_flags" => "R",
792   "comment"   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a + b",
793   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
794   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
795   "outs"      => [ "res", "M" ],
796 },
797
798 "vfsub" => {
799   "irn_flags" => "R",
800   "comment"   => "virtual fp Sub: Sub(a, b) = a - b",
801   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
802   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
803   "outs"      => [ "res", "M" ],
804 },
805
806 "vfdiv" => {
807   "comment"   => "virtual fp Div: Div(a, b) = a / b",
808   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
809   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
810   "outs"      => [ "res", "M" ],
811 },
812
813 "vfabs" => {
814   "irn_flags" => "R",
815   "comment"   => "virtual fp Abs: Abs(a) = |a|",
816   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
817 },
818
819 "vfchs" => {
820   "irn_flags" => "R",
821   "comment"   => "virtual fp Chs: Chs(a) = -a",
822   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
823 },
824
825 "vfsin" => {
826   "irn_flags" => "R",
827   "comment"   => "virtual fp Sin: Sin(a) = sin(a)",
828   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
829 },
830
831 "vfcos" => {
832   "irn_flags" => "R",
833   "comment"   => "virtual fp Cos: Cos(a) = cos(a)",
834   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
835 },
836
837 "vfsqrt" => {
838   "irn_flags" => "R",
839   "comment"   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
840   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
841 },
842
843 # virtual Load and Store
844
845 "vfld" => {
846   "op_flags"  => "L|F",
847   "irn_flags" => "R",
848   "state"     => "exc_pinned",
849   "comment"   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
850   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
851   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
852   "outs"      => [ "res", "M" ],
853 },
854
855 "vfst" => {
856   "op_flags"  => "L|F",
857   "state"     => "exc_pinned",
858   "comment"   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
859   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
860   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
861   "outs"      => [ "M" ],
862 },
863
864 # Conversions
865
866 "vfild" => {
867   "irn_flags" => "R",
868   "comment"   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
869   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
870   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
871   "outs"      => [ "res", "M" ],
872 },
873
874 "vfist" => {
875   "comment"   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
876   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
877   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
878   "outs"      => [ "M" ],
879 },
880
881 # constants
882
883 "vfldz" => {
884   "irn_flags" => "R",
885   "comment"   => "virtual fp Load 0.0: Ld 0.0 -> reg",
886   "reg_req"   => { "out" => [ "vfp" ] },
887 },
888
889 "vfld1" => {
890   "irn_flags" => "R",
891   "comment"   => "virtual fp Load 1.0: Ld 1.0 -> reg",
892   "reg_req"   => { "out" => [ "vfp" ] },
893 },
894
895 "vfldpi" => {
896   "irn_flags" => "R",
897   "comment"   => "virtual fp Load pi: Ld pi -> reg",
898   "reg_req"   => { "out" => [ "vfp" ] },
899 },
900
901 "vfldln2" => {
902   "irn_flags" => "R",
903   "comment"   => "virtual fp Load ln 2: Ld ln 2 -> reg",
904   "reg_req"   => { "out" => [ "vfp" ] },
905 },
906
907 "vfldlg2" => {
908   "irn_flags" => "R",
909   "comment"   => "virtual fp Load lg 2: Ld lg 2 -> reg",
910   "reg_req"   => { "out" => [ "vfp" ] },
911 },
912
913 "vfldl2t" => {
914   "irn_flags" => "R",
915   "comment"   => "virtual fp Load ld 10: Ld ld 10 -> reg",
916   "reg_req"   => { "out" => [ "vfp" ] },
917 },
918
919 "vfldl2e" => {
920   "irn_flags" => "R",
921   "comment"   => "virtual fp Load ld e: Ld ld e -> reg",
922   "reg_req"   => { "out" => [ "vfp" ] },
923 },
924
925 "vfConst" => {
926   "op_flags"  => "c",
927   "irn_flags" => "R",
928   "init_attr" => "  set_ia32_ls_mode(res, mode);",
929   "comment"   => "represents a virtual floating point constant",
930   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
931   "reg_req"   => { "in" => [ "none" ], "out" => [ "vfp" ] },
932 },
933
934 # other
935
936 "vfCondJmp" => {
937   "op_flags"  => "L|X|Y",
938   "comment"   => "represents a virtual floating point compare",
939   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
940   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "none", "none", "eax" ] },
941   "outs"      => [ "false", "true", "temp_reg_eax" ],
942 },
943
944 #------------------------------------------------------------------------#
945 #       ___ _____    __ _             _                     _            #
946 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
947 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
948 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
949 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
950 #------------------------------------------------------------------------#
951
952 "fadd" => {
953   "op_flags"  => "R",
954   "rd_constructor" => "NONE",
955   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
956   "reg_req"   => { },
957   "emit"      => '. fadd %ia32_emit_x87_binop /* x87 fadd(%A1, %A2) -> %D1 */',
958 },
959
960 "faddp" => {
961   "op_flags"  => "R",
962   "rd_constructor" => "NONE",
963   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
964   "reg_req"   => { },
965   "emit"      => '. faddp %ia32_emit_x87_binop /* x87 fadd(%A1, %A2) -> %D1 */',
966 },
967
968 "fmul" => {
969   "op_flags"  => "R",
970   "rd_constructor" => "NONE",
971   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
972   "reg_req"   => { },
973   "emit"      => '. fmul %ia32_emit_x87_binop /* x87 fmul(%A1, %A2) -> %D1 */',
974 },
975
976 "fmulp" => {
977   "op_flags"  => "R",
978   "rd_constructor" => "NONE",
979   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
980   "reg_req"   => { },
981   "emit"      => '. fmulp %ia32_emit_x87_binop /* x87 fmul(%A1, %A2) -> %D1 */',,
982 },
983
984 "fsub" => {
985   "op_flags"  => "R",
986   "rd_constructor" => "NONE",
987   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
988   "reg_req"   => { },
989   "emit"      => '. fsub %ia32_emit_x87_binop /* x87 fsub(%A1, %A2) -> %D1 */',
990 },
991
992 "fsubp" => {
993   "op_flags"  => "R",
994   "rd_constructor" => "NONE",
995   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
996   "reg_req"   => { },
997   "emit"      => '. fsubp %ia32_emit_x87_binop /* x87 fsub(%A1, %A2) -> %D1 */',
998 },
999
1000 "fsubr" => {
1001   "op_flags"  => "R",
1002   "rd_constructor" => "NONE",
1003   "irn_flags" => "R",
1004   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1005   "reg_req"   => { },
1006   "emit"      => '. fsubr %ia32_emit_x87_binop /* x87 fsubr(%A1, %A2) -> %D1 */',
1007 },
1008
1009 "fsubrp" => {
1010   "op_flags"  => "R",
1011   "rd_constructor" => "NONE",
1012   "irn_flags" => "R",
1013   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1014   "reg_req"   => { },
1015   "emit"      => '. fsubrp %ia32_emit_x87_binop /* x87 fsubr(%A1, %A2) -> %D1 */',
1016 },
1017
1018 "fdiv" => {
1019   "op_flags"  => "R",
1020   "rd_constructor" => "NONE",
1021   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1022   "reg_req"   => { },
1023   "emit"      => '. fdiv %ia32_emit_x87_binop /* x87 fdiv(%A1, %A2) -> %D1 */',
1024 },
1025
1026 "fdivp" => {
1027   "op_flags"  => "R",
1028   "rd_constructor" => "NONE",
1029   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1030   "reg_req"   => { },
1031   "emit"      => '. fdivp %ia32_emit_x87_binop /* x87 fdiv(%A1, %A2) -> %D1 */',
1032 },
1033
1034 "fdivr" => {
1035   "op_flags"  => "R",
1036   "rd_constructor" => "NONE",
1037   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1038   "reg_req"   => { },
1039   "emit"      => '. fdivr %ia32_emit_x87_binop /* x87 fdivr(%A1, %A2) -> %D1 */',
1040 },
1041
1042 "fdivrp" => {
1043   "op_flags"  => "R",
1044   "rd_constructor" => "NONE",
1045   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1046   "reg_req"   => { },
1047   "emit"      => '. fdivrp %ia32_emit_x87_binop /* x87 fdivr(%A1, %A2) -> %D1 */',
1048 },
1049
1050 "fabs" => {
1051   "op_flags"  => "R",
1052   "rd_constructor" => "NONE",
1053   "comment"   => "x87 fp Abs: Abs(a) = |a|",
1054   "reg_req"   => { },
1055   "emit"      => '. fabs /* x87 fabs(%S1) -> %D1 */',
1056 },
1057
1058 "fchs" => {
1059   "op_flags"  => "R",
1060   "rd_constructor" => "NONE",
1061   "comment"   => "x87 fp Chs: Chs(a) = -a",
1062   "reg_req"   => { },
1063   "emit"      => '. fchs /* x87 fchs(%S1) -> %D1 */',
1064 },
1065
1066 "fsin" => {
1067   "op_flags"  => "R",
1068   "rd_constructor" => "NONE",
1069   "comment"   => "x87 fp Sin: Sin(a) = sin(a)",
1070   "reg_req"   => { },
1071   "emit"      => '. fsin /* x87 sin(%S1) -> %D1 */',
1072 },
1073
1074 "fcos" => {
1075   "op_flags"  => "R",
1076   "rd_constructor" => "NONE",
1077   "comment"   => "x87 fp Cos: Cos(a) = cos(a)",
1078   "reg_req"   => { },
1079   "emit"      => '. fcos /* x87 cos(%S1) -> %D1 */',
1080 },
1081
1082 "fsqrt" => {
1083   "op_flags"  => "R",
1084   "rd_constructor" => "NONE",
1085   "comment"   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1086   "reg_req"   => { },
1087   "emit"      => '. fsqrt $ /* x87 sqrt(%S1) -> %D1 */',
1088 },
1089
1090 # x87 Load and Store
1091
1092 "fld" => {
1093   "rd_constructor" => "NONE",
1094   "op_flags"  => "R|L|F",
1095   "state"     => "exc_pinned",
1096   "comment"   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1097   "reg_req"   => { },
1098   "emit"      => '. fld %ia32_emit_am /* Load((%A1)) -> %D1 */',
1099 },
1100
1101 "fst" => {
1102   "rd_constructor" => "NONE",
1103   "op_flags"  => "R|L|F",
1104   "state"     => "exc_pinned",
1105   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1106   "reg_req"   => { },
1107   "emit"      => '. fst %ia32_emit_am /* Store(%A3) -> (%A1) */',
1108 },
1109
1110 "fstp" => {
1111   "rd_constructor" => "NONE",
1112   "op_flags"  => "R|L|F",
1113   "state"     => "exc_pinned",
1114   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1115   "reg_req"   => { },
1116   "emit"      => '. fstp %ia32_emit_am /* Store(%A3) -> (%A1) and pop */',
1117 },
1118
1119 # Conversions
1120
1121 "fild" => {
1122   "op_flags"  => "R",
1123   "irn_flags" => "R",
1124   "rd_constructor" => "NONE",
1125   "comment"   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1126   "reg_req"   => { },
1127   "emit"      => '. fild %ia32_emit_am /* integer Load((%A1)) -> %D1 */',
1128 },
1129
1130 "fist" => {
1131   "op_flags"  => "R",
1132   "rd_constructor" => "NONE",
1133   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1134   "reg_req"   => { },
1135   "emit"      => '. fist %ia32_emit_am /* integer Store(%A3) -> (%A1) */',
1136 },
1137
1138 "fistp" => {
1139   "op_flags"  => "R",
1140   "rd_constructor" => "NONE",
1141   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1142   "reg_req"   => { },
1143   "emit"      => '. fistp %ia32_emit_am /* integer Store(%A3) -> (%A1) and pop */',
1144 },
1145
1146 # constants
1147
1148 "fldz" => {
1149   "op_flags"  => "R",
1150   "rd_constructor" => "NONE",
1151   "comment"   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1152   "reg_req"   => { },
1153   "emit"      => '. fldz /* x87 0.0 -> %D1 */',
1154 },
1155
1156 "fld1" => {
1157   "op_flags"  => "R",
1158   "rd_constructor" => "NONE",
1159   "comment"   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1160   "reg_req"   => { },
1161   "emit"      => '. fld1 /* x87 1.0 -> %D1 */',
1162 },
1163
1164 "fldpi" => {
1165   "op_flags"  => "R",
1166   "rd_constructor" => "NONE",
1167   "comment"   => "x87 fp Load pi: Ld pi -> reg",
1168   "reg_req"   => { },
1169   "emit"      => '. fldpi /* x87 pi -> %D1 */',
1170 },
1171
1172 "fldln2" => {
1173   "op_flags"  => "R",
1174   "rd_constructor" => "NONE",
1175   "comment"   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1176   "reg_req"   => { },
1177   "emit"      => '. fldln2 /* x87 ln(2) -> %D1 */',
1178 },
1179
1180 "fldlg2" => {
1181   "op_flags"  => "R",
1182   "rd_constructor" => "NONE",
1183   "comment"   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1184   "reg_req"   => { },
1185   "emit"      => '. fldlg2 /* x87 log(2) -> %D1 */',
1186 },
1187
1188 "fldl2t" => {
1189   "op_flags"  => "R",
1190   "rd_constructor" => "NONE",
1191   "comment"   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1192   "reg_req"   => { },
1193   "emit"      => '. fldll2t /* x87 ld(10) -> %D1 */',
1194 },
1195
1196 "fldl2e" => {
1197   "op_flags"  => "R",
1198   "rd_constructor" => "NONE",
1199   "comment"   => "x87 fp Load ld e: Ld ld e -> reg",
1200   "reg_req"   => { },
1201   "emit"      => '. fldl2e /* x87 ld(e) -> %D1 */',
1202 },
1203
1204 "fldConst" => {
1205   "op_flags"  => "R|c",
1206   "irn_flags" => "R",
1207   "rd_constructor" => "NONE",
1208   "comment"   => "represents a x87 constant",
1209   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1210   "reg_req"   => { "out" => [ "st" ] },
1211   "emit"      => '. fld %ia32_emit_adr /* Load fConst into register -> %D1 */',
1212 },
1213
1214 # fxch, fpush, fpop
1215 # Note that it is NEVER allowed to do CSE on these nodes
1216
1217 "fxch" => {
1218   "op_flags"  => "R|K",
1219   "comment"   => "x87 stack exchange",
1220   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1221   "cmp_attr"  => "  return 1;\n",
1222   "emit"      => '. fxch %X1 /* x87 swap %X1, %X3 */',
1223 },
1224
1225 "fpush" => {
1226   "op_flags"  => "R",
1227   "comment"   => "x87 stack push",
1228   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1229   "cmp_attr"  => "  return 1;\n",
1230   "emit"      => '. fld %X1 /* x87 push %X1 */',
1231 },
1232
1233 "fpop" => {
1234   "op_flags"  => "R|K",
1235   "comment"   => "x87 stack pop",
1236   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1237   "cmp_attr"  => "  return 1;\n",
1238   "emit"      => '. fstp %X1 /* x87 pop %X1 */',
1239 },
1240
1241 # compare
1242
1243 "fcomJmp" => {
1244   "op_flags"  => "L|X|Y",
1245   "comment"   => "floating point compare",
1246   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1247   "reg_req"   => { },
1248 },
1249
1250 "fcompJmp" => {
1251   "op_flags"  => "L|X|Y",
1252   "comment"   => "floating point compare and pop",
1253   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1254   "reg_req"   => { },
1255 },
1256
1257 "fcomppJmp" => {
1258   "op_flags"  => "L|X|Y",
1259   "comment"   => "floating point compare and pop twice",
1260   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1261   "reg_req"   => { },
1262 },
1263
1264 "fcomrJmp" => {
1265   "op_flags"  => "L|X|Y",
1266   "comment"   => "floating point compare reverse",
1267   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1268   "reg_req"   => { },
1269 },
1270
1271 "fcomrpJmp" => {
1272   "op_flags"  => "L|X|Y",
1273   "comment"   => "floating point compare reverse and pop",
1274   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1275   "reg_req"   => { },
1276 },
1277
1278 "fcomrppJmp" => {
1279   "op_flags"  => "L|X|Y",
1280   "comment"   => "floating point compare reverse and pop twice",
1281   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1282   "reg_req"   => { },
1283 },
1284
1285 ); # end of %nodes