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