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