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