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