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