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