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