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