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