More missing config.h
[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|S"
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 #   "latency"   => "latency of this operation (can be float)"
37 # },
38 #
39 # ... # (all nodes you need to describe)
40 #
41 # ); # close the %nodes initializer
42
43 # op_flags: flags for the operation, OPTIONAL (default is "N")
44 # the op_flags correspond to the firm irop_flags:
45 #   N   irop_flag_none
46 #   L   irop_flag_labeled
47 #   C   irop_flag_commutative
48 #   X   irop_flag_cfopcode
49 #   I   irop_flag_ip_cfopcode
50 #   F   irop_flag_fragile
51 #   Y   irop_flag_forking
52 #   H   irop_flag_highlevel
53 #   c   irop_flag_constlike
54 #   K   irop_flag_keep
55 #
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
58 #   R   rematerializeable
59 #   N   not spillable
60 #   I   ignore for register allocation
61 #   S   modifies stack pointer
62 #
63 # state: state of the operation, OPTIONAL (default is "floats")
64 #
65 # arity: arity of the operation, MUST NOT BE OMITTED
66 #
67 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
68 #        are always the first 3 arguments and are always autmatically
69 #        created)
70 #        If this key is missing the following arguments will be created:
71 #        for i = 1 .. arity: ir_node *op_i
72 #        ir_mode *mode
73 #
74 # outs:  if a node defines more than one output, the names of the projections
75 #        nodes having outs having automatically the mode mode_T
76 #        One can also annotate some flags for each out, additional to irn_flags.
77 #        They are separated from name with a colon ':', and concatenated by pipe '|'
78 #        Only I and S are available at the moment (same meaning as in irn_flags).
79 #        example: [ "frame:I", "stack:I|S", "M" ]
80 #
81 # comment: OPTIONAL comment for the node constructor
82 #
83 # rd_constructor: for every operation there will be a
84 #      new_rd_<arch>_<op-name> function with the arguments from above
85 #      which creates the ir_node corresponding to the defined operation
86 #      you can either put the complete source code of this function here
87 #
88 #      This key is OPTIONAL. If omitted, the following constructor will
89 #      be created:
90 #      if (!op_<arch>_<op-name>) assert(0);
91 #      for i = 1 to arity
92 #         set in[i] = op_i
93 #      done
94 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
95 #      return res
96 #
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
98 #
99 # latency: the latency of the operation, default is 1
100 #
101
102 # register types:
103 #   0 - no special type
104 #   1 - caller save (register must be saved by the caller of a function)
105 #   2 - callee save (register must be saved by the called function)
106 #   4 - ignore (do not assign this register)
107 #   8 - emitter can choose an arbitrary register of this class
108 #  16 - the register is a virtual one
109 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
110 %reg_classes = (
111   "gp" => [
112             { "name" => "eax", "type" => 1 },
113             { "name" => "edx", "type" => 1 },
114             { "name" => "ebx", "type" => 2 },
115             { "name" => "ecx", "type" => 1 },
116             { "name" => "esi", "type" => 2 },
117             { "name" => "edi", "type" => 2 },
118 #            { "name" => "r11", "type" => 1 },
119 #            { "name" => "r12", "type" => 1 },
120 #            { "name" => "r13", "type" => 1 },
121 #            { "name" => "r14", "type" => 1 },
122 #            { "name" => "r15", "type" => 1 },
123 #            { "name" => "r16", "type" => 1 },
124 #            { "name" => "r17", "type" => 1 },
125 #            { "name" => "r18", "type" => 1 },
126 #            { "name" => "r19", "type" => 1 },
127 #            { "name" => "r20", "type" => 1 },
128 #            { "name" => "r21", "type" => 1 },
129 #            { "name" => "r22", "type" => 1 },
130 #            { "name" => "r23", "type" => 1 },
131 #            { "name" => "r24", "type" => 1 },
132 #            { "name" => "r25", "type" => 1 },
133 #            { "name" => "r26", "type" => 1 },
134 #            { "name" => "r27", "type" => 1 },
135 #            { "name" => "r28", "type" => 1 },
136 #            { "name" => "r29", "type" => 1 },
137 #            { "name" => "r30", "type" => 1 },
138 #            { "name" => "r31", "type" => 1 },
139 #            { "name" => "r32", "type" => 1 },
140             { "name" => "ebp", "type" => 2 },
141             { "name" => "esp", "type" => 4 },
142             { "name" => "gp_NOREG", "type" => 2 | 4 | 16 },     # we need a dummy register for NoReg nodes
143             { "name" => "gp_UKNWN", "type" => 2 | 4 | 8 | 16},  # we need a dummy register for Unknown nodes
144                         { "mode" => "mode_P" }
145           ],
146   "xmm" => [
147             { "name" => "xmm0", "type" => 1 },
148             { "name" => "xmm1", "type" => 1 },
149             { "name" => "xmm2", "type" => 1 },
150             { "name" => "xmm3", "type" => 1 },
151             { "name" => "xmm4", "type" => 1 },
152             { "name" => "xmm5", "type" => 1 },
153             { "name" => "xmm6", "type" => 1 },
154             { "name" => "xmm7", "type" => 1 },
155             { "name" => "xmm_NOREG", "type" => 2 | 4 | 16 },     # we need a dummy register for NoReg nodes
156             { "name" => "xmm_UKNWN", "type" => 2 | 4 | 8 | 16},  # we need a dummy register for Unknown nodes
157                         { "mode" => "mode_D" }
158           ],
159   "vfp" => [
160             { "name" => "vf0", "type" => 1 | 16 },
161             { "name" => "vf1", "type" => 1 | 16 },
162             { "name" => "vf2", "type" => 1 | 16 },
163             { "name" => "vf3", "type" => 1 | 16 },
164             { "name" => "vf4", "type" => 1 | 16 },
165             { "name" => "vf5", "type" => 1 | 16 },
166             { "name" => "vf6", "type" => 1 | 16 },
167             { "name" => "vf7", "type" => 1 | 16 },
168             { "name" => "vfp_NOREG", "type" => 2 | 4 | 16 },     # we need a dummy register for NoReg nodes
169             { "name" => "vfp_UKNWN", "type" => 2 | 4 | 8 | 16},  # we need a dummy register for Unknown nodes
170                         { "mode" => "mode_E" }
171           ],
172   "st" => [
173             { "name" => "st0", "type" => 1 },
174             { "name" => "st1", "type" => 1 },
175             { "name" => "st2", "type" => 1 },
176             { "name" => "st3", "type" => 1 },
177             { "name" => "st4", "type" => 1 },
178             { "name" => "st5", "type" => 1 },
179             { "name" => "st6", "type" => 1 },
180             { "name" => "st7", "type" => 1 },
181                         { "mode" => "mode_E" }
182           ]
183 ); # %reg_classes
184
185 %cpu = (
186   "ALU"    => [ 1, "ALU1", "ALU2", "ALU3", "ALU4" ],
187   "MUL"    => [ 1, "MUL1", "MUL2" ],
188   "SSE"    => [ 1, "SSE1", "SSE2" ],
189   "FPU"    => [ 1, "FPU1" ],
190   "MEM"    => [ 1, "MEM1", "MEM2" ],
191   "BRANCH" => [ 1, "BRANCH1", "BRANCH2" ],
192   "DUMMY"  => [ 1, "DUMMY1", "DUMMY2", "DUMMY3", "DUMMY4" ]
193 ); # %cpu
194
195 %vliw = (
196         "bundle_size"       => 3,
197         "bundels_per_cycle" => 2
198 ); # vliw
199
200 #--------------------------------------------------#
201 #                        _                         #
202 #                       (_)                        #
203 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
204 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
205 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
206 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
207 #                                      | |         #
208 #                                      |_|         #
209 #--------------------------------------------------#
210
211 %operands = (
212 );
213
214 %nodes = (
215
216 #-----------------------------------------------------------------#
217 #  _       _                                         _            #
218 # (_)     | |                                       | |           #
219 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
220 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
221 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
222 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
223 #                   __/ |                                         #
224 #                  |___/                                          #
225 #-----------------------------------------------------------------#
226
227 # commutative operations
228
229 # NOTE:
230 # All nodes supporting Addressmode have 5 INs:
231 # 1 - base    r1 == NoReg in case of no AM or no base
232 # 2 - index   r2 == NoReg in case of no AM or no index
233 # 3 - op1     r3 == always present
234 # 4 - op2     r4 == NoReg in case of immediate operation
235 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
236
237 "Add" => {
238   "irn_flags" => "R",
239   "comment"   => "construct Add: Add(a, b) = Add(b, a) = a + b",
240   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
241   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
242   "emit"      => '. add %ia32_emit_binop /* Add(%A3, %A4) -> %D1 */',
243   "outs"      => [ "res", "M" ],
244   "units"     => [ "ALU", "MEM" ],
245 },
246
247 "AddC" => {
248   "comment"   => "construct Add with Carry: AddC(a, b) = Add(b, a) = a + b + carry",
249   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
250   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
251   "emit"      => '. adc %ia32_emit_binop /* AddC(%A3, %A4) -> %D1 */',
252   "outs"      => [ "res", "M" ],
253   "units"     => [ "ALU", "MEM" ],
254 },
255
256 "Add64Bit" => {
257   "irn_flags" => "R",
258   "comment"   => "construct 64Bit Add: Add(a_l, a_h, b_l, b_h) = a_l + b_l; a_h + b_h + carry",
259   "arity"     => 4,
260   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp" ], "out" => [ "!in", "!in" ] },
261   "emit"      => '
262 . mov %D1, %S1 /* mov a_l into assigned l_res register */
263 . mov %D2, %S2 /* mov a_h into assigned h_res register */
264 . add %D1, %S3 /* a_l + b_l */
265 . adc %D2, %S4 /* a_h + b_h + carry */
266 ',
267   "outs"      => [ "low_res", "high_res" ],
268   "units"     => [ "ALU", "MEM" ],
269 },
270
271 "l_Add" => {
272   "op_flags"  => "C",
273   "irn_flags" => "R",
274   "cmp_attr"  => "  return 1;\n",
275   "comment"   => "construct lowered Add: Add(a, b) = Add(b, a) = a + b",
276   "arity"     => 2,
277 },
278
279 "l_AddC" => {
280   "op_flags"  => "C",
281   "cmp_attr"  => "  return 1;\n",
282   "comment"   => "construct lowered Add with Carry: AddC(a, b) = Add(b, a) = a + b + carry",
283   "arity"     => 2,
284 },
285
286 "MulS" => {
287   # we should not rematrialize this node. It produces 2 results and has
288   # very strict constrains
289   "comment"   => "construct MulS: MulS(a, b) = MulS(b, a) = a * b",
290   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
291   "reg_req"   => { "in" => [ "gp", "gp", "eax", "gp", "none" ], "out" => [ "eax", "edx" ] },
292   "emit"      => '. mul %ia32_emit_unop /* Mul(%A1, %A2) -> %D1 */',
293   "outs"      => [ "EAX", "EDX", "M" ],
294   "latency"   => 10,
295   "units"     => [ "MUL" ],
296 },
297
298 "l_MulS" => {
299   # we should not rematrialize this node. It produces 2 results and has
300   # very strict constrains
301   "op_flags"  => "C",
302   "cmp_attr"  => "  return 1;\n",
303   "comment"   => "construct lowered MulS: MulS(a, b) = MulS(b, a) = a * b",
304   "outs"      => [ "EAX", "EDX", "M" ],
305   "arity"     => 2
306 },
307
308 "Mul" => {
309   "irn_flags" => "R",
310   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
311   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
312   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
313   "emit"      => '. imul %ia32_emit_binop /* Mul(%A1, %A2) -> %D1 */',
314   "outs"      => [ "res", "M" ],
315   "latency"   => 5,
316   "units"     => [ "MUL" ],
317 },
318
319 "l_Mul" => {
320   "op_flags"  => "C",
321   "cmp_attr"  => "  return 1;\n",
322   "comment"   => "construct lowered Mul: Mul(a, b) = Mul(b, a) = a * b",
323   "arity"     => 2
324 },
325
326 # Mulh is an exception from the 4 INs with AM because the target is always EAX:EDX
327 "Mulh" => {
328   # we should not rematrialize this node. It produces 2 results and has
329   # very strict constrains
330   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
331   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
332   "reg_req"   => { "in" => [ "gp", "gp", "eax", "gp", "none" ], "out" => [ "eax", "edx" ] },
333   "emit"      => '. imul %ia32_emit_unop /* Mulh(%A1, %A2) -> %D1 */',
334   "outs"      => [ "EAX", "EDX", "M" ],
335   "latency"   => 5,
336   "units"     => [ "MUL" ],
337 },
338
339 "And" => {
340   "irn_flags" => "R",
341   "comment"   => "construct And: And(a, b) = And(b, a) = a AND b",
342   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
343   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
344   "emit"      => '. and %ia32_emit_binop /* And(%A1, %A2) -> %D1 */',
345   "outs"      => [ "res", "M" ],
346   "units"     => [ "ALU" ],
347 },
348
349 "Or" => {
350   "irn_flags" => "R",
351   "comment"   => "construct Or: Or(a, b) = Or(b, a) = a OR b",
352   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
353   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
354   "emit"      => '. or %ia32_emit_binop /* Or(%A1, %A2) -> %D1 */',
355   "outs"      => [ "res", "M" ],
356   "units"     => [ "ALU" ],
357 },
358
359 "Eor" => {
360   "irn_flags" => "R",
361   "comment"   => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
362   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
363   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
364   "emit"      => '. xor %ia32_emit_binop /* Xor(%A1, %A2) -> %D1 */',
365   "outs"      => [ "res", "M" ],
366   "units"     => [ "ALU" ],
367 },
368
369 "l_Eor" => {
370   "op_flags"  => "C",
371   "cmp_attr"  => "  return 1;\n",
372   "comment"   => "construct lowered Eor: Eor(a, b) = Eor(b, a) = a EOR b",
373   "arity"     => 2
374 },
375
376 "Max" => {
377   "irn_flags" => "R",
378   "comment"   => "construct Max: Max(a, b) = Max(b, a) = a > b ? a : b",
379   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
380   "emit"      =>
381 '2. cmp %S1, %S2 /* prepare Max (%S1 - %S2), (%A1, %A2) */
382   if (mode_is_signed(get_irn_mode(n))) {
383 4.  cmovl %D1, %S2 /* %S1 is less %S2 */
384   }
385   else {
386 4.  cmovb %D1, %S2 /* %S1 is below %S2 */
387   }
388 ',
389   "latency"   => 2,
390   "units"     => [ "ALU" ],
391 },
392
393 "Min" => {
394   "irn_flags" => "R",
395   "comment"   => "construct Min: Min(a, b) = Min(b, a) = a < b ? a : b",
396   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
397   "emit"      =>
398 '2. cmp %S1, %S2 /* prepare Min (%S1 - %S2), (%A1, %A2) */
399   if (mode_is_signed(get_irn_mode(n))) {
400 2.  cmovg %D1, %S2 /* %S1 is greater %S2 */
401   }
402   else {
403 2.  cmova %D1, %S2, %D1 /* %S1 is above %S2 */
404   }
405 ',
406   "latency"   => 2,
407   "units"     => [ "ALU" ],
408 },
409
410 # not commutative operations
411
412 "Sub" => {
413   "irn_flags" => "R",
414   "comment"   => "construct Sub: Sub(a, b) = a - b",
415   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
416   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
417   "emit"      => '. sub %ia32_emit_binop /* Sub(%A3, %A4) -> %D1 */',
418   "outs"      => [ "res", "M" ],
419   "units"     => [ "ALU" ],
420 },
421
422 "SubC" => {
423   "comment"   => "construct Sub with Carry: SubC(a, b) = a - b - carry",
424   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
425   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3 !in_r4" ] },
426   "emit"      => '. sbb %ia32_emit_binop /* SubC(%A3, %A4) -> %D1 */',
427   "outs"      => [ "res", "M" ],
428   "units"     => [ "ALU" ],
429 },
430
431 "Sub64Bit" => {
432   "irn_flags" => "R",
433   "comment"   => "construct 64Bit Sub: Sub(a_l, a_h, b_l, b_h) = a_l - b_l; a_h - b_h - borrow",
434   "arity"     => 4,
435   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp" ], "out" => [ "!in", "!in" ] },
436   "emit"      => '
437 . mov %D1, %S1 /* mov a_l into assigned l_res register */
438 . mov %D2, %S2 /* mov a_h into assigned h_res register */
439 . sub %D1, %S3 /* a_l - b_l */
440 . sbb %D2, %S4 /* a_h - b_h - borrow */
441 ',
442   "outs"      => [ "low_res", "high_res" ],
443   "units"     => [ "ALU" ],
444 },
445
446 "l_Sub" => {
447   "irn_flags" => "R",
448   "cmp_attr"  => "  return 1;\n",
449   "comment"   => "construct lowered Sub: Sub(a, b) = a - b",
450   "arity"     => 2,
451 },
452
453 "l_SubC" => {
454   "cmp_attr"  => "  return 1;\n",
455   "comment"   => "construct lowered Sub with Carry: SubC(a, b) = a - b - carry",
456   "arity"     => 2,
457 },
458
459 "DivMod" => {
460   "op_flags"  => "F|L",
461   "state"     => "exc_pinned",
462   "reg_req"   => { "in" => [ "eax", "gp", "edx", "none" ], "out" => [ "eax", "edx" ] },
463   "attr"      => "ia32_op_flavour_t dm_flav",
464   "init_attr" => "  attr->data.op_flav = dm_flav;",
465   "cmp_attr"  => "  return attr_a->data.op_flav != attr_b->data.op_flav;\n",
466   "emit"      =>
467 '  if (mode_is_signed(get_ia32_res_mode(n))) {
468 4.  idiv %S2 /* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
469   }
470   else {
471 4.  div %S2 /* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
472   }
473 ',
474   "outs"      => [ "div_res", "mod_res", "M" ],
475   "latency"   => 25,
476   "units"     => [ "ALU" ],
477 },
478
479 "Shl" => {
480   "irn_flags" => "R",
481   "comment"   => "construct Shl: Shl(a, b) = a << b",
482   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
483   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
484   "emit"      => '. shl %ia32_emit_binop /* Shl(%A1, %A2) -> %D1 */',
485   "outs"      => [ "res", "M" ],
486   "units"     => [ "ALU1", "SSE1" ],
487 },
488
489 "l_Shl" => {
490   "cmp_attr"  => "  return 1;\n",
491   "comment"   => "construct lowered Shl: Shl(a, b) = a << b",
492   "arity"     => 2
493 },
494
495 "ShlD" => {
496   "irn_flags" => "R",
497   "comment"   => "construct ShlD: ShlD(a, b, c) = a, b << count (shift left count bits from b into a)",
498   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
499   # Out requirements is: different from all in
500   # This is because, out must be different from LowPart and ShiftCount.
501   # We could say "!ecx !in_r4" but it can occur, that all values live through
502   # this Shift and the only value dying is the ShiftCount. Then there would be a
503   # register missing, as result must not be ecx and all other registers are
504   # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
505   # (and probably never will). So we create artificial interferences of the result
506   # with all inputs, so the spiller can always assure a free register.
507   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "ecx", "none" ], "out" => [ "!in" ] },
508   "emit"      =>
509 '
510 if (get_ia32_immop_type(n) == ia32_ImmNone) {
511   if (get_ia32_op_type(n) == ia32_AddrModeD) {
512 4. shld %ia32_emit_am, %S4, %%cl /* ShlD(%A3, %A4, %A5) -> %D1 */
513   }
514   else {
515 4. shld %S3, %S4, %%cl /* ShlD(%A3, %A4, %A5) -> %D1 */
516   }
517 }
518 else {
519   if (get_ia32_op_type(n) == ia32_AddrModeD) {
520 4. shld %ia32_emit_am, %S4, %C /* ShlD(%A3, %A4, %A5) -> %D1 */
521   }
522   else {
523 4. shld %S3, %S4, %C /* ShlD(%A3, %A4, %A5) -> %D1 */
524   }
525 }
526 ',
527   "outs"      => [ "res", "M" ],
528   "latency"   => 6,
529   "units"     => [ "ALU1", "SSE1" ],
530 },
531
532 "l_ShlD" => {
533   "cmp_attr"  => "  return 1;\n",
534   "comment"   => "construct lowered ShlD: ShlD(a, b, c) = a, b << count (shift left count bits from b into a)",
535   "arity"     => 3
536 },
537
538 "Shr" => {
539   "irn_flags" => "R",
540   "comment"   => "construct Shr: Shr(a, b) = a >> b",
541   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
542   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
543   "emit"      => '. shr %ia32_emit_binop /* Shr(%A1, %A2) -> %D1 */',
544   "outs"      => [ "res", "M" ],
545   "units"     => [ "ALU1", "SSE1" ],
546 },
547
548 "l_Shr" => {
549   "cmp_attr"  => "  return 1;\n",
550   "comment"   => "construct lowered Shr: Shr(a, b) = a << b",
551   "arity"     => 2
552 },
553
554 "ShrD" => {
555   "irn_flags" => "R",
556   "comment"   => "construct ShrD: ShrD(a, b, c) = a, b >> count (shift rigth count bits from a into b)",
557   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
558   # Out requirements is: different from all in
559   # This is because, out must be different from LowPart and ShiftCount.
560   # We could say "!ecx !in_r4" but it can occur, that all values live through
561   # this Shift and the only value dying is the ShiftCount. Then there would be a
562   # register missing, as result must not be ecx and all other registers are
563   # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
564   # (and probably never will). So we create artificial interferences of the result
565   # with all inputs, so the spiller can always assure a free register.
566   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "ecx", "none" ], "out" => [ "!in" ] },
567   "emit"      =>
568 '
569 if (get_ia32_immop_type(n) == ia32_ImmNone) {
570   if (get_ia32_op_type(n) == ia32_AddrModeD) {
571 4. shrd %ia32_emit_am, %S4, %%cl /* ShrD(%A3, %A4, %A5) -> %D1 */
572   }
573   else {
574 4. shrd %S3, %S4, %%cl /* ShrD(%A3, %A4, %A5) -> %D1 */
575   }
576 }
577 else {
578   if (get_ia32_op_type(n) == ia32_AddrModeD) {
579 4. shrd %ia32_emit_am, %S4, %C /* ShrD(%A3, %A4, %A5) -> %D1 */
580   }
581   else {
582 4. shrd %S3, %S4, %C /* ShrD(%A3, %A4, %A5) -> %D1 */
583   }
584 }
585 ',
586   "outs"      => [ "res", "M" ],
587   "latency"   => 6,
588   "units"     => [ "ALU1", "SSE1" ],
589 },
590
591 "l_ShrD" => {
592   "cmp_attr"  => "  return 1;\n",
593   "comment"   => "construct lowered ShrD: ShrD(a, b, c) = a, b >> count (shift rigth count bits from a into b)",
594   "arity"     => 3
595 },
596
597 "Shrs" => {
598   "irn_flags" => "R",
599   "comment"   => "construct Shrs: Shrs(a, b) = a >> b",
600   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
601   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
602   "emit"      => '. sar %ia32_emit_binop /* Shrs(%A1, %A2) -> %D1 */',
603   "outs"      => [ "res", "M" ],
604   "units"     => [ "ALU1", "SSE1" ],
605 },
606
607 "l_Shrs" => {
608   "cmp_attr"  => "  return 1;\n",
609   "comment"   => "construct lowered Shrs: Shrs(a, b) = a << b",
610   "arity"     => 2
611 },
612
613 "RotR" => {
614   "irn_flags" => "R",
615   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
616   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
617   "reg_req"     => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
618   "emit"        => '. ror %ia32_emit_binop /* RotR(%A1, %A2) -> %D1 */',
619   "outs"      => [ "res", "M" ],
620   "units"     => [ "ALU1", "SSE1" ],
621 },
622
623 "RotL" => {
624   "irn_flags" => "R",
625   "comment"   => "construct RotL: RotL(a, b) = a ROTL b",
626   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
627   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
628   "emit"      => '. rol %ia32_emit_binop /* RotL(%A1, %A2) -> %D1 */',
629   "outs"      => [ "res", "M" ],
630   "units"     => [ "ALU1", "SSE1" ],
631 },
632
633 # unary operations
634
635 "Minus" => {
636   "irn_flags" => "R",
637   "comment"   => "construct Minus: Minus(a) = -a",
638   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
639   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
640   "emit"      => '. neg %ia32_emit_unop /* Neg(%A1) -> %D1, (%A1) */',
641   "outs"      => [ "res", "M" ],
642   "units"     => [ "ALU" ],
643 },
644
645 "Minus64Bit" => {
646   "irn_flags" => "R",
647   "comment"   => "construct 64Bit Minus: Minus(a_l, a_h, 0) = 0 - a_l; 0 - a_h - borrow",
648   "arity"     => 4,
649   "reg_req"   => { "in" => [ "gp", "gp", "gp" ], "out" => [ "!in", "!in" ] },
650   "emit"      => '
651 . mov %D1, %S1 /* l_res */
652 . mov %D2, %S1 /* h_res */
653 . sub %D1, %S2 /* 0 - a_l  ->  low_res */
654 . sbb %D2, %S3 /* 0 - a_h - borrow -> high_res */
655 ',
656   "outs"      => [ "low_res", "high_res" ],
657   "units"     => [ "ALU" ],
658 },
659
660
661 "l_Minus" => {
662   "cmp_attr"  => "  return 1;\n",
663   "comment"   => "construct lowered Minus: Minus(a) = -a",
664   "arity"     => 1,
665 },
666
667 "Inc" => {
668   "irn_flags" => "R",
669   "comment"   => "construct Increment: Inc(a) = a++",
670   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
671   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
672   "emit"      => '. inc %ia32_emit_unop /* Inc(%S1) -> %D1, (%A1) */',
673   "outs"      => [ "res", "M" ],
674   "units"     => [ "ALU" ],
675 },
676
677 "Dec" => {
678   "irn_flags" => "R",
679   "comment"   => "construct Decrement: Dec(a) = a--",
680   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
681   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
682   "emit"      => '. dec %ia32_emit_unop /* Dec(%S1) -> %D1, (%A1) */',
683   "outs"      => [ "res", "M" ],
684   "units"     => [ "ALU" ],
685 },
686
687 "Not" => {
688   "irn_flags" => "R",
689   "comment"   => "construct Not: Not(a) = !a",
690   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
691   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
692   "emit"      => '. not %ia32_emit_unop /* Not(%S1) -> %D1, (%A1) */',
693   "outs"      => [ "res", "M" ],
694   "units"     => [ "ALU" ],
695 },
696
697 # other operations
698
699 "CondJmp" => {
700   "op_flags"  => "L|X|Y",
701   "comment"   => "construct conditional jump: CMP A, B && JMPxx LABEL",
702   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
703   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ] },
704   "outs"      => [ "false", "true" ],
705   "latency"   => 3,
706   "units"     => [ "BRANCH" ],
707 },
708
709 "TestJmp" => {
710   "op_flags"  => "L|X|Y",
711   "comment"   => "construct conditional jump: TEST A, B && JMPxx LABEL",
712   "reg_req"  => { "in" => [ "gp", "gp" ] },
713   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
714   "outs"      => [ "false", "true" ],
715   "latency"   => 3,
716   "units"     => [ "BRANCH" ],
717 },
718
719 "CJmpAM" => {
720   "op_flags"  => "L|X|Y",
721   "comment"   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
722   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
723   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "none", "none" ] },
724   "outs"      => [ "false", "true" ],
725   "units"     => [ "BRANCH" ],
726 },
727
728 "CJmp" => {
729   "op_flags"  => "L|X|Y",
730   "comment"   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
731   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
732   "reg_req"   => { "in" => [ "gp", "gp" ] },
733   "units"     => [ "BRANCH" ],
734 },
735
736 "SwitchJmp" => {
737   "op_flags"  => "L|X|Y",
738   "comment"   => "construct switch",
739   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
740   "reg_req"   => { "in" => [ "gp" ], "out" => [ "none" ] },
741   "latency"   => 3,
742   "units"     => [ "BRANCH" ],
743 },
744
745 "Const" => {
746   "op_flags"  => "c",
747   "irn_flags" => "R",
748   "comment"   => "represents an integer constant",
749   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
750   "reg_req"   => { "out" => [ "gp" ] },
751   "units"     => [ "ALU" ],
752 },
753
754 "Cdq" => {
755   # we should not rematrialize this node. It produces 2 results and has
756   # very strict constrains
757   "comment"   => "construct CDQ: sign extend EAX -> EDX:EAX",
758   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax in_r1", "edx" ] },
759   "emit"      => '. cdq /* sign extend EAX -> EDX:EAX, (%A1) */',
760   "outs"      => [ "EAX", "EDX" ],
761   "units"     => [ "ALU" ],
762 },
763
764 # Load / Store
765
766 "Load" => {
767   "op_flags"  => "L|F",
768   "state"     => "exc_pinned",
769   "comment"   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
770   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
771   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
772   "latency"   => 3,
773   "emit"      =>
774 '  if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
775 4.   mov%Mx %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
776   }
777   else {
778 4.   mov %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
779   }
780 ',
781   "outs"      => [ "res", "M" ],
782   "units"     => [ "MEM" ],
783 },
784
785 "l_Load" => {
786   "op_flags"  => "L|F",
787   "cmp_attr"  => "  return 1;\n",
788   "comment"   => "construct lowered Load: Load(ptr, mem) = LD ptr -> reg",
789   "outs"      => [ "res", "M" ],
790   "arity"     => 2,
791 },
792
793 "l_Store" => {
794   "op_flags"  => "L|F",
795   "cmp_attr"  => "  return 1;\n",
796   "state"     => "exc_pinned",
797   "comment"   => "construct lowered Store: Store(ptr, val, mem) = ST ptr,val",
798   "arity"     => 3,
799   "outs"      => [ "M" ],
800 },
801
802 "Store" => {
803   "op_flags"  => "L|F",
804   "state"     => "exc_pinned",
805   "comment"   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
806   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
807   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ] },
808   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
809   "outs"      => [ "M" ],
810   "latency"   => 3,
811   "units"     => [ "MEM" ],
812 },
813
814 "Store8Bit" => {
815   "op_flags"  => "L|F",
816   "state"     => "exc_pinned",
817   "comment"   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
818   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
819   "reg_req"   => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ] },
820   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
821   "outs"      => [ "M" ],
822   "latency"   => 3,
823   "units"     => [ "MEM" ],
824 },
825
826 "Lea" => {
827   "irn_flags" => "R",
828   "comment"   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
829   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
830   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
831   "emit"      => '. lea %D1, %ia32_emit_am /* LEA(%A1, %A2) */',
832   "latency"   => 2,
833   "units"     => [ "ALU" ],
834 },
835
836 "Push" => {
837   "comment"   => "push on the stack",
838   "reg_req"   => { "in" => [ "gp", "gp", "gp", "esp", "none" ], "out" => [ "esp" ] },
839   "emit"      => '. push %ia32_emit_unop /* PUSH(%A1) */',
840   "outs"      => [ "stack:I|S", "M" ],
841   "latency"   => 3,
842   "units"     => [ "MEM" ],
843 },
844
845 "Pop" => {
846   # We don't set class modify stack here (but we will do this on proj 1)
847   "comment"   => "pop a gp register from the stack",
848   "reg_req"   => { "in" => [ "gp", "gp", "esp", "none" ], "out" => [ "gp", "esp" ] },
849   "emit"      => '. pop %ia32_emit_unop /* POP(%A1) */',
850   "outs"      => [ "res", "stack:I|S", "M" ],
851   "latency"   => 4,
852   "units"     => [ "MEM" ],
853 },
854
855 "Enter" => {
856   "comment"   => "create stack frame",
857   "reg_req"   => { "in" => [ "esp" ], "out" => [ "ebp", "esp" ] },
858   "emit"      => '. enter /* Enter */',
859   "outs"      => [ "frame:I", "stack:I|S", "M" ],
860   "latency"   => 15,
861   "units"     => [ "MEM" ],
862 },
863
864 "Leave" => {
865   "comment"   => "destroy stack frame",
866   "reg_req"   => { "in" => [ "esp", "ebp" ], "out" => [ "ebp", "esp" ] },
867   "emit"      => '. leave /* Leave */',
868   "outs"      => [ "frame:I", "stack:I|S", "M" ],
869   "latency"   => 3,
870   "units"     => [ "MEM" ],
871 },
872
873 "AddSP" => {
874   "irn_flags" => "I",
875   "comment"   => "allocate space on stack",
876   "reg_req"   => { "in" => [ "esp", "gp" ], "out" => [ "esp", "none" ] },
877   "outs"      => [ "stack:S", "M" ],
878   "units"     => [ "ALU" ],
879 },
880
881 "SubSP" => {
882   "irn_flags" => "I",
883   "comment"   => "free space on stack",
884   "reg_req"   => { "in" => [ "esp", "gp" ], "out" => [ "esp", "none" ] },
885   "outs"      => [ "stack:S", "M" ],
886   "units"     => [ "ALU" ],
887 },
888
889 "LdTls" => {
890   "irn_flags" => "R",
891   "comment"   => "get the TLS base address",
892   "reg_req"   => { "out" => [ "gp" ] },
893   "units"     => [ "MEM" ],
894 },
895
896
897
898 #-----------------------------------------------------------------------------#
899 #   _____ _____ ______    __ _             _                     _            #
900 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
901 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
902 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
903 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
904 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
905 #-----------------------------------------------------------------------------#
906
907 # commutative operations
908
909 "xAdd" => {
910   "irn_flags" => "R",
911   "comment"   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
912   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
913   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
914   "emit"      => '. adds%M %ia32_emit_binop /* SSE Add(%A3, %A4) -> %D1 */',
915   "outs"      => [ "res", "M" ],
916   "latency"   => 4,
917   "units"     => [ "SSE" ],
918 },
919
920 "xMul" => {
921   "irn_flags" => "R",
922   "comment"   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
923   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
924   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
925   "emit"      => '. muls%M %ia32_emit_binop /* SSE Mul(%A3, %A4) -> %D1 */',
926   "outs"      => [ "res", "M" ],
927   "latency"   => 4,
928   "units"     => [ "SSE" ],
929 },
930
931 "xMax" => {
932   "irn_flags" => "R",
933   "comment"   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
934   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
935   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
936   "emit"      => '. maxs%M %ia32_emit_binop /* SSE Max(%A3, %A4) -> %D1 */',
937   "outs"      => [ "res", "M" ],
938   "latency"   => 2,
939   "units"     => [ "SSE" ],
940 },
941
942 "xMin" => {
943   "irn_flags" => "R",
944   "comment"   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
945   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
946   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
947   "emit"      => '. mins%M %ia32_emit_binop /* SSE Min(%A3, %A4) -> %D1 */',
948   "outs"      => [ "res", "M" ],
949   "latency"   => 2,
950   "units"     => [ "SSE" ],
951 },
952
953 "xAnd" => {
954   "irn_flags" => "R",
955   "comment"   => "construct SSE And: And(a, b) = a AND b",
956   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
957   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
958   "emit"      => '. andp%M %ia32_emit_binop /* SSE And(%A3, %A4) -> %D1 */',
959   "outs"      => [ "res", "M" ],
960   "latency"   => 3,
961   "units"     => [ "SSE" ],
962 },
963
964 "xOr" => {
965   "irn_flags" => "R",
966   "comment"   => "construct SSE Or: Or(a, b) = a OR b",
967   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
968   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
969   "emit"      => '. orp%M %ia32_emit_binop /* SSE Or(%A3, %A4) -> %D1 */',
970   "outs"      => [ "res", "M" ],
971   "units"     => [ "SSE" ],
972 },
973
974 "xEor" => {
975   "irn_flags" => "R",
976   "comment"   => "construct SSE Eor: Eor(a, b) = a XOR b",
977   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
978   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
979   "emit"      => '. xorp%M %ia32_emit_binop /* SSE Xor(%A3, %A4) -> %D1 */',
980   "outs"      => [ "res", "M" ],
981   "latency"   => 3,
982   "units"     => [ "SSE" ],
983 },
984
985 # not commutative operations
986
987 "xAndNot" => {
988   "irn_flags" => "R",
989   "comment"   => "construct SSE AndNot: AndNot(a, b) = a AND NOT b",
990   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
991   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
992   "emit"      => '. andnp%M %ia32_emit_binop /* SSE AndNot(%A3, %A4) -> %D1 */',
993   "outs"      => [ "res", "M" ],
994   "latency"   => 3,
995   "units"     => [ "SSE" ],
996 },
997
998 "xSub" => {
999   "irn_flags" => "R",
1000   "comment"   => "construct SSE Sub: Sub(a, b) = a - b",
1001   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1002   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
1003   "emit"      => '. subs%M %ia32_emit_binop /* SSE Sub(%A1, %A2) -> %D1 */',
1004   "outs"      => [ "res", "M" ],
1005   "latency"   => 4,
1006   "units"     => [ "SSE" ],
1007 },
1008
1009 "xDiv" => {
1010   "irn_flags" => "R",
1011   "comment"   => "construct SSE Div: Div(a, b) = a / b",
1012   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1013   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
1014   "emit"      => '. divs%M %ia32_emit_binop /* SSE Div(%A1, %A2) -> %D1 */',
1015   "outs"      => [ "res", "M" ],
1016   "latency"   => 16,
1017   "units"     => [ "SSE" ],
1018 },
1019
1020 # other operations
1021
1022 "xCmp" => {
1023   "irn_flags" => "R",
1024   "comment"   => "construct SSE Compare: Cmp(a, b) == a = a cmp b",
1025   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
1026   "outs"      => [ "res", "M" ],
1027   "latency"   => 3,
1028   "units"     => [ "SSE" ],
1029 },
1030
1031 "xCondJmp" => {
1032   "op_flags"  => "L|X|Y",
1033   "comment"   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
1034   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1035   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "none", "none" ] },
1036   "outs"      => [ "false", "true" ],
1037   "latency"   => 5,
1038   "units"     => [ "SSE" ],
1039 },
1040
1041 "xConst" => {
1042   "op_flags"  => "c",
1043   "irn_flags" => "R",
1044   "comment"   => "represents a SSE constant",
1045   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1046   "reg_req"   => { "out" => [ "xmm" ] },
1047   "emit"      => '. movs%M %D1, %C /* Load fConst into register */',
1048   "latency"   => 2,
1049   "units"     => [ "SSE" ],
1050 },
1051
1052 # Load / Store
1053
1054 "xLoad" => {
1055   "op_flags"  => "L|F",
1056   "state"     => "exc_pinned",
1057   "comment"   => "construct SSE Load: Load(ptr, mem) = LD ptr",
1058   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1059   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "xmm" ] },
1060   "emit"      => '. movs%M %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */',
1061   "outs"      => [ "res", "M" ],
1062   "latency"   => 2,
1063   "units"     => [ "SSE" ],
1064 },
1065
1066 "xStore" => {
1067   "op_flags" => "L|F",
1068   "state"    => "exc_pinned",
1069   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
1070   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1071   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ] },
1072   "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */',
1073   "outs"      => [ "M" ],
1074   "latency"   => 2,
1075   "units"     => [ "MEM" ],
1076 },
1077
1078 "xStoreSimple" => {
1079   "op_flags" => "L|F",
1080   "state"    => "exc_pinned",
1081   "comment"  => "construct Store without index: Store(ptr, val, mem) = ST ptr,val",
1082   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1083   "reg_req"  => { "in" => [ "gp", "xmm", "none" ] },
1084   "emit"     => '. movs%M %ia32_emit_am, %S2 /* store XMM0 onto stack */',
1085   "outs"      => [ "M" ],
1086   "latency"   => 2,
1087   "units"     => [ "MEM" ],
1088 },
1089
1090 "l_X87toSSE" => {
1091   "op_flags" => "L|F",
1092   "comment"  => "construct: transfer a value from x87 FPU into a SSE register",
1093   "cmp_attr" => "  return 1;\n",
1094   "arity"    => 3,
1095 },
1096
1097 "l_SSEtoX87" => {
1098   "op_flags" => "L|F",
1099   "comment"  => "construct: transfer a value from SSE register to x87 FPU",
1100   "cmp_attr" => "  return 1;\n",
1101   "arity"    => 3,
1102 },
1103
1104 "GetST0" => {
1105   "op_flags" => "L|F",
1106   "irn_flags" => "I",
1107   "state"    => "exc_pinned",
1108   "comment"  => "store ST0 onto stack",
1109   "cmp_attr" => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1110   "reg_req"  => { "in" => [ "gp", "none" ] },
1111   "emit"     => '. fstp %ia32_emit_am /* store ST0 onto stack */',
1112   "outs"     => [ "M" ],
1113   "latency"  => 4,
1114   "units"     => [ "MEM" ],
1115 },
1116
1117 "SetST0" => {
1118   "op_flags" => "L|F",
1119   "irn_flags" => "I",
1120   "state"    => "exc_pinned",
1121   "comment"  => "load ST0 from stack",
1122   "cmp_attr" => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1123   "reg_req"  => { "in" => [ "gp", "none" ], "out" => [ "vf0", "none" ] },
1124   "emit"     => '. fld %ia32_emit_am /* load ST0 from stack */',
1125   "outs"     => [ "res", "M" ],
1126   "latency"  => 2,
1127   "units"     => [ "MEM" ],
1128 },
1129
1130 # CopyB
1131
1132 "CopyB" => {
1133   "op_flags" => "F|H",
1134   "state"    => "pinned",
1135   "comment"  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
1136   "reg_req"  => { "in" => [ "edi", "esi", "ecx", "none" ], "out" => [ "edi", "esi", "ecx", "none" ] },
1137   "outs"     => [ "DST", "SRC", "CNT", "M" ],
1138   "units"     => [ "MEM" ],
1139 },
1140
1141 "CopyB_i" => {
1142   "op_flags" => "F|H",
1143   "state"    => "pinned",
1144   "comment"  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
1145   "cmp_attr" => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1146   "reg_req"  => { "in" => [ "edi", "esi", "none" ], "out" => [  "edi", "esi", "none" ] },
1147   "outs"     => [ "DST", "SRC", "M" ],
1148   "units"     => [ "MEM" ],
1149 },
1150
1151 # Conversions
1152
1153 "Conv_I2I" => {
1154   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3", "none" ] },
1155   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1156   "comment"  => "construct Conv Int -> Int",
1157   "outs"     => [ "res", "M" ],
1158   "units"     => [ "ALU" ],
1159 },
1160
1161 "Conv_I2I8Bit" => {
1162   "reg_req"  => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ], "out" => [ "in_r3", "none" ] },
1163   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1164   "comment"  => "construct Conv Int -> Int",
1165   "outs"     => [ "res", "M" ],
1166   "units"     => [ "ALU" ],
1167 },
1168
1169 "Conv_I2FP" => {
1170   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "xmm", "none" ] },
1171   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1172   "comment"  => "construct Conv Int -> Floating Point",
1173   "outs"     => [ "res", "M" ],
1174   "latency"  => 10,
1175   "units"     => [ "SSE" ],
1176 },
1177
1178 "Conv_FP2I" => {
1179   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "gp", "none" ] },
1180   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1181   "comment"  => "construct Conv Floating Point -> Int",
1182   "outs"     => [ "res", "M" ],
1183   "latency"  => 10,
1184   "units"     => [ "SSE" ],
1185 },
1186
1187 "Conv_FP2FP" => {
1188   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "xmm", "none" ] },
1189   "cmp_attr" => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
1190   "comment"  => "construct Conv Floating Point -> Floating Point",
1191   "outs"     => [ "res", "M" ],
1192   "latency"  => 8,
1193   "units"     => [ "SSE" ],
1194 },
1195
1196 "CmpCMov" => {
1197   "irn_flags" => "R",
1198   "comment"   => "construct Conditional Move: CMov(sel, a, b) == sel ? a : b",
1199   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp" ], "out" => [ "in_r4" ] },
1200   "latency"   => 2,
1201   "units"     => [ "ALU" ],
1202 },
1203
1204 "PsiCondCMov" => {
1205   "irn_flags" => "R",
1206   "comment"   => "check if Psi condition tree evaluates to true and move result accordingly",
1207   "reg_req"   => { "in" => [ "gp", "gp", "gp" ], "out" => [ "in_r3" ] },
1208   "latency"   => 2,
1209   "units"     => [ "ALU" ],
1210 },
1211
1212 "xCmpCMov" => {
1213   "irn_flags" => "R",
1214   "comment"   => "construct Conditional Move: SSE Compare + int CMov ",
1215   "reg_req"   => { "in" => [ "xmm", "xmm", "gp", "gp" ], "out" => [ "in_r4" ] },
1216   "latency"   => 5,
1217   "units"     => [ "SSE" ],
1218 },
1219
1220 "vfCmpCMov" => {
1221   "irn_flags" => "R",
1222   "comment"   => "construct Conditional Move: x87 Compare + int CMov",
1223   "reg_req"   => { "in" => [ "vfp", "vfp", "gp", "gp" ], "out" => [ "in_r4" ] },
1224   "latency"   => 10,
1225   "units"     => [ "FPU" ],
1226 },
1227
1228 "CmpSet" => {
1229   "irn_flags" => "R",
1230   "comment"   => "construct Set: Set(sel) == sel ? 1 : 0",
1231   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1232   "outs"      => [ "res", "M" ],
1233   "latency"   => 2,
1234   "units"     => [ "ALU" ],
1235 },
1236
1237 "PsiCondSet" => {
1238   "irn_flags" => "R",
1239   "comment"   => "check if Psi condition tree evaluates to true and set result accordingly",
1240   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax ebx ecx edx" ] },
1241   "latency"   => 2,
1242   "units"     => [ "ALU" ],
1243 },
1244
1245 "xCmpSet" => {
1246   "irn_flags" => "R",
1247   "comment"   => "construct Set: SSE Compare + int Set",
1248   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1249   "outs"      => [ "res", "M" ],
1250   "latency"   => 5,
1251   "units"     => [ "SSE" ],
1252 },
1253
1254 "vfCmpSet" => {
1255   "irn_flags" => "R",
1256   "comment"   => "construct Set: x87 Compare + int Set",
1257   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1258   "outs"      => [ "res", "M" ],
1259   "latency"   => 10,
1260   "units"     => [ "FPU" ],
1261 },
1262
1263 "vfCMov" => {
1264   "irn_flags" => "R",
1265   "comment"   => "construct x87 Conditional Move: vfCMov(sel, a, b) = sel ? a : b",
1266   "reg_req"   => { "in" => [ "vfp", "vfp", "vfp", "vfp" ], "out" => [ "vfp" ] },
1267   "latency"   => 10,
1268   "units"     => [ "FPU" ],
1269 },
1270
1271 #----------------------------------------------------------#
1272 #        _      _               _    __ _             _    #
1273 #       (_)    | |             | |  / _| |           | |   #
1274 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1275 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1276 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1277 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1278 #                 | |                                      #
1279 #  _ __   ___   __| | ___  ___                             #
1280 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1281 # | | | | (_) | (_| |  __/\__ \                            #
1282 # |_| |_|\___/ \__,_|\___||___/                            #
1283 #----------------------------------------------------------#
1284
1285 "vfadd" => {
1286   "irn_flags" => "R",
1287   "comment"   => "virtual fp Add: Add(a, b) = Add(b, a) = a + b",
1288   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1289   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1290   "outs"      => [ "res", "M" ],
1291   "latency"   => 4,
1292   "units"     => [ "FPU" ],
1293 },
1294
1295 "vfmul" => {
1296   "irn_flags" => "R",
1297   "comment"   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1298   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1299   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1300   "outs"      => [ "res", "M" ],
1301   "latency"   => 4,
1302   "units"     => [ "FPU" ],
1303 },
1304
1305 "l_vfmul" => {
1306   "op_flags"  => "C",
1307   "cmp_attr"  => "  return 1;\n",
1308   "comment"   => "lowered virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1309   "arity"     => 2,
1310 },
1311
1312 "vfsub" => {
1313   "irn_flags" => "R",
1314   "comment"   => "virtual fp Sub: Sub(a, b) = a - b",
1315   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1316   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1317   "outs"      => [ "res", "M" ],
1318   "latency"   => 4,
1319   "units"     => [ "FPU" ],
1320 },
1321
1322 "l_vfsub" => {
1323   "cmp_attr"  => "  return 1;\n",
1324   "comment"   => "lowered virtual fp Sub: Sub(a, b) = a - b",
1325   "arity"     => 2,
1326 },
1327
1328 "vfdiv" => {
1329   "comment"   => "virtual fp Div: Div(a, b) = a / b",
1330   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1331   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1332   "outs"      => [ "res", "M" ],
1333   "latency"   => 20,
1334   "units"     => [ "FPU" ],
1335 },
1336
1337 "l_vfdiv" => {
1338   "cmp_attr"  => "  return 1;\n",
1339   "comment"   => "lowered virtual fp Div: Div(a, b) = a / b",
1340   "arity"     => 2,
1341 },
1342
1343 "vfprem" => {
1344   "comment"   => "virtual fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1345   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1346   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1347   "outs"      => [ "res", "M" ],
1348   "latency"   => 20,
1349   "units"     => [ "FPU" ],
1350 },
1351
1352 "l_vfprem" => {
1353   "cmp_attr"  => "  return 1;\n",
1354   "comment"   => "lowered virtual fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1355   "arity"     => 2,
1356 },
1357
1358 "vfabs" => {
1359   "irn_flags" => "R",
1360   "comment"   => "virtual fp Abs: Abs(a) = |a|",
1361   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1362   "latency"   => 2,
1363   "units"     => [ "FPU" ],
1364 },
1365
1366 "vfchs" => {
1367   "irn_flags" => "R",
1368   "comment"   => "virtual fp Chs: Chs(a) = -a",
1369   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1370   "latency"   => 2,
1371   "units"     => [ "FPU" ],
1372 },
1373
1374 "vfsin" => {
1375   "irn_flags" => "R",
1376   "comment"   => "virtual fp Sin: Sin(a) = sin(a)",
1377   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1378   "latency"   => 150,
1379   "units"     => [ "FPU" ],
1380 },
1381
1382 "vfcos" => {
1383   "irn_flags" => "R",
1384   "comment"   => "virtual fp Cos: Cos(a) = cos(a)",
1385   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1386   "latency"   => 150,
1387   "units"     => [ "FPU" ],
1388 },
1389
1390 "vfsqrt" => {
1391   "irn_flags" => "R",
1392   "comment"   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
1393   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1394   "latency"   => 30,
1395   "units"     => [ "FPU" ],
1396 },
1397
1398 # virtual Load and Store
1399
1400 "vfld" => {
1401   "op_flags"  => "L|F",
1402   "state"     => "exc_pinned",
1403   "comment"   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
1404   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1405   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
1406   "outs"      => [ "res", "M" ],
1407   "latency"   => 2,
1408   "units"     => [ "FPU" ],
1409 },
1410
1411 "vfst" => {
1412   "op_flags"  => "L|F",
1413   "state"     => "exc_pinned",
1414   "comment"   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
1415   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1416   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
1417   "outs"      => [ "M" ],
1418   "latency"   => 2,
1419   "units"     => [ "FPU" ],
1420 },
1421
1422 # Conversions
1423
1424 "vfild" => {
1425   "comment"   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1426   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1427   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
1428   "outs"      => [ "res", "M" ],
1429   "latency"   => 4,
1430   "units"     => [ "FPU" ],
1431 },
1432
1433 "l_vfild" => {
1434   "cmp_attr"  => "  return 1;\n",
1435   "comment"   => "lowered virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1436   "outs"      => [ "res", "M" ],
1437   "arity"     => 2,
1438 },
1439
1440 "vfist" => {
1441   "comment"   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1442   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1443   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
1444   "outs"      => [ "M" ],
1445   "latency"   => 4,
1446   "units"     => [ "FPU" ],
1447 },
1448
1449 "l_vfist" => {
1450   "cmp_attr"  => "  return 1;\n",
1451   "comment"   => "lowered virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1452   "outs"      => [ "M" ],
1453   "arity"     => 3,
1454 },
1455
1456
1457 # constants
1458
1459 "vfldz" => {
1460   "irn_flags" => "R",
1461   "comment"   => "virtual fp Load 0.0: Ld 0.0 -> reg",
1462   "reg_req"   => { "out" => [ "vfp" ] },
1463   "latency"   => 4,
1464   "units"     => [ "FPU" ],
1465 },
1466
1467 "vfld1" => {
1468   "irn_flags" => "R",
1469   "comment"   => "virtual fp Load 1.0: Ld 1.0 -> reg",
1470   "reg_req"   => { "out" => [ "vfp" ] },
1471   "latency"   => 4,
1472   "units"     => [ "FPU" ],
1473 },
1474
1475 "vfldpi" => {
1476   "irn_flags" => "R",
1477   "comment"   => "virtual fp Load pi: Ld pi -> reg",
1478   "reg_req"   => { "out" => [ "vfp" ] },
1479   "latency"   => 4,
1480   "units"     => [ "FPU" ],
1481 },
1482
1483 "vfldln2" => {
1484   "irn_flags" => "R",
1485   "comment"   => "virtual fp Load ln 2: Ld ln 2 -> reg",
1486   "reg_req"   => { "out" => [ "vfp" ] },
1487   "latency"   => 4,
1488   "units"     => [ "FPU" ],
1489 },
1490
1491 "vfldlg2" => {
1492   "irn_flags" => "R",
1493   "comment"   => "virtual fp Load lg 2: Ld lg 2 -> reg",
1494   "reg_req"   => { "out" => [ "vfp" ] },
1495   "latency"   => 4,
1496   "units"     => [ "FPU" ],
1497 },
1498
1499 "vfldl2t" => {
1500   "irn_flags" => "R",
1501   "comment"   => "virtual fp Load ld 10: Ld ld 10 -> reg",
1502   "reg_req"   => { "out" => [ "vfp" ] },
1503   "latency"   => 4,
1504   "units"     => [ "FPU" ],
1505 },
1506
1507 "vfldl2e" => {
1508   "irn_flags" => "R",
1509   "comment"   => "virtual fp Load ld e: Ld ld e -> reg",
1510   "reg_req"   => { "out" => [ "vfp" ] },
1511   "latency"   => 4,
1512   "units"     => [ "FPU" ],
1513 },
1514
1515 "vfConst" => {
1516   "op_flags"  => "c",
1517   "irn_flags" => "R",
1518   "init_attr" => "  set_ia32_ls_mode(res, mode);",
1519   "comment"   => "represents a virtual floating point constant",
1520   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1521   "reg_req"   => { "out" => [ "vfp" ] },
1522   "latency"   => 3,
1523   "units"     => [ "FPU" ],
1524 },
1525
1526 # other
1527
1528 "vfCondJmp" => {
1529   "op_flags"  => "L|X|Y",
1530   "comment"   => "represents a virtual floating point compare",
1531   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1532   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "none", "none", "eax" ] },
1533   "outs"      => [ "false", "true", "temp_reg_eax" ],
1534   "latency"   => 10,
1535   "units"     => [ "FPU" ],
1536 },
1537
1538 #------------------------------------------------------------------------#
1539 #       ___ _____    __ _             _                     _            #
1540 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1541 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1542 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1543 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1544 #------------------------------------------------------------------------#
1545
1546 "fadd" => {
1547   "op_flags"  => "R",
1548   "rd_constructor" => "NONE",
1549   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1550   "reg_req"   => { },
1551   "emit"      => '. fadd %ia32_emit_x87_binop /* x87 fadd(%A3, %A4) -> %D1 */',
1552 },
1553
1554 "faddp" => {
1555   "op_flags"  => "R",
1556   "rd_constructor" => "NONE",
1557   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1558   "reg_req"   => { },
1559   "emit"      => '. faddp %ia32_emit_x87_binop /* x87 fadd(%A3, %A4) -> %D1 */',
1560 },
1561
1562 "fmul" => {
1563   "op_flags"  => "R",
1564   "rd_constructor" => "NONE",
1565   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1566   "reg_req"   => { },
1567   "emit"      => '. fmul %ia32_emit_x87_binop /* x87 fmul(%A3, %A4) -> %D1 */',
1568 },
1569
1570 "fmulp" => {
1571   "op_flags"  => "R",
1572   "rd_constructor" => "NONE",
1573   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1574   "reg_req"   => { },
1575   "emit"      => '. fmulp %ia32_emit_x87_binop /* x87 fmul(%A3, %A4) -> %D1 */',,
1576 },
1577
1578 "fsub" => {
1579   "op_flags"  => "R",
1580   "rd_constructor" => "NONE",
1581   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1582   "reg_req"   => { },
1583   "emit"      => '. fsub %ia32_emit_x87_binop /* x87 fsub(%A3, %A4) -> %D1 */',
1584 },
1585
1586 "fsubp" => {
1587   "op_flags"  => "R",
1588   "rd_constructor" => "NONE",
1589   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1590   "reg_req"   => { },
1591   "emit"      => '. fsubp %ia32_emit_x87_binop /* x87 fsub(%A3, %A4) -> %D1 */',
1592 },
1593
1594 "fsubr" => {
1595   "op_flags"  => "R",
1596   "rd_constructor" => "NONE",
1597   "irn_flags" => "R",
1598   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1599   "reg_req"   => { },
1600   "emit"      => '. fsubr %ia32_emit_x87_binop /* x87 fsubr(%A3, %A4) -> %D1 */',
1601 },
1602
1603 "fsubrp" => {
1604   "op_flags"  => "R",
1605   "rd_constructor" => "NONE",
1606   "irn_flags" => "R",
1607   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1608   "reg_req"   => { },
1609   "emit"      => '. fsubrp %ia32_emit_x87_binop /* x87 fsubr(%A3, %A4) -> %D1 */',
1610 },
1611
1612 "fprem" => {
1613   "op_flags"  => "R",
1614   "rd_constructor" => "NONE",
1615   "comment"   => "x87 fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1616   "reg_req"   => { },
1617   "emit"      => '. fprem1 /* x87 fprem(%A3, %A4) -> %D1 */',
1618 },
1619
1620 # this node is just here, to keep the simulator running
1621 # we can omit this when a fprem simulation function exists
1622 "fpremp" => {
1623   "op_flags"  => "R",
1624   "rd_constructor" => "NONE",
1625   "comment"   => "x87 fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1626   "reg_req"   => { },
1627   "emit"      => '. fprem1 /* x87 fprem(%A3, %A4) -> %D1 WITH POP */',
1628 },
1629
1630 "fdiv" => {
1631   "op_flags"  => "R",
1632   "rd_constructor" => "NONE",
1633   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1634   "reg_req"   => { },
1635   "emit"      => '. fdiv %ia32_emit_x87_binop /* x87 fdiv(%A3, %A4) -> %D1 */',
1636 },
1637
1638 "fdivp" => {
1639   "op_flags"  => "R",
1640   "rd_constructor" => "NONE",
1641   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1642   "reg_req"   => { },
1643   "emit"      => '. fdivp %ia32_emit_x87_binop /* x87 fdiv(%A3, %A4) -> %D1 */',
1644 },
1645
1646 "fdivr" => {
1647   "op_flags"  => "R",
1648   "rd_constructor" => "NONE",
1649   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1650   "reg_req"   => { },
1651   "emit"      => '. fdivr %ia32_emit_x87_binop /* x87 fdivr(%A3, %A4) -> %D1 */',
1652 },
1653
1654 "fdivrp" => {
1655   "op_flags"  => "R",
1656   "rd_constructor" => "NONE",
1657   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1658   "reg_req"   => { },
1659   "emit"      => '. fdivrp %ia32_emit_x87_binop /* x87 fdivr(%A3, %A4) -> %D1 */',
1660 },
1661
1662 "fabs" => {
1663   "op_flags"  => "R",
1664   "rd_constructor" => "NONE",
1665   "comment"   => "x87 fp Abs: Abs(a) = |a|",
1666   "reg_req"   => { },
1667   "emit"      => '. fabs /* x87 fabs(%A1) -> %D1 */',
1668 },
1669
1670 "fchs" => {
1671   "op_flags"  => "R",
1672   "rd_constructor" => "NONE",
1673   "comment"   => "x87 fp Chs: Chs(a) = -a",
1674   "reg_req"   => { },
1675   "emit"      => '. fchs /* x87 fchs(%A1) -> %D1 */',
1676 },
1677
1678 "fsin" => {
1679   "op_flags"  => "R",
1680   "rd_constructor" => "NONE",
1681   "comment"   => "x87 fp Sin: Sin(a) = sin(a)",
1682   "reg_req"   => { },
1683   "emit"      => '. fsin /* x87 sin(%A1) -> %D1 */',
1684 },
1685
1686 "fcos" => {
1687   "op_flags"  => "R",
1688   "rd_constructor" => "NONE",
1689   "comment"   => "x87 fp Cos: Cos(a) = cos(a)",
1690   "reg_req"   => { },
1691   "emit"      => '. fcos /* x87 cos(%A1) -> %D1 */',
1692 },
1693
1694 "fsqrt" => {
1695   "op_flags"  => "R",
1696   "rd_constructor" => "NONE",
1697   "comment"   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1698   "reg_req"   => { },
1699   "emit"      => '. fsqrt $ /* x87 sqrt(%A1) -> %D1 */',
1700 },
1701
1702 # x87 Load and Store
1703
1704 "fld" => {
1705   "rd_constructor" => "NONE",
1706   "op_flags"  => "R|L|F",
1707   "state"     => "exc_pinned",
1708   "comment"   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1709   "reg_req"   => { },
1710   "emit"      => '. fld %ia32_emit_am /* Load((%A1)) -> %D1 */',
1711 },
1712
1713 "fst" => {
1714   "rd_constructor" => "NONE",
1715   "op_flags"  => "R|L|F",
1716   "state"     => "exc_pinned",
1717   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1718   "reg_req"   => { },
1719   "emit"      => '. fst %ia32_emit_am /* Store(%A3) -> (%A1) */',
1720 },
1721
1722 "fstp" => {
1723   "rd_constructor" => "NONE",
1724   "op_flags"  => "R|L|F",
1725   "state"     => "exc_pinned",
1726   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1727   "reg_req"   => { },
1728   "emit"      => '. fstp %ia32_emit_am /* Store(%A3) -> (%A1) and pop */',
1729 },
1730
1731 # Conversions
1732
1733 "fild" => {
1734   "op_flags"  => "R",
1735   "rd_constructor" => "NONE",
1736   "comment"   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1737   "reg_req"   => { },
1738   "emit"      => '. fild %ia32_emit_am /* integer Load((%A1)) -> %D1 */',
1739 },
1740
1741 "fist" => {
1742   "op_flags"  => "R",
1743   "rd_constructor" => "NONE",
1744   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1745   "reg_req"   => { },
1746   "emit"      => '. fist %ia32_emit_am /* integer Store(%A3) -> (%A1) */',
1747 },
1748
1749 "fistp" => {
1750   "op_flags"  => "R",
1751   "rd_constructor" => "NONE",
1752   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1753   "reg_req"   => { },
1754   "emit"      => '. fistp %ia32_emit_am /* integer Store(%A3) -> (%A1) and pop */',
1755 },
1756
1757 # constants
1758
1759 "fldz" => {
1760   "op_flags"  => "R|c",
1761   "irn_flags"  => "R",
1762   "comment"   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1763   "reg_req"   => { "out" => [ "vfp" ] },
1764   "emit"      => '. fldz /* x87 0.0 -> %D1 */',
1765 },
1766
1767 "fld1" => {
1768   "op_flags"  => "R|c",
1769   "irn_flags"  => "R",
1770   "comment"   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1771   "reg_req"   => { "out" => [ "vfp" ] },
1772   "emit"      => '. fld1 /* x87 1.0 -> %D1 */',
1773 },
1774
1775 "fldpi" => {
1776   "op_flags"  => "R|c",
1777   "irn_flags"  => "R",
1778   "comment"   => "x87 fp Load pi: Ld pi -> reg",
1779   "reg_req"   => { "out" => [ "vfp" ] },
1780   "emit"      => '. fldpi /* x87 pi -> %D1 */',
1781 },
1782
1783 "fldln2" => {
1784   "op_flags"  => "R|c",
1785   "irn_flags"  => "R",
1786   "comment"   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1787   "reg_req"   => { "out" => [ "vfp" ] },
1788   "emit"      => '. fldln2 /* x87 ln(2) -> %D1 */',
1789 },
1790
1791 "fldlg2" => {
1792   "op_flags"  => "R|c",
1793   "irn_flags"  => "R",
1794   "comment"   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1795   "reg_req"   => { "out" => [ "vfp" ] },
1796   "emit"      => '. fldlg2 /* x87 log(2) -> %D1 */',
1797 },
1798
1799 "fldl2t" => {
1800   "op_flags"  => "R|c",
1801   "irn_flags"  => "R",
1802   "comment"   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1803   "reg_req"   => { "out" => [ "vfp" ] },
1804   "emit"      => '. fldll2t /* x87 ld(10) -> %D1 */',
1805 },
1806
1807 "fldl2e" => {
1808   "op_flags"  => "R|c",
1809   "irn_flags"  => "R",
1810   "comment"   => "x87 fp Load ld e: Ld ld e -> reg",
1811   "reg_req"   => { "out" => [ "vfp" ] },
1812   "emit"      => '. fldl2e /* x87 ld(e) -> %D1 */',
1813 },
1814
1815 "fldConst" => {
1816   "op_flags"  => "R|c",
1817   "irn_flags" => "R",
1818   "rd_constructor" => "NONE",
1819   "comment"   => "represents a x87 constant",
1820   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1821   "reg_req"   => { "out" => [ "vfp" ] },
1822   "emit"      => '. fld %ia32_emit_adr /* Load fConst into register -> %D1 */',
1823 },
1824
1825 # fxch, fpush, fpop
1826 # Note that it is NEVER allowed to do CSE on these nodes
1827 # Moreover, note the virtual register requierements!
1828
1829 "fxch" => {
1830   "op_flags"  => "R|K",
1831   "comment"   => "x87 stack exchange",
1832   "reg_req"   => { },
1833   "cmp_attr"  => "  return 1;\n",
1834   "emit"      => '. fxch %X1 /* x87 swap %X1, %X3 */',
1835 },
1836
1837 "fpush" => {
1838   "op_flags"  => "R|K",
1839   "comment"   => "x87 stack push",
1840   "reg_req"   => {},
1841   "cmp_attr"  => "  return 1;\n",
1842   "emit"      => '. fld %X1 /* x87 push %X1 */',
1843 },
1844
1845 "fpushCopy" => {
1846   "op_flags"  => "R",
1847   "comment"   => "x87 stack push",
1848   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1849   "cmp_attr"  => "  return 1;\n",
1850   "emit"      => '. fld %X1 /* x87 push %X1 */',
1851 },
1852
1853 "fpop" => {
1854   "op_flags"  => "R|K",
1855   "comment"   => "x87 stack pop",
1856   "reg_req"   => { },
1857   "cmp_attr"  => "  return 1;\n",
1858   "emit"      => '. fstp %X1 /* x87 pop %X1 */',
1859 },
1860
1861 # compare
1862
1863 "fcomJmp" => {
1864   "op_flags"  => "L|X|Y",
1865   "comment"   => "floating point compare",
1866   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1867   "reg_req"   => { },
1868 },
1869
1870 "fcompJmp" => {
1871   "op_flags"  => "L|X|Y",
1872   "comment"   => "floating point compare and pop",
1873   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1874   "reg_req"   => { },
1875 },
1876
1877 "fcomppJmp" => {
1878   "op_flags"  => "L|X|Y",
1879   "comment"   => "floating point compare and pop twice",
1880   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1881   "reg_req"   => { },
1882 },
1883
1884 "fcomrJmp" => {
1885   "op_flags"  => "L|X|Y",
1886   "comment"   => "floating point compare reverse",
1887   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1888   "reg_req"   => { },
1889 },
1890
1891 "fcomrpJmp" => {
1892   "op_flags"  => "L|X|Y",
1893   "comment"   => "floating point compare reverse and pop",
1894   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1895   "reg_req"   => { },
1896 },
1897
1898 "fcomrppJmp" => {
1899   "op_flags"  => "L|X|Y",
1900   "comment"   => "floating point compare reverse and pop twice",
1901   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1902   "reg_req"   => { },
1903 },
1904
1905 ); # end of %nodes