I was annoyed by the compiler warnings about implicit conversions.
[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",
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",
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 Set => {
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, int ins_permuted",
1100         init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1101                       "\tset_ia32_ls_mode(res, mode_Bu);\n",
1102         emit      => '. set%CMP0 %DB0',
1103         latency   => 1,
1104         units     => [ "GP" ],
1105         mode      => $mode_gp,
1106 },
1107
1108 SetMem => {
1109         #irn_flags => "R",
1110         state     => "exc_pinned",
1111         reg_req   => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1112         ins       => [ "base", "index", "mem","eflags" ],
1113         attr_type => "ia32_condcode_attr_t",
1114         attr      => "pn_Cmp pnc, int ins_permuted",
1115         init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1116                       "\tset_ia32_ls_mode(res, mode_Bu);\n",
1117         emit      => '. set%CMP3 %AM',
1118         latency   => 1,
1119         units     => [ "GP" ],
1120         mode      => 'mode_M',
1121 },
1122
1123 CMov => {
1124         #irn_flags => "R",
1125         # (note: leave the false,true order intact to make it compatible with other
1126         #  ia32_binary ops)
1127         state     => "exc_pinned",
1128         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1129                        out => [ "in_r4 in_r5", "flags", "none" ] },
1130         ins       => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1131         outs      => [ "res", "flags", "M" ],
1132         am        => "source,binary",
1133         attr_type => "ia32_condcode_attr_t",
1134         attr      => "int ins_permuted, pn_Cmp pnc",
1135         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1136         latency   => 1,
1137         units     => [ "GP" ],
1138         mode      => $mode_gp,
1139 },
1140
1141 Jcc => {
1142         state     => "pinned",
1143         op_flags  => "L|X|Y",
1144         reg_req   => { in  => [ "eflags" ], out => [ "none", "none" ] },
1145         ins       => [ "eflags" ],
1146         outs      => [ "false", "true" ],
1147         attr_type => "ia32_condcode_attr_t",
1148         attr      => "pn_Cmp pnc",
1149         latency   => 2,
1150         units     => [ "BRANCH" ],
1151 },
1152
1153 SwitchJmp => {
1154         state     => "pinned",
1155         op_flags  => "L|X|Y",
1156         reg_req   => { in => [ "gp" ] },
1157         mode      => "mode_T",
1158         attr_type => "ia32_condcode_attr_t",
1159         attr      => "long pnc",
1160         latency   => 3,
1161         units     => [ "BRANCH" ],
1162         modified_flags => $status_flags,
1163         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1164 },
1165
1166 Jmp => {
1167         state     => "pinned",
1168         irn_flags => "J",
1169         op_flags  => "X",
1170         reg_req   => { out => [ "none" ] },
1171         latency   => 1,
1172         units     => [ "BRANCH" ],
1173         mode      => "mode_X",
1174 },
1175
1176 IJmp => {
1177         state     => "pinned",
1178         op_flags  => "X",
1179         reg_req   => { in => [ "gp", "gp", "none", "gp" ] },
1180         ins       => [ "base", "index", "mem", "target" ],
1181         am        => "source,unary",
1182         emit      => '. jmp *%unop3',
1183         latency   => 1,
1184         units     => [ "BRANCH" ],
1185         mode      => "mode_X",
1186         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1187 },
1188
1189 Const => {
1190         op_flags  => "c",
1191         irn_flags => "R",
1192         reg_req   => { out => [ "gp" ] },
1193         units     => [ "GP" ],
1194         attr      => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1195         attr_type => "ia32_immediate_attr_t",
1196         latency   => 1,
1197         mode      => $mode_gp,
1198 },
1199
1200 GetEIP => {
1201         op_flags => "c",
1202         reg_req  => { out => [ "gp" ] },
1203         units    => [ "GP" ],
1204         latency  => 5,
1205         mode     => $mode_gp,
1206         modified_flags => $status_flags,
1207 },
1208
1209 Unknown_GP => {
1210         state     => "pinned",
1211         op_flags  => "c|NB",
1212         reg_req   => { out => [ "gp_UKNWN:I" ] },
1213         units     => [],
1214         emit      => "",
1215         latency   => 0,
1216         mode      => $mode_gp
1217 },
1218
1219 Unknown_VFP => {
1220         state     => "pinned",
1221         op_flags  => "c|NB",
1222         reg_req   => { out => [ "vfp_UKNWN:I" ] },
1223         units     => [],
1224         emit      => "",
1225         mode      => "mode_E",
1226         latency   => 0,
1227         attr_type => "ia32_x87_attr_t",
1228 },
1229
1230 Unknown_XMM => {
1231         state     => "pinned",
1232         op_flags  => "c|NB",
1233         reg_req   => { out => [ "xmm_UKNWN:I" ] },
1234         units     => [],
1235         emit      => "",
1236         latency   => 0,
1237         mode      => $mode_xmm
1238 },
1239
1240 NoReg_GP => {
1241         state     => "pinned",
1242         op_flags  => "c|NB|NI",
1243         reg_req   => { out => [ "gp_NOREG:I" ] },
1244         units     => [],
1245         emit      => "",
1246         latency   => 0,
1247         mode      => $mode_gp
1248 },
1249
1250 NoReg_VFP => {
1251         state     => "pinned",
1252         op_flags  => "c|NB|NI",
1253         reg_req   => { out => [ "vfp_NOREG:I" ] },
1254         units     => [],
1255         emit      => "",
1256         mode      => "mode_E",
1257         latency   => 0,
1258         attr_type => "ia32_x87_attr_t",
1259 },
1260
1261 NoReg_XMM => {
1262         state     => "pinned",
1263         op_flags  => "c|NB|NI",
1264         reg_req   => { out => [ "xmm_NOREG:I" ] },
1265         units     => [],
1266         emit      => "",
1267         latency   => 0,
1268         mode      => "mode_E"
1269 },
1270
1271 ChangeCW => {
1272         state     => "pinned",
1273         op_flags  => "c",
1274         reg_req   => { out => [ "fpcw:I" ] },
1275         mode      => $mode_fpcw,
1276         latency   => 3,
1277         units     => [ "GP" ],
1278         modified_flags => $fpcw_flags
1279 },
1280
1281 FldCW => {
1282         op_flags  => "L|F",
1283         state     => "pinned",
1284         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1285         ins       => [ "base", "index", "mem" ],
1286         latency   => 5,
1287         emit      => ". fldcw %AM",
1288         mode      => $mode_fpcw,
1289         units     => [ "GP" ],
1290         modified_flags => $fpcw_flags
1291 },
1292
1293 FnstCW => {
1294         op_flags  => "L|F",
1295         state     => "pinned",
1296         reg_req   => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1297         ins       => [ "base", "index", "mem", "fpcw" ],
1298         latency   => 5,
1299         emit      => ". fnstcw %AM",
1300         mode      => "mode_M",
1301         units     => [ "GP" ],
1302 },
1303
1304 FnstCWNOP => {
1305         op_flags  => "L|F",
1306         state     => "pinned",
1307         reg_req   => { in => [ "fp_cw" ], out => [ "none" ] },
1308         ins       => [ "fpcw" ],
1309         latency   => 0,
1310         emit      => "",
1311         mode      => "mode_M",
1312 },
1313
1314 Cltd => {
1315         # we should not rematrialize this node. It has very strict constraints.
1316         reg_req   => { in => [ "eax", "edx" ], out => [ "edx" ] },
1317         ins       => [ "val", "clobbered" ],
1318         emit      => '. cltd',
1319         latency   => 1,
1320         mode      => $mode_gp,
1321         units     => [ "GP" ],
1322 },
1323
1324 # Load / Store
1325 #
1326 # Note that we add additional latency values depending on address mode, so a
1327 # lateny of 0 for load is correct
1328
1329 Load => {
1330         op_flags  => "L|F",
1331         state     => "exc_pinned",
1332         reg_req   => { in => [ "gp", "gp", "none" ],
1333                        out => [ "gp", "none", "none", "none" ] },
1334         ins       => [ "base", "index", "mem" ],
1335         outs      => [ "res", "unused", "M", "X_exc" ],
1336         latency   => 0,
1337         emit      => ". mov%EX%.l %AM, %D0",
1338         units     => [ "GP" ],
1339 },
1340
1341 Store => {
1342         op_flags  => "L|F",
1343         state     => "exc_pinned",
1344         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1345         ins       => [ "base", "index", "mem", "val" ],
1346         outs      => [ "M", "X_exc" ],
1347         emit      => '. mov%M %SI3, %AM',
1348         latency   => 2,
1349         units     => [ "GP" ],
1350         mode      => "mode_M",
1351 },
1352
1353 Store8Bit => {
1354         op_flags  => "L|F",
1355         state     => "exc_pinned",
1356         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1357         ins       => [ "base", "index", "mem", "val" ],
1358         outs      => [ "M", "X_exc" ],
1359         emit      => '. mov%M %SB3, %AM',
1360         latency   => 2,
1361         units     => [ "GP" ],
1362         mode      => "mode_M",
1363 },
1364
1365 Lea => {
1366         irn_flags => "R",
1367         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
1368         ins       => [ "base", "index" ],
1369         emit      => '. leal %AM, %D0',
1370         latency   => 2,
1371         units     => [ "GP" ],
1372         mode      => $mode_gp,
1373 # lea doesn't modify the flags, but setting this seems advantageous since it
1374 # increases chances that the Lea is transformed back to an Add
1375         modified_flags => 1,
1376 },
1377
1378 Push => {
1379         state     => "exc_pinned",
1380         reg_req   => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1381         ins       => [ "base", "index", "mem", "val", "stack" ],
1382         emit      => '. push%M %unop3',
1383         outs      => [ "stack", "M" ],
1384         am        => "source,unary",
1385         latency   => 2,
1386         units     => [ "GP" ],
1387 },
1388
1389 Pop => {
1390         state     => "exc_pinned",
1391         reg_req   => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1392         ins       => [ "mem", "stack" ],
1393         outs      => [ "res", "M", "unused", "stack" ],
1394         emit      => '. pop%M %D0',
1395         latency   => 3, # Pop is more expensive than Push on Athlon
1396         units     => [ "GP" ],
1397 },
1398
1399 PopEbp => {
1400         state     => "exc_pinned",
1401         reg_req   => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1402         ins       => [ "mem", "stack" ],
1403         outs      => [ "res", "M", "unused", "stack" ],
1404         emit      => '. pop%M %D0',
1405         latency   => 3, # Pop is more expensive than Push on Athlon
1406         units     => [ "GP" ],
1407 },
1408
1409 PopMem => {
1410         state     => "exc_pinned",
1411         reg_req   => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1412         ins       => [ "base", "index", "mem", "stack" ],
1413         outs      => [ "unused0", "M", "unused1", "stack" ],
1414         emit      => '. pop%M %AM',
1415         latency   => 3, # Pop is more expensive than Push on Athlon
1416         units     => [ "GP" ],
1417 },
1418
1419 Enter => {
1420         reg_req   => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1421         emit      => '. enter',
1422         outs      => [ "frame", "stack", "M" ],
1423         latency   => 15,
1424         units     => [ "GP" ],
1425 },
1426
1427 Leave => {
1428         reg_req   => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1429         emit      => '. leave',
1430         outs      => [ "frame", "stack" ],
1431         latency   => 3,
1432         units     => [ "GP" ],
1433 },
1434
1435 AddSP => {
1436         state     => "pinned",
1437         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1438         ins       => [ "base", "index", "mem", "stack", "size" ],
1439         am        => "source,binary",
1440         emit      => '. addl %binop',
1441         latency   => 1,
1442         outs      => [ "stack", "M" ],
1443         units     => [ "GP" ],
1444         modified_flags => $status_flags
1445 },
1446
1447 SubSP => {
1448         state     => "pinned",
1449         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1450         ins       => [ "base", "index", "mem", "stack", "size" ],
1451         am        => "source,binary",
1452         emit      => ". subl %binop\n".
1453                      ". movl %%esp, %D1",
1454         latency   => 2,
1455         outs      => [ "stack", "addr", "M" ],
1456         units     => [ "GP" ],
1457         modified_flags => $status_flags
1458 },
1459
1460 RepPrefix => {
1461         op_flags  => "K",
1462         state     => "pinned",
1463         mode      => "mode_M",
1464         emit      => ". rep",
1465         latency   => 0,
1466 },
1467
1468 LdTls => {
1469         irn_flags => "R",
1470         reg_req   => { out => [ "gp" ] },
1471         units     => [ "GP" ],
1472         latency   => 1,
1473 },
1474
1475 #
1476 # BT supports source address mode, but this is unused yet
1477 #
1478 Bt => {
1479         irn_flags => "R",
1480         state     => "exc_pinned",
1481         reg_req   => { in => [ "gp", "gp" ], out => [ "flags" ] },
1482         ins       => [ "left", "right" ],
1483         emit      => '. bt%M %S1, %S0',
1484         units     => [ "GP" ],
1485         latency   => 1,
1486         mode      => $mode_flags,
1487         modified_flags => $status_flags  # only CF is set, but the other flags are undefined
1488 },
1489
1490 Bsf => {
1491         irn_flags => "R",
1492         state     => "exc_pinned",
1493         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
1494                        out => [ "gp", "flags", "none" ] },
1495         ins       => [ "base", "index", "mem", "operand" ],
1496         outs      => [ "res", "flags", "M" ],
1497         am        => "source,binary",
1498         emit      => '. bsf%M %unop3, %D0',
1499         units     => [ "GP" ],
1500         latency   => 1,
1501         mode      => $mode_gp,
1502         modified_flags => $status_flags
1503 },
1504
1505 Bsr => {
1506         irn_flags => "R",
1507         state     => "exc_pinned",
1508         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
1509                        out => [ "gp", "flags", "none" ] },
1510         ins       => [ "base", "index", "mem", "operand" ],
1511         outs      => [ "res", "flags", "M" ],
1512         am        => "source,binary",
1513         emit      => '. bsr%M %unop3, %D0',
1514         units     => [ "GP" ],
1515         latency   => 1,
1516         mode      => $mode_gp,
1517         modified_flags => $status_flags
1518 },
1519
1520 #
1521 # SSE4.2 or SSE4a popcnt instruction
1522 #
1523 Popcnt => {
1524         irn_flags => "R",
1525         state     => "exc_pinned",
1526         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
1527                        out => [ "gp", "flags", "none" ] },
1528         ins       => [ "base", "index", "mem", "operand" ],
1529         outs      => [ "res", "flags", "M" ],
1530         am        => "source,binary",
1531         emit      => '. popcnt%M %unop3, %D0',
1532         units     => [ "GP" ],
1533         latency   => 1,
1534         mode      => $mode_gp,
1535         modified_flags => $status_flags
1536 },
1537
1538 Call => {
1539         state     => "exc_pinned",
1540         reg_req   => {
1541                 in  => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1542                 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" ]
1543         },
1544         ins       => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1545         outs      => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1546         attr_type => "ia32_call_attr_t",
1547         attr      => "unsigned pop, ir_type *call_tp",
1548         am        => "source,unary",
1549         units     => [ "BRANCH" ],
1550         latency   => 4, # random number
1551         modified_flags => $status_flags
1552 },
1553
1554 #
1555 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1556 #
1557 # PS: try gcc __builtin_frame_address(100000) :-)
1558 #
1559 ClimbFrame => {
1560         reg_req   => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1561         ins       => [ "frame", "cnt", "tmp" ],
1562         outs      => [ "res" ],
1563         latency   => 4, # random number
1564         attr_type => "ia32_climbframe_attr_t",
1565         attr      => "unsigned count",
1566         units     => [ "GP" ],
1567         mode      => $mode_gp
1568 },
1569
1570 #
1571 # bswap
1572 #
1573 Bswap => {
1574         irn_flags => "R",
1575         reg_req   => { in => [ "gp" ],
1576                        out => [ "in_r1" ] },
1577         emit      => '. bswap%M %S0',
1578         ins       => [ "val" ],
1579         units     => [ "GP" ],
1580         latency   => 1,
1581         mode      => $mode_gp,
1582 },
1583
1584 #
1585 # bswap16, use xchg here
1586 #
1587 Bswap16 => {
1588         irn_flags => "R",
1589         reg_req   => { in => [ "eax ebx ecx edx" ],
1590                        out => [ "in_r1" ] },
1591         emit      => '. xchg %SB0, %SH0',
1592         ins       => [ "val" ],
1593         units     => [ "GP" ],
1594         latency   => 1,
1595         mode      => $mode_gp,
1596 },
1597
1598 #
1599 # BreakPoint
1600 #
1601 Breakpoint => {
1602         state     => "pinned",
1603         reg_req   => { in => [ "none" ], out => [ "none" ] },
1604         ins       => [ "mem" ],
1605         latency   => 0,
1606         emit      => ". int3",
1607         units     => [ "GP" ],
1608         mode      => mode_M,
1609 },
1610
1611 #
1612 # Undefined Instruction on ALL x86 CPU's
1613 #
1614 UD2 => {
1615         state     => "pinned",
1616         reg_req   => { in => [ "none" ], out => [ "none" ] },
1617         ins       => [ "mem" ],
1618         latency   => 0,
1619         emit      => ". .value  0x0b0f",
1620         units     => [ "GP" ],
1621         mode      => mode_M,
1622 },
1623
1624 #
1625 # outport
1626 #
1627 Outport => {
1628         irn_flags => "R",
1629         state     => "pinned",
1630         reg_req   => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1631         ins       => [ "port", "value", "mem" ],
1632         emit      => '. out%M %SS0, %SI1',
1633         units     => [ "GP" ],
1634         latency   => 1,
1635         mode      => mode_M,
1636         modified_flags => $status_flags
1637 },
1638
1639 #
1640 # inport
1641 #
1642 Inport => {
1643         irn_flags => "R",
1644         state     => "pinned",
1645         reg_req   => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1646         ins       => [ "port", "mem" ],
1647         outs      => [ "res", "M" ],
1648         emit      => '. in%M %DS0, %SS0',
1649         units     => [ "GP" ],
1650         latency   => 1,
1651         mode      => mode_T,
1652         modified_flags => $status_flags
1653 },
1654
1655 #
1656 # Intel style prefetching
1657 #
1658 Prefetch0 => {
1659         op_flags  => "L|F",
1660         state     => "exc_pinned",
1661         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1662         ins       => [ "base", "index", "mem" ],
1663         outs      => [ "M" ],
1664         latency   => 0,
1665         emit      => ". prefetcht0 %AM",
1666         units     => [ "GP" ],
1667 },
1668
1669 Prefetch1 => {
1670         op_flags  => "L|F",
1671         state     => "exc_pinned",
1672         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1673         ins       => [ "base", "index", "mem" ],
1674         outs      => [ "M" ],
1675         latency   => 0,
1676         emit      => ". prefetcht1 %AM",
1677         units     => [ "GP" ],
1678 },
1679
1680 Prefetch2 => {
1681         op_flags  => "L|F",
1682         state     => "exc_pinned",
1683         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1684         ins       => [ "base", "index", "mem" ],
1685         outs      => [ "M" ],
1686         latency   => 0,
1687         emit      => ". prefetcht2 %AM",
1688         units     => [ "GP" ],
1689 },
1690
1691 PrefetchNTA => {
1692         op_flags  => "L|F",
1693         state     => "exc_pinned",
1694         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1695         ins       => [ "base", "index", "mem" ],
1696         outs      => [ "M" ],
1697         latency   => 0,
1698         emit      => ". prefetchnta %AM",
1699         units     => [ "GP" ],
1700 },
1701
1702 #
1703 # 3DNow! prefetch instructions
1704 #
1705 Prefetch => {
1706         op_flags  => "L|F",
1707         state     => "exc_pinned",
1708         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1709         ins       => [ "base", "index", "mem" ],
1710         outs      => [ "M" ],
1711         latency   => 0,
1712         emit      => ". prefetch %AM",
1713         units     => [ "GP" ],
1714 },
1715
1716 PrefetchW => {
1717         op_flags  => "L|F",
1718         state     => "exc_pinned",
1719         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1720         ins       => [ "base", "index", "mem" ],
1721         outs      => [ "M" ],
1722         latency   => 0,
1723         emit      => ". prefetchw %AM",
1724         units     => [ "GP" ],
1725 },
1726
1727 # produces a 0/+0.0
1728 xZero => {
1729         irn_flags => "R",
1730         reg_req   => { out => [ "xmm" ] },
1731         emit      => '. xorp%XSD %D0, %D0',
1732         latency   => 3,
1733         units     => [ "SSE" ],
1734         mode      => $mode_xmm
1735 },
1736
1737 xPzero => {
1738         irn_flags => "R",
1739         reg_req   => { out => [ "xmm" ] },
1740         emit      => '. pxor %D0, %D0',
1741         latency   => 3,
1742         units     => [ "SSE" ],
1743         mode      => $mode_xmm
1744 },
1745
1746 # produces all 1 bits
1747 xAllOnes => {
1748         irn_flags => "R",
1749         reg_req   => { out => [ "xmm" ] },
1750         emit      => '. pcmpeqb %D0, %D0',
1751         latency   => 3,
1752         units     => [ "SSE" ],
1753         mode      => $mode_xmm
1754 },
1755
1756 # integer shift left, dword
1757 xPslld => {
1758         irn_flags => "R",
1759         reg_req   => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1760         emit      => '. pslld %SI1, %D0',
1761         latency   => 3,
1762         units     => [ "SSE" ],
1763         mode      => $mode_xmm
1764 },
1765
1766 # integer shift left, qword
1767 xPsllq => {
1768         irn_flags => "R",
1769         reg_req   => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1770         emit      => '. psllq %SI1, %D0',
1771         latency   => 3,
1772         units     => [ "SSE" ],
1773         mode      => $mode_xmm
1774 },
1775
1776 # integer shift right, dword
1777 xPsrld => {
1778         irn_flags => "R",
1779         reg_req   => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1780         emit      => '. psrld %SI1, %D0',
1781         latency   => 1,
1782         units     => [ "SSE" ],
1783         mode      => $mode_xmm
1784 },
1785
1786 # mov from integer to SSE register
1787 xMovd  => {
1788         irn_flags => "R",
1789         reg_req   => { in => [ "gp" ], out => [ "xmm" ] },
1790         emit      => '. movd %S0, %D0',
1791         latency   => 1,
1792         units     => [ "SSE" ],
1793         mode      => $mode_xmm
1794 },
1795
1796 xAdd => {
1797         irn_flags => "R",
1798         state     => "exc_pinned",
1799         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1800                        out => [ "in_r4 in_r5", "flags", "none" ] },
1801         ins       => [ "base", "index", "mem", "left", "right" ],
1802         outs      => [ "res", "flags", "M" ],
1803         am        => "source,binary",
1804         emit      => '. add%XXM %binop',
1805         latency   => 4,
1806         units     => [ "SSE" ],
1807         mode      => $mode_xmm
1808 },
1809
1810 xMul => {
1811         irn_flags => "R",
1812         state     => "exc_pinned",
1813         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1814                        out => [ "in_r4 in_r5", "flags", "none" ] },
1815         ins       => [ "base", "index", "mem", "left", "right" ],
1816         outs      => [ "res", "flags", "M" ],
1817         am        => "source,binary",
1818         emit      => '. mul%XXM %binop',
1819         latency   => 4,
1820         units     => [ "SSE" ],
1821         mode      => $mode_xmm
1822 },
1823
1824 xMax => {
1825         irn_flags => "R",
1826         state     => "exc_pinned",
1827         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1828                        out => [ "in_r4 in_r5", "flags", "none" ] },
1829         ins       => [ "base", "index", "mem", "left", "right" ],
1830         outs      => [ "res", "flags", "M" ],
1831         am        => "source,binary",
1832         emit      => '. max%XXM %binop',
1833         latency   => 2,
1834         units     => [ "SSE" ],
1835         mode      => $mode_xmm
1836 },
1837
1838 xMin => {
1839         irn_flags => "R",
1840         state     => "exc_pinned",
1841         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1842                        out => [ "in_r4 in_r5", "flags", "none" ] },
1843         ins       => [ "base", "index", "mem", "left", "right" ],
1844         outs      => [ "res", "flags", "M" ],
1845         am        => "source,binary",
1846         emit      => '. min%XXM %binop',
1847         latency   => 2,
1848         units     => [ "SSE" ],
1849         mode      => $mode_xmm
1850 },
1851
1852 xAnd => {
1853         irn_flags => "R",
1854         state     => "exc_pinned",
1855         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1856                        out => [ "in_r4 in_r5", "flags", "none" ] },
1857         ins       => [ "base", "index", "mem", "left", "right" ],
1858         outs      => [ "res", "flags", "M" ],
1859         am        => "source,binary",
1860         emit      => '. andp%XSD %binop',
1861         latency   => 3,
1862         units     => [ "SSE" ],
1863         mode      => $mode_xmm
1864 },
1865
1866 xOr => {
1867         irn_flags => "R",
1868         state     => "exc_pinned",
1869         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1870                        out => [ "in_r4 in_r5", "flags", "none" ] },
1871         ins       => [ "base", "index", "mem", "left", "right" ],
1872         outs      => [ "res", "flags", "M" ],
1873         am        => "source,binary",
1874         emit      => '. orp%XSD %binop',
1875         latency   => 3,
1876         units     => [ "SSE" ],
1877         mode      => $mode_xmm
1878 },
1879
1880 xXor => {
1881         irn_flags => "R",
1882         state     => "exc_pinned",
1883         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1884                        out => [ "in_r4 in_r5", "flags", "none" ] },
1885         ins       => [ "base", "index", "mem", "left", "right" ],
1886         outs      => [ "res", "flags", "M" ],
1887         am        => "source,binary",
1888         emit      => '. xorp%XSD %binop',
1889         latency   => 3,
1890         units     => [ "SSE" ],
1891         mode      => $mode_xmm
1892 },
1893
1894 xAndNot => {
1895         irn_flags => "R",
1896         state     => "exc_pinned",
1897         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1898                        out => [ "in_r4 !in_r5", "flags", "none" ] },
1899         ins       => [ "base", "index", "mem", "left", "right" ],
1900         outs      => [ "res", "flags", "M" ],
1901         am        => "source,binary",
1902         emit      => '. andnp%XSD %binop',
1903         latency   => 3,
1904         units     => [ "SSE" ],
1905         mode      => $mode_xmm
1906 },
1907
1908 xSub => {
1909         irn_flags => "R",
1910         state     => "exc_pinned",
1911         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1912                        out => [ "in_r4", "flags", "none" ] },
1913         ins       => [ "base", "index", "mem", "minuend", "subtrahend" ],
1914         outs      => [ "res", "flags", "M" ],
1915         am        => "source,binary",
1916         emit      => '. sub%XXM %binop',
1917         latency   => 4,
1918         units     => [ "SSE" ],
1919         mode      => $mode_xmm
1920 },
1921
1922 xDiv => {
1923         irn_flags => "R",
1924         state     => "exc_pinned",
1925         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1926                        out => [ "in_r4 !in_r5", "flags", "none" ] },
1927         ins       => [ "base", "index", "mem", "dividend", "divisor" ],
1928         outs      => [ "res", "flags", "M" ],
1929         am        => "source,binary",
1930         emit      => '. div%XXM %binop',
1931         latency   => 16,
1932         units     => [ "SSE" ],
1933 },
1934
1935 Ucomi => {
1936         irn_flags => "R",
1937         state     => "exc_pinned",
1938         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1939                        out => [ "eflags" ] },
1940         ins       => [ "base", "index", "mem", "left", "right" ],
1941         outs      => [ "flags" ],
1942         am        => "source,binary",
1943         attr      => "int ins_permuted",
1944         init_attr => "attr->data.ins_permuted = ins_permuted;",
1945         emit      => ' .ucomi%XXM %binop',
1946         latency   => 3,
1947         units     => [ "SSE" ],
1948         mode      => $mode_flags,
1949         modified_flags => 1,
1950 },
1951
1952 xLoad => {
1953         op_flags  => "L|F",
1954         state     => "exc_pinned",
1955         reg_req   => { in => [ "gp", "gp", "none" ],
1956                        out => [ "xmm", "none", "none", "none" ] },
1957         ins       => [ "base", "index", "mem" ],
1958         outs      => [ "res", "unused", "M", "X_exc" ],
1959         emit      => '. mov%XXM %AM, %D0',
1960         attr      => "ir_mode *load_mode",
1961         init_attr => "attr->ls_mode = load_mode;",
1962         latency   => 0,
1963         units     => [ "SSE" ],
1964 },
1965
1966 xStore => {
1967         op_flags => "L|F",
1968         state    => "exc_pinned",
1969         reg_req  => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1970         ins       => [ "base", "index", "mem", "val" ],
1971         outs      => [ "M", "X_exc" ],
1972         emit     => '. mov%XXM %S3, %AM',
1973         latency  => 0,
1974         units    => [ "SSE" ],
1975         mode     => "mode_M",
1976 },
1977
1978 xStoreSimple => {
1979         op_flags => "L|F",
1980         state    => "exc_pinned",
1981         reg_req  => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1982         ins      => [ "base", "index", "mem", "val" ],
1983         outs     => [ "M" ],
1984         emit     => '. mov%XXM %S3, %AM',
1985         latency  => 0,
1986         units    => [ "SSE" ],
1987         mode     => "mode_M",
1988 },
1989
1990 CvtSI2SS => {
1991         op_flags => "L|F",
1992         state     => "exc_pinned",
1993         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1994         ins      => [ "base", "index", "mem", "val" ],
1995         am       => "source,unary",
1996         emit     => '. cvtsi2ss %unop3, %D0',
1997         latency  => 2,
1998         units    => [ "SSE" ],
1999         mode     => $mode_xmm
2000 },
2001
2002 CvtSI2SD => {
2003         op_flags => "L|F",
2004         state     => "exc_pinned",
2005         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2006         ins      => [ "base", "index", "mem", "val" ],
2007         am       => "source,unary",
2008         emit     => '. cvtsi2sd %unop3, %D0',
2009         latency  => 2,
2010         units    => [ "SSE" ],
2011         mode     => $mode_xmm
2012 },
2013
2014
2015 l_LLtoFloat => {
2016         op_flags => "L|F",
2017         cmp_attr => "return 1;",
2018         ins      => [ "val_high", "val_low" ],
2019         reg_req  => { in => [ "none", "none" ], out => [ "none" ] }
2020 },
2021
2022 l_FloattoLL => {
2023         op_flags => "L|F",
2024         cmp_attr => "return 1;",
2025         ins      => [ "val" ],
2026         outs     => [ "res_high", "res_low" ],
2027         reg_req  => { in => [ "none" ], out => [ "none", "none" ] }
2028 },
2029
2030 CopyB => {
2031         op_flags  => "F|H",
2032         state     => "pinned",
2033         reg_req   => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2034         outs      => [ "DST", "SRC", "CNT", "M" ],
2035         attr_type => "ia32_copyb_attr_t",
2036         attr      => "unsigned size",
2037         units     => [ "GP" ],
2038         latency  => 3,
2039 # we don't care about this flag, so no need to mark this node
2040 #       modified_flags => [ "DF" ]
2041 },
2042
2043 CopyB_i => {
2044         op_flags  => "F|H",
2045         state     => "pinned",
2046         reg_req   => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
2047         outs      => [ "DST", "SRC", "M" ],
2048         attr_type => "ia32_copyb_attr_t",
2049         attr      => "unsigned size",
2050         units     => [ "GP" ],
2051         latency  => 3,
2052 # we don't care about this flag, so no need to mark this node
2053 #       modified_flags => [ "DF" ]
2054 },
2055
2056 Cwtl => {
2057         state     => "exc_pinned",
2058         reg_req   => { in => [ "eax" ], out => [ "eax" ] },
2059         ins       => [ "val" ],
2060         outs      => [ "res" ],
2061         emit      => '. cwtl',
2062         units     => [ "GP" ],
2063         latency   => 1,
2064         mode      => $mode_gp,
2065 },
2066
2067 Conv_I2I => {
2068         state     => "exc_pinned",
2069         reg_req   => { in => [ "gp", "gp", "none", "gp" ],
2070                        out => [ "gp", "none", "none" ] },
2071         ins       => [ "base", "index", "mem", "val" ],
2072         outs      => [ "res", "flags", "M" ],
2073         am        => "source,unary",
2074         units     => [ "GP" ],
2075         latency   => 1,
2076         attr      => "ir_mode *smaller_mode",
2077         init_attr => "attr->ls_mode = smaller_mode;",
2078         mode      => $mode_gp,
2079 },
2080
2081 Conv_I2I8Bit => {
2082         state     => "exc_pinned",
2083         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2084                        out => [ "gp", "none", "none" ] },
2085         ins       => [ "base", "index", "mem", "val" ],
2086         outs      => [ "res", "flags", "M" ],
2087         am        => "source,unary",
2088         units     => [ "GP" ],
2089         latency   => 1,
2090         attr      => "ir_mode *smaller_mode",
2091         init_attr => "attr->ls_mode = smaller_mode;",
2092         mode      => $mode_gp,
2093 },
2094
2095 Conv_I2FP => {
2096         state     => "exc_pinned",
2097         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2098         ins       => [ "base", "index", "mem", "val" ],
2099         am        => "source,unary",
2100         latency   => 10,
2101         units     => [ "SSE" ],
2102         mode      => $mode_xmm,
2103 },
2104
2105 Conv_FP2I => {
2106         state     => "exc_pinned",
2107         reg_req   => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2108         ins       => [ "base", "index", "mem", "val" ],
2109         am        => "source,unary",
2110         latency   => 10,
2111         units     => [ "SSE" ],
2112         mode      => $mode_gp,
2113 },
2114
2115 Conv_FP2FP => {
2116         state     => "exc_pinned",
2117         reg_req   => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2118         ins       => [ "base", "index", "mem", "val" ],
2119         am        => "source,unary",
2120         latency   => 8,
2121         units     => [ "SSE" ],
2122         mode      => $mode_xmm,
2123 },
2124
2125 # rematerialisation disabled for all float nodes for now, because the fpcw
2126 # handler runs before spilling and we might end up with wrong fpcw then
2127
2128 vfadd => {
2129 #       irn_flags => "R",
2130         state     => "exc_pinned",
2131         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2132                        out => [ "vfp", "none", "none" ] },
2133         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
2134         outs      => [ "res", "dummy", "M" ],
2135         am        => "source,binary",
2136         latency   => 4,
2137         units     => [ "VFP" ],
2138         mode      => "mode_E",
2139         attr_type => "ia32_x87_attr_t",
2140 },
2141
2142 vfmul => {
2143 #       irn_flags => "R",
2144         state     => "exc_pinned",
2145         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2146                        out => [ "vfp", "none", "none" ] },
2147         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
2148         outs      => [ "res", "dummy", "M" ],
2149         am        => "source,binary",
2150         latency   => 4,
2151         units     => [ "VFP" ],
2152         mode      => "mode_E",
2153         attr_type => "ia32_x87_attr_t",
2154 },
2155
2156 vfsub => {
2157 #       irn_flags => "R",
2158         state     => "exc_pinned",
2159         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2160                        out => [ "vfp", "none", "none" ] },
2161         ins       => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2162         outs      => [ "res", "dummy", "M" ],
2163         am        => "source,binary",
2164         latency   => 4,
2165         units     => [ "VFP" ],
2166         mode      => "mode_E",
2167         attr_type => "ia32_x87_attr_t",
2168 },
2169
2170 vfdiv => {
2171         state     => "exc_pinned",
2172         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2173                        out => [ "vfp", "none", "none" ] },
2174         ins       => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2175         outs      => [ "res", "dummy", "M" ],
2176         am        => "source,binary",
2177         latency   => 20,
2178         units     => [ "VFP" ],
2179         attr_type => "ia32_x87_attr_t",
2180 },
2181
2182 vfprem => {
2183         reg_req   => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2184         ins       => [ "left", "right", "fpcw" ],
2185         latency   => 20,
2186         units     => [ "VFP" ],
2187         mode      => "mode_E",
2188         attr_type => "ia32_x87_attr_t",
2189 },
2190
2191 vfabs => {
2192         irn_flags => "R",
2193         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2194         ins       => [ "value" ],
2195         latency   => 2,
2196         units     => [ "VFP" ],
2197         mode      => "mode_E",
2198         attr_type => "ia32_x87_attr_t",
2199 },
2200
2201 vfchs => {
2202         irn_flags => "R",
2203         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2204         ins       => [ "value" ],
2205         latency   => 2,
2206         units     => [ "VFP" ],
2207         mode      => "mode_E",
2208         attr_type => "ia32_x87_attr_t",
2209 },
2210
2211 vfld => {
2212         irn_flags => "R",
2213         op_flags  => "L|F",
2214         state     => "exc_pinned",
2215         reg_req   => { in => [ "gp", "gp", "none" ],
2216                        out => [ "vfp", "none", "none", "none" ] },
2217         ins       => [ "base", "index", "mem" ],
2218         outs      => [ "res", "unused", "M", "X_exc" ],
2219         attr      => "ir_mode *load_mode",
2220         init_attr => "attr->attr.ls_mode = load_mode;",
2221         latency   => 2,
2222         units     => [ "VFP" ],
2223         attr_type => "ia32_x87_attr_t",
2224 },
2225
2226 vfst => {
2227         irn_flags => "R",
2228         op_flags  => "L|F",
2229         state     => "exc_pinned",
2230         reg_req   => { in => [ "gp", "gp", "none", "vfp" ],
2231                        out => [ "none", "none" ] },
2232         ins       => [ "base", "index", "mem", "val" ],
2233         outs      => [ "M", "X_exc" ],
2234         attr      => "ir_mode *store_mode",
2235         init_attr => "attr->attr.ls_mode = store_mode;",
2236         latency   => 2,
2237         units     => [ "VFP" ],
2238         mode      => "mode_M",
2239         attr_type => "ia32_x87_attr_t",
2240 },
2241
2242 vfild => {
2243         state     => "exc_pinned",
2244         reg_req   => { in => [ "gp", "gp", "none" ],
2245                        out => [ "vfp", "none", "none" ] },
2246         outs      => [ "res", "unused", "M" ],
2247         ins       => [ "base", "index", "mem" ],
2248         latency   => 4,
2249         units     => [ "VFP" ],
2250         attr_type => "ia32_x87_attr_t",
2251 },
2252
2253 vfist => {
2254         state     => "exc_pinned",
2255         reg_req   => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2256         ins       => [ "base", "index", "mem", "val", "fpcw" ],
2257         outs      => [ "M" ],
2258         latency   => 4,
2259         units     => [ "VFP" ],
2260         mode      => "mode_M",
2261         attr_type => "ia32_x87_attr_t",
2262 },
2263
2264 # SSE3 fisttp instruction
2265 vfisttp => {
2266         state     => "exc_pinned",
2267         reg_req   => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2268         ins       => [ "base", "index", "mem", "val" ],
2269         outs      => [ "res", "M" ],
2270         latency   => 4,
2271         units     => [ "VFP" ],
2272         attr_type => "ia32_x87_attr_t",
2273 },
2274
2275 vfldz => {
2276         irn_flags => "R",
2277         reg_req   => { out => [ "vfp" ] },
2278         outs      => [ "res" ],
2279         latency   => 4,
2280         units     => [ "VFP" ],
2281         mode      => "mode_E",
2282         attr_type => "ia32_x87_attr_t",
2283 },
2284
2285 vfld1 => {
2286         irn_flags => "R",
2287         reg_req   => { out => [ "vfp" ] },
2288         outs      => [ "res" ],
2289         latency   => 4,
2290         units     => [ "VFP" ],
2291         mode      => "mode_E",
2292         attr_type => "ia32_x87_attr_t",
2293 },
2294
2295 vfldpi => {
2296         irn_flags => "R",
2297         reg_req   => { out => [ "vfp" ] },
2298         outs      => [ "res" ],
2299         latency   => 4,
2300         units     => [ "VFP" ],
2301         mode      => "mode_E",
2302         attr_type => "ia32_x87_attr_t",
2303 },
2304
2305 vfldln2 => {
2306         irn_flags => "R",
2307         reg_req   => { out => [ "vfp" ] },
2308         outs      => [ "res" ],
2309         latency   => 4,
2310         units     => [ "VFP" ],
2311         mode      => "mode_E",
2312         attr_type => "ia32_x87_attr_t",
2313 },
2314
2315 vfldlg2 => {
2316         irn_flags => "R",
2317         reg_req   => { out => [ "vfp" ] },
2318         outs      => [ "res" ],
2319         latency   => 4,
2320         units     => [ "VFP" ],
2321         mode      => "mode_E",
2322         attr_type => "ia32_x87_attr_t",
2323 },
2324
2325 vfldl2t => {
2326         irn_flags => "R",
2327         reg_req   => { out => [ "vfp" ] },
2328         outs      => [ "res" ],
2329         latency   => 4,
2330         units     => [ "VFP" ],
2331         mode      => "mode_E",
2332         attr_type => "ia32_x87_attr_t",
2333 },
2334
2335 vfldl2e => {
2336         irn_flags => "R",
2337         reg_req   => { out => [ "vfp" ] },
2338         outs      => [ "res" ],
2339         latency   => 4,
2340         units     => [ "VFP" ],
2341         mode      => "mode_E",
2342         attr_type => "ia32_x87_attr_t",
2343 },
2344
2345 vFucomFnstsw => {
2346 # we can't allow to rematerialize this node so we don't
2347 #  accidently produce Phi(Fucom, Fucom(ins_permuted))
2348 #       irn_flags => "R",
2349         reg_req   => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2350         ins       => [ "left", "right" ],
2351         outs      => [ "flags" ],
2352         attr      => "int ins_permuted",
2353         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2354         latency   => 3,
2355         units     => [ "VFP" ],
2356         attr_type => "ia32_x87_attr_t",
2357         mode      => $mode_gp
2358 },
2359
2360 vFucomi => {
2361         irn_flags => "R",
2362         reg_req   => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2363         ins       => [ "left", "right" ],
2364         outs      => [ "flags" ],
2365         attr      => "int ins_permuted",
2366         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2367         latency   => 3,
2368         units     => [ "VFP" ],
2369         attr_type => "ia32_x87_attr_t",
2370         mode      => $mode_gp
2371 },
2372
2373 vFtstFnstsw => {
2374 #       irn_flags => "R",
2375         reg_req   => { in => [ "vfp" ], out => [ "eax" ] },
2376         ins       => [ "left" ],
2377         outs      => [ "flags" ],
2378         attr      => "int ins_permuted",
2379         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2380         latency   => 3,
2381         units     => [ "VFP" ],
2382         attr_type => "ia32_x87_attr_t",
2383         mode      => $mode_gp
2384 },
2385
2386 Sahf => {
2387         irn_flags => "R",
2388         reg_req   => { in => [ "eax" ], out => [ "eflags" ] },
2389         ins       => [ "val" ],
2390         outs      => [ "flags" ],
2391         emit      => '. sahf',
2392         latency   => 1,
2393         units     => [ "GP" ],
2394         mode      => $mode_flags,
2395 },
2396
2397 fadd => {
2398         state     => "exc_pinned",
2399         emit      => '. fadd%XM %x87_binop',
2400         latency   => 4,
2401         attr_type => "ia32_x87_attr_t",
2402         constructors => {},
2403 },
2404
2405 faddp => {
2406         state     => "exc_pinned",
2407         emit      => '. faddp%XM %x87_binop',
2408         latency   => 4,
2409         attr_type => "ia32_x87_attr_t",
2410         constructors => {},
2411 },
2412
2413 fmul => {
2414         state     => "exc_pinned",
2415         emit      => '. fmul%XM %x87_binop',
2416         latency   => 4,
2417         attr_type => "ia32_x87_attr_t",
2418         constructors => {},
2419 },
2420
2421 fmulp => {
2422         state     => "exc_pinned",
2423         emit      => '. fmulp%XM %x87_binop',,
2424         latency   => 4,
2425         attr_type => "ia32_x87_attr_t",
2426         constructors => {},
2427 },
2428
2429 fsub => {
2430         state     => "exc_pinned",
2431         emit      => '. fsub%XM %x87_binop',
2432         latency   => 4,
2433         attr_type => "ia32_x87_attr_t",
2434         constructors => {},
2435 },
2436
2437 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2438 #       are swapped, we work this around in the emitter...
2439
2440 fsubp => {
2441         state     => "exc_pinned",
2442 # see note about gas bugs
2443         emit      => '. fsubrp%XM %x87_binop',
2444         latency   => 4,
2445         attr_type => "ia32_x87_attr_t",
2446         constructors => {},
2447 },
2448
2449 fsubr => {
2450         state     => "exc_pinned",
2451         irn_flags => "R",
2452         emit      => '. fsubr%XM %x87_binop',
2453         latency   => 4,
2454         attr_type => "ia32_x87_attr_t",
2455         constructors => {},
2456 },
2457
2458 fsubrp => {
2459         state     => "exc_pinned",
2460         irn_flags => "R",
2461 # see note about gas bugs before fsubp
2462         emit      => '. fsubp%XM %x87_binop',
2463         latency   => 4,
2464         attr_type => "ia32_x87_attr_t",
2465         constructors => {},
2466 },
2467
2468 fprem => {
2469         emit      => '. fprem1',
2470         latency   => 20,
2471         attr_type => "ia32_x87_attr_t",
2472         constructors => {},
2473 },
2474
2475 # this node is just here, to keep the simulator running
2476 # we can omit this when a fprem simulation function exists
2477 fpremp => {
2478         emit      => '. fprem1\n'.
2479                      '. fstp %X0',
2480         latency   => 20,
2481         attr_type => "ia32_x87_attr_t",
2482         constructors => {},
2483 },
2484
2485 fdiv => {
2486         state     => "exc_pinned",
2487         emit      => '. fdiv%XM %x87_binop',
2488         latency   => 20,
2489         attr_type => "ia32_x87_attr_t",
2490         constructors => {},
2491 },
2492
2493 fdivp => {
2494         state     => "exc_pinned",
2495 # see note about gas bugs before fsubp
2496         emit      => '. fdivrp%XM %x87_binop',
2497         latency   => 20,
2498         attr_type => "ia32_x87_attr_t",
2499         constructors => {},
2500 },
2501
2502 fdivr => {
2503         state     => "exc_pinned",
2504         emit      => '. fdivr%XM %x87_binop',
2505         latency   => 20,
2506         attr_type => "ia32_x87_attr_t",
2507         constructors => {},
2508 },
2509
2510 fdivrp => {
2511         state     => "exc_pinned",
2512 # see note about gas bugs before fsubp
2513         emit      => '. fdivp%XM %x87_binop',
2514         latency   => 20,
2515         attr_type => "ia32_x87_attr_t",
2516         constructors => {},
2517 },
2518
2519 fabs => {
2520         emit      => '. fabs',
2521         latency   => 4,
2522         attr_type => "ia32_x87_attr_t",
2523         constructors => {},
2524 },
2525
2526 fchs => {
2527         op_flags  => "R|K",
2528         emit      => '. fchs',
2529         latency   => 4,
2530         attr_type => "ia32_x87_attr_t",
2531         constructors => {},
2532 },
2533
2534 fld => {
2535         op_flags  => "R|L|F",
2536         state     => "exc_pinned",
2537         emit      => '. fld%XM %AM',
2538         attr_type => "ia32_x87_attr_t",
2539         latency   => 2,
2540         constructors => {},
2541 },
2542
2543 fst => {
2544         op_flags  => "R|L|F",
2545         state     => "exc_pinned",
2546         emit      => '. fst%XM %AM',
2547         mode      => "mode_M",
2548         attr_type => "ia32_x87_attr_t",
2549         latency   => 2,
2550         constructors => {},
2551 },
2552
2553 fstp => {
2554         op_flags  => "R|L|F",
2555         state     => "exc_pinned",
2556         emit      => '. fstp%XM %AM',
2557         mode      => "mode_M",
2558         attr_type => "ia32_x87_attr_t",
2559         latency   => 2,
2560         constructors => {},
2561 },
2562
2563 fild => {
2564         state     => "exc_pinned",
2565         emit      => '. fild%XM %AM',
2566         attr_type => "ia32_x87_attr_t",
2567         latency   => 2,
2568         constructors => {},
2569 },
2570
2571 fist => {
2572         state     => "exc_pinned",
2573         emit      => '. fist%XM %AM',
2574         mode      => "mode_M",
2575         attr_type => "ia32_x87_attr_t",
2576         latency   => 2,
2577         constructors => {},
2578 },
2579
2580 fistp => {
2581         state     => "exc_pinned",
2582         emit      => '. fistp%XM %AM',
2583         mode      => "mode_M",
2584         attr_type => "ia32_x87_attr_t",
2585         latency   => 2,
2586         constructors => {},
2587 },
2588
2589 # SSE3 fisttp instruction
2590 fisttp => {
2591         state     => "exc_pinned",
2592         emit      => '. fisttp%XM %AM',
2593         mode      => "mode_M",
2594         attr_type => "ia32_x87_attr_t",
2595         latency   => 2,
2596         constructors => {},
2597 },
2598
2599 fldz => {
2600         op_flags  => "R|c|K",
2601         irn_flags => "R",
2602         reg_req   => { out => [ "vfp" ] },
2603         emit      => '. fldz',
2604         attr_type => "ia32_x87_attr_t",
2605         latency   => 2,
2606 },
2607
2608 fld1 => {
2609         op_flags  => "R|c|K",
2610         irn_flags => "R",
2611         reg_req   => { out => [ "vfp" ] },
2612         emit      => '. fld1',
2613         attr_type => "ia32_x87_attr_t",
2614         latency   => 2,
2615 },
2616
2617 fldpi => {
2618         op_flags  => "R|c|K",
2619         irn_flags => "R",
2620         reg_req   => { out => [ "vfp" ] },
2621         emit      => '. fldpi',
2622         attr_type => "ia32_x87_attr_t",
2623         latency   => 2,
2624 },
2625
2626 fldln2 => {
2627         op_flags  => "R|c|K",
2628         irn_flags => "R",
2629         reg_req   => { out => [ "vfp" ] },
2630         emit      => '. fldln2',
2631         attr_type => "ia32_x87_attr_t",
2632         latency   => 2,
2633 },
2634
2635 fldlg2 => {
2636         op_flags  => "R|c|K",
2637         irn_flags => "R",
2638         reg_req   => { out => [ "vfp" ] },
2639         emit      => '. fldlg2',
2640         attr_type => "ia32_x87_attr_t",
2641         latency   => 2,
2642 },
2643
2644 fldl2t => {
2645         op_flags  => "R|c|K",
2646         irn_flags => "R",
2647         reg_req   => { out => [ "vfp" ] },
2648         emit      => '. fldll2t',
2649         attr_type => "ia32_x87_attr_t",
2650         latency   => 2,
2651 },
2652
2653 fldl2e => {
2654         op_flags  => "R|c|K",
2655         irn_flags => "R",
2656         reg_req   => { out => [ "vfp" ] },
2657         emit      => '. fldl2e',
2658         attr_type => "ia32_x87_attr_t",
2659         latency   => 2,
2660 },
2661
2662 # fxch, fpush, fpop
2663 # Note that it is NEVER allowed to do CSE on these nodes
2664 # Moreover, note the virtual register requierements!
2665
2666 fxch => {
2667         op_flags  => "R|K",
2668         reg_req   => { out => [ "none" ] },
2669         cmp_attr  => "return 1;",
2670         emit      => '. fxch %X0',
2671         attr_type => "ia32_x87_attr_t",
2672         mode      => "mode_ANY",
2673         latency   => 1,
2674 },
2675
2676 fpush => {
2677         op_flags  => "R|K",
2678         reg_req   => { out => [ "none" ] },
2679         cmp_attr  => "return 1;",
2680         emit      => '. fld %X0',
2681         attr_type => "ia32_x87_attr_t",
2682         mode      => "mode_ANY",
2683         latency   => 1,
2684 },
2685
2686 fpushCopy => {
2687         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2688         cmp_attr  => "return 1;",
2689         emit      => '. fld %X0',
2690         attr_type => "ia32_x87_attr_t",
2691         latency   => 1,
2692 },
2693
2694 fpop => {
2695         op_flags  => "K",
2696         reg_req   => { out => [ "none" ] },
2697         cmp_attr  => "return 1;",
2698         emit      => '. fstp %X0',
2699         attr_type => "ia32_x87_attr_t",
2700         mode      => "mode_ANY",
2701         latency   => 1,
2702 },
2703
2704 ffreep => {
2705         op_flags  => "K",
2706         reg_req   => { out => [ "none" ] },
2707         cmp_attr  => "return 1;",
2708         emit      => '. ffreep %X0',
2709         attr_type => "ia32_x87_attr_t",
2710         mode      => "mode_ANY",
2711         latency   => 1,
2712 },
2713
2714 emms => {
2715         op_flags  => "K",
2716         reg_req   => { out => [ "none" ] },
2717         cmp_attr  => "return 1;",
2718         emit      => '. emms',
2719         attr_type => "ia32_x87_attr_t",
2720         mode      => "mode_ANY",
2721         latency   => 3,
2722 },
2723
2724 femms => {
2725         op_flags  => "K",
2726         reg_req   => { out => [ "none" ] },
2727         cmp_attr  => "return 1;",
2728         emit      => '. femms',
2729         attr_type => "ia32_x87_attr_t",
2730         mode      => "mode_ANY",
2731         latency   => 3,
2732 },
2733
2734 FucomFnstsw => {
2735         reg_req   => { },
2736         emit      => ". fucom %X1\n".
2737                      ". fnstsw %%ax",
2738         attr_type => "ia32_x87_attr_t",
2739         latency   => 2,
2740 },
2741
2742 FucompFnstsw => {
2743         reg_req   => { },
2744         emit      => ". fucomp %X1\n".
2745                      ". fnstsw %%ax",
2746         attr_type => "ia32_x87_attr_t",
2747         latency   => 2,
2748 },
2749
2750 FucomppFnstsw => {
2751         reg_req   => { },
2752         emit      => ". fucompp\n".
2753                      ". fnstsw %%ax",
2754         attr_type => "ia32_x87_attr_t",
2755         latency   => 2,
2756 },
2757
2758 Fucomi => {
2759         reg_req   => { },
2760         emit      => '. fucomi %X1',
2761         attr_type => "ia32_x87_attr_t",
2762         latency   => 1,
2763 },
2764
2765 Fucompi => {
2766         reg_req   => { },
2767         emit      => '. fucompi %X1',
2768         attr_type => "ia32_x87_attr_t",
2769         latency   => 1,
2770 },
2771
2772 FtstFnstsw => {
2773         reg_req   => { },
2774         emit      => ". ftst\n".
2775                      ". fnstsw %%ax",
2776         attr_type => "ia32_x87_attr_t",
2777         latency   => 2,
2778 },
2779
2780 # Spilling and reloading of SSE registers, hardcoded, not generated #
2781
2782 xxLoad => {
2783         op_flags  => "L|F",
2784         state     => "exc_pinned",
2785         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2786         emit      => '. movdqu %D0, %AM',
2787         outs      => [ "res", "M" ],
2788         units     => [ "SSE" ],
2789         latency   => 1,
2790 },
2791
2792 xxStore => {
2793         op_flags => "L|F",
2794         state    => "exc_pinned",
2795         reg_req  => { in => [ "gp", "gp", "none", "xmm" ] },
2796         ins      => [ "base", "index", "mem", "val" ],
2797         emit     => '. movdqu %binop',
2798         units    => [ "SSE" ],
2799         latency   => 1,
2800         mode     => "mode_M",
2801 },
2802
2803 ); # end of %nodes
2804
2805 # Transform some attributes
2806 foreach my $op (keys(%nodes)) {
2807         my $node         = $nodes{$op};
2808         my $op_attr_init = $node->{op_attr_init};
2809
2810         if(defined($op_attr_init)) {
2811                 $op_attr_init .= "\n\t";
2812         } else {
2813                 $op_attr_init = "";
2814         }
2815
2816         if(!defined($node->{latency})) {
2817                 if($op =~ m/^l_/) {
2818                         $node->{latency} = 0;
2819                 } else {
2820                         die("Latency missing for op $op");
2821                 }
2822         }
2823         $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2824
2825         $node->{op_attr_init} = $op_attr_init;
2826 }
2827
2828 print "";