3df9a729f0b0b7d3c71db311358673821c6deca5
[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 use File::Basename;
6
7 my $myname = $0;
8
9 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
10 $arch = "ia32";
11
12 # The node description is done as a perl hash initializer with the
13 # following structure:
14 #
15 # %nodes = (
16 #
17 # <op-name> => {
18 #   op_flags  => "N|L|C|X|I|F|Y|H|c|K|n",
19 #   irn_flags => "R|N"
20 #   arity     => "0|1|2|3 ... |variable|dynamic|any",
21 #   state     => "floats|pinned|mem_pinned|exc_pinned",
22 #   args      => [
23 #                    { type => "type 1", name => "name 1" },
24 #                    { type => "type 2", name => "name 2" },
25 #                    ...
26 #                  ],
27 #   comment   => "any comment for constructor",
28 #   reg_req   => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
29 #   cmp_attr  => "c source code for comparing node attributes",
30 #   outs      => { "out1", "out2" } # optional, creates pn_op_out1, ... consts
31 #   ins       => { "in1", "in2" }   # optional, creates n_op_in1, ... consts
32 #   mode      => "mode_Iu"          # optional, predefines the mode
33 #   emit      => "emit code with templates",
34 #   attr      => "additional attribute arguments for constructor",
35 #   init_attr => "emit attribute initialization template",
36 #   hash_func => "name of the hash function for this operation",
37 #   latency   => "latency of this operation (can be float)"
38 #   attr_type => "name of the attribute struct",
39 #   modified_flags =>  [ "CF", ... ] # optional, list of modified flags
40 # },
41 #
42 # ... # (all nodes you need to describe)
43 #
44 # ); # close the %nodes initializer
45
46 # op_flags: flags for the operation, OPTIONAL (default is "N")
47 # the op_flags correspond to the firm irop_flags:
48 #   N   irop_flag_none
49 #   L   irop_flag_labeled
50 #   C   irop_flag_commutative
51 #   X   irop_flag_cfopcode
52 #   I   irop_flag_ip_cfopcode
53 #   F   irop_flag_fragile
54 #   Y   irop_flag_forking
55 #   H   irop_flag_highlevel
56 #   c   irop_flag_constlike
57 #   K   irop_flag_keep
58 #   NB  irop_flag_dump_noblock
59 #   NI  irop_flag_dump_noinput
60 #
61 # irn_flags: special node flags, OPTIONAL (default is 0)
62 # following irn_flags are supported:
63 #   R   rematerializeable
64 #   N   not spillable
65 #
66 # state: state of the operation, OPTIONAL (default is "floats")
67 #
68 # arity: arity of the operation, MUST NOT BE OMITTED
69 #
70 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
71 #        are always the first 3 arguments and are always autmatically
72 #        created)
73 #        If this key is missing the following arguments will be created:
74 #        for i = 1 .. arity: ir_node *op_i
75 #        ir_mode *mode
76 #
77 # outs:  if a node defines more than one output, the names of the projections
78 #        nodes having outs having automatically the mode mode_T
79 #        example: [ "frame", "stack", "M" ]
80 #
81 # comment: OPTIONAL comment for the node constructor
82 #
83 # rd_constructor: for every operation there will be a
84 #      new_rd_<arch>_<op-name> function with the arguments from above
85 #      which creates the ir_node corresponding to the defined operation
86 #      you can either put the complete source code of this function here
87 #
88 #      This key is OPTIONAL. If omitted, the following constructor will
89 #      be created:
90 #      if (!op_<arch>_<op-name>) assert(0);
91 #      for i = 1 to arity
92 #         set in[i] = op_i
93 #      done
94 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
95 #      return res
96 #
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
98 #
99
100 # register types:
101 #   0 - no special type
102 #   1 - caller save (register must be saved by the caller of a function)
103 #   2 - callee save (register must be saved by the called function)
104 #   4 - ignore (do not automatically assign this register)
105 #   8 - emitter can choose an arbitrary register of this class
106 #  16 - the register is a virtual one
107 #  32 - register represents a state
108 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
109 %reg_classes = (
110         gp => [
111                 { name => "edx", type => 1 },
112                 { name => "ecx", type => 1 },
113                 { name => "eax", type => 1 },
114                 { name => "ebx", type => 2 },
115                 { name => "esi", type => 2 },
116                 { name => "edi", type => 2 },
117                 { name => "ebp", type => 2 },
118                 { name => "esp", type => 4 },
119                 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
120                 { name => "gp_UKNWN", type => 4 | 8 | 16 },  # we need a dummy register for Unknown nodes
121                 { mode => "mode_Iu" }
122         ],
123         mmx => [
124                 { name => "mm0", type => 4 },
125                 { name => "mm1", type => 4 },
126                 { name => "mm2", type => 4 },
127                 { name => "mm3", type => 4 },
128                 { name => "mm4", type => 4 },
129                 { name => "mm5", type => 4 },
130                 { name => "mm6", type => 4 },
131                 { name => "mm7", type => 4 },
132                 { mode => "mode_E", flags => "manual_ra" }
133         ],
134         xmm => [
135                 { name => "xmm0", type => 1 },
136                 { name => "xmm1", type => 1 },
137                 { name => "xmm2", type => 1 },
138                 { name => "xmm3", type => 1 },
139                 { name => "xmm4", type => 1 },
140                 { name => "xmm5", type => 1 },
141                 { name => "xmm6", type => 1 },
142                 { name => "xmm7", type => 1 },
143                 { name => "xmm_NOREG", type => 4 | 16 },     # we need a dummy register for NoReg nodes
144                 { name => "xmm_UKNWN", type => 4 | 8 | 16},  # we need a dummy register for Unknown nodes
145                 { mode => "mode_E" }
146         ],
147         vfp => [
148                 { name => "vf0", type => 1 },
149                 { name => "vf1", type => 1 },
150                 { name => "vf2", type => 1 },
151                 { name => "vf3", type => 1 },
152                 { name => "vf4", type => 1 },
153                 { name => "vf5", type => 1 },
154                 { name => "vf6", type => 1 },
155                 { name => "vf7", type => 1 },
156                 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
157                 { name => "vfp_UKNWN", type => 4 | 8 | 16 },  # we need a dummy register for Unknown nodes
158                 { mode => "mode_E" }
159         ],
160         st => [
161                 { name => "st0", realname => "st",    type => 4 },
162                 { name => "st1", realname => "st(1)", type => 4 },
163                 { name => "st2", realname => "st(2)", type => 4 },
164                 { name => "st3", realname => "st(3)", type => 4 },
165                 { name => "st4", realname => "st(4)", type => 4 },
166                 { name => "st5", realname => "st(5)", type => 4 },
167                 { name => "st6", realname => "st(6)", type => 4 },
168                 { name => "st7", realname => "st(7)", type => 4 },
169                 { mode => "mode_E", flags => "manual_ra" }
170         ],
171         fp_cw => [      # the floating point control word
172                 { name => "fpcw", type => 4|32 },
173                 { mode => "mode_fpcw", flags => "manual_ra|state" }
174         ],
175         flags => [
176                 { name => "eflags", type => 0 },
177                 { mode => "mode_Iu", flags => "manual_ra" }
178         ],
179 ); # %reg_classes
180
181 %cpu = (
182         GP     => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
183         SSE    => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
184         VFP    => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
185         BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
186 ); # %cpu
187
188 %vliw = (
189         bundle_size       => 1,
190         bundels_per_cycle => 1
191 ); # vliw
192
193 %emit_templates = (
194         S0 => "${arch}_emit_source_register(node, 0);",
195         S1 => "${arch}_emit_source_register(node, 1);",
196         S2 => "${arch}_emit_source_register(node, 2);",
197         S3 => "${arch}_emit_source_register(node, 3);",
198         SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
199         SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
200         SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
201         SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
202         SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
203         SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
204         SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
205         SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
206         SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
207         D0 => "${arch}_emit_dest_register(node, 0);",
208         D1 => "${arch}_emit_dest_register(node, 1);",
209         DS0 => "${arch}_emit_dest_register_size(node, 0);",
210         DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
211         X0 => "${arch}_emit_x87_register(node, 0);",
212         X1 => "${arch}_emit_x87_register(node, 1);",
213         EX => "${arch}_emit_extend_suffix(node);",
214         M  => "${arch}_emit_mode_suffix(node);",
215         XM => "${arch}_emit_x87_mode_suffix(node);",
216         XXM => "${arch}_emit_xmm_mode_suffix(node);",
217         XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
218         AM => "${arch}_emit_am(node);",
219         unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
220         unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
221         binop => "${arch}_emit_binop(node);",
222         x87_binop => "${arch}_emit_x87_binop(node);",
223         CMP0  => "${arch}_emit_cmp_suffix_node(node, 0);",
224         CMP3  => "${arch}_emit_cmp_suffix_node(node, 3);",
225 );
226
227
228
229
230 $default_op_attr_type = "ia32_op_attr_t";
231 $default_attr_type    = "ia32_attr_t";
232 $default_copy_attr    = "ia32_copy_attr";
233
234 sub ia32_custom_init_attr {
235         my $constr = shift;
236         my $node   = shift;
237         my $name   = shift;
238         my $res    = "";
239
240         if(defined($node->{modified_flags})) {
241                 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
242         }
243         if(defined($node->{am})) {
244                 my $am = $node->{am};
245                 if($am eq "source,unary") {
246                         $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
247                 } elsif($am eq "source,binary") {
248                         $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
249                 } elsif($am eq "none") {
250                         # nothing to do
251                 } else {
252                         die("Invalid address mode '$am' specified on op $name");
253                 }
254                 if($am ne "none") {
255                         if($node->{state} ne "exc_pinned"
256                                         and $node->{state} ne "pinned") {
257                                 die("AM nodes must have pinned or AM pinned state ($name)");
258                         }
259                 }
260         }
261         return $res;
262 }
263 $custom_init_attr_func = \&ia32_custom_init_attr;
264
265 %init_attr = (
266         ia32_asm_attr_t =>
267                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
268                 "\tinit_ia32_x87_attributes(res);".
269                 "\tinit_ia32_asm_attributes(res);",
270         ia32_attr_t     =>
271                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
272         ia32_call_attr_t =>
273                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
274                 "\tinit_ia32_call_attributes(res, pop, call_tp);",
275         ia32_condcode_attr_t =>
276                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
277                 "\tinit_ia32_condcode_attributes(res, pnc);",
278         ia32_copyb_attr_t =>
279                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
280                 "\tinit_ia32_copyb_attributes(res, size);",
281         ia32_immediate_attr_t =>
282                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
283                 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
284         ia32_x87_attr_t =>
285                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
286                 "\tinit_ia32_x87_attributes(res);",
287         ia32_climbframe_attr_t =>
288                 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
289                 "\tinit_ia32_climbframe_attributes(res, count);",
290 );
291
292 %compare_attr = (
293         ia32_asm_attr_t       => "ia32_compare_asm_attr",
294         ia32_attr_t            => "ia32_compare_nodes_attr",
295         ia32_call_attr_t       => "ia32_compare_call_attr",
296         ia32_condcode_attr_t   => "ia32_compare_condcode_attr",
297         ia32_copyb_attr_t      => "ia32_compare_copyb_attr",
298         ia32_immediate_attr_t  => "ia32_compare_immediate_attr",
299         ia32_x87_attr_t        => "ia32_compare_x87_attr",
300         ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
301 );
302
303 %operands = (
304 );
305
306 $mode_xmm           = "mode_E";
307 $mode_gp            = "mode_Iu";
308 $mode_flags         = "mode_Iu";
309 $mode_fpcw          = "mode_fpcw";
310 $status_flags       = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
311 $status_flags_wo_cf = [       "PF", "AF", "ZF", "SF", "OF" ];
312 $fpcw_flags         = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
313                         "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
314
315 %nodes = (
316
317 Immediate => {
318         state     => "pinned",
319         op_flags  => "c",
320         reg_req   => { out => [ "gp_NOREG:I" ] },
321         attr      => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
322         attr_type => "ia32_immediate_attr_t",
323         hash_func => "ia32_hash_Immediate",
324         latency   => 0,
325         mode      => $mode_gp,
326 },
327
328 Asm => {
329         mode      => "mode_T",
330         arity     => "variable",
331         out_arity => "variable",
332         attr_type => "ia32_asm_attr_t",
333         attr      => "ident *asm_text, const ia32_asm_reg_t *register_map",
334         init_attr => "attr->asm_text = asm_text;\n".
335                      "\tattr->register_map = register_map;\n",
336         latency   => 10,
337         modified_flags => $status_flags,
338 },
339
340 # "allocates" a free register
341 ProduceVal => {
342         op_flags  => "c|n",
343         irn_flags => "R",
344         reg_req   => { out => [ "gp" ] },
345         emit      => "",
346         units     => [ ],
347         latency   => 0,
348         mode      => $mode_gp,
349         cmp_attr  => "return 1;",
350 },
351
352 Add => {
353         irn_flags => "R",
354         state     => "exc_pinned",
355         reg_req   => { in  => [ "gp", "gp", "none", "gp", "gp" ],
356                        out => [ "in_r4 in_r5", "flags", "none" ] },
357         ins       => [ "base", "index", "mem", "left", "right" ],
358         outs      => [ "res", "flags", "M" ],
359         emit      => '. add%M %binop',
360         am        => "source,binary",
361         units     => [ "GP" ],
362         latency   => 1,
363         mode      => $mode_gp,
364         modified_flags => $status_flags
365 },
366
367 AddMem => {
368         irn_flags => "R",
369         state     => "exc_pinned",
370         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
371         ins       => [ "base", "index", "mem", "val" ],
372         emit      => ". add%M %SI3, %AM",
373         units     => [ "GP" ],
374         latency   => 1,
375         mode      => "mode_M",
376         modified_flags => $status_flags
377 },
378
379 AddMem8Bit => {
380         irn_flags => "R",
381         state     => "exc_pinned",
382         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
383         ins       => [ "base", "index", "mem", "val" ],
384         emit      => ". add%M %SB3, %AM",
385         units     => [ "GP" ],
386         latency   => 1,
387         mode      => "mode_M",
388         modified_flags => $status_flags
389 },
390
391 Adc => {
392         state     => "exc_pinned",
393         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
394                        out => [ "in_r4 in_r5", "flags", "none" ] },
395         ins       => [ "base", "index", "mem", "left", "right", "eflags" ],
396         outs      => [ "res", "flags", "M" ],
397         emit      => '. adc%M %binop',
398         am        => "source,binary",
399         units     => [ "GP" ],
400         latency   => 1,
401         mode      => $mode_gp,
402         modified_flags => $status_flags
403 },
404
405 l_Add => {
406         op_flags  => "C",
407         reg_req   => { in => [ "none", "none" ], out => [ "none" ] },
408         ins       => [ "left", "right" ],
409 },
410
411 l_Adc => {
412         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
413         ins       => [ "left", "right", "eflags" ],
414 },
415
416 Mul => {
417         # we should not rematrialize this node. It produces 2 results and has
418         # very strict constraints
419         state     => "exc_pinned",
420         reg_req   => { in => [ "gp", "gp", "none", "eax", "gp" ],
421                        out => [ "eax", "flags", "none", "edx" ] },
422         ins       => [ "base", "index", "mem", "left", "right" ],
423         emit      => '. mul%M %unop4',
424         outs      => [ "res_low", "flags", "M", "res_high" ],
425         am        => "source,binary",
426         latency   => 10,
427         units     => [ "GP" ],
428         modified_flags => $status_flags
429 },
430
431 l_Mul => {
432         # we should not rematrialize this node. It produces 2 results and has
433         # very strict constraints
434         op_flags  => "C",
435         cmp_attr  => "return 1;",
436         reg_req   => { in => [ "none", "none" ],
437                        out => [ "none", "none", "none", "none" ] },
438         ins       => [ "left", "right" ],
439         outs      => [ "res_low", "flags", "M", "res_high" ],
440 },
441
442 IMul => {
443         irn_flags => "R",
444         state     => "exc_pinned",
445         # TODO: adjust out requirements for the 3 operand form
446         # (no need for should_be_same then)
447         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ],
448                            out => [ "in_r4 in_r5", "flags", "none" ] },
449         ins       => [ "base", "index", "mem", "left", "right" ],
450         outs      => [ "res", "flags", "M" ],
451         am        => "source,binary",
452         latency   => 5,
453         units     => [ "GP" ],
454         mode      => $mode_gp,
455         modified_flags => $status_flags
456 },
457
458 IMul1OP => {
459         irn_flags => "R",
460         state     => "exc_pinned",
461         reg_req   => { in => [ "gp", "gp", "none", "eax", "gp" ],
462                        out => [ "eax", "flags", "none", "edx" ] },
463         ins       => [ "base", "index", "mem", "left", "right" ],
464         emit      => '. imul%M %unop4',
465         outs      => [ "res_low", "flags", "M", "res_high" ],
466         am        => "source,binary",
467         latency   => 5,
468         units     => [ "GP" ],
469         modified_flags => $status_flags
470 },
471
472 l_IMul => {
473         op_flags  => "C",
474         cmp_attr  => "return 1;",
475         reg_req   => { in => [ "none", "none" ],
476                        out => [ "none", "none", "none", "none" ] },
477         ins       => [ "left", "right" ],
478         outs      => [ "res_low", "flags", "M", "res_high" ],
479 },
480
481 And => {
482         irn_flags => "R",
483         state     => "exc_pinned",
484         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ],
485                            out => [ "in_r4 in_r5", "flags", "none" ] },
486         ins       => [ "base", "index", "mem", "left", "right" ],
487         outs      => [ "res", "flags", "M" ],
488         am        => "source,binary",
489         emit      => '. and%M %binop',
490         units     => [ "GP" ],
491         latency   => 1,
492         mode      => $mode_gp,
493         modified_flags => $status_flags
494 },
495
496 AndMem => {
497         irn_flags => "R",
498         state     => "exc_pinned",
499         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
500         ins       => [ "base", "index", "mem", "val" ],
501         emit      => '. and%M %SI3, %AM',
502         units     => [ "GP" ],
503         latency   => 1,
504         mode      => "mode_M",
505         modified_flags => $status_flags
506 },
507
508 AndMem8Bit => {
509         irn_flags => "R",
510         state     => "exc_pinned",
511         reg_req   => { in => [ "gp", "gp", "none",  "eax ebx ecx edx" ], out => [ "none" ] },
512         ins       => [ "base", "index", "mem", "val" ],
513         emit      => '. and%M %SB3, %AM',
514         units     => [ "GP" ],
515         latency   => 1,
516         mode      => "mode_M",
517         modified_flags => $status_flags
518 },
519
520 Or => {
521         irn_flags => "R",
522         state     => "exc_pinned",
523         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ],
524                        out => [ "in_r4 in_r5", "flags", "none" ] },
525         ins       => [ "base", "index", "mem", "left", "right" ],
526         outs      => [ "res", "flags", "M" ],
527         am        => "source,binary",
528         emit      => '. or%M %binop',
529         units     => [ "GP" ],
530         latency   => 1,
531         mode      => $mode_gp,
532         modified_flags => $status_flags
533 },
534
535 OrMem => {
536         irn_flags => "R",
537         state     => "exc_pinned",
538         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
539         ins       => [ "base", "index", "mem", "val" ],
540         emit      => '. or%M %SI3, %AM',
541         units     => [ "GP" ],
542         latency   => 1,
543         mode      => "mode_M",
544         modified_flags => $status_flags
545 },
546
547 OrMem8Bit => {
548         irn_flags => "R",
549         state     => "exc_pinned",
550         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
551         ins       => [ "base", "index", "mem", "val" ],
552         emit      => '. or%M %SB3, %AM',
553         units     => [ "GP" ],
554         latency   => 1,
555         mode      => "mode_M",
556         modified_flags => $status_flags
557 },
558
559 Xor => {
560         irn_flags => "R",
561         state     => "exc_pinned",
562         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ],
563                        out => [ "in_r4 in_r5", "flags", "none" ] },
564         ins       => [ "base", "index", "mem", "left", "right" ],
565         outs      => [ "res", "flags", "M" ],
566         am        => "source,binary",
567         emit      => '. xor%M %binop',
568         units     => [ "GP" ],
569         latency   => 1,
570         mode      => $mode_gp,
571         modified_flags => $status_flags
572 },
573
574 Xor0 => {
575         op_flags  => "c",
576         irn_flags => "R",
577         reg_req   => { out => [ "gp", "flags" ] },
578         outs      => [ "res", "flags" ],
579         emit      => ". xor%M %D0, %D0",
580         units     => [ "GP" ],
581         latency   => 1,
582         mode      => $mode_gp,
583         modified_flags => $status_flags
584 },
585
586 XorMem => {
587         irn_flags => "R",
588         state     => "exc_pinned",
589         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
590         ins       => [ "base", "index", "mem", "val" ],
591         emit      => '. xor%M %SI3, %AM',
592         units     => [ "GP" ],
593         latency   => 1,
594         mode      => "mode_M",
595         modified_flags => $status_flags
596 },
597
598 XorMem8Bit => {
599         irn_flags => "R",
600         state     => "exc_pinned",
601         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
602         ins       => [ "base", "index", "mem", "val" ],
603         emit      => '. xor%M %SB3, %AM',
604         units     => [ "GP" ],
605         latency   => 1,
606         mode      => "mode_M",
607         modified_flags => $status_flags
608 },
609
610 Sub => {
611         irn_flags => "R",
612         state     => "exc_pinned",
613         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ],
614                        out => [ "in_r4", "flags", "none" ] },
615         ins       => [ "base", "index", "mem", "minuend", "subtrahend" ],
616         outs      => [ "res", "flags", "M" ],
617         am        => "source,binary",
618         emit      => '. sub%M %binop',
619         units     => [ "GP" ],
620         latency   => 1,
621         mode      => $mode_gp,
622         modified_flags => $status_flags
623 },
624
625 SubMem => {
626         irn_flags => "R",
627         state     => "exc_pinned",
628         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
629         ins       => [ "base", "index", "mem", "subtrahend" ],
630         emit      => '. sub%M %SI3, %AM',
631         units     => [ "GP" ],
632         latency   => 1,
633         mode      => 'mode_M',
634         modified_flags => $status_flags
635 },
636
637 SubMem8Bit => {
638         irn_flags => "R",
639         state     => "exc_pinned",
640         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
641         ins       => [ "base", "index", "mem", "subtrahend" ],
642         emit      => '. sub%M %SB3, %AM',
643         units     => [ "GP" ],
644         latency   => 1,
645         mode      => 'mode_M',
646         modified_flags => $status_flags
647 },
648
649 Sbb => {
650         state     => "exc_pinned",
651         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
652                        out => [ "in_r4 !in_r5", "flags", "none" ] },
653         ins       => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
654         outs      => [ "res", "flags", "M" ],
655         am        => "source,binary",
656         emit      => '. sbb%M %binop',
657         units     => [ "GP" ],
658         latency   => 1,
659         mode      => $mode_gp,
660         modified_flags => $status_flags
661 },
662
663 Sbb0 => {
664         irn_flags => "R",
665         reg_req   => { in => [ "flags" ], out => [ "gp", "flags" ] },
666         outs      => [ "res", "flags" ],
667         emit      => ". sbb%M %D0, %D0",
668         units     => [ "GP" ],
669         latency   => 1,
670         mode      => $mode_gp,
671         modified_flags => $status_flags
672 },
673
674 l_Sub => {
675         reg_req   => { in => [ "none", "none" ], out => [ "none" ] },
676         ins       => [ "minuend", "subtrahend" ],
677 },
678
679 l_Sbb => {
680         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
681         ins       => [ "minuend", "subtrahend", "eflags" ],
682 },
683
684 IDiv => {
685         op_flags  => "F|L",
686         state     => "exc_pinned",
687         reg_req   => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
688                        out => [ "eax", "flags", "none", "edx", "none" ] },
689         ins       => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
690         outs      => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
691         am        => "source,unary",
692         emit      => ". idiv%M %unop3",
693         latency   => 25,
694         units     => [ "GP" ],
695         modified_flags => $status_flags
696 },
697
698 Div => {
699         op_flags  => "F|L",
700         state     => "exc_pinned",
701         reg_req   => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
702                        out => [ "eax", "flags", "none", "edx", "none" ] },
703         ins       => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
704         outs      => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
705         am        => "source,unary",
706         emit      => ". div%M %unop3",
707         latency   => 25,
708         units     => [ "GP" ],
709         modified_flags => $status_flags
710 },
711
712 Shl => {
713         irn_flags => "R",
714         reg_req   => { in => [ "gp", "ecx" ],
715                        out => [ "in_r1 !in_r2", "flags" ] },
716         ins       => [ "val", "count" ],
717         outs      => [ "res", "flags" ],
718         emit      => '. shl%M %SB1, %S0',
719         units     => [ "GP" ],
720         latency   => 1,
721         mode      => $mode_gp,
722         modified_flags => $status_flags
723 },
724
725 ShlMem => {
726         irn_flags => "R",
727         state     => "exc_pinned",
728         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
729         ins       => [ "base", "index", "mem", "count" ],
730         emit      => '. shl%M %SB3, %AM',
731         units     => [ "GP" ],
732         latency   => 1,
733         mode      => "mode_M",
734         modified_flags => $status_flags
735 },
736
737 l_ShlDep => {
738         cmp_attr => "return 1;",
739         reg_req  => { in => [ "none", "none", "none" ], out => [ "none" ] },
740         ins      => [ "val", "count", "dep" ],
741 },
742
743 ShlD => {
744         irn_flags => "R",
745         reg_req   => { in => [ "gp", "gp", "ecx" ],
746                        out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
747         ins       => [ "val_high", "val_low", "count" ],
748         outs      => [ "res", "flags" ],
749         emit      => ". shld%M %SB2, %S1, %D0",
750         latency   => 6,
751         units     => [ "GP" ],
752         mode      => $mode_gp,
753         modified_flags => $status_flags
754 },
755
756 l_ShlD => {
757         cmp_attr  => "return 1;",
758         reg_req  => { in => [ "none", "none", "none" ], out => [ "none" ] },
759         ins       => [ "val_high", "val_low", "count" ],
760 },
761
762 Shr => {
763         irn_flags => "R",
764         reg_req   => { in => [ "gp", "ecx" ],
765                        out => [ "in_r1 !in_r2", "flags" ] },
766         ins       => [ "val", "count" ],
767         outs      => [ "res", "flags" ],
768         emit      => '. shr%M %SB1, %S0',
769         units     => [ "GP" ],
770         mode      => $mode_gp,
771         latency   => 1,
772         modified_flags => $status_flags
773 },
774
775 ShrMem => {
776         irn_flags => "R",
777         state     => "exc_pinned",
778         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
779         ins       => [ "base", "index", "mem", "count" ],
780         emit      => '. shr%M %SB3, %AM',
781         units     => [ "GP" ],
782         mode      => "mode_M",
783         latency   => 1,
784         modified_flags => $status_flags
785 },
786
787 l_ShrDep => {
788         cmp_attr  => "return 1;",
789         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
790         ins       => [ "val", "count", "dep" ],
791 },
792
793 ShrD => {
794         irn_flags => "R",
795         reg_req   => { in => [ "gp", "gp", "ecx" ],
796                        out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
797         ins       => [ "val_high", "val_low", "count" ],
798         outs      => [ "res", "flags" ],
799         emit      => ". shrd%M %SB2, %S1, %D0",
800         latency   => 6,
801         units     => [ "GP" ],
802         mode      => $mode_gp,
803         modified_flags => $status_flags
804 },
805
806 l_ShrD => {
807         cmp_attr  => "return 1;",
808         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
809         ins       => [ "val_high", "val_low", "count" ],
810 },
811
812 Sar => {
813         irn_flags => "R",
814         reg_req   => { in => [ "gp", "ecx" ],
815                        out => [ "in_r1 !in_r2", "flags" ] },
816         ins       => [ "val", "count" ],
817         outs      => [ "res", "flags" ],
818         emit      => '. sar%M %SB1, %S0',
819         units     => [ "GP" ],
820         latency   => 1,
821         mode      => $mode_gp,
822         modified_flags => $status_flags
823 },
824
825 SarMem => {
826         irn_flags => "R",
827         state     => "exc_pinned",
828         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
829         ins       => [ "base", "index", "mem", "count" ],
830         emit      => '. sar%M %SB3, %AM',
831         units     => [ "GP" ],
832         latency   => 1,
833         mode      => "mode_M",
834         modified_flags => $status_flags
835 },
836
837 l_SarDep => {
838         cmp_attr  => "return 1;",
839         ins       => [ "val", "count", "dep" ],
840         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
841 },
842
843 Ror => {
844         irn_flags => "R",
845         reg_req   => { in => [ "gp", "ecx" ],
846                        out => [ "in_r1 !in_r2", "flags" ] },
847         ins       => [ "val", "count" ],
848         outs      => [ "res", "flags" ],
849         emit      => '. ror%M %SB1, %S0',
850         units     => [ "GP" ],
851         latency   => 1,
852         mode      => $mode_gp,
853         modified_flags => $status_flags
854 },
855
856 RorMem => {
857         irn_flags => "R",
858         state     => "exc_pinned",
859         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
860         ins       => [ "base", "index", "mem", "count" ],
861         emit      => '. ror%M %SB3, %AM',
862         units     => [ "GP" ],
863         latency   => 1,
864         mode      => "mode_M",
865         modified_flags => $status_flags
866 },
867
868 Rol => {
869         irn_flags => "R",
870         reg_req   => { in => [ "gp", "ecx" ],
871                        out => [ "in_r1 !in_r2", "flags" ] },
872         ins       => [ "val", "count" ],
873         outs      => [ "res", "flags" ],
874         emit      => '. rol%M %SB1, %S0',
875         units     => [ "GP" ],
876         latency   => 1,
877         mode      => $mode_gp,
878         modified_flags => $status_flags
879 },
880
881 RolMem => {
882         irn_flags => "R",
883         state     => "exc_pinned",
884         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
885         ins       => [ "base", "index", "mem", "count" ],
886         emit      => '. rol%M %SB3, %AM',
887         units     => [ "GP" ],
888         latency   => 1,
889         mode      => "mode_M",
890         modified_flags => $status_flags
891 },
892
893 Neg => {
894         irn_flags => "R",
895         reg_req   => { in => [ "gp" ],
896                        out => [ "in_r1", "flags" ] },
897         emit      => '. neg%M %S0',
898         ins       => [ "val" ],
899         outs      => [ "res", "flags" ],
900         units     => [ "GP" ],
901         latency   => 1,
902         mode      => $mode_gp,
903         modified_flags => $status_flags
904 },
905
906 NegMem => {
907         irn_flags => "R",
908         state     => "exc_pinned",
909         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
910         ins       => [ "base", "index", "mem" ],
911         emit      => '. neg%M %AM',
912         units     => [ "GP" ],
913         latency   => 1,
914         mode      => "mode_M",
915         modified_flags => $status_flags
916 },
917
918 Minus64Bit => {
919         irn_flags => "R",
920         reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
921         outs      => [ "low_res", "high_res" ],
922         units     => [ "GP" ],
923         latency   => 3,
924         modified_flags => $status_flags
925 },
926
927
928 Inc => {
929         irn_flags => "R",
930         reg_req   => { in => [ "gp" ],
931                        out => [ "in_r1", "flags" ] },
932         ins       => [ "val" ],
933         outs      => [ "res", "flags" ],
934         emit      => '. inc%M %S0',
935         units     => [ "GP" ],
936         mode      => $mode_gp,
937         latency   => 1,
938         modified_flags => $status_flags_wo_cf
939 },
940
941 IncMem => {
942         irn_flags => "R",
943         state     => "exc_pinned",
944         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
945         ins       => [ "base", "index", "mem" ],
946         emit      => '. inc%M %AM',
947         units     => [ "GP" ],
948         mode      => "mode_M",
949         latency   => 1,
950         modified_flags => $status_flags_wo_cf
951 },
952
953 Dec => {
954         irn_flags => "R",
955         reg_req   => { in => [ "gp" ],
956                        out => [ "in_r1", "flags" ] },
957         ins       => [ "val" ],
958         outs      => [ "res", "flags" ],
959         emit      => '. dec%M %S0',
960         units     => [ "GP" ],
961         mode      => $mode_gp,
962         latency   => 1,
963         modified_flags => $status_flags_wo_cf
964 },
965
966 DecMem => {
967         irn_flags => "R",
968         state     => "exc_pinned",
969         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
970         ins       => [ "base", "index", "mem" ],
971         emit      => '. dec%M %AM',
972         units     => [ "GP" ],
973         mode      => "mode_M",
974         latency   => 1,
975         modified_flags => $status_flags_wo_cf
976 },
977
978 Not => {
979         irn_flags => "R",
980         reg_req   => { in => [ "gp" ],
981                        out => [ "in_r1", "flags" ] },
982         ins       => [ "val" ],
983         outs      => [ "res", "flags" ],
984         emit      => '. not%M %S0',
985         units     => [ "GP" ],
986         latency   => 1,
987         mode      => $mode_gp,
988         # no flags modified
989 },
990
991 NotMem => {
992         irn_flags => "R",
993         state     => "exc_pinned",
994         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
995         ins       => [ "base", "index", "mem" ],
996         emit      => '. not%M %AM',
997         units     => [ "GP" ],
998         latency   => 1,
999         mode      => "mode_M",
1000         # no flags modified
1001 },
1002
1003 Cmc => {
1004         reg_req   => { in => [ "flags" ], out => [ "flags" ] },
1005         emit      => '.cmc',
1006         units     => [ "GP" ],
1007         latency   => 1,
1008         mode      => $mode_flags,
1009         modified_flags => $status_flags
1010 },
1011
1012 Stc => {
1013         reg_req   => { out => [ "flags" ] },
1014         emit      => '.stc',
1015         units     => [ "GP" ],
1016         latency   => 1,
1017         mode      => $mode_flags,
1018         modified_flags => $status_flags
1019 },
1020
1021 Cmp => {
1022         irn_flags => "R",
1023         state     => "exc_pinned",
1024         reg_req   => { in  => [ "gp", "gp", "none", "gp", "gp" ],
1025                        out => [ "flags", "none", "none" ] },
1026         ins       => [ "base", "index", "mem", "left", "right" ],
1027         outs      => [ "eflags", "unused", "M" ],
1028         am        => "source,binary",
1029         emit      => '. cmp%M %binop',
1030         attr      => "int ins_permuted, int cmp_unsigned",
1031         init_attr => "attr->data.ins_permuted   = ins_permuted;\n".
1032                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1033         latency   => 1,
1034         units     => [ "GP" ],
1035         mode      => $mode_flags,
1036         modified_flags => $status_flags
1037 },
1038
1039 Cmp8Bit => {
1040         irn_flags => "R",
1041         state     => "exc_pinned",
1042         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1043                        out => [ "flags", "none", "none" ] },
1044         ins       => [ "base", "index", "mem", "left", "right" ],
1045         outs      => [ "eflags", "unused", "M" ],
1046         am        => "source,binary",
1047         emit      => '. cmpb %binop',
1048         attr      => "int ins_permuted, int cmp_unsigned",
1049         init_attr => "attr->data.ins_permuted   = ins_permuted;\n".
1050                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1051         latency   => 1,
1052         units     => [ "GP" ],
1053         mode      => $mode_flags,
1054         modified_flags => $status_flags
1055 },
1056
1057 Test => {
1058         irn_flags => "R",
1059         state     => "exc_pinned",
1060         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
1061                        out => [ "flags", "none", "none" ] },
1062         ins       => [ "base", "index", "mem", "left", "right" ],
1063         outs      => [ "eflags", "unused", "M" ],
1064         am        => "source,binary",
1065         emit      => '. test%M %binop',
1066         attr      => "int ins_permuted, int cmp_unsigned",
1067         init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1068                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1069         latency   => 1,
1070         units     => [ "GP" ],
1071         mode      => $mode_flags,
1072         modified_flags => $status_flags
1073 },
1074
1075 Test8Bit => {
1076         irn_flags => "R",
1077         state     => "exc_pinned",
1078         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1079                        out => [ "flags", "none", "none" ] },
1080         ins       => [ "base", "index", "mem", "left", "right" ],
1081         outs      => [ "eflags", "unused", "M" ],
1082         am        => "source,binary",
1083         emit      => '. testb %binop',
1084         attr      => "int ins_permuted, int cmp_unsigned",
1085         init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1086                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1087         latency   => 1,
1088         units     => [ "GP" ],
1089         mode      => $mode_flags,
1090         modified_flags => $status_flags
1091 },
1092
1093 Setcc => {
1094         #irn_flags => "R",
1095         reg_req   => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1096         ins       => [ "eflags" ],
1097         outs      => [ "res" ],
1098         attr_type => "ia32_condcode_attr_t",
1099         attr      => "pn_Cmp pnc",
1100         init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1101         latency   => 1,
1102         units     => [ "GP" ],
1103         mode      => $mode_gp,
1104 },
1105
1106 SetccMem => {
1107         #irn_flags => "R",
1108         state     => "exc_pinned",
1109         reg_req   => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1110         ins       => [ "base", "index", "mem","eflags" ],
1111         attr_type => "ia32_condcode_attr_t",
1112         attr      => "pn_Cmp pnc",
1113         init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1114         emit      => '. set%CMP3 %AM',
1115         latency   => 1,
1116         units     => [ "GP" ],
1117         mode      => 'mode_M',
1118 },
1119
1120 CMovcc => {
1121         #irn_flags => "R",
1122         # (note: leave the false,true order intact to make it compatible with other
1123         #  ia32_binary ops)
1124         state     => "exc_pinned",
1125         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1126                        out => [ "in_r4 in_r5", "flags", "none" ] },
1127         ins       => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1128         outs      => [ "res", "flags", "M" ],
1129         am        => "source,binary",
1130         attr_type => "ia32_condcode_attr_t",
1131         attr      => "pn_Cmp pnc",
1132         latency   => 1,
1133         units     => [ "GP" ],
1134         mode      => $mode_gp,
1135 },
1136
1137 Jcc => {
1138         state     => "pinned",
1139         op_flags  => "L|X|Y",
1140         reg_req   => { in  => [ "eflags" ], out => [ "none", "none" ] },
1141         ins       => [ "eflags" ],
1142         outs      => [ "false", "true" ],
1143         attr_type => "ia32_condcode_attr_t",
1144         attr      => "pn_Cmp pnc",
1145         latency   => 2,
1146         units     => [ "BRANCH" ],
1147 },
1148
1149 SwitchJmp => {
1150         state     => "pinned",
1151         op_flags  => "L|X|Y",
1152         reg_req   => { in => [ "gp" ] },
1153         mode      => "mode_T",
1154         attr_type => "ia32_condcode_attr_t",
1155         attr      => "long pnc",
1156         latency   => 3,
1157         units     => [ "BRANCH" ],
1158         modified_flags => $status_flags,
1159         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1160 },
1161
1162 Jmp => {
1163         state     => "pinned",
1164         irn_flags => "J",
1165         op_flags  => "X",
1166         reg_req   => { out => [ "none" ] },
1167         latency   => 1,
1168         units     => [ "BRANCH" ],
1169         mode      => "mode_X",
1170 },
1171
1172 IJmp => {
1173         state     => "pinned",
1174         op_flags  => "X",
1175         reg_req   => { in => [ "gp", "gp", "none", "gp" ] },
1176         ins       => [ "base", "index", "mem", "target" ],
1177         am        => "source,unary",
1178         emit      => '. jmp *%unop3',
1179         latency   => 1,
1180         units     => [ "BRANCH" ],
1181         mode      => "mode_X",
1182         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1183 },
1184
1185 Const => {
1186         op_flags  => "c",
1187         irn_flags => "R",
1188         reg_req   => { out => [ "gp" ] },
1189         units     => [ "GP" ],
1190         attr      => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1191         attr_type => "ia32_immediate_attr_t",
1192         latency   => 1,
1193         mode      => $mode_gp,
1194 },
1195
1196 GetEIP => {
1197         op_flags => "c",
1198         reg_req  => { out => [ "gp" ] },
1199         units    => [ "GP" ],
1200         latency  => 5,
1201         mode     => $mode_gp,
1202         modified_flags => $status_flags,
1203 },
1204
1205 Unknown_GP => {
1206         state     => "pinned",
1207         op_flags  => "c|NB",
1208         reg_req   => { out => [ "gp_UKNWN:I" ] },
1209         units     => [],
1210         emit      => "",
1211         latency   => 0,
1212         mode      => $mode_gp
1213 },
1214
1215 Unknown_VFP => {
1216         state     => "pinned",
1217         op_flags  => "c|NB",
1218         reg_req   => { out => [ "vfp_UKNWN:I" ] },
1219         units     => [],
1220         emit      => "",
1221         mode      => "mode_E",
1222         latency   => 0,
1223         attr_type => "ia32_x87_attr_t",
1224 },
1225
1226 Unknown_XMM => {
1227         state     => "pinned",
1228         op_flags  => "c|NB",
1229         reg_req   => { out => [ "xmm_UKNWN:I" ] },
1230         units     => [],
1231         emit      => "",
1232         latency   => 0,
1233         mode      => $mode_xmm
1234 },
1235
1236 NoReg_GP => {
1237         state     => "pinned",
1238         op_flags  => "c|NB|NI",
1239         reg_req   => { out => [ "gp_NOREG:I" ] },
1240         units     => [],
1241         emit      => "",
1242         latency   => 0,
1243         mode      => $mode_gp
1244 },
1245
1246 NoReg_VFP => {
1247         state     => "pinned",
1248         op_flags  => "c|NB|NI",
1249         reg_req   => { out => [ "vfp_NOREG:I" ] },
1250         units     => [],
1251         emit      => "",
1252         mode      => "mode_E",
1253         latency   => 0,
1254         attr_type => "ia32_x87_attr_t",
1255 },
1256
1257 NoReg_XMM => {
1258         state     => "pinned",
1259         op_flags  => "c|NB|NI",
1260         reg_req   => { out => [ "xmm_NOREG:I" ] },
1261         units     => [],
1262         emit      => "",
1263         latency   => 0,
1264         mode      => "mode_E"
1265 },
1266
1267 ChangeCW => {
1268         state     => "pinned",
1269         op_flags  => "c",
1270         reg_req   => { out => [ "fpcw:I" ] },
1271         mode      => $mode_fpcw,
1272         latency   => 3,
1273         units     => [ "GP" ],
1274         modified_flags => $fpcw_flags
1275 },
1276
1277 FldCW => {
1278         op_flags  => "L|F",
1279         state     => "pinned",
1280         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1281         ins       => [ "base", "index", "mem" ],
1282         latency   => 5,
1283         emit      => ". fldcw %AM",
1284         mode      => $mode_fpcw,
1285         units     => [ "GP" ],
1286         modified_flags => $fpcw_flags
1287 },
1288
1289 FnstCW => {
1290         op_flags  => "L|F",
1291         state     => "pinned",
1292         reg_req   => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1293         ins       => [ "base", "index", "mem", "fpcw" ],
1294         latency   => 5,
1295         emit      => ". fnstcw %AM",
1296         mode      => "mode_M",
1297         units     => [ "GP" ],
1298 },
1299
1300 FnstCWNOP => {
1301         op_flags  => "L|F",
1302         state     => "pinned",
1303         reg_req   => { in => [ "fp_cw" ], out => [ "none" ] },
1304         ins       => [ "fpcw" ],
1305         latency   => 0,
1306         emit      => "",
1307         mode      => "mode_M",
1308 },
1309
1310 Cltd => {
1311         # we should not rematrialize this node. It has very strict constraints.
1312         reg_req   => { in => [ "eax", "edx" ], out => [ "edx" ] },
1313         ins       => [ "val", "clobbered" ],
1314         emit      => '. cltd',
1315         latency   => 1,
1316         mode      => $mode_gp,
1317         units     => [ "GP" ],
1318 },
1319
1320 # Load / Store
1321 #
1322 # Note that we add additional latency values depending on address mode, so a
1323 # lateny of 0 for load is correct
1324
1325 Load => {
1326         op_flags  => "L|F",
1327         state     => "exc_pinned",
1328         reg_req   => { in => [ "gp", "gp", "none" ],
1329                        out => [ "gp", "none", "none", "none" ] },
1330         ins       => [ "base", "index", "mem" ],
1331         outs      => [ "res", "unused", "M", "X_exc" ],
1332         latency   => 0,
1333         emit      => ". mov%EX%.l %AM, %D0",
1334         units     => [ "GP" ],
1335 },
1336
1337 Store => {
1338         op_flags  => "L|F",
1339         state     => "exc_pinned",
1340         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1341         ins       => [ "base", "index", "mem", "val" ],
1342         outs      => [ "M", "X_exc" ],
1343         emit      => '. mov%M %SI3, %AM',
1344         latency   => 2,
1345         units     => [ "GP" ],
1346         mode      => "mode_M",
1347 },
1348
1349 Store8Bit => {
1350         op_flags  => "L|F",
1351         state     => "exc_pinned",
1352         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1353         ins       => [ "base", "index", "mem", "val" ],
1354         outs      => [ "M", "X_exc" ],
1355         emit      => '. mov%M %SB3, %AM',
1356         latency   => 2,
1357         units     => [ "GP" ],
1358         mode      => "mode_M",
1359 },
1360
1361 Lea => {
1362         irn_flags => "R",
1363         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
1364         ins       => [ "base", "index" ],
1365         emit      => '. leal %AM, %D0',
1366         latency   => 2,
1367         units     => [ "GP" ],
1368         mode      => $mode_gp,
1369 # lea doesn't modify the flags, but setting this seems advantageous since it
1370 # increases chances that the Lea is transformed back to an Add
1371         modified_flags => 1,
1372 },
1373
1374 Push => {
1375         state     => "exc_pinned",
1376         reg_req   => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1377         ins       => [ "base", "index", "mem", "val", "stack" ],
1378         emit      => '. push%M %unop3',
1379         outs      => [ "stack", "M" ],
1380         am        => "source,unary",
1381         latency   => 2,
1382         units     => [ "GP" ],
1383 },
1384
1385 Pop => {
1386         state     => "exc_pinned",
1387         reg_req   => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1388         ins       => [ "mem", "stack" ],
1389         outs      => [ "res", "M", "unused", "stack" ],
1390         emit      => '. pop%M %D0',
1391         latency   => 3, # Pop is more expensive than Push on Athlon
1392         units     => [ "GP" ],
1393 },
1394
1395 PopEbp => {
1396         state     => "exc_pinned",
1397         reg_req   => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1398         ins       => [ "mem", "stack" ],
1399         outs      => [ "res", "M", "unused", "stack" ],
1400         emit      => '. pop%M %D0',
1401         latency   => 3, # Pop is more expensive than Push on Athlon
1402         units     => [ "GP" ],
1403 },
1404
1405 PopMem => {
1406         state     => "exc_pinned",
1407         reg_req   => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1408         ins       => [ "base", "index", "mem", "stack" ],
1409         outs      => [ "unused0", "M", "unused1", "stack" ],
1410         emit      => '. pop%M %AM',
1411         latency   => 3, # Pop is more expensive than Push on Athlon
1412         units     => [ "GP" ],
1413 },
1414
1415 Enter => {
1416         reg_req   => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1417         emit      => '. enter',
1418         outs      => [ "frame", "stack", "M" ],
1419         latency   => 15,
1420         units     => [ "GP" ],
1421 },
1422
1423 Leave => {
1424         reg_req   => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1425         emit      => '. leave',
1426         outs      => [ "frame", "stack" ],
1427         latency   => 3,
1428         units     => [ "GP" ],
1429 },
1430
1431 AddSP => {
1432         state     => "pinned",
1433         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1434         ins       => [ "base", "index", "mem", "stack", "size" ],
1435         am        => "source,binary",
1436         emit      => '. addl %binop',
1437         latency   => 1,
1438         outs      => [ "stack", "M" ],
1439         units     => [ "GP" ],
1440         modified_flags => $status_flags
1441 },
1442
1443 SubSP => {
1444         state     => "pinned",
1445         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1446         ins       => [ "base", "index", "mem", "stack", "size" ],
1447         am        => "source,binary",
1448         emit      => ". subl %binop\n".
1449                      ". movl %%esp, %D1",
1450         latency   => 2,
1451         outs      => [ "stack", "addr", "M" ],
1452         units     => [ "GP" ],
1453         modified_flags => $status_flags
1454 },
1455
1456 RepPrefix => {
1457         op_flags  => "K",
1458         state     => "pinned",
1459         mode      => "mode_M",
1460         emit      => ". rep",
1461         latency   => 0,
1462 },
1463
1464 LdTls => {
1465         irn_flags => "R",
1466         reg_req   => { out => [ "gp" ] },
1467         units     => [ "GP" ],
1468         latency   => 1,
1469 },
1470
1471 #
1472 # BT supports source address mode, but this is unused yet
1473 #
1474 Bt => {
1475         irn_flags => "R",
1476         state     => "exc_pinned",
1477         reg_req   => { in => [ "gp", "gp" ], out => [ "flags" ] },
1478         ins       => [ "left", "right" ],
1479         emit      => '. bt%M %S1, %S0',
1480         units     => [ "GP" ],
1481         latency   => 1,
1482         mode      => $mode_flags,
1483         modified_flags => $status_flags  # only CF is set, but the other flags are undefined
1484 },
1485
1486 Bsf => {
1487         irn_flags => "R",
1488         state     => "exc_pinned",
1489         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
1490                        out => [ "gp", "flags", "none" ] },
1491         ins       => [ "base", "index", "mem", "operand" ],
1492         outs      => [ "res", "flags", "M" ],
1493         am        => "source,binary",
1494         emit      => '. bsf%M %unop3, %D0',
1495         units     => [ "GP" ],
1496         latency   => 1,
1497         mode      => $mode_gp,
1498         modified_flags => $status_flags
1499 },
1500
1501 Bsr => {
1502         irn_flags => "R",
1503         state     => "exc_pinned",
1504         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
1505                        out => [ "gp", "flags", "none" ] },
1506         ins       => [ "base", "index", "mem", "operand" ],
1507         outs      => [ "res", "flags", "M" ],
1508         am        => "source,binary",
1509         emit      => '. bsr%M %unop3, %D0',
1510         units     => [ "GP" ],
1511         latency   => 1,
1512         mode      => $mode_gp,
1513         modified_flags => $status_flags
1514 },
1515
1516 #
1517 # SSE4.2 or SSE4a popcnt instruction
1518 #
1519 Popcnt => {
1520         irn_flags => "R",
1521         state     => "exc_pinned",
1522         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
1523                        out => [ "gp", "flags", "none" ] },
1524         ins       => [ "base", "index", "mem", "operand" ],
1525         outs      => [ "res", "flags", "M" ],
1526         am        => "source,binary",
1527         emit      => '. popcnt%M %unop3, %D0',
1528         units     => [ "GP" ],
1529         latency   => 1,
1530         mode      => $mode_gp,
1531         modified_flags => $status_flags
1532 },
1533
1534 Call => {
1535         state     => "exc_pinned",
1536         reg_req   => {
1537                 in  => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1538                 out => [ "esp:I|S", "fpcw:I", "none", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ]
1539         },
1540         ins       => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1541         outs      => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1542         attr_type => "ia32_call_attr_t",
1543         attr      => "unsigned pop, ir_type *call_tp",
1544         am        => "source,unary",
1545         units     => [ "BRANCH" ],
1546         latency   => 4, # random number
1547         modified_flags => $status_flags
1548 },
1549
1550 #
1551 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1552 #
1553 # PS: try gcc __builtin_frame_address(100000) :-)
1554 #
1555 ClimbFrame => {
1556         reg_req   => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1557         ins       => [ "frame", "cnt", "tmp" ],
1558         outs      => [ "res" ],
1559         latency   => 4, # random number
1560         attr_type => "ia32_climbframe_attr_t",
1561         attr      => "unsigned count",
1562         units     => [ "GP" ],
1563         mode      => $mode_gp
1564 },
1565
1566 #
1567 # bswap
1568 #
1569 Bswap => {
1570         irn_flags => "R",
1571         reg_req   => { in => [ "gp" ],
1572                        out => [ "in_r1" ] },
1573         emit      => '. bswap%M %S0',
1574         ins       => [ "val" ],
1575         units     => [ "GP" ],
1576         latency   => 1,
1577         mode      => $mode_gp,
1578 },
1579
1580 #
1581 # bswap16, use xchg here
1582 #
1583 Bswap16 => {
1584         irn_flags => "R",
1585         reg_req   => { in => [ "eax ebx ecx edx" ],
1586                        out => [ "in_r1" ] },
1587         emit      => '. xchg %SB0, %SH0',
1588         ins       => [ "val" ],
1589         units     => [ "GP" ],
1590         latency   => 1,
1591         mode      => $mode_gp,
1592 },
1593
1594 #
1595 # BreakPoint
1596 #
1597 Breakpoint => {
1598         state     => "pinned",
1599         reg_req   => { in => [ "none" ], out => [ "none" ] },
1600         ins       => [ "mem" ],
1601         latency   => 0,
1602         emit      => ". int3",
1603         units     => [ "GP" ],
1604         mode      => mode_M,
1605 },
1606
1607 #
1608 # Undefined Instruction on ALL x86 CPU's
1609 #
1610 UD2 => {
1611         state     => "pinned",
1612         reg_req   => { in => [ "none" ], out => [ "none" ] },
1613         ins       => [ "mem" ],
1614         latency   => 0,
1615         emit      => ". .value  0x0b0f",
1616         units     => [ "GP" ],
1617         mode      => mode_M,
1618 },
1619
1620 #
1621 # outport
1622 #
1623 Outport => {
1624         irn_flags => "R",
1625         state     => "pinned",
1626         reg_req   => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1627         ins       => [ "port", "value", "mem" ],
1628         emit      => '. out%M %SS0, %SI1',
1629         units     => [ "GP" ],
1630         latency   => 1,
1631         mode      => mode_M,
1632         modified_flags => $status_flags
1633 },
1634
1635 #
1636 # inport
1637 #
1638 Inport => {
1639         irn_flags => "R",
1640         state     => "pinned",
1641         reg_req   => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1642         ins       => [ "port", "mem" ],
1643         outs      => [ "res", "M" ],
1644         emit      => '. in%M %DS0, %SS0',
1645         units     => [ "GP" ],
1646         latency   => 1,
1647         mode      => mode_T,
1648         modified_flags => $status_flags
1649 },
1650
1651 #
1652 # Intel style prefetching
1653 #
1654 Prefetch0 => {
1655         op_flags  => "L|F",
1656         state     => "exc_pinned",
1657         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1658         ins       => [ "base", "index", "mem" ],
1659         outs      => [ "M" ],
1660         latency   => 0,
1661         emit      => ". prefetcht0 %AM",
1662         units     => [ "GP" ],
1663 },
1664
1665 Prefetch1 => {
1666         op_flags  => "L|F",
1667         state     => "exc_pinned",
1668         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1669         ins       => [ "base", "index", "mem" ],
1670         outs      => [ "M" ],
1671         latency   => 0,
1672         emit      => ". prefetcht1 %AM",
1673         units     => [ "GP" ],
1674 },
1675
1676 Prefetch2 => {
1677         op_flags  => "L|F",
1678         state     => "exc_pinned",
1679         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1680         ins       => [ "base", "index", "mem" ],
1681         outs      => [ "M" ],
1682         latency   => 0,
1683         emit      => ". prefetcht2 %AM",
1684         units     => [ "GP" ],
1685 },
1686
1687 PrefetchNTA => {
1688         op_flags  => "L|F",
1689         state     => "exc_pinned",
1690         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1691         ins       => [ "base", "index", "mem" ],
1692         outs      => [ "M" ],
1693         latency   => 0,
1694         emit      => ". prefetchnta %AM",
1695         units     => [ "GP" ],
1696 },
1697
1698 #
1699 # 3DNow! prefetch instructions
1700 #
1701 Prefetch => {
1702         op_flags  => "L|F",
1703         state     => "exc_pinned",
1704         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1705         ins       => [ "base", "index", "mem" ],
1706         outs      => [ "M" ],
1707         latency   => 0,
1708         emit      => ". prefetch %AM",
1709         units     => [ "GP" ],
1710 },
1711
1712 PrefetchW => {
1713         op_flags  => "L|F",
1714         state     => "exc_pinned",
1715         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1716         ins       => [ "base", "index", "mem" ],
1717         outs      => [ "M" ],
1718         latency   => 0,
1719         emit      => ". prefetchw %AM",
1720         units     => [ "GP" ],
1721 },
1722
1723 # produces a 0/+0.0
1724 xZero => {
1725         irn_flags => "R",
1726         reg_req   => { out => [ "xmm" ] },
1727         emit      => '. xorp%XSD %D0, %D0',
1728         latency   => 3,
1729         units     => [ "SSE" ],
1730         mode      => $mode_xmm
1731 },
1732
1733 xPzero => {
1734         irn_flags => "R",
1735         reg_req   => { out => [ "xmm" ] },
1736         emit      => '. pxor %D0, %D0',
1737         latency   => 3,
1738         units     => [ "SSE" ],
1739         mode      => $mode_xmm
1740 },
1741
1742 # produces all 1 bits
1743 xAllOnes => {
1744         irn_flags => "R",
1745         reg_req   => { out => [ "xmm" ] },
1746         emit      => '. pcmpeqb %D0, %D0',
1747         latency   => 3,
1748         units     => [ "SSE" ],
1749         mode      => $mode_xmm
1750 },
1751
1752 # integer shift left, dword
1753 xPslld => {
1754         irn_flags => "R",
1755         reg_req   => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1756         emit      => '. pslld %SI1, %D0',
1757         latency   => 3,
1758         units     => [ "SSE" ],
1759         mode      => $mode_xmm
1760 },
1761
1762 # integer shift left, qword
1763 xPsllq => {
1764         irn_flags => "R",
1765         reg_req   => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1766         emit      => '. psllq %SI1, %D0',
1767         latency   => 3,
1768         units     => [ "SSE" ],
1769         mode      => $mode_xmm
1770 },
1771
1772 # integer shift right, dword
1773 xPsrld => {
1774         irn_flags => "R",
1775         reg_req   => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1776         emit      => '. psrld %SI1, %D0',
1777         latency   => 1,
1778         units     => [ "SSE" ],
1779         mode      => $mode_xmm
1780 },
1781
1782 # mov from integer to SSE register
1783 xMovd  => {
1784         irn_flags => "R",
1785         reg_req   => { in => [ "gp" ], out => [ "xmm" ] },
1786         emit      => '. movd %S0, %D0',
1787         latency   => 1,
1788         units     => [ "SSE" ],
1789         mode      => $mode_xmm
1790 },
1791
1792 xAdd => {
1793         irn_flags => "R",
1794         state     => "exc_pinned",
1795         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1796                        out => [ "in_r4 in_r5", "flags", "none" ] },
1797         ins       => [ "base", "index", "mem", "left", "right" ],
1798         outs      => [ "res", "flags", "M" ],
1799         am        => "source,binary",
1800         emit      => '. add%XXM %binop',
1801         latency   => 4,
1802         units     => [ "SSE" ],
1803         mode      => $mode_xmm
1804 },
1805
1806 xMul => {
1807         irn_flags => "R",
1808         state     => "exc_pinned",
1809         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1810                        out => [ "in_r4 in_r5", "flags", "none" ] },
1811         ins       => [ "base", "index", "mem", "left", "right" ],
1812         outs      => [ "res", "flags", "M" ],
1813         am        => "source,binary",
1814         emit      => '. mul%XXM %binop',
1815         latency   => 4,
1816         units     => [ "SSE" ],
1817         mode      => $mode_xmm
1818 },
1819
1820 xMax => {
1821         irn_flags => "R",
1822         state     => "exc_pinned",
1823         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1824                        out => [ "in_r4 in_r5", "flags", "none" ] },
1825         ins       => [ "base", "index", "mem", "left", "right" ],
1826         outs      => [ "res", "flags", "M" ],
1827         am        => "source,binary",
1828         emit      => '. max%XXM %binop',
1829         latency   => 2,
1830         units     => [ "SSE" ],
1831         mode      => $mode_xmm
1832 },
1833
1834 xMin => {
1835         irn_flags => "R",
1836         state     => "exc_pinned",
1837         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1838                        out => [ "in_r4 in_r5", "flags", "none" ] },
1839         ins       => [ "base", "index", "mem", "left", "right" ],
1840         outs      => [ "res", "flags", "M" ],
1841         am        => "source,binary",
1842         emit      => '. min%XXM %binop',
1843         latency   => 2,
1844         units     => [ "SSE" ],
1845         mode      => $mode_xmm
1846 },
1847
1848 xAnd => {
1849         irn_flags => "R",
1850         state     => "exc_pinned",
1851         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1852                        out => [ "in_r4 in_r5", "flags", "none" ] },
1853         ins       => [ "base", "index", "mem", "left", "right" ],
1854         outs      => [ "res", "flags", "M" ],
1855         am        => "source,binary",
1856         emit      => '. andp%XSD %binop',
1857         latency   => 3,
1858         units     => [ "SSE" ],
1859         mode      => $mode_xmm
1860 },
1861
1862 xOr => {
1863         irn_flags => "R",
1864         state     => "exc_pinned",
1865         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1866                        out => [ "in_r4 in_r5", "flags", "none" ] },
1867         ins       => [ "base", "index", "mem", "left", "right" ],
1868         outs      => [ "res", "flags", "M" ],
1869         am        => "source,binary",
1870         emit      => '. orp%XSD %binop',
1871         latency   => 3,
1872         units     => [ "SSE" ],
1873         mode      => $mode_xmm
1874 },
1875
1876 xXor => {
1877         irn_flags => "R",
1878         state     => "exc_pinned",
1879         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1880                        out => [ "in_r4 in_r5", "flags", "none" ] },
1881         ins       => [ "base", "index", "mem", "left", "right" ],
1882         outs      => [ "res", "flags", "M" ],
1883         am        => "source,binary",
1884         emit      => '. xorp%XSD %binop',
1885         latency   => 3,
1886         units     => [ "SSE" ],
1887         mode      => $mode_xmm
1888 },
1889
1890 xAndNot => {
1891         irn_flags => "R",
1892         state     => "exc_pinned",
1893         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1894                        out => [ "in_r4 !in_r5", "flags", "none" ] },
1895         ins       => [ "base", "index", "mem", "left", "right" ],
1896         outs      => [ "res", "flags", "M" ],
1897         am        => "source,binary",
1898         emit      => '. andnp%XSD %binop',
1899         latency   => 3,
1900         units     => [ "SSE" ],
1901         mode      => $mode_xmm
1902 },
1903
1904 xSub => {
1905         irn_flags => "R",
1906         state     => "exc_pinned",
1907         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1908                        out => [ "in_r4", "flags", "none" ] },
1909         ins       => [ "base", "index", "mem", "minuend", "subtrahend" ],
1910         outs      => [ "res", "flags", "M" ],
1911         am        => "source,binary",
1912         emit      => '. sub%XXM %binop',
1913         latency   => 4,
1914         units     => [ "SSE" ],
1915         mode      => $mode_xmm
1916 },
1917
1918 xDiv => {
1919         irn_flags => "R",
1920         state     => "exc_pinned",
1921         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1922                        out => [ "in_r4 !in_r5", "flags", "none" ] },
1923         ins       => [ "base", "index", "mem", "dividend", "divisor" ],
1924         outs      => [ "res", "flags", "M" ],
1925         am        => "source,binary",
1926         emit      => '. div%XXM %binop',
1927         latency   => 16,
1928         units     => [ "SSE" ],
1929 },
1930
1931 Ucomi => {
1932         irn_flags => "R",
1933         state     => "exc_pinned",
1934         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1935                        out => [ "eflags" ] },
1936         ins       => [ "base", "index", "mem", "left", "right" ],
1937         outs      => [ "flags" ],
1938         am        => "source,binary",
1939         attr      => "int ins_permuted",
1940         init_attr => "attr->data.ins_permuted = ins_permuted;",
1941         emit      => ' .ucomi%XXM %binop',
1942         latency   => 3,
1943         units     => [ "SSE" ],
1944         mode      => $mode_flags,
1945         modified_flags => 1,
1946 },
1947
1948 xLoad => {
1949         op_flags  => "L|F",
1950         state     => "exc_pinned",
1951         reg_req   => { in => [ "gp", "gp", "none" ],
1952                        out => [ "xmm", "none", "none", "none" ] },
1953         ins       => [ "base", "index", "mem" ],
1954         outs      => [ "res", "unused", "M", "X_exc" ],
1955         emit      => '. mov%XXM %AM, %D0',
1956         attr      => "ir_mode *load_mode",
1957         init_attr => "attr->ls_mode = load_mode;",
1958         latency   => 0,
1959         units     => [ "SSE" ],
1960 },
1961
1962 xStore => {
1963         op_flags => "L|F",
1964         state    => "exc_pinned",
1965         reg_req  => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1966         ins       => [ "base", "index", "mem", "val" ],
1967         outs      => [ "M", "X_exc" ],
1968         emit     => '. mov%XXM %S3, %AM',
1969         latency  => 0,
1970         units    => [ "SSE" ],
1971         mode     => "mode_M",
1972 },
1973
1974 xStoreSimple => {
1975         op_flags => "L|F",
1976         state    => "exc_pinned",
1977         reg_req  => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1978         ins      => [ "base", "index", "mem", "val" ],
1979         outs     => [ "M" ],
1980         emit     => '. mov%XXM %S3, %AM',
1981         latency  => 0,
1982         units    => [ "SSE" ],
1983         mode     => "mode_M",
1984 },
1985
1986 CvtSI2SS => {
1987         op_flags => "L|F",
1988         state     => "exc_pinned",
1989         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1990         ins      => [ "base", "index", "mem", "val" ],
1991         am       => "source,unary",
1992         emit     => '. cvtsi2ss %unop3, %D0',
1993         latency  => 2,
1994         units    => [ "SSE" ],
1995         mode     => $mode_xmm
1996 },
1997
1998 CvtSI2SD => {
1999         op_flags => "L|F",
2000         state     => "exc_pinned",
2001         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2002         ins      => [ "base", "index", "mem", "val" ],
2003         am       => "source,unary",
2004         emit     => '. cvtsi2sd %unop3, %D0',
2005         latency  => 2,
2006         units    => [ "SSE" ],
2007         mode     => $mode_xmm
2008 },
2009
2010
2011 l_LLtoFloat => {
2012         op_flags => "L|F",
2013         cmp_attr => "return 1;",
2014         ins      => [ "val_high", "val_low" ],
2015         reg_req  => { in => [ "none", "none" ], out => [ "none" ] }
2016 },
2017
2018 l_FloattoLL => {
2019         op_flags => "L|F",
2020         cmp_attr => "return 1;",
2021         ins      => [ "val" ],
2022         outs     => [ "res_high", "res_low" ],
2023         reg_req  => { in => [ "none" ], out => [ "none", "none" ] }
2024 },
2025
2026 CopyB => {
2027         op_flags  => "F|H",
2028         state     => "pinned",
2029         reg_req   => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2030         outs      => [ "DST", "SRC", "CNT", "M" ],
2031         attr_type => "ia32_copyb_attr_t",
2032         attr      => "unsigned size",
2033         units     => [ "GP" ],
2034         latency  => 3,
2035 # we don't care about this flag, so no need to mark this node
2036 #       modified_flags => [ "DF" ]
2037 },
2038
2039 CopyB_i => {
2040         op_flags  => "F|H",
2041         state     => "pinned",
2042         reg_req   => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
2043         outs      => [ "DST", "SRC", "M" ],
2044         attr_type => "ia32_copyb_attr_t",
2045         attr      => "unsigned size",
2046         units     => [ "GP" ],
2047         latency  => 3,
2048 # we don't care about this flag, so no need to mark this node
2049 #       modified_flags => [ "DF" ]
2050 },
2051
2052 Cwtl => {
2053         state     => "exc_pinned",
2054         reg_req   => { in => [ "eax" ], out => [ "eax" ] },
2055         ins       => [ "val" ],
2056         outs      => [ "res" ],
2057         emit      => '. cwtl',
2058         units     => [ "GP" ],
2059         latency   => 1,
2060         mode      => $mode_gp,
2061 },
2062
2063 Conv_I2I => {
2064         state     => "exc_pinned",
2065         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
2066                        out => [ "gp", "none", "none" ] },
2067         ins       => [ "base", "index", "mem", "val" ],
2068         outs      => [ "res", "flags", "M" ],
2069         am        => "source,unary",
2070         units     => [ "GP" ],
2071         latency   => 1,
2072         attr      => "ir_mode *smaller_mode",
2073         init_attr => "attr->ls_mode = smaller_mode;",
2074         mode      => $mode_gp,
2075 },
2076
2077 Conv_I2I8Bit => {
2078         state     => "exc_pinned",
2079         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2080                        out => [ "gp", "none", "none" ] },
2081         ins       => [ "base", "index", "mem", "val" ],
2082         outs      => [ "res", "flags", "M" ],
2083         am        => "source,unary",
2084         units     => [ "GP" ],
2085         latency   => 1,
2086         attr      => "ir_mode *smaller_mode",
2087         init_attr => "attr->ls_mode = smaller_mode;",
2088         mode      => $mode_gp,
2089 },
2090
2091 Conv_I2FP => {
2092         state     => "exc_pinned",
2093         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2094         ins       => [ "base", "index", "mem", "val" ],
2095         am        => "source,unary",
2096         latency   => 10,
2097         units     => [ "SSE" ],
2098         mode      => $mode_xmm,
2099 },
2100
2101 Conv_FP2I => {
2102         state     => "exc_pinned",
2103         reg_req   => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2104         ins       => [ "base", "index", "mem", "val" ],
2105         am        => "source,unary",
2106         latency   => 10,
2107         units     => [ "SSE" ],
2108         mode      => $mode_gp,
2109 },
2110
2111 Conv_FP2FP => {
2112         state     => "exc_pinned",
2113         reg_req   => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2114         ins       => [ "base", "index", "mem", "val" ],
2115         am        => "source,unary",
2116         latency   => 8,
2117         units     => [ "SSE" ],
2118         mode      => $mode_xmm,
2119 },
2120
2121 # rematerialisation disabled for all float nodes for now, because the fpcw
2122 # handler runs before spilling and we might end up with wrong fpcw then
2123
2124 vfadd => {
2125 #       irn_flags => "R",
2126         state     => "exc_pinned",
2127         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2128                        out => [ "vfp", "none", "none" ] },
2129         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
2130         outs      => [ "res", "dummy", "M" ],
2131         am        => "source,binary",
2132         latency   => 4,
2133         units     => [ "VFP" ],
2134         mode      => "mode_E",
2135         attr_type => "ia32_x87_attr_t",
2136 },
2137
2138 vfmul => {
2139 #       irn_flags => "R",
2140         state     => "exc_pinned",
2141         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2142                        out => [ "vfp", "none", "none" ] },
2143         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
2144         outs      => [ "res", "dummy", "M" ],
2145         am        => "source,binary",
2146         latency   => 4,
2147         units     => [ "VFP" ],
2148         mode      => "mode_E",
2149         attr_type => "ia32_x87_attr_t",
2150 },
2151
2152 vfsub => {
2153 #       irn_flags => "R",
2154         state     => "exc_pinned",
2155         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2156                        out => [ "vfp", "none", "none" ] },
2157         ins       => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2158         outs      => [ "res", "dummy", "M" ],
2159         am        => "source,binary",
2160         latency   => 4,
2161         units     => [ "VFP" ],
2162         mode      => "mode_E",
2163         attr_type => "ia32_x87_attr_t",
2164 },
2165
2166 vfdiv => {
2167         state     => "exc_pinned",
2168         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2169                        out => [ "vfp", "none", "none" ] },
2170         ins       => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2171         outs      => [ "res", "dummy", "M" ],
2172         am        => "source,binary",
2173         latency   => 20,
2174         units     => [ "VFP" ],
2175         attr_type => "ia32_x87_attr_t",
2176 },
2177
2178 vfprem => {
2179         reg_req   => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2180         ins       => [ "left", "right", "fpcw" ],
2181         latency   => 20,
2182         units     => [ "VFP" ],
2183         mode      => "mode_E",
2184         attr_type => "ia32_x87_attr_t",
2185 },
2186
2187 vfabs => {
2188         irn_flags => "R",
2189         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2190         ins       => [ "value" ],
2191         latency   => 2,
2192         units     => [ "VFP" ],
2193         mode      => "mode_E",
2194         attr_type => "ia32_x87_attr_t",
2195 },
2196
2197 vfchs => {
2198         irn_flags => "R",
2199         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2200         ins       => [ "value" ],
2201         latency   => 2,
2202         units     => [ "VFP" ],
2203         mode      => "mode_E",
2204         attr_type => "ia32_x87_attr_t",
2205 },
2206
2207 vfld => {
2208         irn_flags => "R",
2209         op_flags  => "L|F",
2210         state     => "exc_pinned",
2211         reg_req   => { in => [ "gp", "gp", "none" ],
2212                        out => [ "vfp", "none", "none", "none" ] },
2213         ins       => [ "base", "index", "mem" ],
2214         outs      => [ "res", "unused", "M", "X_exc" ],
2215         attr      => "ir_mode *load_mode",
2216         init_attr => "attr->attr.ls_mode = load_mode;",
2217         latency   => 2,
2218         units     => [ "VFP" ],
2219         attr_type => "ia32_x87_attr_t",
2220 },
2221
2222 vfst => {
2223         irn_flags => "R",
2224         op_flags  => "L|F",
2225         state     => "exc_pinned",
2226         reg_req   => { in => [ "gp", "gp", "none", "vfp" ],
2227                        out => [ "none", "none" ] },
2228         ins       => [ "base", "index", "mem", "val" ],
2229         outs      => [ "M", "X_exc" ],
2230         attr      => "ir_mode *store_mode",
2231         init_attr => "attr->attr.ls_mode = store_mode;",
2232         latency   => 2,
2233         units     => [ "VFP" ],
2234         mode      => "mode_M",
2235         attr_type => "ia32_x87_attr_t",
2236 },
2237
2238 vfild => {
2239         state     => "exc_pinned",
2240         reg_req   => { in => [ "gp", "gp", "none" ],
2241                        out => [ "vfp", "none", "none" ] },
2242         outs      => [ "res", "unused", "M" ],
2243         ins       => [ "base", "index", "mem" ],
2244         latency   => 4,
2245         units     => [ "VFP" ],
2246         attr_type => "ia32_x87_attr_t",
2247 },
2248
2249 vfist => {
2250         state     => "exc_pinned",
2251         reg_req   => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2252         ins       => [ "base", "index", "mem", "val", "fpcw" ],
2253         outs      => [ "M" ],
2254         latency   => 4,
2255         units     => [ "VFP" ],
2256         mode      => "mode_M",
2257         attr_type => "ia32_x87_attr_t",
2258 },
2259
2260 # SSE3 fisttp instruction
2261 vfisttp => {
2262         state     => "exc_pinned",
2263         reg_req   => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2264         ins       => [ "base", "index", "mem", "val" ],
2265         outs      => [ "res", "M" ],
2266         latency   => 4,
2267         units     => [ "VFP" ],
2268         attr_type => "ia32_x87_attr_t",
2269 },
2270
2271 vfldz => {
2272         irn_flags => "R",
2273         reg_req   => { out => [ "vfp" ] },
2274         outs      => [ "res" ],
2275         latency   => 4,
2276         units     => [ "VFP" ],
2277         mode      => "mode_E",
2278         attr_type => "ia32_x87_attr_t",
2279 },
2280
2281 vfld1 => {
2282         irn_flags => "R",
2283         reg_req   => { out => [ "vfp" ] },
2284         outs      => [ "res" ],
2285         latency   => 4,
2286         units     => [ "VFP" ],
2287         mode      => "mode_E",
2288         attr_type => "ia32_x87_attr_t",
2289 },
2290
2291 vfldpi => {
2292         irn_flags => "R",
2293         reg_req   => { out => [ "vfp" ] },
2294         outs      => [ "res" ],
2295         latency   => 4,
2296         units     => [ "VFP" ],
2297         mode      => "mode_E",
2298         attr_type => "ia32_x87_attr_t",
2299 },
2300
2301 vfldln2 => {
2302         irn_flags => "R",
2303         reg_req   => { out => [ "vfp" ] },
2304         outs      => [ "res" ],
2305         latency   => 4,
2306         units     => [ "VFP" ],
2307         mode      => "mode_E",
2308         attr_type => "ia32_x87_attr_t",
2309 },
2310
2311 vfldlg2 => {
2312         irn_flags => "R",
2313         reg_req   => { out => [ "vfp" ] },
2314         outs      => [ "res" ],
2315         latency   => 4,
2316         units     => [ "VFP" ],
2317         mode      => "mode_E",
2318         attr_type => "ia32_x87_attr_t",
2319 },
2320
2321 vfldl2t => {
2322         irn_flags => "R",
2323         reg_req   => { out => [ "vfp" ] },
2324         outs      => [ "res" ],
2325         latency   => 4,
2326         units     => [ "VFP" ],
2327         mode      => "mode_E",
2328         attr_type => "ia32_x87_attr_t",
2329 },
2330
2331 vfldl2e => {
2332         irn_flags => "R",
2333         reg_req   => { out => [ "vfp" ] },
2334         outs      => [ "res" ],
2335         latency   => 4,
2336         units     => [ "VFP" ],
2337         mode      => "mode_E",
2338         attr_type => "ia32_x87_attr_t",
2339 },
2340
2341 vFucomFnstsw => {
2342 # we can't allow to rematerialize this node so we don't
2343 #  accidently produce Phi(Fucom, Fucom(ins_permuted))
2344 #       irn_flags => "R",
2345         reg_req   => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2346         ins       => [ "left", "right" ],
2347         outs      => [ "flags" ],
2348         attr      => "int ins_permuted",
2349         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2350         latency   => 3,
2351         units     => [ "VFP" ],
2352         attr_type => "ia32_x87_attr_t",
2353         mode      => $mode_gp
2354 },
2355
2356 vFucomi => {
2357         irn_flags => "R",
2358         reg_req   => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2359         ins       => [ "left", "right" ],
2360         outs      => [ "flags" ],
2361         attr      => "int ins_permuted",
2362         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2363         latency   => 3,
2364         units     => [ "VFP" ],
2365         attr_type => "ia32_x87_attr_t",
2366         mode      => $mode_gp
2367 },
2368
2369 vFtstFnstsw => {
2370 #       irn_flags => "R",
2371         reg_req   => { in => [ "vfp" ], out => [ "eax" ] },
2372         ins       => [ "left" ],
2373         outs      => [ "flags" ],
2374         attr      => "int ins_permuted",
2375         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2376         latency   => 3,
2377         units     => [ "VFP" ],
2378         attr_type => "ia32_x87_attr_t",
2379         mode      => $mode_gp
2380 },
2381
2382 Sahf => {
2383         irn_flags => "R",
2384         reg_req   => { in => [ "eax" ], out => [ "eflags" ] },
2385         ins       => [ "val" ],
2386         outs      => [ "flags" ],
2387         emit      => '. sahf',
2388         latency   => 1,
2389         units     => [ "GP" ],
2390         mode      => $mode_flags,
2391 },
2392
2393 fadd => {
2394         state     => "exc_pinned",
2395         emit      => '. fadd%XM %x87_binop',
2396         latency   => 4,
2397         attr_type => "ia32_x87_attr_t",
2398         constructors => {},
2399 },
2400
2401 faddp => {
2402         state     => "exc_pinned",
2403         emit      => '. faddp%XM %x87_binop',
2404         latency   => 4,
2405         attr_type => "ia32_x87_attr_t",
2406         constructors => {},
2407 },
2408
2409 fmul => {
2410         state     => "exc_pinned",
2411         emit      => '. fmul%XM %x87_binop',
2412         latency   => 4,
2413         attr_type => "ia32_x87_attr_t",
2414         constructors => {},
2415 },
2416
2417 fmulp => {
2418         state     => "exc_pinned",
2419         emit      => '. fmulp%XM %x87_binop',,
2420         latency   => 4,
2421         attr_type => "ia32_x87_attr_t",
2422         constructors => {},
2423 },
2424
2425 fsub => {
2426         state     => "exc_pinned",
2427         emit      => '. fsub%XM %x87_binop',
2428         latency   => 4,
2429         attr_type => "ia32_x87_attr_t",
2430         constructors => {},
2431 },
2432
2433 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2434 #       are swapped, we work this around in the emitter...
2435
2436 fsubp => {
2437         state     => "exc_pinned",
2438 # see note about gas bugs
2439         emit      => '. fsubrp%XM %x87_binop',
2440         latency   => 4,
2441         attr_type => "ia32_x87_attr_t",
2442         constructors => {},
2443 },
2444
2445 fsubr => {
2446         state     => "exc_pinned",
2447         irn_flags => "R",
2448         emit      => '. fsubr%XM %x87_binop',
2449         latency   => 4,
2450         attr_type => "ia32_x87_attr_t",
2451         constructors => {},
2452 },
2453
2454 fsubrp => {
2455         state     => "exc_pinned",
2456         irn_flags => "R",
2457 # see note about gas bugs before fsubp
2458         emit      => '. fsubp%XM %x87_binop',
2459         latency   => 4,
2460         attr_type => "ia32_x87_attr_t",
2461         constructors => {},
2462 },
2463
2464 fprem => {
2465         emit      => '. fprem1',
2466         latency   => 20,
2467         attr_type => "ia32_x87_attr_t",
2468         constructors => {},
2469 },
2470
2471 # this node is just here, to keep the simulator running
2472 # we can omit this when a fprem simulation function exists
2473 fpremp => {
2474         emit      => '. fprem1\n'.
2475                      '. fstp %X0',
2476         latency   => 20,
2477         attr_type => "ia32_x87_attr_t",
2478         constructors => {},
2479 },
2480
2481 fdiv => {
2482         state     => "exc_pinned",
2483         emit      => '. fdiv%XM %x87_binop',
2484         latency   => 20,
2485         attr_type => "ia32_x87_attr_t",
2486         constructors => {},
2487 },
2488
2489 fdivp => {
2490         state     => "exc_pinned",
2491 # see note about gas bugs before fsubp
2492         emit      => '. fdivrp%XM %x87_binop',
2493         latency   => 20,
2494         attr_type => "ia32_x87_attr_t",
2495         constructors => {},
2496 },
2497
2498 fdivr => {
2499         state     => "exc_pinned",
2500         emit      => '. fdivr%XM %x87_binop',
2501         latency   => 20,
2502         attr_type => "ia32_x87_attr_t",
2503         constructors => {},
2504 },
2505
2506 fdivrp => {
2507         state     => "exc_pinned",
2508 # see note about gas bugs before fsubp
2509         emit      => '. fdivp%XM %x87_binop',
2510         latency   => 20,
2511         attr_type => "ia32_x87_attr_t",
2512         constructors => {},
2513 },
2514
2515 fabs => {
2516         emit      => '. fabs',
2517         latency   => 4,
2518         attr_type => "ia32_x87_attr_t",
2519         constructors => {},
2520 },
2521
2522 fchs => {
2523         op_flags  => "R|K",
2524         emit      => '. fchs',
2525         latency   => 4,
2526         attr_type => "ia32_x87_attr_t",
2527         constructors => {},
2528 },
2529
2530 fld => {
2531         op_flags  => "R|L|F",
2532         state     => "exc_pinned",
2533         emit      => '. fld%XM %AM',
2534         attr_type => "ia32_x87_attr_t",
2535         latency   => 2,
2536         constructors => {},
2537 },
2538
2539 fst => {
2540         op_flags  => "R|L|F",
2541         state     => "exc_pinned",
2542         emit      => '. fst%XM %AM',
2543         mode      => "mode_M",
2544         attr_type => "ia32_x87_attr_t",
2545         latency   => 2,
2546         constructors => {},
2547 },
2548
2549 fstp => {
2550         op_flags  => "R|L|F",
2551         state     => "exc_pinned",
2552         emit      => '. fstp%XM %AM',
2553         mode      => "mode_M",
2554         attr_type => "ia32_x87_attr_t",
2555         latency   => 2,
2556         constructors => {},
2557 },
2558
2559 fild => {
2560         state     => "exc_pinned",
2561         emit      => '. fild%XM %AM',
2562         attr_type => "ia32_x87_attr_t",
2563         latency   => 2,
2564         constructors => {},
2565 },
2566
2567 fist => {
2568         state     => "exc_pinned",
2569         emit      => '. fist%XM %AM',
2570         mode      => "mode_M",
2571         attr_type => "ia32_x87_attr_t",
2572         latency   => 2,
2573         constructors => {},
2574 },
2575
2576 fistp => {
2577         state     => "exc_pinned",
2578         emit      => '. fistp%XM %AM',
2579         mode      => "mode_M",
2580         attr_type => "ia32_x87_attr_t",
2581         latency   => 2,
2582         constructors => {},
2583 },
2584
2585 # SSE3 fisttp instruction
2586 fisttp => {
2587         state     => "exc_pinned",
2588         emit      => '. fisttp%XM %AM',
2589         mode      => "mode_M",
2590         attr_type => "ia32_x87_attr_t",
2591         latency   => 2,
2592         constructors => {},
2593 },
2594
2595 fldz => {
2596         op_flags  => "R|c|K",
2597         irn_flags => "R",
2598         reg_req   => { out => [ "vfp" ] },
2599         emit      => '. fldz',
2600         attr_type => "ia32_x87_attr_t",
2601         latency   => 2,
2602 },
2603
2604 fld1 => {
2605         op_flags  => "R|c|K",
2606         irn_flags => "R",
2607         reg_req   => { out => [ "vfp" ] },
2608         emit      => '. fld1',
2609         attr_type => "ia32_x87_attr_t",
2610         latency   => 2,
2611 },
2612
2613 fldpi => {
2614         op_flags  => "R|c|K",
2615         irn_flags => "R",
2616         reg_req   => { out => [ "vfp" ] },
2617         emit      => '. fldpi',
2618         attr_type => "ia32_x87_attr_t",
2619         latency   => 2,
2620 },
2621
2622 fldln2 => {
2623         op_flags  => "R|c|K",
2624         irn_flags => "R",
2625         reg_req   => { out => [ "vfp" ] },
2626         emit      => '. fldln2',
2627         attr_type => "ia32_x87_attr_t",
2628         latency   => 2,
2629 },
2630
2631 fldlg2 => {
2632         op_flags  => "R|c|K",
2633         irn_flags => "R",
2634         reg_req   => { out => [ "vfp" ] },
2635         emit      => '. fldlg2',
2636         attr_type => "ia32_x87_attr_t",
2637         latency   => 2,
2638 },
2639
2640 fldl2t => {
2641         op_flags  => "R|c|K",
2642         irn_flags => "R",
2643         reg_req   => { out => [ "vfp" ] },
2644         emit      => '. fldll2t',
2645         attr_type => "ia32_x87_attr_t",
2646         latency   => 2,
2647 },
2648
2649 fldl2e => {
2650         op_flags  => "R|c|K",
2651         irn_flags => "R",
2652         reg_req   => { out => [ "vfp" ] },
2653         emit      => '. fldl2e',
2654         attr_type => "ia32_x87_attr_t",
2655         latency   => 2,
2656 },
2657
2658 # fxch, fpush, fpop
2659 # Note that it is NEVER allowed to do CSE on these nodes
2660 # Moreover, note the virtual register requierements!
2661
2662 fxch => {
2663         op_flags  => "R|K",
2664         reg_req   => { out => [ "none" ] },
2665         cmp_attr  => "return 1;",
2666         emit      => '. fxch %X0',
2667         attr_type => "ia32_x87_attr_t",
2668         mode      => "mode_ANY",
2669         latency   => 1,
2670 },
2671
2672 fpush => {
2673         op_flags  => "R|K",
2674         reg_req   => { out => [ "none" ] },
2675         cmp_attr  => "return 1;",
2676         emit      => '. fld %X0',
2677         attr_type => "ia32_x87_attr_t",
2678         mode      => "mode_ANY",
2679         latency   => 1,
2680 },
2681
2682 fpushCopy => {
2683         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2684         cmp_attr  => "return 1;",
2685         emit      => '. fld %X0',
2686         attr_type => "ia32_x87_attr_t",
2687         latency   => 1,
2688 },
2689
2690 fpop => {
2691         op_flags  => "K",
2692         reg_req   => { out => [ "none" ] },
2693         cmp_attr  => "return 1;",
2694         emit      => '. fstp %X0',
2695         attr_type => "ia32_x87_attr_t",
2696         mode      => "mode_ANY",
2697         latency   => 1,
2698 },
2699
2700 ffreep => {
2701         op_flags  => "K",
2702         reg_req   => { out => [ "none" ] },
2703         cmp_attr  => "return 1;",
2704         emit      => '. ffreep %X0',
2705         attr_type => "ia32_x87_attr_t",
2706         mode      => "mode_ANY",
2707         latency   => 1,
2708 },
2709
2710 emms => {
2711         op_flags  => "K",
2712         reg_req   => { out => [ "none" ] },
2713         cmp_attr  => "return 1;",
2714         emit      => '. emms',
2715         attr_type => "ia32_x87_attr_t",
2716         mode      => "mode_ANY",
2717         latency   => 3,
2718 },
2719
2720 femms => {
2721         op_flags  => "K",
2722         reg_req   => { out => [ "none" ] },
2723         cmp_attr  => "return 1;",
2724         emit      => '. femms',
2725         attr_type => "ia32_x87_attr_t",
2726         mode      => "mode_ANY",
2727         latency   => 3,
2728 },
2729
2730 FucomFnstsw => {
2731         reg_req   => { },
2732         emit      => ". fucom %X1\n".
2733                      ". fnstsw %%ax",
2734         attr_type => "ia32_x87_attr_t",
2735         latency   => 2,
2736 },
2737
2738 FucompFnstsw => {
2739         reg_req   => { },
2740         emit      => ". fucomp %X1\n".
2741                      ". fnstsw %%ax",
2742         attr_type => "ia32_x87_attr_t",
2743         latency   => 2,
2744 },
2745
2746 FucomppFnstsw => {
2747         reg_req   => { },
2748         emit      => ". fucompp\n".
2749                      ". fnstsw %%ax",
2750         attr_type => "ia32_x87_attr_t",
2751         latency   => 2,
2752 },
2753
2754 Fucomi => {
2755         reg_req   => { },
2756         emit      => '. fucomi %X1',
2757         attr_type => "ia32_x87_attr_t",
2758         latency   => 1,
2759 },
2760
2761 Fucompi => {
2762         reg_req   => { },
2763         emit      => '. fucompi %X1',
2764         attr_type => "ia32_x87_attr_t",
2765         latency   => 1,
2766 },
2767
2768 FtstFnstsw => {
2769         reg_req   => { },
2770         emit      => ". ftst\n".
2771                      ". fnstsw %%ax",
2772         attr_type => "ia32_x87_attr_t",
2773         latency   => 2,
2774 },
2775
2776 # Spilling and reloading of SSE registers, hardcoded, not generated #
2777
2778 xxLoad => {
2779         op_flags  => "L|F",
2780         state     => "exc_pinned",
2781         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2782         emit      => '. movdqu %D0, %AM',
2783         outs      => [ "res", "M" ],
2784         units     => [ "SSE" ],
2785         latency   => 1,
2786 },
2787
2788 xxStore => {
2789         op_flags => "L|F",
2790         state    => "exc_pinned",
2791         reg_req  => { in => [ "gp", "gp", "none", "xmm" ] },
2792         ins      => [ "base", "index", "mem", "val" ],
2793         emit     => '. movdqu %binop',
2794         units    => [ "SSE" ],
2795         latency   => 1,
2796         mode     => "mode_M",
2797 },
2798
2799 ); # end of %nodes
2800
2801 # Transform some attributes
2802 foreach my $op (keys(%nodes)) {
2803         my $node         = $nodes{$op};
2804         my $op_attr_init = $node->{op_attr_init};
2805
2806         if(defined($op_attr_init)) {
2807                 $op_attr_init .= "\n\t";
2808         } else {
2809                 $op_attr_init = "";
2810         }
2811
2812         if(!defined($node->{latency})) {
2813                 if($op =~ m/^l_/) {
2814                         $node->{latency} = 0;
2815                 } else {
2816                         die("Latency missing for op $op");
2817                 }
2818         }
2819         $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2820
2821         $node->{op_attr_init} = $op_attr_init;
2822 }
2823
2824 print "";