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