7b3c2fa7c2a2394b1f2012a9b26196da064f40b5
[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   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1234   "latency"   => 2,
1235   "units"     => [ "ALU" ],
1236 },
1237
1238 "PsiCondSet" => {
1239   "irn_flags" => "R",
1240   "comment"   => "check if Psi condition tree evaluates to true and set result accordingly",
1241   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax ebx ecx edx" ] },
1242   "latency"   => 2,
1243   "units"     => [ "ALU" ],
1244 },
1245
1246 "xCmpSet" => {
1247   "irn_flags" => "R",
1248   "comment"   => "construct Set: SSE Compare + int Set",
1249   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1250   "outs"      => [ "res", "M" ],
1251   "latency"   => 5,
1252   "units"     => [ "SSE" ],
1253 },
1254
1255 "vfCmpSet" => {
1256   "irn_flags" => "R",
1257   "comment"   => "construct Set: x87 Compare + int Set",
1258   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "eax ebx ecx edx", "none" ] },
1259   "outs"      => [ "res", "M" ],
1260   "latency"   => 10,
1261   "units"     => [ "FPU" ],
1262 },
1263
1264 "vfCMov" => {
1265   "irn_flags" => "R",
1266   "comment"   => "construct x87 Conditional Move: vfCMov(sel, a, b) = sel ? a : b",
1267   "reg_req"   => { "in" => [ "vfp", "vfp", "vfp", "vfp" ], "out" => [ "vfp" ] },
1268   "latency"   => 10,
1269   "units"     => [ "FPU" ],
1270 },
1271
1272 #----------------------------------------------------------#
1273 #        _      _               _    __ _             _    #
1274 #       (_)    | |             | |  / _| |           | |   #
1275 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1276 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1277 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1278 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1279 #                 | |                                      #
1280 #  _ __   ___   __| | ___  ___                             #
1281 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1282 # | | | | (_) | (_| |  __/\__ \                            #
1283 # |_| |_|\___/ \__,_|\___||___/                            #
1284 #----------------------------------------------------------#
1285
1286 "vfadd" => {
1287   "irn_flags" => "R",
1288   "comment"   => "virtual fp Add: Add(a, b) = Add(b, a) = a + b",
1289   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1290   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1291   "outs"      => [ "res", "M" ],
1292   "latency"   => 4,
1293   "units"     => [ "FPU" ],
1294 },
1295
1296 "vfmul" => {
1297   "irn_flags" => "R",
1298   "comment"   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1299   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1300   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1301   "outs"      => [ "res", "M" ],
1302   "latency"   => 4,
1303   "units"     => [ "FPU" ],
1304 },
1305
1306 "l_vfmul" => {
1307   "op_flags"  => "C",
1308   "cmp_attr"  => "  return 1;\n",
1309   "comment"   => "lowered virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1310   "arity"     => 2,
1311 },
1312
1313 "vfsub" => {
1314   "irn_flags" => "R",
1315   "comment"   => "virtual fp Sub: Sub(a, b) = a - b",
1316   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1317   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1318   "outs"      => [ "res", "M" ],
1319   "latency"   => 4,
1320   "units"     => [ "FPU" ],
1321 },
1322
1323 "l_vfsub" => {
1324   "cmp_attr"  => "  return 1;\n",
1325   "comment"   => "lowered virtual fp Sub: Sub(a, b) = a - b",
1326   "arity"     => 2,
1327 },
1328
1329 "vfdiv" => {
1330   "comment"   => "virtual fp Div: Div(a, b) = a / b",
1331   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1332   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1333   "outs"      => [ "res", "M" ],
1334   "latency"   => 20,
1335   "units"     => [ "FPU" ],
1336 },
1337
1338 "l_vfdiv" => {
1339   "cmp_attr"  => "  return 1;\n",
1340   "comment"   => "lowered virtual fp Div: Div(a, b) = a / b",
1341   "arity"     => 2,
1342 },
1343
1344 "vfprem" => {
1345   "comment"   => "virtual fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1346   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1347   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
1348   "outs"      => [ "res", "M" ],
1349   "latency"   => 20,
1350   "units"     => [ "FPU" ],
1351 },
1352
1353 "l_vfprem" => {
1354   "cmp_attr"  => "  return 1;\n",
1355   "comment"   => "lowered virtual fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1356   "arity"     => 2,
1357 },
1358
1359 "vfabs" => {
1360   "irn_flags" => "R",
1361   "comment"   => "virtual fp Abs: Abs(a) = |a|",
1362   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1363   "latency"   => 2,
1364   "units"     => [ "FPU" ],
1365 },
1366
1367 "vfchs" => {
1368   "irn_flags" => "R",
1369   "comment"   => "virtual fp Chs: Chs(a) = -a",
1370   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1371   "latency"   => 2,
1372   "units"     => [ "FPU" ],
1373 },
1374
1375 "vfsin" => {
1376   "irn_flags" => "R",
1377   "comment"   => "virtual fp Sin: Sin(a) = sin(a)",
1378   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1379   "latency"   => 150,
1380   "units"     => [ "FPU" ],
1381 },
1382
1383 "vfcos" => {
1384   "irn_flags" => "R",
1385   "comment"   => "virtual fp Cos: Cos(a) = cos(a)",
1386   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1387   "latency"   => 150,
1388   "units"     => [ "FPU" ],
1389 },
1390
1391 "vfsqrt" => {
1392   "irn_flags" => "R",
1393   "comment"   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
1394   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1395   "latency"   => 30,
1396   "units"     => [ "FPU" ],
1397 },
1398
1399 # virtual Load and Store
1400
1401 "vfld" => {
1402   "op_flags"  => "L|F",
1403   "state"     => "exc_pinned",
1404   "comment"   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
1405   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1406   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
1407   "outs"      => [ "res", "M" ],
1408   "latency"   => 2,
1409   "units"     => [ "FPU" ],
1410 },
1411
1412 "vfst" => {
1413   "op_flags"  => "L|F",
1414   "state"     => "exc_pinned",
1415   "comment"   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
1416   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1417   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
1418   "outs"      => [ "M" ],
1419   "latency"   => 2,
1420   "units"     => [ "FPU" ],
1421 },
1422
1423 # Conversions
1424
1425 "vfild" => {
1426   "comment"   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1427   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1428   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
1429   "outs"      => [ "res", "M" ],
1430   "latency"   => 4,
1431   "units"     => [ "FPU" ],
1432 },
1433
1434 "l_vfild" => {
1435   "cmp_attr"  => "  return 1;\n",
1436   "comment"   => "lowered virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1437   "outs"      => [ "res", "M" ],
1438   "arity"     => 2,
1439 },
1440
1441 "vfist" => {
1442   "comment"   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1443   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1444   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
1445   "outs"      => [ "M" ],
1446   "latency"   => 4,
1447   "units"     => [ "FPU" ],
1448 },
1449
1450 "l_vfist" => {
1451   "cmp_attr"  => "  return 1;\n",
1452   "comment"   => "lowered virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1453   "outs"      => [ "M" ],
1454   "arity"     => 3,
1455 },
1456
1457
1458 # constants
1459
1460 "vfldz" => {
1461   "irn_flags" => "R",
1462   "comment"   => "virtual fp Load 0.0: Ld 0.0 -> reg",
1463   "reg_req"   => { "out" => [ "vfp" ] },
1464   "latency"   => 4,
1465   "units"     => [ "FPU" ],
1466 },
1467
1468 "vfld1" => {
1469   "irn_flags" => "R",
1470   "comment"   => "virtual fp Load 1.0: Ld 1.0 -> reg",
1471   "reg_req"   => { "out" => [ "vfp" ] },
1472   "latency"   => 4,
1473   "units"     => [ "FPU" ],
1474 },
1475
1476 "vfldpi" => {
1477   "irn_flags" => "R",
1478   "comment"   => "virtual fp Load pi: Ld pi -> reg",
1479   "reg_req"   => { "out" => [ "vfp" ] },
1480   "latency"   => 4,
1481   "units"     => [ "FPU" ],
1482 },
1483
1484 "vfldln2" => {
1485   "irn_flags" => "R",
1486   "comment"   => "virtual fp Load ln 2: Ld ln 2 -> reg",
1487   "reg_req"   => { "out" => [ "vfp" ] },
1488   "latency"   => 4,
1489   "units"     => [ "FPU" ],
1490 },
1491
1492 "vfldlg2" => {
1493   "irn_flags" => "R",
1494   "comment"   => "virtual fp Load lg 2: Ld lg 2 -> reg",
1495   "reg_req"   => { "out" => [ "vfp" ] },
1496   "latency"   => 4,
1497   "units"     => [ "FPU" ],
1498 },
1499
1500 "vfldl2t" => {
1501   "irn_flags" => "R",
1502   "comment"   => "virtual fp Load ld 10: Ld ld 10 -> reg",
1503   "reg_req"   => { "out" => [ "vfp" ] },
1504   "latency"   => 4,
1505   "units"     => [ "FPU" ],
1506 },
1507
1508 "vfldl2e" => {
1509   "irn_flags" => "R",
1510   "comment"   => "virtual fp Load ld e: Ld ld e -> reg",
1511   "reg_req"   => { "out" => [ "vfp" ] },
1512   "latency"   => 4,
1513   "units"     => [ "FPU" ],
1514 },
1515
1516 "vfConst" => {
1517   "op_flags"  => "c",
1518   "irn_flags" => "R",
1519   "init_attr" => "  set_ia32_ls_mode(res, mode);",
1520   "comment"   => "represents a virtual floating point constant",
1521   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1522   "reg_req"   => { "out" => [ "vfp" ] },
1523   "latency"   => 3,
1524   "units"     => [ "FPU" ],
1525 },
1526
1527 # other
1528
1529 "vfCondJmp" => {
1530   "op_flags"  => "L|X|Y",
1531   "comment"   => "represents a virtual floating point compare",
1532   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1533   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "none", "none", "eax" ] },
1534   "outs"      => [ "false", "true", "temp_reg_eax" ],
1535   "latency"   => 10,
1536   "units"     => [ "FPU" ],
1537 },
1538
1539 #------------------------------------------------------------------------#
1540 #       ___ _____    __ _             _                     _            #
1541 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1542 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1543 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1544 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1545 #------------------------------------------------------------------------#
1546
1547 "fadd" => {
1548   "op_flags"  => "R",
1549   "rd_constructor" => "NONE",
1550   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1551   "reg_req"   => { },
1552   "emit"      => '. fadd %ia32_emit_x87_binop /* x87 fadd(%A3, %A4) -> %D1 */',
1553 },
1554
1555 "faddp" => {
1556   "op_flags"  => "R",
1557   "rd_constructor" => "NONE",
1558   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1559   "reg_req"   => { },
1560   "emit"      => '. faddp %ia32_emit_x87_binop /* x87 fadd(%A3, %A4) -> %D1 */',
1561 },
1562
1563 "fmul" => {
1564   "op_flags"  => "R",
1565   "rd_constructor" => "NONE",
1566   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1567   "reg_req"   => { },
1568   "emit"      => '. fmul %ia32_emit_x87_binop /* x87 fmul(%A3, %A4) -> %D1 */',
1569 },
1570
1571 "fmulp" => {
1572   "op_flags"  => "R",
1573   "rd_constructor" => "NONE",
1574   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1575   "reg_req"   => { },
1576   "emit"      => '. fmulp %ia32_emit_x87_binop /* x87 fmul(%A3, %A4) -> %D1 */',,
1577 },
1578
1579 "fsub" => {
1580   "op_flags"  => "R",
1581   "rd_constructor" => "NONE",
1582   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1583   "reg_req"   => { },
1584   "emit"      => '. fsub %ia32_emit_x87_binop /* x87 fsub(%A3, %A4) -> %D1 */',
1585 },
1586
1587 "fsubp" => {
1588   "op_flags"  => "R",
1589   "rd_constructor" => "NONE",
1590   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
1591   "reg_req"   => { },
1592   "emit"      => '. fsubp %ia32_emit_x87_binop /* x87 fsub(%A3, %A4) -> %D1 */',
1593 },
1594
1595 "fsubr" => {
1596   "op_flags"  => "R",
1597   "rd_constructor" => "NONE",
1598   "irn_flags" => "R",
1599   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1600   "reg_req"   => { },
1601   "emit"      => '. fsubr %ia32_emit_x87_binop /* x87 fsubr(%A3, %A4) -> %D1 */',
1602 },
1603
1604 "fsubrp" => {
1605   "op_flags"  => "R",
1606   "rd_constructor" => "NONE",
1607   "irn_flags" => "R",
1608   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
1609   "reg_req"   => { },
1610   "emit"      => '. fsubrp %ia32_emit_x87_binop /* x87 fsubr(%A3, %A4) -> %D1 */',
1611 },
1612
1613 "fprem" => {
1614   "op_flags"  => "R",
1615   "rd_constructor" => "NONE",
1616   "comment"   => "x87 fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1617   "reg_req"   => { },
1618   "emit"      => '. fprem1 /* x87 fprem(%A3, %A4) -> %D1 */',
1619 },
1620
1621 # this node is just here, to keep the simulator running
1622 # we can omit this when a fprem simulation function exists
1623 "fpremp" => {
1624   "op_flags"  => "R",
1625   "rd_constructor" => "NONE",
1626   "comment"   => "x87 fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1627   "reg_req"   => { },
1628   "emit"      => '. fprem1 /* x87 fprem(%A3, %A4) -> %D1 WITH POP */',
1629 },
1630
1631 "fdiv" => {
1632   "op_flags"  => "R",
1633   "rd_constructor" => "NONE",
1634   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1635   "reg_req"   => { },
1636   "emit"      => '. fdiv %ia32_emit_x87_binop /* x87 fdiv(%A3, %A4) -> %D1 */',
1637 },
1638
1639 "fdivp" => {
1640   "op_flags"  => "R",
1641   "rd_constructor" => "NONE",
1642   "comment"   => "x87 fp Div: Div(a, b) = a / b",
1643   "reg_req"   => { },
1644   "emit"      => '. fdivp %ia32_emit_x87_binop /* x87 fdiv(%A3, %A4) -> %D1 */',
1645 },
1646
1647 "fdivr" => {
1648   "op_flags"  => "R",
1649   "rd_constructor" => "NONE",
1650   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1651   "reg_req"   => { },
1652   "emit"      => '. fdivr %ia32_emit_x87_binop /* x87 fdivr(%A3, %A4) -> %D1 */',
1653 },
1654
1655 "fdivrp" => {
1656   "op_flags"  => "R",
1657   "rd_constructor" => "NONE",
1658   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1659   "reg_req"   => { },
1660   "emit"      => '. fdivrp %ia32_emit_x87_binop /* x87 fdivr(%A3, %A4) -> %D1 */',
1661 },
1662
1663 "fabs" => {
1664   "op_flags"  => "R",
1665   "rd_constructor" => "NONE",
1666   "comment"   => "x87 fp Abs: Abs(a) = |a|",
1667   "reg_req"   => { },
1668   "emit"      => '. fabs /* x87 fabs(%A1) -> %D1 */',
1669 },
1670
1671 "fchs" => {
1672   "op_flags"  => "R",
1673   "rd_constructor" => "NONE",
1674   "comment"   => "x87 fp Chs: Chs(a) = -a",
1675   "reg_req"   => { },
1676   "emit"      => '. fchs /* x87 fchs(%A1) -> %D1 */',
1677 },
1678
1679 "fsin" => {
1680   "op_flags"  => "R",
1681   "rd_constructor" => "NONE",
1682   "comment"   => "x87 fp Sin: Sin(a) = sin(a)",
1683   "reg_req"   => { },
1684   "emit"      => '. fsin /* x87 sin(%A1) -> %D1 */',
1685 },
1686
1687 "fcos" => {
1688   "op_flags"  => "R",
1689   "rd_constructor" => "NONE",
1690   "comment"   => "x87 fp Cos: Cos(a) = cos(a)",
1691   "reg_req"   => { },
1692   "emit"      => '. fcos /* x87 cos(%A1) -> %D1 */',
1693 },
1694
1695 "fsqrt" => {
1696   "op_flags"  => "R",
1697   "rd_constructor" => "NONE",
1698   "comment"   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1699   "reg_req"   => { },
1700   "emit"      => '. fsqrt $ /* x87 sqrt(%A1) -> %D1 */',
1701 },
1702
1703 # x87 Load and Store
1704
1705 "fld" => {
1706   "rd_constructor" => "NONE",
1707   "op_flags"  => "R|L|F",
1708   "state"     => "exc_pinned",
1709   "comment"   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1710   "reg_req"   => { },
1711   "emit"      => '. fld %ia32_emit_am /* Load((%A1)) -> %D1 */',
1712 },
1713
1714 "fst" => {
1715   "rd_constructor" => "NONE",
1716   "op_flags"  => "R|L|F",
1717   "state"     => "exc_pinned",
1718   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1719   "reg_req"   => { },
1720   "emit"      => '. fst %ia32_emit_am /* Store(%A3) -> (%A1) */',
1721 },
1722
1723 "fstp" => {
1724   "rd_constructor" => "NONE",
1725   "op_flags"  => "R|L|F",
1726   "state"     => "exc_pinned",
1727   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1728   "reg_req"   => { },
1729   "emit"      => '. fstp %ia32_emit_am /* Store(%A3) -> (%A1) and pop */',
1730 },
1731
1732 # Conversions
1733
1734 "fild" => {
1735   "op_flags"  => "R",
1736   "rd_constructor" => "NONE",
1737   "comment"   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1738   "reg_req"   => { },
1739   "emit"      => '. fild %ia32_emit_am /* integer Load((%A1)) -> %D1 */',
1740 },
1741
1742 "fist" => {
1743   "op_flags"  => "R",
1744   "rd_constructor" => "NONE",
1745   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1746   "reg_req"   => { },
1747   "emit"      => '. fist %ia32_emit_am /* integer Store(%A3) -> (%A1) */',
1748 },
1749
1750 "fistp" => {
1751   "op_flags"  => "R",
1752   "rd_constructor" => "NONE",
1753   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1754   "reg_req"   => { },
1755   "emit"      => '. fistp %ia32_emit_am /* integer Store(%A3) -> (%A1) and pop */',
1756 },
1757
1758 # constants
1759
1760 "fldz" => {
1761   "op_flags"  => "R|c",
1762   "irn_flags"  => "R",
1763   "comment"   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1764   "reg_req"   => { "out" => [ "vfp" ] },
1765   "emit"      => '. fldz /* x87 0.0 -> %D1 */',
1766 },
1767
1768 "fld1" => {
1769   "op_flags"  => "R|c",
1770   "irn_flags"  => "R",
1771   "comment"   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1772   "reg_req"   => { "out" => [ "vfp" ] },
1773   "emit"      => '. fld1 /* x87 1.0 -> %D1 */',
1774 },
1775
1776 "fldpi" => {
1777   "op_flags"  => "R|c",
1778   "irn_flags"  => "R",
1779   "comment"   => "x87 fp Load pi: Ld pi -> reg",
1780   "reg_req"   => { "out" => [ "vfp" ] },
1781   "emit"      => '. fldpi /* x87 pi -> %D1 */',
1782 },
1783
1784 "fldln2" => {
1785   "op_flags"  => "R|c",
1786   "irn_flags"  => "R",
1787   "comment"   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1788   "reg_req"   => { "out" => [ "vfp" ] },
1789   "emit"      => '. fldln2 /* x87 ln(2) -> %D1 */',
1790 },
1791
1792 "fldlg2" => {
1793   "op_flags"  => "R|c",
1794   "irn_flags"  => "R",
1795   "comment"   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1796   "reg_req"   => { "out" => [ "vfp" ] },
1797   "emit"      => '. fldlg2 /* x87 log(2) -> %D1 */',
1798 },
1799
1800 "fldl2t" => {
1801   "op_flags"  => "R|c",
1802   "irn_flags"  => "R",
1803   "comment"   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1804   "reg_req"   => { "out" => [ "vfp" ] },
1805   "emit"      => '. fldll2t /* x87 ld(10) -> %D1 */',
1806 },
1807
1808 "fldl2e" => {
1809   "op_flags"  => "R|c",
1810   "irn_flags"  => "R",
1811   "comment"   => "x87 fp Load ld e: Ld ld e -> reg",
1812   "reg_req"   => { "out" => [ "vfp" ] },
1813   "emit"      => '. fldl2e /* x87 ld(e) -> %D1 */',
1814 },
1815
1816 "fldConst" => {
1817   "op_flags"  => "R|c",
1818   "irn_flags" => "R",
1819   "rd_constructor" => "NONE",
1820   "comment"   => "represents a x87 constant",
1821   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1822   "reg_req"   => { "out" => [ "vfp" ] },
1823   "emit"      => '. fld %ia32_emit_adr /* Load fConst into register -> %D1 */',
1824 },
1825
1826 # fxch, fpush, fpop
1827 # Note that it is NEVER allowed to do CSE on these nodes
1828 # Moreover, note the virtual register requierements!
1829
1830 "fxch" => {
1831   "op_flags"  => "R|K",
1832   "comment"   => "x87 stack exchange",
1833   "reg_req"   => { },
1834   "cmp_attr"  => "  return 1;\n",
1835   "emit"      => '. fxch %X1 /* x87 swap %X1, %X3 */',
1836 },
1837
1838 "fpush" => {
1839   "op_flags"  => "R|K",
1840   "comment"   => "x87 stack push",
1841   "reg_req"   => {},
1842   "cmp_attr"  => "  return 1;\n",
1843   "emit"      => '. fld %X1 /* x87 push %X1 */',
1844 },
1845
1846 "fpushCopy" => {
1847   "op_flags"  => "R",
1848   "comment"   => "x87 stack push",
1849   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
1850   "cmp_attr"  => "  return 1;\n",
1851   "emit"      => '. fld %X1 /* x87 push %X1 */',
1852 },
1853
1854 "fpop" => {
1855   "op_flags"  => "R|K",
1856   "comment"   => "x87 stack pop",
1857   "reg_req"   => { },
1858   "cmp_attr"  => "  return 1;\n",
1859   "emit"      => '. fstp %X1 /* x87 pop %X1 */',
1860 },
1861
1862 # compare
1863
1864 "fcomJmp" => {
1865   "op_flags"  => "L|X|Y",
1866   "comment"   => "floating point compare",
1867   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1868   "reg_req"   => { },
1869 },
1870
1871 "fcompJmp" => {
1872   "op_flags"  => "L|X|Y",
1873   "comment"   => "floating point compare and pop",
1874   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1875   "reg_req"   => { },
1876 },
1877
1878 "fcomppJmp" => {
1879   "op_flags"  => "L|X|Y",
1880   "comment"   => "floating point compare and pop twice",
1881   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1882   "reg_req"   => { },
1883 },
1884
1885 "fcomrJmp" => {
1886   "op_flags"  => "L|X|Y",
1887   "comment"   => "floating point compare reverse",
1888   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1889   "reg_req"   => { },
1890 },
1891
1892 "fcomrpJmp" => {
1893   "op_flags"  => "L|X|Y",
1894   "comment"   => "floating point compare reverse and pop",
1895   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1896   "reg_req"   => { },
1897 },
1898
1899 "fcomrppJmp" => {
1900   "op_flags"  => "L|X|Y",
1901   "comment"   => "floating point compare reverse and pop twice",
1902   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1903   "reg_req"   => { },
1904 },
1905
1906 ); # end of %nodes