0bd0fcea57550e72102121a25ba14a217b1dda54
[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 "xCmpCMov" => {
302   "irn_flags" => "R",
303   "comment"   => "construct Conditional Move: SSE Compare + int CMov ",
304   "reg_req"   => { "in" => [ "xmm", "xmm", "gp", "gp" ], "out" => [ "in_r4" ] }
305 },
306
307 "vfCmpCMov" => {
308   "irn_flags" => "R",
309   "comment"   => "construct Conditional Move: x87 Compare + int CMov",
310   "reg_req"   => { "in" => [ "vfp", "vfp", "gp", "gp" ], "out" => [ "in_r4" ] }
311 },
312
313 "Set" => {
314   "irn_flags" => "R",
315   "comment"   => "construct Set: Set(sel) == sel ? 1 : 0",
316   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "eax ebx ecx edx" ] },
317 },
318
319 "xCmpSet" => {
320   "irn_flags" => "R",
321   "comment"   => "construct Set: SSE Compare + int Set",
322   "reg_req"   => { "in" => [ "xmm", "xmm" ], "out" => [ "eax ebx ecx edx" ] },
323 },
324
325 "vfCmpSet" => {
326   "irn_flags" => "R",
327   "comment"   => "construct Set: x87 Compare + int Set",
328   "reg_req"   => { "in" => [ "vfp", "vfp" ], "out" => [ "eax ebx ecx edx" ] },
329 },
330
331 # not commutative operations
332
333 "Sub" => {
334   "irn_flags" => "R",
335   "comment"   => "construct Sub: Sub(a, b) = a - b",
336   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
337   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
338   "emit"      => '. sub %ia32_emit_binop /* Sub(%A1, %A2) -> %D1 */',
339   "outs"      => [ "res", "M" ],
340 },
341
342 "DivMod" => {
343   "op_flags"  => "F|L",
344   "state"     => "exc_pinned",
345   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "eax in_r1", "edx in_r3" ] },
346   "attr"      => "ia32_op_flavour_t dm_flav",
347   "init_attr" => "  attr->data.op_flav = dm_flav;",
348   "cmp_attr"  => "  return attr_a->data.op_flav != attr_b->data.op_flav;\n",
349   "emit"      =>
350 '  if (mode_is_signed(get_irn_mode(n))) {
351 4.  idiv %S2 /* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
352   }
353   else {
354 4.  div %S2 /* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
355   }
356 ',
357   "outs"      => [ "div_res", "mod_res", "M" ],
358 },
359
360 "Shl" => {
361   "irn_flags" => "R",
362   "comment"   => "construct Shl: Shl(a, b) = a << b",
363   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
364   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
365   "emit"      => '. shl %ia32_emit_binop /* Shl(%A1, %A2) -> %D1 */',
366   "outs"      => [ "res", "M" ],
367 },
368
369 "Shr" => {
370   "irn_flags" => "R",
371   "comment"   => "construct Shr: Shr(a, b) = a >> b",
372   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
373   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
374   "emit"      => '. shr %ia32_emit_binop /* Shr(%A1, %A2) -> %D1 */',
375   "outs"      => [ "res", "M" ],
376 },
377
378 "Shrs" => {
379   "irn_flags" => "R",
380   "comment"   => "construct Shrs: Shrs(a, b) = a >> b",
381   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
382   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
383   "emit"      => '. sar %ia32_emit_binop /* Shrs(%A1, %A2) -> %D1 */',
384   "outs"      => [ "res", "M" ],
385 },
386
387 "RotR" => {
388   "irn_flags" => "R",
389   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
390   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
391   "reg_req"     => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
392   "emit"        => '. ror %ia32_emit_binop /* RotR(%A1, %A2) -> %D1 */',
393   "outs"      => [ "res", "M" ],
394 },
395
396 "RotL" => {
397   "irn_flags" => "R",
398   "comment"   => "construct RotL: RotL(a, b) = a ROTL b",
399   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
400   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
401   "emit"      => '. rol %ia32_emit_binop /* RotL(%A1, %A2) -> %D1 */',
402   "outs"      => [ "res", "M" ],
403 },
404
405 # unary operations
406
407 "Minus" => {
408   "irn_flags" => "R",
409   "comment"   => "construct Minus: Minus(a) = -a",
410   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
411   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
412   "emit"      => '. neg %ia32_emit_unop /* Neg(%A1) -> %D1, (%A1) */',
413   "outs"      => [ "res", "M" ],
414 },
415
416 "Inc" => {
417   "irn_flags" => "R",
418   "comment"   => "construct Increment: Inc(a) = a++",
419   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
420   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
421   "emit"      => '. inc %ia32_emit_unop /* Inc(%S1) -> %D1, (%A1) */',
422   "outs"      => [ "res", "M" ],
423 },
424
425 "Dec" => {
426   "irn_flags" => "R",
427   "comment"   => "construct Decrement: Dec(a) = a--",
428   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
429   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
430   "emit"      => '. dec %ia32_emit_unop /* Dec(%S1) -> %D1, (%A1) */',
431   "outs"      => [ "res", "M" ],
432 },
433
434 "Not" => {
435   "irn_flags" => "R",
436   "comment"   => "construct Not: Not(a) = !a",
437   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
438   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
439   "emit"      => '. not %ia32_emit_unop /* Not(%S1) -> %D1, (%A1) */',
440   "outs"      => [ "res", "M" ],
441 },
442
443 # other operations
444
445 "CondJmp" => {
446   "op_flags"  => "L|X|Y",
447   "comment"   => "construct conditional jump: CMP A, B && JMPxx LABEL",
448   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
449   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ] },
450   "outs"      => [ "false", "true" ],
451 },
452
453 "TestJmp" => {
454   "op_flags"  => "L|X|Y",
455   "comment"   => "construct conditional jump: TEST A, B && JMPxx LABEL",
456   "reg_req"  => { "in" => [ "gp", "gp" ] },
457   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
458   "outs"      => [ "false", "true" ],
459 },
460
461 "CJmpAM" => {
462   "op_flags"  => "L|X|Y",
463   "comment"   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
464   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
465   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "none", "none" ] },
466   "outs"      => [ "false", "true" ],
467 },
468
469 "CJmp" => {
470   "op_flags"  => "L|X|Y",
471   "comment"   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
472   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
473   "reg_req"   => { "in" => [ "gp", "gp" ] },
474 },
475
476 "SwitchJmp" => {
477   "op_flags"  => "L|X|Y",
478   "comment"   => "construct switch",
479   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
480   "reg_req"   => { "in" => [ "gp" ], "out" => [ "none" ] },
481 },
482
483 "Const" => {
484   "op_flags"  => "c",
485   "irn_flags" => "R",
486   "comment"   => "represents an integer constant",
487   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
488   "reg_req"   => { "in" => [ "none" ], "out" => [ "gp" ] },
489 },
490
491 "Cdq" => {
492   "irn_flags" => "R",
493   "comment"   => "construct CDQ: sign extend EAX -> EDX:EAX",
494   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax in_r1", "edx" ] },
495   "emit"      => '. cdq /* sign extend EAX -> EDX:EAX, (%A1) */',
496   "outs"      => [ "EAX", "EDX" ],
497 },
498
499 # Load / Store
500
501 "Load" => {
502   "op_flags"  => "L|F",
503   "irn_flags" => "R",
504   "state"     => "exc_pinned",
505   "comment"   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
506   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
507   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
508   "emit"      =>
509 '  if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
510 4.   mov%Mx %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
511   }
512   else {
513 4.   mov %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
514   }
515 ',
516   "outs"      => [ "res", "M" ],
517 },
518
519 "Store" => {
520   "op_flags"  => "L|F",
521   "state"     => "exc_pinned",
522   "comment"   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
523   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
524   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ] },
525   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
526   "outs"      => [ "M" ],
527 },
528
529 "Store8Bit" => {
530   "op_flags"  => "L|F",
531   "state"     => "exc_pinned",
532   "comment"   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
533   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
534   "reg_req"   => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ] },
535   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
536   "outs"      => [ "M" ],
537 },
538
539 "Lea" => {
540   "irn_flags" => "R",
541   "comment"   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
542   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
543   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
544   "emit"      => '. lea %D1, %ia32_emit_am /* LEA(%A1, %A2) */'
545 },
546
547 "Push" => {
548   "comment"   => "push a gp register on the stack",
549   "reg_req"   => { "in" => [ "esp", "gp", "none" ], "out" => [ "esp" ] },
550   "emit"      => '
551 if (get_ia32_id_cnst(n)) {
552         if (get_ia32_immop_type(n) == ia32_ImmConst) {
553 . push %C /* Push(%A2) */
554         } else {
555 . push OFFSET FLAT:%C /* Push(%A2) */
556         }
557 }
558 else {
559 . push %S2 /* Push(%A2) */
560 }
561 ',
562   "outs"      => [ "stack", "M" ],
563 },
564
565 "Pop" => {
566   "comment"   => "pop a gp register from the stack",
567   "reg_req"   => { "in" => [ "esp", "none" ], "out" => [ "gp", "esp" ] },
568   "emit"      => '. pop %D1 /* Pop -> %D1 */',
569   "outs"      => [ "res", "stack", "M" ],
570 },
571
572 "Enter" => {
573   "comment"   => "create stack frame",
574   "reg_req"   => { "in" => [ "esp" ], "out" => [ "ebp", "esp" ] },
575   "emit"      => '. enter /* Enter */',
576   "outs"      => [ "frame", "stack", "M" ],
577 },
578
579 "Leave" => {
580   "comment"   => "destroy stack frame",
581   "reg_req"   => { "in" => [ "esp", "ebp" ], "out" => [ "ebp", "esp" ] },
582   "emit"      => '. leave /* Leave */',
583   "outs"      => [ "frame", "stack", "M" ],
584 },
585
586 #-----------------------------------------------------------------------------#
587 #   _____ _____ ______    __ _             _                     _            #
588 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
589 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
590 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
591 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
592 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
593 #-----------------------------------------------------------------------------#
594
595 # commutative operations
596
597 "xAdd" => {
598   "irn_flags" => "R",
599   "comment"   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
600   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
601   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
602   "emit"      => '. adds%M %ia32_emit_binop /* SSE Add(%A3, %A4) -> %D1 */',
603   "outs"      => [ "res", "M" ],
604 },
605
606 "xMul" => {
607   "irn_flags" => "R",
608   "comment"   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
609   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
610   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
611   "emit"      => '. muls%M %ia32_emit_binop /* SSE Mul(%A3, %A4) -> %D1 */',
612   "outs"      => [ "res", "M" ],
613 },
614
615 "xMax" => {
616   "irn_flags" => "R",
617   "comment"   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
618   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
619   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
620   "emit"      => '. maxs%M %ia32_emit_binop /* SSE Max(%A3, %A4) -> %D1 */',
621   "outs"      => [ "res", "M" ],
622 },
623
624 "xMin" => {
625   "irn_flags" => "R",
626   "comment"   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
627   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
628   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
629   "emit"      => '. mins%M %ia32_emit_binop /* SSE Min(%A3, %A4) -> %D1 */',
630   "outs"      => [ "res", "M" ],
631 },
632
633 "xAnd" => {
634   "irn_flags" => "R",
635   "comment"   => "construct SSE And: And(a, b) = a AND b",
636   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
637   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
638   "emit"      => '. andp%M %ia32_emit_binop /* SSE And(%A3, %A4) -> %D1 */',
639   "outs"      => [ "res", "M" ],
640 },
641
642 "xOr" => {
643   "irn_flags" => "R",
644   "comment"   => "construct SSE Or: Or(a, b) = a OR b",
645   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
646   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
647   "emit"      => '. orp%M %ia32_emit_binop /* SSE Or(%A3, %A4) -> %D1 */',
648   "outs"      => [ "res", "M" ],
649 },
650
651 "xEor" => {
652   "irn_flags" => "R",
653   "comment"   => "construct SSE Eor: Eor(a, b) = a XOR b",
654   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
655   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
656   "emit"      => '. xorp%M %ia32_emit_binop /* SSE Xor(%A3, %A4) -> %D1 */',
657   "outs"      => [ "res", "M" ],
658 },
659
660 # not commutative operations
661
662 "xAndNot" => {
663   "irn_flags" => "R",
664   "comment"   => "construct SSE AndNot: AndNot(a, b) = a AND NOT b",
665   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
666   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
667   "emit"      => '. andnp%M %ia32_emit_binop /* SSE AndNot(%A3, %A4) -> %D1 */',
668   "outs"      => [ "res", "M" ],
669 },
670
671 "xSub" => {
672   "irn_flags" => "R",
673   "comment"   => "construct SSE Sub: Sub(a, b) = a - b",
674   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
675   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
676   "emit"      => '. subs%M %ia32_emit_binop /* SSE Sub(%A1, %A2) -> %D1 */',
677   "outs"      => [ "res", "M" ],
678 },
679
680 "xDiv" => {
681   "irn_flags" => "R",
682   "comment"   => "construct SSE Div: Div(a, b) = a / b",
683   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
684   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
685   "emit"      => '. divs%M %ia32_emit_binop /* SSE Div(%A1, %A2) -> %D1 */',
686   "outs"      => [ "res", "M" ],
687 },
688
689 # other operations
690
691 "xCmp" => {
692   "irn_flags" => "R",
693   "comment"   => "construct SSE Compare: Cmp(a, b) == a = a cmp b",
694   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
695   "outs"      => [ "res", "M" ],
696 },
697
698 "xCondJmp" => {
699   "op_flags"  => "L|X|Y",
700   "comment"   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
701   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
702   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "none", "none" ] },
703   "outs"      => [ "false", "true" ],
704 },
705
706 "xConst" => {
707   "op_flags"  => "c",
708   "irn_flags" => "R",
709   "comment"   => "represents a SSE constant",
710   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
711   "reg_req"   => { "in" => [ "none" ], "out" => [ "xmm" ] },
712   "emit"      => '. movs%M %D1, %C /* Load fConst into register */',
713 },
714
715 # Load / Store
716
717 "xLoad" => {
718   "op_flags"  => "L|F",
719   "irn_flags" => "R",
720   "state"     => "exc_pinned",
721   "comment"   => "construct SSE Load: Load(ptr, mem) = LD ptr",
722   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
723   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "xmm" ] },
724   "emit"      => '. movs%M %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */',
725   "outs"      => [ "res", "M" ],
726 },
727
728 "xStore" => {
729   "op_flags" => "L|F",
730   "state"    => "exc_pinned",
731   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
732   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
733   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ] },
734   "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */',
735   "outs"      => [ "M" ],
736 },
737
738 # CopyB
739
740 "CopyB" => {
741   "op_flags" => "F|H",
742   "state"    => "pinned",
743   "comment"  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
744   "reg_req"  => { "in" => [ "edi", "esi", "ecx", "none" ], "out" => [ "none" ] },
745 },
746
747 "CopyB_i" => {
748   "op_flags" => "F|H",
749   "state"    => "pinned",
750   "comment"  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
751   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
752   "reg_req"  => { "in" => [ "edi", "esi", "none" ], "out" => [ "none" ] },
753 },
754
755 # Conversions
756
757 "Conv_I2I" => {
758   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3", "none" ] },
759   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
760   "comment"  => "construct Conv Int -> Int",
761   "outs"      => [ "res", "M" ],
762 },
763
764 "Conv_I2I8Bit" => {
765   "reg_req"  => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ], "out" => [ "in_r3", "none" ] },
766   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
767   "comment"  => "construct Conv Int -> Int",
768   "outs"      => [ "res", "M" ],
769 },
770
771 "Conv_I2FP" => {
772   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "xmm", "none" ] },
773   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
774   "comment"  => "construct Conv Int -> Floating Point",
775   "outs"      => [ "res", "M" ],
776 },
777
778 "Conv_FP2I" => {
779   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "gp", "none" ] },
780   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
781   "comment"  => "construct Conv Floating Point -> Int",
782   "outs"      => [ "res", "M" ],
783 },
784
785 "Conv_FP2FP" => {
786   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "xmm", "none" ] },
787   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
788   "comment"  => "construct Conv Floating Point -> Floating Point",
789   "outs"      => [ "res", "M" ],
790 },
791
792 #----------------------------------------------------------#
793 #        _      _               _    __ _             _    #
794 #       (_)    | |             | |  / _| |           | |   #
795 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
796 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
797 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
798 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
799 #                 | |                                      #
800 #  _ __   ___   __| | ___  ___                             #
801 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
802 # | | | | (_) | (_| |  __/\__ \                            #
803 # |_| |_|\___/ \__,_|\___||___/                            #
804 #----------------------------------------------------------#
805
806 "vfadd" => {
807   "irn_flags" => "R",
808   "comment"   => "virtual fp 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", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
811   "outs"      => [ "res", "M" ],
812 },
813
814 "vfmul" => {
815   "irn_flags" => "R",
816   "comment"   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a + b",
817   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
818   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
819   "outs"      => [ "res", "M" ],
820 },
821
822 "vfsub" => {
823   "irn_flags" => "R",
824   "comment"   => "virtual fp Sub: Sub(a, b) = a - b",
825   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
826   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
827   "outs"      => [ "res", "M" ],
828 },
829
830 "vfdiv" => {
831   "comment"   => "virtual fp Div: Div(a, b) = a / b",
832   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
833   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
834   "outs"      => [ "res", "M" ],
835 },
836
837 "vfabs" => {
838   "irn_flags" => "R",
839   "comment"   => "virtual fp Abs: Abs(a) = |a|",
840   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
841 },
842
843 "vfchs" => {
844   "irn_flags" => "R",
845   "comment"   => "virtual fp Chs: Chs(a) = -a",
846   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
847 },
848
849 "vfsin" => {
850   "irn_flags" => "R",
851   "comment"   => "virtual fp Sin: Sin(a) = sin(a)",
852   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
853 },
854
855 "vfcos" => {
856   "irn_flags" => "R",
857   "comment"   => "virtual fp Cos: Cos(a) = cos(a)",
858   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
859 },
860
861 "vfsqrt" => {
862   "irn_flags" => "R",
863   "comment"   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
864   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
865 },
866
867 # virtual Load and Store
868
869 "vfld" => {
870   "op_flags"  => "L|F",
871   "irn_flags" => "R",
872   "state"     => "exc_pinned",
873   "comment"   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
874   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
875   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
876   "outs"      => [ "res", "M" ],
877 },
878
879 "vfst" => {
880   "op_flags"  => "L|F",
881   "state"     => "exc_pinned",
882   "comment"   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
883   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
884   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
885   "outs"      => [ "M" ],
886 },
887
888 # Conversions
889
890 "vfild" => {
891   "irn_flags" => "R",
892   "comment"   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
893   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
894   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
895   "outs"      => [ "res", "M" ],
896 },
897
898 "vfist" => {
899   "comment"   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
900   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
901   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
902   "outs"      => [ "M" ],
903 },
904
905 # constants
906
907 "vfldz" => {
908   "irn_flags" => "R",
909   "comment"   => "virtual fp Load 0.0: Ld 0.0 -> reg",
910   "reg_req"   => { "out" => [ "vfp" ] },
911 },
912
913 "vfld1" => {
914   "irn_flags" => "R",
915   "comment"   => "virtual fp Load 1.0: Ld 1.0 -> reg",
916   "reg_req"   => { "out" => [ "vfp" ] },
917 },
918
919 "vfldpi" => {
920   "irn_flags" => "R",
921   "comment"   => "virtual fp Load pi: Ld pi -> reg",
922   "reg_req"   => { "out" => [ "vfp" ] },
923 },
924
925 "vfldln2" => {
926   "irn_flags" => "R",
927   "comment"   => "virtual fp Load ln 2: Ld ln 2 -> reg",
928   "reg_req"   => { "out" => [ "vfp" ] },
929 },
930
931 "vfldlg2" => {
932   "irn_flags" => "R",
933   "comment"   => "virtual fp Load lg 2: Ld lg 2 -> reg",
934   "reg_req"   => { "out" => [ "vfp" ] },
935 },
936
937 "vfldl2t" => {
938   "irn_flags" => "R",
939   "comment"   => "virtual fp Load ld 10: Ld ld 10 -> reg",
940   "reg_req"   => { "out" => [ "vfp" ] },
941 },
942
943 "vfldl2e" => {
944   "irn_flags" => "R",
945   "comment"   => "virtual fp Load ld e: Ld ld e -> reg",
946   "reg_req"   => { "out" => [ "vfp" ] },
947 },
948
949 "vfConst" => {
950   "op_flags"  => "c",
951   "irn_flags" => "R",
952   "init_attr" => "  set_ia32_ls_mode(res, mode);",
953   "comment"   => "represents a virtual floating point constant",
954   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
955   "reg_req"   => { "in" => [ "none" ], "out" => [ "vfp" ] },
956 },
957
958 # other
959
960 "vfCondJmp" => {
961   "op_flags"  => "L|X|Y",
962   "comment"   => "represents a virtual floating point compare",
963   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
964   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "none", "none", "eax" ] },
965   "outs"      => [ "false", "true", "temp_reg_eax" ],
966 },
967
968 #------------------------------------------------------------------------#
969 #       ___ _____    __ _             _                     _            #
970 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
971 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
972 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
973 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
974 #------------------------------------------------------------------------#
975
976 "fadd" => {
977   "op_flags"  => "R",
978   "rd_constructor" => "NONE",
979   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
980   "reg_req"   => { },
981   "emit"      => '. fadd %ia32_emit_x87_binop /* x87 fadd(%A1, %A2) -> %D1 */',
982 },
983
984 "faddp" => {
985   "op_flags"  => "R",
986   "rd_constructor" => "NONE",
987   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
988   "reg_req"   => { },
989   "emit"      => '. faddp %ia32_emit_x87_binop /* x87 fadd(%A1, %A2) -> %D1 */',
990 },
991
992 "fmul" => {
993   "op_flags"  => "R",
994   "rd_constructor" => "NONE",
995   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
996   "reg_req"   => { },
997   "emit"      => '. fmul %ia32_emit_x87_binop /* x87 fmul(%A1, %A2) -> %D1 */',
998 },
999
1000 "fmulp" => {
1001   "op_flags"  => "R",
1002   "rd_constructor" => "NONE",
1003   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1004   "reg_req"   => { },
1005   "emit"      => '. fmulp %ia32_emit_x87_binop /* x87 fmul(%A1, %A2) -> %D1 */',,
1006 },
1007
1008 "fsub" => {
1009   "op_flags"  => "R",
1010   "rd_constructor" => "NONE",
1011   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1012   "reg_req"   => { },
1013   "emit"      => '. fsub %ia32_emit_x87_binop /* x87 fsub(%A1, %A2) -> %D1 */',
1014 },
1015
1016 "fsubp" => {
1017   "op_flags"  => "R",
1018   "rd_constructor" => "NONE",
1019   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1020   "reg_req"   => { },
1021   "emit"      => '. fsubp %ia32_emit_x87_binop /* x87 fsub(%A1, %A2) -> %D1 */',
1022 },
1023
1024 "fsubr" => {
1025   "op_flags"  => "R",
1026   "rd_constructor" => "NONE",
1027   "irn_flags" => "R",
1028   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1029   "reg_req"   => { },
1030   "emit"      => '. fsubr %ia32_emit_x87_binop /* x87 fsubr(%A1, %A2) -> %D1 */',
1031 },
1032
1033 "fsubrp" => {
1034   "op_flags"  => "R",
1035   "rd_constructor" => "NONE",
1036   "irn_flags" => "R",
1037   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1038   "reg_req"   => { },
1039   "emit"      => '. fsubrp %ia32_emit_x87_binop /* x87 fsubr(%A1, %A2) -> %D1 */',
1040 },
1041
1042 "fdiv" => {
1043   "op_flags"  => "R",
1044   "rd_constructor" => "NONE",
1045   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1046   "reg_req"   => { },
1047   "emit"      => '. fdiv %ia32_emit_x87_binop /* x87 fdiv(%A1, %A2) -> %D1 */',
1048 },
1049
1050 "fdivp" => {
1051   "op_flags"  => "R",
1052   "rd_constructor" => "NONE",
1053   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1054   "reg_req"   => { },
1055   "emit"      => '. fdivp %ia32_emit_x87_binop /* x87 fdiv(%A1, %A2) -> %D1 */',
1056 },
1057
1058 "fdivr" => {
1059   "op_flags"  => "R",
1060   "rd_constructor" => "NONE",
1061   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1062   "reg_req"   => { },
1063   "emit"      => '. fdivr %ia32_emit_x87_binop /* x87 fdivr(%A1, %A2) -> %D1 */',
1064 },
1065
1066 "fdivrp" => {
1067   "op_flags"  => "R",
1068   "rd_constructor" => "NONE",
1069   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1070   "reg_req"   => { },
1071   "emit"      => '. fdivrp %ia32_emit_x87_binop /* x87 fdivr(%A1, %A2) -> %D1 */',
1072 },
1073
1074 "fabs" => {
1075   "op_flags"  => "R",
1076   "rd_constructor" => "NONE",
1077   "comment"   => "x87 fp Abs: Abs(a) = |a|",
1078   "reg_req"   => { },
1079   "emit"      => '. fabs /* x87 fabs(%S1) -> %D1 */',
1080 },
1081
1082 "fchs" => {
1083   "op_flags"  => "R",
1084   "rd_constructor" => "NONE",
1085   "comment"   => "x87 fp Chs: Chs(a) = -a",
1086   "reg_req"   => { },
1087   "emit"      => '. fchs /* x87 fchs(%S1) -> %D1 */',
1088 },
1089
1090 "fsin" => {
1091   "op_flags"  => "R",
1092   "rd_constructor" => "NONE",
1093   "comment"   => "x87 fp Sin: Sin(a) = sin(a)",
1094   "reg_req"   => { },
1095   "emit"      => '. fsin /* x87 sin(%S1) -> %D1 */',
1096 },
1097
1098 "fcos" => {
1099   "op_flags"  => "R",
1100   "rd_constructor" => "NONE",
1101   "comment"   => "x87 fp Cos: Cos(a) = cos(a)",
1102   "reg_req"   => { },
1103   "emit"      => '. fcos /* x87 cos(%S1) -> %D1 */',
1104 },
1105
1106 "fsqrt" => {
1107   "op_flags"  => "R",
1108   "rd_constructor" => "NONE",
1109   "comment"   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1110   "reg_req"   => { },
1111   "emit"      => '. fsqrt $ /* x87 sqrt(%S1) -> %D1 */',
1112 },
1113
1114 # x87 Load and Store
1115
1116 "fld" => {
1117   "rd_constructor" => "NONE",
1118   "op_flags"  => "R|L|F",
1119   "state"     => "exc_pinned",
1120   "comment"   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1121   "reg_req"   => { },
1122   "emit"      => '. fld %ia32_emit_am /* Load((%A1)) -> %D1 */',
1123 },
1124
1125 "fst" => {
1126   "rd_constructor" => "NONE",
1127   "op_flags"  => "R|L|F",
1128   "state"     => "exc_pinned",
1129   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1130   "reg_req"   => { },
1131   "emit"      => '. fst %ia32_emit_am /* Store(%A3) -> (%A1) */',
1132 },
1133
1134 "fstp" => {
1135   "rd_constructor" => "NONE",
1136   "op_flags"  => "R|L|F",
1137   "state"     => "exc_pinned",
1138   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1139   "reg_req"   => { },
1140   "emit"      => '. fstp %ia32_emit_am /* Store(%A3) -> (%A1) and pop */',
1141 },
1142
1143 # Conversions
1144
1145 "fild" => {
1146   "op_flags"  => "R",
1147   "irn_flags" => "R",
1148   "rd_constructor" => "NONE",
1149   "comment"   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1150   "reg_req"   => { },
1151   "emit"      => '. fild %ia32_emit_am /* integer Load((%A1)) -> %D1 */',
1152 },
1153
1154 "fist" => {
1155   "op_flags"  => "R",
1156   "rd_constructor" => "NONE",
1157   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1158   "reg_req"   => { },
1159   "emit"      => '. fist %ia32_emit_am /* integer Store(%A3) -> (%A1) */',
1160 },
1161
1162 "fistp" => {
1163   "op_flags"  => "R",
1164   "rd_constructor" => "NONE",
1165   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1166   "reg_req"   => { },
1167   "emit"      => '. fistp %ia32_emit_am /* integer Store(%A3) -> (%A1) and pop */',
1168 },
1169
1170 # constants
1171
1172 "fldz" => {
1173   "op_flags"  => "R",
1174   "rd_constructor" => "NONE",
1175   "comment"   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1176   "reg_req"   => { },
1177   "emit"      => '. fldz /* x87 0.0 -> %D1 */',
1178 },
1179
1180 "fld1" => {
1181   "op_flags"  => "R",
1182   "rd_constructor" => "NONE",
1183   "comment"   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1184   "reg_req"   => { },
1185   "emit"      => '. fld1 /* x87 1.0 -> %D1 */',
1186 },
1187
1188 "fldpi" => {
1189   "op_flags"  => "R",
1190   "rd_constructor" => "NONE",
1191   "comment"   => "x87 fp Load pi: Ld pi -> reg",
1192   "reg_req"   => { },
1193   "emit"      => '. fldpi /* x87 pi -> %D1 */',
1194 },
1195
1196 "fldln2" => {
1197   "op_flags"  => "R",
1198   "rd_constructor" => "NONE",
1199   "comment"   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1200   "reg_req"   => { },
1201   "emit"      => '. fldln2 /* x87 ln(2) -> %D1 */',
1202 },
1203
1204 "fldlg2" => {
1205   "op_flags"  => "R",
1206   "rd_constructor" => "NONE",
1207   "comment"   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1208   "reg_req"   => { },
1209   "emit"      => '. fldlg2 /* x87 log(2) -> %D1 */',
1210 },
1211
1212 "fldl2t" => {
1213   "op_flags"  => "R",
1214   "rd_constructor" => "NONE",
1215   "comment"   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1216   "reg_req"   => { },
1217   "emit"      => '. fldll2t /* x87 ld(10) -> %D1 */',
1218 },
1219
1220 "fldl2e" => {
1221   "op_flags"  => "R",
1222   "rd_constructor" => "NONE",
1223   "comment"   => "x87 fp Load ld e: Ld ld e -> reg",
1224   "reg_req"   => { },
1225   "emit"      => '. fldl2e /* x87 ld(e) -> %D1 */',
1226 },
1227
1228 "fldConst" => {
1229   "op_flags"  => "R|c",
1230   "irn_flags" => "R",
1231   "rd_constructor" => "NONE",
1232   "comment"   => "represents a x87 constant",
1233   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1234   "reg_req"   => { "out" => [ "st" ] },
1235   "emit"      => '. fld %ia32_emit_adr /* Load fConst into register -> %D1 */',
1236 },
1237
1238 # fxch, fpush, fpop
1239 # Note that it is NEVER allowed to do CSE on these nodes
1240
1241 "fxch" => {
1242   "op_flags"  => "R|K",
1243   "comment"   => "x87 stack exchange",
1244   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1245   "cmp_attr"  => "  return 1;\n",
1246   "emit"      => '. fxch %X1 /* x87 swap %X1, %X3 */',
1247 },
1248
1249 "fpush" => {
1250   "op_flags"  => "R",
1251   "comment"   => "x87 stack push",
1252   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1253   "cmp_attr"  => "  return 1;\n",
1254   "emit"      => '. fld %X1 /* x87 push %X1 */',
1255 },
1256
1257 "fpop" => {
1258   "op_flags"  => "R|K",
1259   "comment"   => "x87 stack pop",
1260   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1261   "cmp_attr"  => "  return 1;\n",
1262   "emit"      => '. fstp %X1 /* x87 pop %X1 */',
1263 },
1264
1265 # compare
1266
1267 "fcomJmp" => {
1268   "op_flags"  => "L|X|Y",
1269   "comment"   => "floating point compare",
1270   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1271   "reg_req"   => { },
1272 },
1273
1274 "fcompJmp" => {
1275   "op_flags"  => "L|X|Y",
1276   "comment"   => "floating point compare and pop",
1277   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1278   "reg_req"   => { },
1279 },
1280
1281 "fcomppJmp" => {
1282   "op_flags"  => "L|X|Y",
1283   "comment"   => "floating point compare and pop twice",
1284   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1285   "reg_req"   => { },
1286 },
1287
1288 "fcomrJmp" => {
1289   "op_flags"  => "L|X|Y",
1290   "comment"   => "floating point compare reverse",
1291   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1292   "reg_req"   => { },
1293 },
1294
1295 "fcomrpJmp" => {
1296   "op_flags"  => "L|X|Y",
1297   "comment"   => "floating point compare reverse and pop",
1298   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1299   "reg_req"   => { },
1300 },
1301
1302 "fcomrppJmp" => {
1303   "op_flags"  => "L|X|Y",
1304   "comment"   => "floating point compare reverse and pop twice",
1305   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1306   "reg_req"   => { },
1307 },
1308
1309 ); # end of %nodes