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