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